aboutsummaryrefslogtreecommitdiff
path: root/deps/v8/src/objects/js-objects.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/objects/js-objects.h')
-rw-r--r--deps/v8/src/objects/js-objects.h427
1 files changed, 254 insertions, 173 deletions
diff --git a/deps/v8/src/objects/js-objects.h b/deps/v8/src/objects/js-objects.h
index 586fe757db..0eab21c137 100644
--- a/deps/v8/src/objects/js-objects.h
+++ b/deps/v8/src/objects/js-objects.h
@@ -6,7 +6,9 @@
#define V8_OBJECTS_JS_OBJECTS_H_
#include "src/objects.h"
+#include "src/objects/embedder-data-slot.h"
#include "src/objects/property-array.h"
+#include "torque-generated/class-definitions-from-dsl.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
@@ -14,13 +16,15 @@
namespace v8 {
namespace internal {
+enum InstanceType : uint16_t;
class JSGlobalObject;
class JSGlobalProxy;
// JSReceiver includes types on which properties can be defined, i.e.,
// JSObject and JSProxy.
-class JSReceiver : public HeapObject, public NeverReadOnlySpaceObject {
+class JSReceiver : public HeapObject {
public:
+ NEVER_READ_ONLY_SPACE
// Returns true if there is no slow (ie, dictionary) backing store.
inline bool HasFastProperties() const;
@@ -28,15 +32,15 @@ class JSReceiver : public HeapObject, public NeverReadOnlySpaceObject {
// exists. Otherwise, returns an empty_property_array when there's a
// Smi (hash code) or an empty_fixed_array for a fast properties
// map.
- inline PropertyArray* property_array() const;
+ inline PropertyArray property_array() const;
// Gets slow properties for non-global objects.
- inline NameDictionary* property_dictionary() const;
+ inline NameDictionary property_dictionary() const;
// Sets the properties backing store and makes sure any existing hash is moved
// to the new properties store. To clear out the properties store, pass in the
// empty_fixed_array(), the hash will be maintained in this case as well.
- void SetProperties(HeapObject* properties);
+ void SetProperties(HeapObject properties);
// There are five possible values for the properties offset.
// 1) EmptyFixedArray/EmptyPropertyDictionary - This is the standard
@@ -123,9 +127,10 @@ class JSReceiver : public HeapObject, public NeverReadOnlySpaceObject {
Handle<JSReceiver> object, uint32_t index,
LanguageMode language_mode = LanguageMode::kSloppy);
- V8_WARN_UNUSED_RESULT static Object* DefineProperty(
- Isolate* isolate, Handle<Object> object, Handle<Object> name,
- Handle<Object> attributes);
+ V8_WARN_UNUSED_RESULT static Object DefineProperty(Isolate* isolate,
+ Handle<Object> object,
+ Handle<Object> name,
+ Handle<Object> attributes);
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> DefineProperties(
Isolate* isolate, Handle<Object> object, Handle<Object> properties);
@@ -186,7 +191,7 @@ class JSReceiver : public HeapObject, public NeverReadOnlySpaceObject {
Handle<JSReceiver> object);
// Returns the class name ([[Class]] property in the specification).
- V8_EXPORT_PRIVATE String* class_name();
+ V8_EXPORT_PRIVATE String class_name();
// Returns the constructor (the function that was used to instantiate the
// object).
@@ -224,12 +229,12 @@ class JSReceiver : public HeapObject, public NeverReadOnlySpaceObject {
// Retrieves a permanent object identity hash code. The undefined value might
// be returned in case no hash was created yet.
- Object* GetIdentityHash(Isolate* isolate);
+ Object GetIdentityHash();
// Retrieves a permanent object identity hash code. May create and store a
// hash code if needed and none exists.
- static Smi* CreateIdentityHash(Isolate* isolate, JSReceiver* key);
- Smi* GetOrCreateIdentityHash(Isolate* isolate);
+ static Smi CreateIdentityHash(Isolate* isolate, JSReceiver key);
+ Smi GetOrCreateIdentityHash(Isolate* isolate);
// Stores the hash code. The hash passed in must be masked with
// JSReceiver::kHashMask.
@@ -252,16 +257,14 @@ class JSReceiver : public HeapObject, public NeverReadOnlySpaceObject {
static const int kHashMask = PropertyArray::HashField::kMask;
- // Layout description.
- static const int kPropertiesOrHashOffset = HeapObject::kHeaderSize;
- static const int kHeaderSize = HeapObject::kHeaderSize + kPointerSize;
+ DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, JSRECEIVER_FIELDS)
+ static const int kHeaderSize = kSize;
bool HasProxyInPrototype(Isolate* isolate);
bool HasComplexElements();
- private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(JSReceiver);
+ OBJECT_CONSTRUCTORS(JSReceiver, HeapObject);
};
// The JSObject describes real heap allocated JavaScript objects with
@@ -270,7 +273,7 @@ class JSReceiver : public HeapObject, public NeverReadOnlySpaceObject {
// caching.
class JSObject : public JSReceiver {
public:
- static bool IsUnmodifiedApiObject(Object** o);
+ static bool IsUnmodifiedApiObject(FullObjectSlot o);
static V8_WARN_UNUSED_RESULT MaybeHandle<JSObject> New(
Handle<JSFunction> constructor, Handle<JSReceiver> new_target,
@@ -350,7 +353,7 @@ class JSObject : public JSReceiver {
inline bool HasSlowStringWrapperElements();
bool HasEnumerableElements();
- inline NumberDictionary* element_dictionary(); // Gets slow elements.
+ inline NumberDictionary element_dictionary(); // Gets slow elements.
// Requires: HasFastElements().
static void EnsureWritableFastElements(Handle<JSObject> object);
@@ -401,6 +404,11 @@ class JSObject : public JSReceiver {
Handle<Name> name, Handle<Object> value,
PropertyAttributes attributes);
+ // {name} must be a UTF-8 encoded, null-terminated string.
+ static void AddProperty(Isolate* isolate, Handle<JSObject> object,
+ const char* name, Handle<Object> value,
+ PropertyAttributes attributes);
+
static void AddDataElement(Handle<JSObject> receiver, uint32_t index,
Handle<Object> value,
PropertyAttributes attributes);
@@ -440,8 +448,8 @@ class JSObject : public JSReceiver {
Handle<Map> new_map,
Isolate* isolate);
static bool UnregisterPrototypeUser(Handle<Map> user, Isolate* isolate);
- static Map* InvalidatePrototypeChains(Map* map);
- static void InvalidatePrototypeValidityCell(JSGlobalObject* global);
+ static Map InvalidatePrototypeChains(Map map);
+ static void InvalidatePrototypeValidityCell(JSGlobalObject global);
// Updates prototype chain tracking information when an object changes its
// map from |old_map| to |new_map|.
@@ -449,15 +457,15 @@ class JSObject : public JSReceiver {
Isolate* isolate);
// Utility used by many Array builtins and runtime functions
- static inline bool PrototypeHasNoElements(Isolate* isolate, JSObject* object);
+ static inline bool PrototypeHasNoElements(Isolate* isolate, JSObject object);
// To be passed to PrototypeUsers::Compact.
- static void PrototypeRegistryCompactionCallback(HeapObject* value,
+ static void PrototypeRegistryCompactionCallback(HeapObject value,
int old_index, int new_index);
// Retrieve interceptors.
- inline InterceptorInfo* GetNamedInterceptor();
- inline InterceptorInfo* GetIndexedInterceptor();
+ inline InterceptorInfo GetNamedInterceptor();
+ inline InterceptorInfo GetIndexedInterceptor();
// Used from JSReceiver.
V8_WARN_UNUSED_RESULT static Maybe<PropertyAttributes>
@@ -488,14 +496,16 @@ class JSObject : public JSReceiver {
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> GetPropertyWithInterceptor(
LookupIterator* it, bool* done);
- static void ValidateElements(JSObject* object);
+ static void ValidateElements(JSObject object);
// Makes sure that this object can contain HeapObject as elements.
static inline void EnsureCanContainHeapObjectElements(Handle<JSObject> obj);
// Makes sure that this object can contain the specified elements.
+ // TSlot here is either ObjectSlot or FullObjectSlot.
+ template <typename TSlot>
static inline void EnsureCanContainElements(Handle<JSObject> object,
- Object** elements, uint32_t count,
+ TSlot elements, uint32_t count,
EnsureElementsMode mode);
static inline void EnsureCanContainElements(Handle<JSObject> object,
Handle<FixedArrayBase> elements,
@@ -543,15 +553,18 @@ class JSObject : public JSReceiver {
// JSFunction objects.
static int GetHeaderSize(InstanceType instance_type,
bool function_has_prototype_slot = false);
- static inline int GetHeaderSize(const Map* map);
+ static inline int GetHeaderSize(const Map map);
inline int GetHeaderSize() const;
- static inline int GetEmbedderFieldCount(const Map* map);
+ static inline int GetEmbedderFieldsStartOffset(const Map map);
+ inline int GetEmbedderFieldsStartOffset();
+
+ static inline int GetEmbedderFieldCount(const Map map);
inline int GetEmbedderFieldCount() const;
inline int GetEmbedderFieldOffset(int index);
- inline Object* GetEmbedderField(int index);
- inline void SetEmbedderField(int index, Object* value);
- inline void SetEmbedderField(int index, Smi* value);
+ inline Object GetEmbedderField(int index);
+ inline void SetEmbedderField(int index, Object value);
+ inline void SetEmbedderField(int index, Smi value);
// Returns true when the object is potentially a wrapper that gets special
// garbage collection treatment.
@@ -592,7 +605,7 @@ class JSObject : public JSReceiver {
// NumberDictionary dictionary. Returns the backing after conversion.
static Handle<NumberDictionary> NormalizeElements(Handle<JSObject> object);
- void RequireSlowElements(NumberDictionary* dictionary);
+ void RequireSlowElements(NumberDictionary dictionary);
// Transform slow named properties to fast variants.
static void MigrateSlowToFast(Handle<JSObject> object,
@@ -604,21 +617,21 @@ class JSObject : public JSReceiver {
static Handle<Object> FastPropertyAt(Handle<JSObject> object,
Representation representation,
FieldIndex index);
- inline Object* RawFastPropertyAt(FieldIndex index);
+ inline Object RawFastPropertyAt(FieldIndex index);
inline double RawFastDoublePropertyAt(FieldIndex index);
inline uint64_t RawFastDoublePropertyAsBitsAt(FieldIndex index);
- inline void FastPropertyAtPut(FieldIndex index, Object* value);
- inline void RawFastPropertyAtPut(FieldIndex index, Object* value);
+ inline void FastPropertyAtPut(FieldIndex index, Object value);
+ inline void RawFastPropertyAtPut(FieldIndex index, Object value);
inline void RawFastDoublePropertyAsBitsAtPut(FieldIndex index, uint64_t bits);
inline void WriteToField(int descriptor, PropertyDetails details,
- Object* value);
+ Object value);
// Access to in object properties.
inline int GetInObjectPropertyOffset(int index);
- inline Object* InObjectPropertyAt(int index);
- inline Object* InObjectPropertyAtPut(
- int index, Object* value, WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
+ inline Object InObjectPropertyAt(int index);
+ inline Object InObjectPropertyAtPut(
+ int index, Object value, WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
// Set the object's prototype (only JSReceiver and null are allowed values).
V8_WARN_UNUSED_RESULT static Maybe<bool> SetPrototype(
@@ -634,11 +647,11 @@ class JSObject : public JSReceiver {
// pre_allocated_value and the rest with filler_value.
// Note: this call does not update write barrier, the caller is responsible
// to ensure that |filler_value| can be collected without WB here.
- inline void InitializeBody(Map* map, int start_offset,
- Object* pre_allocated_value, Object* filler_value);
+ inline void InitializeBody(Map map, int start_offset,
+ Object pre_allocated_value, Object filler_value);
// Check whether this object references another object
- bool ReferencesObject(Object* obj);
+ bool ReferencesObject(Object obj);
V8_WARN_UNUSED_RESULT static Maybe<bool> TestIntegrityLevel(
Handle<JSObject> object, IntegrityLevel lvl);
@@ -668,7 +681,7 @@ class JSObject : public JSReceiver {
ElementsKind to_kind,
Handle<FixedArrayBase> to_elements);
- void PrintInstanceMigration(FILE* file, Map* original_map, Map* new_map);
+ void PrintInstanceMigration(FILE* file, Map original_map, Map new_map);
#ifdef DEBUG
// Structure for collecting spill information about JSObjects.
@@ -699,7 +712,7 @@ class JSObject : public JSReceiver {
bool ElementsAreSafeToExamine() const;
#endif
- Object* SlowReverseLookup(Object* value);
+ Object SlowReverseLookup(Object value);
// Maximal number of elements (numbered 0 .. kMaxElementCount - 1).
// Also maximal value of JSArray's length property.
@@ -724,7 +737,7 @@ class JSObject : public JSReceiver {
// not to arbitrary other JSObject maps.
static const int kInitialGlobalObjectUnusedPropertiesCount = 4;
- static const int kMaxInstanceSize = 255 * kPointerSize;
+ static const int kMaxInstanceSize = 255 * kTaggedSize;
// When extending the backing storage for property values, we increase
// its size by more than the 1 entry necessary, so sequentially adding fields
@@ -733,19 +746,34 @@ class JSObject : public JSReceiver {
STATIC_ASSERT(kMaxNumberOfDescriptors + kFieldsAdded <=
PropertyArray::kMaxLength);
- // Layout description.
- static const int kElementsOffset = JSReceiver::kHeaderSize;
- static const int kHeaderSize = kElementsOffset + kPointerSize;
+// Layout description.
+#define JS_OBJECT_FIELDS(V) \
+ V(kElementsOffset, kTaggedSize) \
+ /* Header size. */ \
+ V(kHeaderSize, 0) \
+ V(kOptionalEmbedderFieldPadding, \
+ POINTER_SIZE_PADDING(kOptionalEmbedderFieldPadding)) \
+ /* Header size aligned to kSystemPointerSize. */ \
+ V(kHeaderSizeForEmbedderFields, 0)
+
+ DEFINE_FIELD_OFFSET_CONSTANTS(JSReceiver::kHeaderSize, JS_OBJECT_FIELDS)
+#undef JS_OBJECT_FIELDS
STATIC_ASSERT(kHeaderSize == Internals::kJSObjectHeaderSize);
static const int kMaxInObjectProperties =
- (kMaxInstanceSize - kHeaderSize) >> kPointerSizeLog2;
+ (kMaxInstanceSize - kHeaderSize) >> kTaggedSizeLog2;
STATIC_ASSERT(kMaxInObjectProperties <= kMaxNumberOfDescriptors);
- // TODO(cbruni): Revisit calculation of the max supported embedder fields.
+
+ STATIC_ASSERT(kHeaderSizeForEmbedderFields ==
+ Internals::kJSObjectHeaderSizeForEmbedderFields);
+ static const int kMaxFirstInobjectPropertyOffset =
+ (1 << kFirstInobjectPropertyOffsetBitCount) - 1;
static const int kMaxEmbedderFields =
- ((1 << kFirstInobjectPropertyOffsetBitCount) - 1 - kHeaderSize) >>
- kPointerSizeLog2;
- STATIC_ASSERT(kMaxEmbedderFields <= kMaxInObjectProperties);
+ (kMaxFirstInobjectPropertyOffset - kHeaderSizeForEmbedderFields) /
+ kEmbedderDataSlotSize;
+ STATIC_ASSERT(kHeaderSizeForEmbedderFields +
+ kMaxEmbedderFields * kEmbedderDataSlotSizeInTaggedSlots <=
+ kMaxInstanceSize);
class BodyDescriptor;
@@ -771,8 +799,8 @@ class JSObject : public JSReceiver {
V8_WARN_UNUSED_RESULT static Maybe<bool> DeletePropertyWithInterceptor(
LookupIterator* it, ShouldThrow should_throw);
- bool ReferencesObjectFromElements(FixedArray* elements, ElementsKind kind,
- Object* object);
+ bool ReferencesObjectFromElements(FixedArray elements, ElementsKind kind,
+ Object object);
// Helper for fast versions of preventExtensions, seal, and freeze.
// attrs is one of NONE, SEALED, or FROZEN (depending on the operation).
@@ -780,7 +808,7 @@ class JSObject : public JSReceiver {
V8_WARN_UNUSED_RESULT static Maybe<bool> PreventExtensionsWithTransition(
Handle<JSObject> object, ShouldThrow should_throw);
- DISALLOW_IMPLICIT_CONSTRUCTORS(JSObject);
+ OBJECT_CONSTRUCTORS(JSObject, JSReceiver);
};
// JSAccessorPropertyDescriptor is just a JSObject with a specific initial
@@ -789,12 +817,19 @@ class JSObject : public JSReceiver {
// FromPropertyDescriptor function for regular accessor properties.
class JSAccessorPropertyDescriptor : public JSObject {
public:
- // Offsets of object fields.
- static const int kGetOffset = JSObject::kHeaderSize;
- static const int kSetOffset = kGetOffset + kPointerSize;
- static const int kEnumerableOffset = kSetOffset + kPointerSize;
- static const int kConfigurableOffset = kEnumerableOffset + kPointerSize;
- static const int kSize = kConfigurableOffset + kPointerSize;
+ // Layout description.
+#define JS_ACCESSOR_PROPERTY_DESCRIPTOR_FIELDS(V) \
+ V(kGetOffset, kTaggedSize) \
+ V(kSetOffset, kTaggedSize) \
+ V(kEnumerableOffset, kTaggedSize) \
+ V(kConfigurableOffset, kTaggedSize) \
+ /* Total size. */ \
+ V(kSize, 0)
+
+ DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
+ JS_ACCESSOR_PROPERTY_DESCRIPTOR_FIELDS)
+#undef JS_ACCESSOR_PROPERTY_DESCRIPTOR_FIELDS
+
// Indices of in-object properties.
static const int kGetIndex = 0;
static const int kSetIndex = 1;
@@ -811,12 +846,19 @@ class JSAccessorPropertyDescriptor : public JSObject {
// FromPropertyDescriptor function for regular data properties.
class JSDataPropertyDescriptor : public JSObject {
public:
- // Offsets of object fields.
- static const int kValueOffset = JSObject::kHeaderSize;
- static const int kWritableOffset = kValueOffset + kPointerSize;
- static const int kEnumerableOffset = kWritableOffset + kPointerSize;
- static const int kConfigurableOffset = kEnumerableOffset + kPointerSize;
- static const int kSize = kConfigurableOffset + kPointerSize;
+ // Layout description.
+#define JS_DATA_PROPERTY_DESCRIPTOR_FIELDS(V) \
+ V(kValueOffset, kTaggedSize) \
+ V(kWritableOffset, kTaggedSize) \
+ V(kEnumerableOffset, kTaggedSize) \
+ V(kConfigurableOffset, kTaggedSize) \
+ /* Total size. */ \
+ V(kSize, 0)
+
+ DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
+ JS_DATA_PROPERTY_DESCRIPTOR_FIELDS)
+#undef JS_DATA_PROPERTY_DESCRIPTOR_FIELDS
+
// Indices of in-object properties.
static const int kValueIndex = 0;
static const int kWritableIndex = 1;
@@ -836,23 +878,31 @@ class JSIteratorResult : public JSObject {
DECL_ACCESSORS(done, Object)
- // Offsets of object fields.
- static const int kValueOffset = JSObject::kHeaderSize;
- static const int kDoneOffset = kValueOffset + kPointerSize;
- static const int kSize = kDoneOffset + kPointerSize;
+ // Layout description.
+#define JS_ITERATOR_RESULT_FIELDS(V) \
+ V(kValueOffset, kTaggedSize) \
+ V(kDoneOffset, kTaggedSize) \
+ /* Total size. */ \
+ V(kSize, 0)
+
+ DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
+ JS_ITERATOR_RESULT_FIELDS)
+#undef JS_ITERATOR_RESULT_FIELDS
+
// Indices of in-object properties.
static const int kValueIndex = 0;
static const int kDoneIndex = 1;
- private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(JSIteratorResult);
+ DECL_CAST(JSIteratorResult)
+
+ OBJECT_CONSTRUCTORS(JSIteratorResult, JSObject);
};
// JSBoundFunction describes a bound function exotic object.
class JSBoundFunction : public JSObject {
public:
// [bound_target_function]: The wrapped function object.
- inline Object* raw_bound_target_function() const;
+ inline Object raw_bound_target_function() const;
DECL_ACCESSORS(bound_target_function, JSReceiver)
// [bound_this]: The value that is always passed as the this value when
@@ -881,13 +931,9 @@ class JSBoundFunction : public JSObject {
static Handle<String> ToString(Handle<JSBoundFunction> function);
// Layout description.
- static const int kBoundTargetFunctionOffset = JSObject::kHeaderSize;
- static const int kBoundThisOffset = kBoundTargetFunctionOffset + kPointerSize;
- static const int kBoundArgumentsOffset = kBoundThisOffset + kPointerSize;
- static const int kSize = kBoundArgumentsOffset + kPointerSize;
+ DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JSBOUND_FUNCTION_FIELDS)
- private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(JSBoundFunction);
+ OBJECT_CONSTRUCTORS(JSBoundFunction, JSObject);
};
// JSFunction describes JavaScript functions.
@@ -906,11 +952,11 @@ class JSFunction : public JSObject {
static const int kMaybeHomeObjectDescriptorIndex = 2;
// [context]: The context for this function.
- inline Context* context();
+ inline Context context();
inline bool has_context() const;
- inline void set_context(Object* context);
- inline JSGlobalProxy* global_proxy();
- inline Context* native_context();
+ inline void set_context(Object context);
+ inline JSGlobalProxy global_proxy();
+ inline Context native_context();
static Handle<Object> GetName(Isolate* isolate, Handle<JSFunction> function);
static Maybe<int> GetLength(Isolate* isolate, Handle<JSFunction> function);
@@ -920,13 +966,13 @@ class JSFunction : public JSObject {
// when the function is invoked, e.g. foo() or new foo(). See
// [[Call]] and [[Construct]] description in ECMA-262, section
// 8.6.2, page 27.
- inline Code* code();
- inline void set_code(Code* code);
- inline void set_code_no_write_barrier(Code* code);
+ inline Code code() const;
+ inline void set_code(Code code);
+ inline void set_code_no_write_barrier(Code code);
// Get the abstract code associated with the function, which will either be
// a Code object or a BytecodeArray.
- inline AbstractCode* abstract_code();
+ inline AbstractCode abstract_code();
// Tells whether or not this function is interpreted.
//
@@ -981,22 +1027,28 @@ class JSFunction : public JSObject {
// Completes inobject slack tracking on initial map if it is active.
inline void CompleteInobjectSlackTrackingIfActive();
- // [feedback_cell]: The FeedbackCell used to hold the FeedbackVector
- // eventually.
- DECL_ACCESSORS(feedback_cell, FeedbackCell)
+ // [raw_feedback_cell]: Gives raw access to the FeedbackCell used to hold the
+ /// FeedbackVector eventually. Generally this shouldn't be used to get the
+ // feedback_vector, instead use feedback_vector() which correctly deals with
+ // the JSFunction's bytecode being flushed.
+ DECL_ACCESSORS(raw_feedback_cell, FeedbackCell)
// feedback_vector() can be used once the function is compiled.
- inline FeedbackVector* feedback_vector() const;
+ inline FeedbackVector feedback_vector() const;
inline bool has_feedback_vector() const;
static void EnsureFeedbackVector(Handle<JSFunction> function);
// Unconditionally clear the type feedback vector.
void ClearTypeFeedbackInfo();
+ // Resets function to clear compiled data after bytecode has been flushed.
+ inline bool NeedsResetDueToFlushedBytecode();
+ inline void ResetIfBytecodeFlushed();
+
inline bool has_prototype_slot() const;
// The initial map for an object created by this constructor.
- inline Map* initial_map();
+ inline Map initial_map();
static void SetInitialMap(Handle<JSFunction> function, Handle<Map> map,
Handle<Object> prototype);
inline bool has_initial_map();
@@ -1015,14 +1067,14 @@ class JSFunction : public JSObject {
// until an initial map is needed.
inline bool has_prototype();
inline bool has_instance_prototype();
- inline Object* prototype();
- inline Object* instance_prototype();
+ inline Object prototype();
+ inline Object instance_prototype();
inline bool has_prototype_property();
inline bool PrototypeRequiresRuntimeLookup();
static void SetPrototype(Handle<JSFunction> function, Handle<Object> value);
// Returns if this function has been compiled to native code yet.
- inline bool is_compiled();
+ inline bool is_compiled() const;
static int GetHeaderSize(bool function_has_prototype_slot) {
return function_has_prototype_slot ? JSFunction::kSizeWithPrototype
@@ -1046,8 +1098,6 @@ class JSFunction : public JSObject {
int* instance_size,
int* in_object_properties);
- class BodyDescriptor;
-
// Dispatched behavior.
DECL_PRINTER(JSFunction)
DECL_VERIFIER(JSFunction)
@@ -1073,25 +1123,12 @@ class JSFunction : public JSObject {
// ES6 section 19.2.3.5 Function.prototype.toString ( ).
static Handle<String> ToString(Handle<JSFunction> function);
-// Layout description.
-#define JS_FUNCTION_FIELDS(V) \
- /* Pointer fields. */ \
- V(kSharedFunctionInfoOffset, kPointerSize) \
- V(kContextOffset, kPointerSize) \
- V(kFeedbackCellOffset, kPointerSize) \
- V(kEndOfStrongFieldsOffset, 0) \
- V(kCodeOffset, kPointerSize) \
- /* Size of JSFunction object without prototype field. */ \
- V(kSizeWithoutPrototype, 0) \
- V(kPrototypeOrInitialMapOffset, kPointerSize) \
- /* Size of JSFunction object with prototype field. */ \
- V(kSizeWithPrototype, 0)
-
- DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JS_FUNCTION_FIELDS)
-#undef JS_FUNCTION_FIELDS
+ DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JSFUNCTION_FIELDS)
- private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(JSFunction);
+ static constexpr int kSizeWithoutPrototype = kPrototypeOrInitialMapOffset;
+ static constexpr int kSizeWithPrototype = kSize;
+
+ OBJECT_CONSTRUCTORS(JSFunction, JSObject);
};
// JSGlobalProxy's prototype must be a JSGlobalObject or null,
@@ -1110,7 +1147,7 @@ class JSGlobalProxy : public JSObject {
DECL_CAST(JSGlobalProxy)
- inline bool IsDetachedFrom(JSGlobalObject* global) const;
+ inline bool IsDetachedFrom(JSGlobalObject global) const;
static int SizeWithEmbedderFields(int embedder_field_count);
@@ -1119,11 +1156,15 @@ class JSGlobalProxy : public JSObject {
DECL_VERIFIER(JSGlobalProxy)
// Layout description.
- static const int kNativeContextOffset = JSObject::kHeaderSize;
- static const int kSize = kNativeContextOffset + kPointerSize;
+#define JS_GLOBAL_PROXY_FIELDS(V) \
+ V(kNativeContextOffset, kTaggedSize) \
+ /* Header size. */ \
+ V(kSize, 0)
- private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalProxy);
+ DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JS_GLOBAL_PROXY_FIELDS)
+#undef JS_GLOBAL_PROXY_FIELDS
+
+ OBJECT_CONSTRUCTORS(JSGlobalProxy, JSObject);
};
// JavaScript global object.
@@ -1136,8 +1177,8 @@ class JSGlobalObject : public JSObject {
DECL_ACCESSORS(global_proxy, JSObject)
// Gets global object properties.
- inline GlobalDictionary* global_dictionary();
- inline void set_global_dictionary(GlobalDictionary* dictionary);
+ inline GlobalDictionary global_dictionary();
+ inline void set_global_dictionary(GlobalDictionary dictionary);
static void InvalidatePropertyCell(Handle<JSGlobalObject> object,
Handle<Name> name);
@@ -1155,13 +1196,17 @@ class JSGlobalObject : public JSObject {
DECL_VERIFIER(JSGlobalObject)
// Layout description.
- static const int kNativeContextOffset = JSObject::kHeaderSize;
- static const int kGlobalProxyOffset = kNativeContextOffset + kPointerSize;
- static const int kHeaderSize = kGlobalProxyOffset + kPointerSize;
- static const int kSize = kHeaderSize;
+#define JS_GLOBAL_OBJECT_FIELDS(V) \
+ V(kNativeContextOffset, kTaggedSize) \
+ V(kGlobalProxyOffset, kTaggedSize) \
+ /* Header size. */ \
+ V(kHeaderSize, 0) \
+ V(kSize, 0)
- private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalObject);
+ DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JS_GLOBAL_OBJECT_FIELDS)
+#undef JS_GLOBAL_OBJECT_FIELDS
+
+ OBJECT_CONSTRUCTORS(JSGlobalObject, JSObject);
};
// Representation for JS Wrapper objects, String, Number, Boolean, etc.
@@ -1177,11 +1222,15 @@ class JSValue : public JSObject {
DECL_VERIFIER(JSValue)
// Layout description.
- static const int kValueOffset = JSObject::kHeaderSize;
- static const int kSize = kValueOffset + kPointerSize;
+#define JS_VALUE_FIELDS(V) \
+ V(kValueOffset, kTaggedSize) \
+ /* Header size. */ \
+ V(kSize, 0)
- private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(JSValue);
+ DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JS_VALUE_FIELDS)
+#undef JS_VALUE_FIELDS
+
+ OBJECT_CONSTRUCTORS(JSValue, JSObject);
};
class DateCache;
@@ -1220,11 +1269,16 @@ class JSDate : public JSObject {
// Returns the date field with the specified index.
// See FieldIndex for the list of date fields.
- static Object* GetField(Object* date, Smi* index);
+ // Arguments and result are raw Address values because this is called
+ // via ExternalReference.
+ // {raw_date} is a tagged Object pointer.
+ // {smi_index} is a tagged Smi.
+ // The return value is a tagged Object pointer.
+ static Address GetField(Address raw_date, Address smi_index);
static Handle<Object> SetValue(Handle<JSDate> date, double v);
- void SetValue(Object* value, bool is_value_nan);
+ void SetValue(Object value, bool is_value_nan);
// Dispatched behavior.
DECL_PRINTER(JSDate)
@@ -1260,26 +1314,31 @@ class JSDate : public JSObject {
};
// Layout description.
- static const int kValueOffset = JSObject::kHeaderSize;
- static const int kYearOffset = kValueOffset + kPointerSize;
- static const int kMonthOffset = kYearOffset + kPointerSize;
- static const int kDayOffset = kMonthOffset + kPointerSize;
- static const int kWeekdayOffset = kDayOffset + kPointerSize;
- static const int kHourOffset = kWeekdayOffset + kPointerSize;
- static const int kMinOffset = kHourOffset + kPointerSize;
- static const int kSecOffset = kMinOffset + kPointerSize;
- static const int kCacheStampOffset = kSecOffset + kPointerSize;
- static const int kSize = kCacheStampOffset + kPointerSize;
+#define JS_DATE_FIELDS(V) \
+ V(kValueOffset, kTaggedSize) \
+ V(kYearOffset, kTaggedSize) \
+ V(kMonthOffset, kTaggedSize) \
+ V(kDayOffset, kTaggedSize) \
+ V(kWeekdayOffset, kTaggedSize) \
+ V(kHourOffset, kTaggedSize) \
+ V(kMinOffset, kTaggedSize) \
+ V(kSecOffset, kTaggedSize) \
+ V(kCacheStampOffset, kTaggedSize) \
+ /* Header size. */ \
+ V(kSize, 0)
+
+ DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JS_DATE_FIELDS)
+#undef JS_DATE_FIELDS
private:
- inline Object* DoGetField(FieldIndex index);
+ inline Object DoGetField(FieldIndex index);
- Object* GetUTCField(FieldIndex index, double value, DateCache* date_cache);
+ Object GetUTCField(FieldIndex index, double value, DateCache* date_cache);
// Computes and caches the cacheable fields of the date.
inline void SetCachedFields(int64_t local_time_ms, DateCache* date_cache);
- DISALLOW_IMPLICIT_CONSTRUCTORS(JSDate);
+ OBJECT_CONSTRUCTORS(JSDate, JSObject);
};
// Representation of message objects used for error reporting through
@@ -1291,8 +1350,8 @@ class JSDate : public JSObject {
class JSMessageObject : public JSObject {
public:
// [type]: the type of error message.
- inline int type() const;
- inline void set_type(int value);
+ inline MessageTemplate type() const;
+ inline void set_type(MessageTemplate value);
// [arguments]: the arguments for formatting the error message.
DECL_ACCESSORS(argument, Object)
@@ -1332,18 +1391,29 @@ class JSMessageObject : public JSObject {
DECL_VERIFIER(JSMessageObject)
// Layout description.
- static const int kTypeOffset = JSObject::kHeaderSize;
- static const int kArgumentsOffset = kTypeOffset + kPointerSize;
- static const int kScriptOffset = kArgumentsOffset + kPointerSize;
- static const int kStackFramesOffset = kScriptOffset + kPointerSize;
- static const int kStartPositionOffset = kStackFramesOffset + kPointerSize;
- static const int kEndPositionOffset = kStartPositionOffset + kPointerSize;
- static const int kErrorLevelOffset = kEndPositionOffset + kPointerSize;
- static const int kSize = kErrorLevelOffset + kPointerSize;
-
- typedef FixedBodyDescriptor<HeapObject::kMapOffset,
- kStackFramesOffset + kPointerSize, kSize>
+#define JS_MESSAGE_FIELDS(V) \
+ /* Tagged fields. */ \
+ V(kTypeOffset, kTaggedSize) \
+ V(kArgumentsOffset, kTaggedSize) \
+ V(kScriptOffset, kTaggedSize) \
+ V(kStackFramesOffset, kTaggedSize) \
+ V(kPointerFieldsEndOffset, 0) \
+ /* Raw data fields. */ \
+ /* TODO(ishell): store as int32 instead of Smi. */ \
+ V(kStartPositionOffset, kTaggedSize) \
+ V(kEndPositionOffset, kTaggedSize) \
+ V(kErrorLevelOffset, kTaggedSize) \
+ /* Total size. */ \
+ V(kSize, 0)
+
+ DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JS_MESSAGE_FIELDS)
+#undef JS_MESSAGE_FIELDS
+
+ typedef FixedBodyDescriptor<HeapObject::kMapOffset, kPointerFieldsEndOffset,
+ kSize>
BodyDescriptor;
+
+ OBJECT_CONSTRUCTORS(JSMessageObject, JSObject)
};
// The [Async-from-Sync Iterator] object
@@ -1368,13 +1438,18 @@ class JSAsyncFromSyncIterator : public JSObject {
// subsequent "next" invocations.
DECL_ACCESSORS(next, Object)
- // Offsets of object fields.
- static const int kSyncIteratorOffset = JSObject::kHeaderSize;
- static const int kNextOffset = kSyncIteratorOffset + kPointerSize;
- static const int kSize = kNextOffset + kPointerSize;
+ // Layout description.
+#define JS_ASYNC_FROM_SYNC_ITERATOR_FIELDS(V) \
+ V(kSyncIteratorOffset, kTaggedSize) \
+ V(kNextOffset, kTaggedSize) \
+ /* Total size. */ \
+ V(kSize, 0)
- private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(JSAsyncFromSyncIterator);
+ DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
+ JS_ASYNC_FROM_SYNC_ITERATOR_FIELDS)
+#undef JS_ASYNC_FROM_SYNC_ITERATOR_FIELDS
+
+ OBJECT_CONSTRUCTORS(JSAsyncFromSyncIterator, JSObject);
};
class JSStringIterator : public JSObject {
@@ -1392,12 +1467,18 @@ class JSStringIterator : public JSObject {
inline int index() const;
inline void set_index(int value);
- static const int kStringOffset = JSObject::kHeaderSize;
- static const int kNextIndexOffset = kStringOffset + kPointerSize;
- static const int kSize = kNextIndexOffset + kPointerSize;
+ // Layout description.
+#define JS_STRING_ITERATOR_FIELDS(V) \
+ V(kStringOffset, kTaggedSize) \
+ V(kNextIndexOffset, kTaggedSize) \
+ /* Total size. */ \
+ V(kSize, 0)
+
+ DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
+ JS_STRING_ITERATOR_FIELDS)
+#undef JS_STRING_ITERATOR_FIELDS
- private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(JSStringIterator);
+ OBJECT_CONSTRUCTORS(JSStringIterator, JSObject);
};
} // namespace internal