📄 objects.h.svn-base
字号:
// Useful when the map pointer field is used for other purposes. // GC internal. inline int SizeFromMap(Map* map); // Support for the marking heap objects during the marking phase of GC. // True if the object is marked live. inline bool IsMarked(); // Mutate this object's map pointer to indicate that the object is live. inline void SetMark(); // Mutate this object's map pointer to remove the indication that the // object is live (ie, partially restore the map pointer). inline void ClearMark(); // True if this object is marked as overflowed. Overflowed objects have // been reached and marked during marking of the heap, but their children // have not necessarily been marked and they have not been pushed on the // marking stack. inline bool IsOverflowed(); // Mutate this object's map pointer to indicate that the object is // overflowed. inline void SetOverflow(); // Mutate this object's map pointer to remove the indication that the // object is overflowed (ie, partially restore the map pointer). inline void ClearOverflow(); static inline Object* GetHeapObjectField(HeapObject* obj, int index); // Casting. static inline HeapObject* cast(Object* obj); // Dispatched behavior. void HeapObjectShortPrint(StringStream* accumulator);#ifdef DEBUG void HeapObjectPrint(); void HeapObjectVerify(); inline void VerifyObjectField(int offset); void PrintHeader(const char* id); // Verify a pointer is a valid HeapObject pointer that points to object // areas in the heap. static void VerifyHeapPointer(Object* p);#endif // Layout description. // First field in a heap object is map. static const int kMapOffset = Object::kHeaderSize; static const int kHeaderSize = kMapOffset + kPointerSize; protected: // helpers for calling an ObjectVisitor to iterate over pointers in the // half-open range [start, end) specified as integer offsets inline void IteratePointers(ObjectVisitor* v, int start, int end); // as above, for the single element at "offset" inline void IteratePointer(ObjectVisitor* v, int offset); // Computes the object size from the map. // Should only be used from SizeFromMap. int SlowSizeFromMap(Map* map); private: DISALLOW_IMPLICIT_CONSTRUCTORS(HeapObject);};// The HeapNumber class describes heap allocated numbers that cannot be// represented in a Smi (small integer)class HeapNumber: public HeapObject { public: // [value]: number value. inline double value(); inline void set_value(double value); // Casting. static inline HeapNumber* cast(Object* obj); // Dispatched behavior. Object* HeapNumberToBoolean(); void HeapNumberPrint(); void HeapNumberPrint(StringStream* accumulator);#ifdef DEBUG void HeapNumberVerify();#endif // Layout description. static const int kValueOffset = HeapObject::kHeaderSize; static const int kSize = kValueOffset + kDoubleSize; private: DISALLOW_IMPLICIT_CONSTRUCTORS(HeapNumber);};// The JSObject describes real heap allocated JavaScript objects with// properties.// Note that the map of JSObject changes during execution to enable inline// caching.class JSObject: public HeapObject { public: // [properties]: Backing storage for properties. // properties is a FixedArray in the fast case, and a Dictionary in the // slow case. DECL_ACCESSORS(properties, FixedArray) // Get and set fast properties. inline void initialize_properties(); inline bool HasFastProperties(); inline Dictionary* property_dictionary(); // Gets slow properties. // [elements]: The elements (properties with names that are integers). // elements is a FixedArray in the fast case, and a Dictionary in the slow // case. DECL_ACCESSORS(elements, HeapObject) // Get and set fast elements. inline void initialize_elements(); inline bool HasFastElements(); inline Dictionary* element_dictionary(); // Gets slow elements. Object* SetProperty(String* key, Object* value, PropertyAttributes attributes); Object* SetProperty(LookupResult* result, String* key, Object* value, PropertyAttributes attributes); Object* SetPropertyWithFailedAccessCheck(LookupResult* result, String* name, Object* value); Object* SetPropertyWithCallback(Object* structure, String* name, Object* value, JSObject* holder); Object* SetPropertyWithInterceptor(String* name, Object* value, PropertyAttributes attributes); Object* SetPropertyPostInterceptor(String* name, Object* value, PropertyAttributes attributes); Object* IgnoreAttributesAndSetLocalProperty(String* key, Object* value); // Sets a property that currently has lazy loading. Object* SetLazyProperty(LookupResult* result, String* name, Object* value, PropertyAttributes attributes); // Returns the class name ([[Class]] property in the specification). String* class_name(); // Retrieve interceptors. InterceptorInfo* GetNamedInterceptor(); InterceptorInfo* GetIndexedInterceptor(); inline PropertyAttributes GetPropertyAttribute(String* name); PropertyAttributes GetPropertyAttributeWithReceiver(JSObject* receiver, String* name); PropertyAttributes GetLocalPropertyAttribute(String* name); Object* DefineAccessor(String* name, bool is_getter, JSFunction* fun, PropertyAttributes attributes); Object* LookupAccessor(String* name, bool is_getter); // Used from Object::GetProperty(). Object* GetPropertyWithFailedAccessCheck(Object* receiver, LookupResult* result, String* name); Object* GetPropertyWithInterceptor(JSObject* receiver, String* name, PropertyAttributes* attributes); Object* GetPropertyPostInterceptor(JSObject* receiver, String* name, PropertyAttributes* attributes); Object* GetLazyProperty(Object* receiver, LookupResult* result, String* name, PropertyAttributes* attributes); bool HasProperty(String* name) { return GetPropertyAttribute(name) != ABSENT; } bool HasLocalProperty(String* name) { return GetLocalPropertyAttribute(name) != ABSENT; } Object* DeleteProperty(String* name); Object* DeleteElement(uint32_t index); Object* DeleteLazyProperty(LookupResult* result, String* name); // Tests for the fast common case for property enumeration. bool IsSimpleEnum(); // Do we want to keep the elements in fast case when increasing the // capacity? bool ShouldConvertToSlowElements(int new_capacity); // Returns true if the backing storage for the slow-case elements of // this object takes up nearly as much space as a fast-case backing // storage would. In that case the JSObject should have fast // elements. bool ShouldConvertToFastElements(); // Return the object's prototype (might be Heap::null_value()). inline Object* GetPrototype(); // Tells whether the index'th element is present. inline bool HasElement(uint32_t index); bool HasElementWithReceiver(JSObject* receiver, uint32_t index); bool HasLocalElement(uint32_t index); bool HasElementWithInterceptor(JSObject* receiver, uint32_t index); bool HasElementPostInterceptor(JSObject* receiver, uint32_t index); Object* SetFastElement(uint32_t index, Object* value); // Set the index'th array element. // A Failure object is returned if GC is needed. Object* SetElement(uint32_t index, Object* value); // Returns the index'th element. // The undefined object if index is out of bounds. Object* GetElementWithReceiver(JSObject* receiver, uint32_t index); void SetFastElements(FixedArray* elements); Object* SetSlowElements(Object* length); // Lookup interceptors are used for handling properties controlled by host // objects. inline bool HasNamedInterceptor(); inline bool HasIndexedInterceptor(); // Support functions for v8 api (needed for correct interceptor behavior). bool HasRealNamedProperty(String* key); bool HasRealElementProperty(uint32_t index); bool HasRealNamedCallbackProperty(String* key); // Initializes the array to a certain length Object* SetElementsLength(Object* length); // Get the header size for a JSObject. Used to compute the index of // internal fields as well as the number of internal fields. inline int GetHeaderSize(); inline int GetInternalFieldCount(); inline Object* GetInternalField(int index); inline void SetInternalField(int index, Object* value); // Returns a deep copy of the JavaScript object. // Properties and elements are copied too. // Returns failure if allocation failed. Object* Copy(PretenureFlag pretenure = NOT_TENURED); // Lookup a property. If found, the result is valid and has // detailed information. void LocalLookup(String* name, LookupResult* result); void Lookup(String* name, LookupResult* result); // The following lookup functions skip interceptors. void LocalLookupRealNamedProperty(String* name, LookupResult* result); void LookupRealNamedProperty(String* name, LookupResult* result); void LookupRealNamedPropertyInPrototypes(String* name, LookupResult* result); void LookupCallbackSetterInPrototypes(String* name, LookupResult* result); // Returns the number of properties on this object filtering out properties // with the specified attributes (ignoring interceptors). int NumberOfLocalProperties(PropertyAttributes filter); // Returns the number of enumerable properties (ignoring interceptors). int NumberOfEnumProperties(); // Fill in details for properties into storage. void GetLocalPropertyNames(FixedArray* storage); // Returns the number of properties on this object filtering out properties // with the specified attributes (ignoring interceptors). int NumberOfLocalElements(PropertyAttributes filter); // Returns the number of enumerable elements (ignoring interceptors). int NumberOfEnumElements(); // Returns the number of elements on this object filtering out elements // with the specified attributes (ignoring interceptors). int GetLocalElementKeys(FixedArray* storage, PropertyAttributes filter); // Count and fill in the enumerable elements into storage. // (storage->length() == NumberOfEnumElements()). // If storage is NULL, will count the elements without adding // them to any storage. // Returns the number of enumerable elements. int GetEnumElementKeys(FixedArray* storage); // Add a property to a fast-case object using a map transition to // new_map. Object* AddFastPropertyUsingMap(Map* new_map, String* name, Object* value); // Add a constant function property to a fast-case object. // This leaves a CONSTANT_TRANSITION in the old map, and // if it is called on a second object with this map, a // normal property is added instead, with a map transition. // This avoids the creation of many maps with the same constant // function, all orphaned. Object* AddConstantFunctionProperty(String* name, JSFunction* function, PropertyAttributes attributes); // Replace a constant function property on a fast-case object. Object* ReplaceConstantFunctionProperty(String* name, Object* value); // Add a property to a fast-case object. Object* AddFastProperty(String* name, Object* value, PropertyAttributes attributes); // Add a property to a slow-case object. Object* AddSlowProperty(String* name, Object* value, PropertyAttributes attributes); // Add a property to an object. Object* AddProperty(String* name, Object* value, PropertyAttributes attributes); // Convert the object to use the canonical dictionary // representation. Object* NormalizeProperties(); Object* NormalizeElements(); // Transform slow named properties to fast variants. // Returns failure if allocation failed. Object* TransformToFastProperties(int unused_property_fields); // initializes the body after properties slot, properties slot is // initialized by set_properties
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -