code); DECLARE_CAST(HeapObject) // Return the write barrier mode for this. Callers of this function // must be able to present a reference to an DisallowHeapAllocation // object as a sign that they are not going to use this function // from code that allocates and thus invalidates the returned write // barrier mode. inline WriteBarrierMode GetWriteBarrierMode( const DisallowHeapAllocation& promise); // Dispatched behavior. void HeapObjectShortPrint(std::ostream& os); // NOLINT #ifdef OBJECT_PRINT void PrintHeader(std::ostream& os, const char* id); // NOLINT #endif DECLARE_PRINTER(HeapObject) DECLARE_VERIFIER(HeapObject) #ifdef VERIFY_HEAP inline void VerifyObjectField(int offset); inline void VerifySmiField(int offset); // Verify a pointer is a valid HeapObject pointer that points to object // areas in the heap. static void VerifyHeapPointer(Object* p); #endif inline AllocationAlignment RequiredAlignment(); // Layout description. // First field in a heap object is map. static const int kMapOffset = Object::kHeaderSize; static const int kHeaderSize = kMapOffset + kPointerSize; STATIC_ASSERT(kMapOffset == Internals::kHeapObjectMapOffset); private: DISALLOW_IMPLICIT_CONSTRUCTORS(HeapObject); }; template class FixedBodyDescriptor; template class FlexibleBodyDescriptor; // 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() const; inline void set_value(double value); inline uint64_t value_as_bits() const; inline void set_value_as_bits(uint64_t bits); DECLARE_CAST(HeapNumber) // Dispatched behavior. bool HeapNumberBooleanValue(); V8_EXPORT_PRIVATE void HeapNumberPrint(std::ostream& os); // NOLINT DECLARE_VERIFIER(HeapNumber) inline int get_exponent(); inline int get_sign(); // Layout description. static const int kValueOffset = HeapObject::kHeaderSize; // IEEE doubles are two 32 bit words. The first is just mantissa, the second // is a mixture of sign, exponent and mantissa. The offsets of two 32 bit // words within double numbers are endian dependent and they are set // accordingly. #if defined(V8_TARGET_LITTLE_ENDIAN) static const int kMantissaOffset = kValueOffset; static const int kExponentOffset = kValueOffset + 4; #elif defined(V8_TARGET_BIG_ENDIAN) static const int kMantissaOffset = kValueOffset + 4; static const int kExponentOffset = kValueOffset; #else #error Unknown byte ordering #endif static const int kSize = kValueOffset + kDoubleSize; static const uint32_t kSignMask = 0x80000000u; static const uint32_t kExponentMask = 0x7ff00000u; static const uint32_t kMantissaMask = 0xfffffu; static const int kMantissaBits = 52; static const int kExponentBits = 11; static const int kExponentBias = 1023; static const int kExponentShift = 20; static const int kInfinityOrNanExponent = (kExponentMask >> kExponentShift) - kExponentBias; static const int kMantissaBitsInTopWord = 20; static const int kNonMantissaBitsInTopWord = 12; private: DISALLOW_IMPLICIT_CONSTRUCTORS(HeapNumber); }; enum EnsureElementsMode { DONT_ALLOW_DOUBLE_ELEMENTS, ALLOW_COPIED_DOUBLE_ELEMENTS, ALLOW_CONVERTED_DOUBLE_ELEMENTS }; // Indicator for one component of an AccessorPair. enum AccessorComponent { ACCESSOR_GETTER, ACCESSOR_SETTER }; enum class GetKeysConversion { kKeepNumbers, kConvertToString }; enum class KeyCollectionMode { kOwnOnly = static_cast(v8::KeyCollectionMode::kOwnOnly), kIncludePrototypes = static_cast(v8::KeyCollectionMode::kIncludePrototypes) }; enum class AllocationSiteUpdateMode { kUpdate, kCheckOnly }; // JSReceiver includes types on which properties can be defined, i.e., // JSObject and JSProxy. class JSReceiver: 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(); // Gets slow properties for non-global objects. inline NameDictionary* property_dictionary(); // Deletes an existing named property in a normalized object. static void DeleteNormalizedProperty(Handle object, Handle name, int entry); DECLARE_CAST(JSReceiver) // ES6 section 7.1.1 ToPrimitive MUST_USE_RESULT static MaybeHandle ToPrimitive( Handle receiver, ToPrimitiveHint hint = ToPrimitiveHint::kDefault); // ES6 section 7.1.1.1 OrdinaryToPrimitive MUST_USE_RESULT static MaybeHandle OrdinaryToPrimitive( Handle receiver, OrdinaryToPrimitiveHint hint); static MaybeHandle GetFunctionRealm(Handle receiver); // Get the first non-hidden prototype. static inline MaybeHandle GetPrototype(Isolate* isolate, Handle receiver); MUST_USE_RESULT static Maybe HasInPrototypeChain( Isolate* isolate, Handle object, Handle proto); // Reads all enumerable own properties of source and adds them to // target, using either Set or CreateDataProperty depending on the // use_set argument. This only copies values not present in the // maybe_excluded_properties list. MUST_USE_RESULT static Maybe SetOrCopyDataProperties( Isolate* isolate, Handle target, Handle source, const ScopedVector>* excluded_properties = nullptr, bool use_set = true); // Implementation of [[HasProperty]], ECMA-262 5th edition, section 8.12.6. MUST_USE_RESULT static Maybe HasProperty(LookupIterator* it); MUST_USE_RESULT static inline Maybe HasProperty( Handle object, Handle name); MUST_USE_RESULT static inline Maybe HasElement( Handle object, uint32_t index); MUST_USE_RESULT static inline Maybe HasOwnProperty( Handle object, Handle name); MUST_USE_RESULT static inline Maybe HasOwnProperty( Handle object, uint32_t index); MUST_USE_RESULT static inline MaybeHandle GetProperty( Isolate* isolate, Handle receiver, const char* key); MUST_USE_RESULT static inline MaybeHandle GetProperty( Handle receiver, Handle name); MUST_USE_RESULT static inline MaybeHandle GetElement( Isolate* isolate, Handle receiver, uint32_t index); // Implementation of ES6 [[Delete]] MUST_USE_RESULT static Maybe DeletePropertyOrElement( Handle object, Handle name, LanguageMode language_mode = SLOPPY); MUST_USE_RESULT static Maybe DeleteProperty( Handle object, Handle name, LanguageMode language_mode = SLOPPY); MUST_USE_RESULT static Maybe DeleteProperty(LookupIterator* it, LanguageMode language_mode); MUST_USE_RESULT static Maybe DeleteElement( Handle object, uint32_t index, LanguageMode language_mode = SLOPPY); MUST_USE_RESULT static Object* DefineProperty(Isolate* isolate, Handle object, Handle name, Handle attributes); MUST_USE_RESULT static MaybeHandle DefineProperties( Isolate* isolate, Handle object, Handle properties); // "virtual" dispatcher to the correct [[DefineOwnProperty]] implementation. MUST_USE_RESULT static Maybe DefineOwnProperty( Isolate* isolate, Handle object, Handle