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); DECLARE_CAST(HeapNumber) // Dispatched behavior. bool HeapNumberBooleanValue(); 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); }; // The Simd128Value class describes heap allocated 128 bit SIMD values. class Simd128Value : public HeapObject { public: DECLARE_CAST(Simd128Value) DECLARE_PRINTER(Simd128Value) DECLARE_VERIFIER(Simd128Value) static Handle ToString(Handle input); // Equality operations. inline bool Equals(Simd128Value* that); static inline bool Equals(Handle one, Handle two); // Checks that another instance is bit-wise equal. bool BitwiseEquals(const Simd128Value* other) const; // Computes a hash from the 128 bit value, viewed as 4 32-bit integers. uint32_t Hash() const; // Copies the 16 bytes of SIMD data to the destination address. void CopyBits(void* destination) const; // Layout description. static const int kValueOffset = HeapObject::kHeaderSize; static const int kSize = kValueOffset + kSimd128Size; private: DISALLOW_IMPLICIT_CONSTRUCTORS(Simd128Value); }; // V has parameters (TYPE, Type, type, lane count, lane type) #define SIMD128_TYPES(V) \ V(FLOAT32X4, Float32x4, float32x4, 4, float) \ V(INT32X4, Int32x4, int32x4, 4, int32_t) \ V(UINT32X4, Uint32x4, uint32x4, 4, uint32_t) \ V(BOOL32X4, Bool32x4, bool32x4, 4, bool) \ V(INT16X8, Int16x8, int16x8, 8, int16_t) \ V(UINT16X8, Uint16x8, uint16x8, 8, uint16_t) \ V(BOOL16X8, Bool16x8, bool16x8, 8, bool) \ V(INT8X16, Int8x16, int8x16, 16, int8_t) \ V(UINT8X16, Uint8x16, uint8x16, 16, uint8_t) \ V(BOOL8X16, Bool8x16, bool8x16, 16, bool) #define SIMD128_VALUE_CLASS(TYPE, Type, type, lane_count, lane_type) \ class Type final : public Simd128Value { \ public: \ inline lane_type get_lane(int lane) const; \ inline void set_lane(int lane, lane_type value); \ \ DECLARE_CAST(Type) \ \ DECLARE_PRINTER(Type) \ \ static Handle ToString(Handle input); \ \ inline bool Equals(Type* that); \ \ private: \ DISALLOW_IMPLICIT_CONSTRUCTORS(Type); \ }; SIMD128_TYPES(SIMD128_VALUE_CLASS) #undef SIMD128_VALUE_CLASS 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 GetKeysConversion { KEEP_NUMBERS, CONVERT_TO_STRING }; // 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); MUST_USE_RESULT static MaybeHandle OrdinaryToPrimitive( Handle receiver, OrdinaryToPrimitiveHint hint); static MaybeHandle GetFunctionRealm(Handle receiver); // 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); // 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 key, PropertyDescriptor* desc, ShouldThrow should_throw); // ES6 7.3.4 (when passed DONT_THROW) MUST_USE_RESULT static Maybe CreateDataProperty( LookupIterator* it, Handle value, ShouldThrow should_throw); // ES6 9.1.6.1 MUST_USE_RESULT static Maybe OrdinaryDefineOwnProperty( Isolate* isolate, Handle object, Handle key, PropertyDescriptor* desc, ShouldThrow should_throw); MUST_USE_RESULT static Maybe OrdinaryDefineOwnProperty( LookupIterator* it, PropertyDescriptor* desc, ShouldThrow should_throw); // ES6 9.1.6.2 MUST_USE_RESULT static Maybe IsCompatiblePropertyDescriptor( Isolate* isolate, bool extensible, PropertyDescriptor* desc, PropertyDescriptor* current, Handle property_name, ShouldThrow should_throw); // ES6 9.1.6.3 // |it| can be NULL in cases where the ES spec passes |undefined| as the // receiver. Exactly one of |it| and |property_name| must be provided. MUST_USE_RESULT static Maybe ValidateAndApplyPropertyDescriptor( Isolate* isolate, LookupIterator* it, bool extensible, PropertyDescriptor* desc, PropertyDescriptor* current, ShouldThrow should_throw, Handle property_name = Handle()); MUST_USE_RESULT static Maybe GetOwnPropertyDescriptor( Isolate* isolate, Handle object, Handle key, PropertyDescriptor* desc); MUST_USE_RESULT static Maybe GetOwnPropertyDescriptor( LookupIterator* it, PropertyDescriptor* desc); typedef PropertyAttributes IntegrityLevel; // ES6 7.3.14 (when passed DONT_THROW) // 'level' must be SEALED or FROZEN. MUST_USE_RESULT static Maybe SetIntegrityLevel( Handle object, IntegrityLevel lvl, ShouldThrow should_throw); // ES6 7.3.15 // 'level' must be SEALED or FROZEN. MUST_USE_RESULT static Maybe TestIntegrityLevel( Handle object, IntegrityLevel lvl); // ES6 [[PreventExtensions]] (when passed DONT_THROW) MUST_USE_RESULT static Maybe PreventExtensions( Handle object, ShouldThrow should_throw); MUST_USE_RESULT static Maybe IsExtensible(Handle object); // Tests for the fast common case for property enumeration. bool IsSimpleEnum(); // Returns the class name ([[Class]] property in the specification). String* class_name(); // Returns the builtin string tag used in Object.prototype.toString. MUST_USE_RESULT static MaybeHandle BuiltinStringTag( Handle object); // Returns the constructor name (the name (possibly, inferred name) of the // function that was used to instantiate the object). static Handle GetConstructorName(Handle receiver); Context* GetCreationContext(); MUST_USE_RESULT static inline Maybe GetPropertyAttributes( Handle object, Handle name); MUST_USE_RESULT static inline Maybe GetOwnPropertyAttributes(Handle object, Handle name); MUST_USE_RESULT static inline Maybe GetElementAttributes( Handle object, uint32_t index); MUST_USE_RESULT static inline Maybe