⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 objects.h.svn-base

📁 Google浏览器V8内核代码
💻 SVN-BASE
📖 第 1 页 / 共 5 页
字号:
  // Note: this call does not update write barrier, it is caller's  // reponsibility to ensure that *v* can be collected without WB here.  inline void InitializeBody(int object_size);  // Check whether this object references another object  bool ReferencesObject(Object* obj);  // Casting.  static inline JSObject* cast(Object* obj);  // Dispatched behavior.  void JSObjectIterateBody(int object_size, ObjectVisitor* v);  void JSObjectShortPrint(StringStream* accumulator);#ifdef DEBUG  void JSObjectPrint();  void JSObjectVerify();  void PrintProperties();  void PrintElements();  // Structure for collecting spill information about JSObjects.  class SpillInformation {   public:    void Clear();    void Print();    int number_of_objects_;    int number_of_objects_with_fast_properties_;    int number_of_objects_with_fast_elements_;    int number_of_fast_used_fields_;    int number_of_fast_unused_fields_;    int number_of_slow_used_properties_;    int number_of_slow_unused_properties_;    int number_of_fast_used_elements_;    int number_of_fast_unused_elements_;    int number_of_slow_used_elements_;    int number_of_slow_unused_elements_;  };  void IncrementSpillStatistics(SpillInformation* info);#endif  Object* SlowReverseLookup(Object* value);  static const uint32_t kMaxGap = 1024;  static const int kMaxFastElementsLength = 5000;  static const int kMaxFastProperties = 8;  // Layout description.  static const int kPropertiesOffset = HeapObject::kHeaderSize;  static const int kElementsOffset = kPropertiesOffset + kPointerSize;  static const int kHeaderSize = kElementsOffset + kPointerSize;  Object* GetElementWithInterceptor(JSObject* receiver, uint32_t index); private:  Object* SetElementWithInterceptor(uint32_t index, Object* value);  Object* SetElementPostInterceptor(uint32_t index, Object* value);  Object* GetElementPostInterceptor(JSObject* receiver, uint32_t index);  Object* DeletePropertyPostInterceptor(String* name);  Object* DeletePropertyWithInterceptor(String* name);  Object* DeleteElementPostInterceptor(uint32_t index);  Object* DeleteElementWithInterceptor(uint32_t index);  PropertyAttributes GetPropertyAttributePostInterceptor(JSObject* receiver,                                                         String* name,                                                         bool continue_search);  PropertyAttributes GetPropertyAttributeWithInterceptor(JSObject* receiver,                                                         String* name,                                                         bool continue_search);  PropertyAttributes GetPropertyAttribute(JSObject* receiver,                                          LookupResult* result,                                          String* name,                                          bool continue_search);  // Returns true if most of the elements backing storage is used.  bool HasDenseElements();  Object* DefineGetterSetter(String* name, PropertyAttributes attributes);  void LookupInDescriptor(String* name, LookupResult* result);  DISALLOW_IMPLICIT_CONSTRUCTORS(JSObject);};// Abstract super class arrays. It provides length behavior.class Array: public HeapObject { public:  // [length]: length of the array.  inline int length();  inline void set_length(int value);  // Convert an object to an array index.  // Returns true if the conversion succeeded.  static inline bool IndexFromObject(Object* object, uint32_t* index);  // Layout descriptor.  static const int kLengthOffset = HeapObject::kHeaderSize;  static const int kHeaderSize = kLengthOffset + kIntSize; private:  DISALLOW_IMPLICIT_CONSTRUCTORS(Array);};// FixedArray describes fixed sized arrays where element// type is Object*.class FixedArray: public Array { public:  // Setter and getter for elements.  inline Object* get(int index);  inline void set(int index, Object* value);  // Setters for frequently used oddballs located in old space.  inline void set_undefined(int index);  inline void set_null(int index);  inline void set_the_hole(int index);  // Setter that skips the write barrier if mode is SKIP_WRITE_BARRIER.  enum WriteBarrierMode { SKIP_WRITE_BARRIER, UPDATE_WRITE_BARRIER };  inline void set(int index, Object* value, WriteBarrierMode mode);  // Return the write barrier mode for this.  inline WriteBarrierMode GetWriteBarrierMode();  // Copy operations.  Object* Copy();  Object* CopySize(int new_length);  // Add the elements of a JSArray to this FixedArray.  Object* AddKeysFromJSArray(JSArray* array);  // Compute the union of this and other.  Object* UnionOfKeys(FixedArray* other);  // Copy a sub array from the receiver to dest.  void CopyTo(int pos, FixedArray* dest, int dest_pos, int len);  // Garbage collection support.  static int SizeFor(int length) { return kHeaderSize + length * kPointerSize; }  // Casting.  static inline FixedArray* cast(Object* obj);  // Dispatched behavior.  int FixedArraySize() { return SizeFor(length()); }  void FixedArrayIterateBody(ObjectVisitor* v);#ifdef DEBUG  void FixedArrayPrint();  void FixedArrayVerify();  // Checks if two FixedArrays have identical contents.  bool IsEqualTo(FixedArray* other);#endif  // Swap two elements.  void Swap(int i, int j);  // Sort this array and the smis as pairs wrt. the smis.  void SortPairs(FixedArray* smis); protected:  // Set operation on FixedArray without using write barriers.  static inline void fast_set(FixedArray* array, int index, Object* value); private:  DISALLOW_IMPLICIT_CONSTRUCTORS(FixedArray);};// DescriptorArrays are fixed arrays used to hold instance descriptors.// The format of the these objects is://   [0]: point to a fixed array with (value, detail) pairs.//   [1]: next enumeration index (Smi), or pointer to small fixed array://          [0]: next enumeration index (Smi)//          [1]: pointer to fixed array with enum cache//   [2]: first key//   [length() - 1]: last key//class DescriptorArray: public FixedArray { public:  // Is this the singleton empty_descriptor_array?  inline bool IsEmpty();  // Returns the number of descriptors in the array.  int number_of_descriptors() {    return IsEmpty() ? 0 : length() - kFirstIndex;  }  int NextEnumerationIndex() {    if (IsEmpty()) return PropertyDetails::kInitialIndex;    Object* obj = get(kEnumerationIndexIndex);    if (obj->IsSmi()) {      return Smi::cast(obj)->value();    } else {      Object* index = FixedArray::cast(obj)->get(kEnumCacheBridgeEnumIndex);      return Smi::cast(index)->value();    }  }  // Set next enumeration index and flush any enum cache.  void SetNextEnumerationIndex(int value) {    if (!IsEmpty()) {      fast_set(this, kEnumerationIndexIndex, Smi::FromInt(value));    }  }  bool HasEnumCache() {    return !IsEmpty() && !get(kEnumerationIndexIndex)->IsSmi();  }  Object* GetEnumCache() {    ASSERT(HasEnumCache());    FixedArray* bridge = FixedArray::cast(get(kEnumerationIndexIndex));    return bridge->get(kEnumCacheBridgeCacheIndex);  }  // Initialize or change the enum cache,  // using the supplied storage for the small "bridge".  void SetEnumCache(FixedArray* bridge_storage, FixedArray* new_cache);  // Accessors for fetching instance descriptor at descriptor number..  inline String* GetKey(int descriptor_number);  inline Object* GetValue(int descriptor_number);  inline Smi* GetDetails(int descriptor_number);  // Accessor for complete descriptor.  inline void Get(int descriptor_number, Descriptor* desc);  inline void Set(int descriptor_number, Descriptor* desc);  void ReplaceConstantFunction(int descriptor_number, JSFunction* value);  // Copy the descriptor array, insert a new descriptor and optionally  // remove map transitions.  If the descriptor is already present, it is  // replaced.  If a replaced descriptor is a real property (not a transition  // or null), its enumeration index is kept as is.  // If adding a real property, map transitions must be removed.  If adding  // a transition, they must not be removed.  All null descriptors are removed.  Object* CopyInsert(Descriptor* descriptor, TransitionFlag transition_flag);  // Makes a copy of the descriptor array with the descriptor with key name  // removed.  If name is the empty string, the descriptor array is copied.  // Transitions are removed if TransitionFlag is REMOVE_TRANSITIONS.  // All null descriptors are removed.  Object* CopyRemove(TransitionFlag remove_transitions, String* name);  // Copy the descriptor array, replace the property index and attributes  // of the named property, but preserve its enumeration index.  Object* CopyReplace(String* name, int index, PropertyAttributes attributes);  // Copy the descriptor array, removing the property index and attributes  // of the named property.  Object* CopyRemove(String* name);  // Remove all transitions.  Return  a copy of the array with all transitions  // removed, or a Failure object if the new array could not be allocated.  Object* RemoveTransitions();  // Sort the instance descriptors by the hash codes of their keys.  void Sort();  // Search the instance descriptors for given name.  inline int Search(String* name);  // Tells whether the name is present int the array.  bool Contains(String* name) { return kNotFound != Search(name); }  // Perform a binary search in the instance descriptors represented  // by this fixed array.  low and high are descriptor indices.  If there  // are three instance descriptors in this array it should be called  // with low=0 and high=2.  int BinarySearch(String* name, int low, int high);  // Allocates a DescriptorArray, but returns the singleton  // empty descriptor array object if number_of_descriptors is 0.  static Object* Allocate(int number_of_descriptors);  // Casting.  static inline DescriptorArray* cast(Object* obj);  // Constant for denoting key was not found.  static const int kNotFound = -1;  static const int kContentArrayIndex = 0;  static const int kEnumerationIndexIndex = 1;  static const int kFirstIndex = 2;  // The length of the "bridge" to the enum cache.  static const int kEnumCacheBridgeLength = 2;  static const int kEnumCacheBridgeEnumIndex = 0;  static const int kEnumCacheBridgeCacheIndex = 1;  // Layout description.  static const int kContentArrayOffset = FixedArray::kHeaderSize;  static const int kEnumerationIndexOffset = kContentArrayOffset + kPointerSize;  static const int kFirstOffset = kEnumerationIndexOffset + kPointerSize;  // Layout description for the bridge array.  static const int kEnumCacheBridgeEnumOffset = FixedArray::kHeaderSize;  static const int kEnumCacheBridgeCacheOffset =    kEnumCacheBridgeEnumOffset + kPointerSize;#ifdef DEBUG  // Print all the descriptors.  void PrintDescriptors();  // Is the descriptor array sorted and without duplicates?  bool IsSortedNoDuplicates();  // Are two DescriptorArrays equal?  bool IsEqualTo(DescriptorArray* other);#endif  // The maximum number of descriptors we want in a descriptor array (should  // fit in a page).  static const int kMaxNumberOfDescriptors = 1024 + 512; private:  // Conversion from descriptor number to array indices.  static int ToKeyIndex(int descriptor_number) {    return descriptor_number+kFirstIndex;  }  static int ToValueIndex(int descriptor_number) {    return descriptor_number << 1;  }  static int ToDetailsIndex(int descriptor_number) {    return( descriptor_number << 1) + 1;  }  // Swap operation on FixedArray without using write barriers.  static inline void fast_sw

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -