Commit 78ca705f authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[cleanup] Fix kPointerSize usages in src/objects/, part 2

Bug: v8:8477, v8:8238
Tbr: bmeurer@chromium.org
Change-Id: I03e6e83bc805c6880318161e00b367df0a3b4003
Reviewed-on: https://chromium-review.googlesource.com/c/1348434
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57756}
parent be77c3ef
...@@ -2821,9 +2821,10 @@ void CodeStubAssembler::StoreFixedArrayOrPropertyArrayElement( ...@@ -2821,9 +2821,10 @@ void CodeStubAssembler::StoreFixedArrayOrPropertyArrayElement(
FixedArray::kHeaderSize + additional_offset - kHeapObjectTag; FixedArray::kHeaderSize + additional_offset - kHeapObjectTag;
Node* offset = ElementOffsetFromIndex(index_node, HOLEY_ELEMENTS, Node* offset = ElementOffsetFromIndex(index_node, HOLEY_ELEMENTS,
parameter_mode, header_size); parameter_mode, header_size);
STATIC_ASSERT(FixedArrayBase::kLengthOffset == WeakFixedArray::kLengthOffset); STATIC_ASSERT(static_cast<int>(FixedArrayBase::kLengthOffset) ==
STATIC_ASSERT(FixedArrayBase::kLengthOffset == static_cast<int>(WeakFixedArray::kLengthOffset));
PropertyArray::kLengthAndHashOffset); STATIC_ASSERT(static_cast<int>(FixedArrayBase::kLengthOffset) ==
static_cast<int>(PropertyArray::kLengthAndHashOffset));
// Check that index_node + additional_offset <= object.length. // Check that index_node + additional_offset <= object.length.
// TODO(cbruni): Use proper LoadXXLength helpers // TODO(cbruni): Use proper LoadXXLength helpers
CSA_ASSERT( CSA_ASSERT(
......
...@@ -3011,8 +3011,9 @@ Reduction JSCallReducer::ReduceCallOrConstructWithArrayLikeOrSpread( ...@@ -3011,8 +3011,9 @@ Reduction JSCallReducer::ReduceCallOrConstructWithArrayLikeOrSpread(
FieldAccess const& access = FieldAccessOf(user->op()); FieldAccess const& access = FieldAccessOf(user->op());
if (access.offset == JSArray::kLengthOffset) { if (access.offset == JSArray::kLengthOffset) {
// Ignore uses for arguments#length. // Ignore uses for arguments#length.
STATIC_ASSERT(JSArray::kLengthOffset == STATIC_ASSERT(
JSArgumentsObjectWithLength::kLengthOffset); static_cast<int>(JSArray::kLengthOffset) ==
static_cast<int>(JSArgumentsObjectWithLength::kLengthOffset));
continue; continue;
} else if (access.offset == JSObject::kElementsOffset) { } else if (access.offset == JSObject::kElementsOffset) {
// Ignore safe uses for arguments#elements. // Ignore safe uses for arguments#elements.
......
...@@ -836,6 +836,10 @@ constexpr int kIeeeDoubleExponentWordOffset = 0; ...@@ -836,6 +836,10 @@ constexpr int kIeeeDoubleExponentWordOffset = 0;
#define POINTER_SIZE_ALIGN(value) \ #define POINTER_SIZE_ALIGN(value) \
(((value) + kPointerAlignmentMask) & ~kPointerAlignmentMask) (((value) + kPointerAlignmentMask) & ~kPointerAlignmentMask)
// POINTER_SIZE_PADDING returns the padding size required to align value
// as a system pointer.
#define POINTER_SIZE_PADDING(value) (POINTER_SIZE_ALIGN(value) - (value))
// CODE_POINTER_ALIGN returns the value aligned as a generated code segment. // CODE_POINTER_ALIGN returns the value aligned as a generated code segment.
#define CODE_POINTER_ALIGN(value) \ #define CODE_POINTER_ALIGN(value) \
(((value) + kCodeAlignmentMask) & ~kCodeAlignmentMask) (((value) + kCodeAlignmentMask) & ~kCodeAlignmentMask)
......
...@@ -166,18 +166,21 @@ class DebugInfo : public Struct, public NeverReadOnlySpaceObject { ...@@ -166,18 +166,21 @@ class DebugInfo : public Struct, public NeverReadOnlySpaceObject {
DECL_PRINTER(DebugInfo) DECL_PRINTER(DebugInfo)
DECL_VERIFIER(DebugInfo) DECL_VERIFIER(DebugInfo)
static const int kSharedFunctionInfoOffset = Struct::kHeaderSize; // Layout description.
static const int kDebuggerHintsOffset = #define DEBUG_INFO_FIELDS(V) \
kSharedFunctionInfoOffset + kPointerSize; V(kSharedFunctionInfoOffset, kTaggedSize) \
static const int kScriptOffset = kDebuggerHintsOffset + kPointerSize; V(kDebuggerHintsOffset, kTaggedSize) \
static const int kOriginalBytecodeArrayOffset = kScriptOffset + kPointerSize; V(kScriptOffset, kTaggedSize) \
static const int kDebugBytecodeArrayOffset = V(kOriginalBytecodeArrayOffset, kTaggedSize) \
kOriginalBytecodeArrayOffset + kPointerSize; V(kDebugBytecodeArrayOffset, kTaggedSize) \
static const int kBreakPointsStateOffset = V(kBreakPointsStateOffset, kTaggedSize) \
kDebugBytecodeArrayOffset + kPointerSize; V(kFlagsOffset, kTaggedSize) \
static const int kFlagsOffset = kBreakPointsStateOffset + kPointerSize; V(kCoverageInfoOffset, kTaggedSize) \
static const int kCoverageInfoOffset = kFlagsOffset + kPointerSize; /* Total size. */ \
static const int kSize = kCoverageInfoOffset + kPointerSize; V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(Struct::kHeaderSize, DEBUG_INFO_FIELDS)
#undef DEBUG_INFO_FIELDS
static const int kEstimatedNofBreakPointsInFunction = 4; static const int kEstimatedNofBreakPointsInFunction = 4;
......
...@@ -141,9 +141,15 @@ class DescriptorArray : public WeakFixedArray { ...@@ -141,9 +141,15 @@ class DescriptorArray : public WeakFixedArray {
static const int kFirstIndex = 2; static const int kFirstIndex = 2;
// Layout description. // Layout description.
static const int kDescriptorLengthOffset = FixedArray::kHeaderSize; #define DESCRIPTOR_ARRAY_FIELDS(V) \
static const int kEnumCacheOffset = kDescriptorLengthOffset + kPointerSize; V(kDescriptorLengthOffset, kTaggedSize) \
static const int kFirstOffset = kEnumCacheOffset + kPointerSize; V(kEnumCacheOffset, kTaggedSize) \
/* Header size. */ \
V(kFirstOffset, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(FixedArray::kHeaderSize,
DESCRIPTOR_ARRAY_FIELDS)
#undef DESCRIPTOR_ARRAY_FIELDS
// Layout of descriptor. // Layout of descriptor.
// Naming is consistent with Dictionary classes for easy templating. // Naming is consistent with Dictionary classes for easy templating.
......
...@@ -75,11 +75,11 @@ bool FixedArrayPtr::ContainsOnlySmisOrHoles() { ...@@ -75,11 +75,11 @@ bool FixedArrayPtr::ContainsOnlySmisOrHoles() {
Object* FixedArray::get(int index) const { Object* FixedArray::get(int index) const {
DCHECK(index >= 0 && index < this->length()); DCHECK(index >= 0 && index < this->length());
return RELAXED_READ_FIELD(this, kHeaderSize + index * kPointerSize); return RELAXED_READ_FIELD(this, kHeaderSize + index * kTaggedSize);
} }
Object* FixedArrayPtr::get(int index) const { Object* FixedArrayPtr::get(int index) const {
DCHECK(index >= 0 && index < this->length()); DCHECK(index >= 0 && index < this->length());
return RELAXED_READ_FIELD(this, kHeaderSize + index * kPointerSize); return RELAXED_READ_FIELD(this, kHeaderSize + index * kTaggedSize);
} }
Handle<Object> FixedArray::get(FixedArray* array, int index, Isolate* isolate) { Handle<Object> FixedArray::get(FixedArray* array, int index, Isolate* isolate) {
...@@ -127,7 +127,7 @@ void FixedArray::set(int index, Smi value) { ...@@ -127,7 +127,7 @@ void FixedArray::set(int index, Smi value) {
DCHECK_NE(map(), GetReadOnlyRoots().fixed_cow_array_map()); DCHECK_NE(map(), GetReadOnlyRoots().fixed_cow_array_map());
DCHECK_LT(index, this->length()); DCHECK_LT(index, this->length());
DCHECK(ObjectPtr(value).IsSmi()); DCHECK(ObjectPtr(value).IsSmi());
int offset = kHeaderSize + index * kPointerSize; int offset = kHeaderSize + index * kTaggedSize;
RELAXED_WRITE_FIELD(this, offset, value); RELAXED_WRITE_FIELD(this, offset, value);
} }
void FixedArrayPtr::set(int index, Smi value) { void FixedArrayPtr::set(int index, Smi value) {
...@@ -139,7 +139,7 @@ void FixedArray::set(int index, Object* value) { ...@@ -139,7 +139,7 @@ void FixedArray::set(int index, Object* value) {
DCHECK(IsFixedArray()); DCHECK(IsFixedArray());
DCHECK_GE(index, 0); DCHECK_GE(index, 0);
DCHECK_LT(index, this->length()); DCHECK_LT(index, this->length());
int offset = kHeaderSize + index * kPointerSize; int offset = kHeaderSize + index * kTaggedSize;
RELAXED_WRITE_FIELD(this, offset, value); RELAXED_WRITE_FIELD(this, offset, value);
WRITE_BARRIER(this, offset, value); WRITE_BARRIER(this, offset, value);
} }
...@@ -151,7 +151,7 @@ void FixedArray::set(int index, Object* value, WriteBarrierMode mode) { ...@@ -151,7 +151,7 @@ void FixedArray::set(int index, Object* value, WriteBarrierMode mode) {
DCHECK_NE(map(), GetReadOnlyRoots().fixed_cow_array_map()); DCHECK_NE(map(), GetReadOnlyRoots().fixed_cow_array_map());
DCHECK_GE(index, 0); DCHECK_GE(index, 0);
DCHECK_LT(index, this->length()); DCHECK_LT(index, this->length());
int offset = kHeaderSize + index * kPointerSize; int offset = kHeaderSize + index * kTaggedSize;
RELAXED_WRITE_FIELD(this, offset, value); RELAXED_WRITE_FIELD(this, offset, value);
CONDITIONAL_WRITE_BARRIER(this, offset, value, mode); CONDITIONAL_WRITE_BARRIER(this, offset, value, mode);
} }
...@@ -165,7 +165,7 @@ void FixedArray::NoWriteBarrierSet(FixedArray* array, int index, ...@@ -165,7 +165,7 @@ void FixedArray::NoWriteBarrierSet(FixedArray* array, int index,
DCHECK_GE(index, 0); DCHECK_GE(index, 0);
DCHECK_LT(index, array->length()); DCHECK_LT(index, array->length());
DCHECK(!Heap::InNewSpace(value)); DCHECK(!Heap::InNewSpace(value));
RELAXED_WRITE_FIELD(array, kHeaderSize + index * kPointerSize, value); RELAXED_WRITE_FIELD(array, kHeaderSize + index * kTaggedSize, value);
} }
void FixedArrayPtr::NoWriteBarrierSet(FixedArrayPtr array, int index, void FixedArrayPtr::NoWriteBarrierSet(FixedArrayPtr array, int index,
Object* value) { Object* value) {
...@@ -173,7 +173,7 @@ void FixedArrayPtr::NoWriteBarrierSet(FixedArrayPtr array, int index, ...@@ -173,7 +173,7 @@ void FixedArrayPtr::NoWriteBarrierSet(FixedArrayPtr array, int index,
DCHECK_GE(index, 0); DCHECK_GE(index, 0);
DCHECK_LT(index, array->length()); DCHECK_LT(index, array->length());
DCHECK(!Heap::InNewSpace(value)); DCHECK(!Heap::InNewSpace(value));
RELAXED_WRITE_FIELD(array, kHeaderSize + index * kPointerSize, value); RELAXED_WRITE_FIELD(array, kHeaderSize + index * kTaggedSize, value);
} }
void FixedArray::set_undefined(int index) { void FixedArray::set_undefined(int index) {
...@@ -419,7 +419,7 @@ void ArrayList::Clear(int index, Object* undefined) { ...@@ -419,7 +419,7 @@ void ArrayList::Clear(int index, Object* undefined) {
SKIP_WRITE_BARRIER); SKIP_WRITE_BARRIER);
} }
int ByteArray::Size() { return RoundUp(length() + kHeaderSize, kPointerSize); } int ByteArray::Size() { return RoundUp(length() + kHeaderSize, kTaggedSize); }
byte ByteArray::get(int index) const { byte ByteArray::get(int index) const {
DCHECK(index >= 0 && index < this->length()); DCHECK(index >= 0 && index < this->length());
...@@ -475,7 +475,7 @@ ByteArray* ByteArray::FromDataStartAddress(Address address) { ...@@ -475,7 +475,7 @@ ByteArray* ByteArray::FromDataStartAddress(Address address) {
return reinterpret_cast<ByteArray*>(address - kHeaderSize + kHeapObjectTag); return reinterpret_cast<ByteArray*>(address - kHeaderSize + kHeapObjectTag);
} }
int ByteArray::DataSize() const { return RoundUp(length(), kPointerSize); } int ByteArray::DataSize() const { return RoundUp(length(), kTaggedSize); }
int ByteArray::ByteArraySize() { return SizeFor(this->length()); } int ByteArray::ByteArraySize() { return SizeFor(this->length()); }
......
...@@ -97,9 +97,14 @@ class FixedArrayBase : public HeapObject { ...@@ -97,9 +97,14 @@ class FixedArrayBase : public HeapObject {
#endif // V8_HOST_ARCH_32_BIT #endif // V8_HOST_ARCH_32_BIT
// Layout description. // Layout description.
// Length is smi tagged when it is stored. #define FIXED_ARRAY_BASE_FIELDS(V) \
static const int kLengthOffset = HeapObject::kHeaderSize; V(kLengthOffset, kTaggedSize) \
static const int kHeaderSize = kLengthOffset + kPointerSize; /* Header size. */ \
V(kHeaderSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
FIXED_ARRAY_BASE_FIELDS)
#undef FIXED_ARRAY_BASE_FIELDS
}; };
// TODO(3770): Replacement for the above. // TODO(3770): Replacement for the above.
...@@ -201,7 +206,7 @@ class FixedArray : public FixedArrayBase { ...@@ -201,7 +206,7 @@ class FixedArray : public FixedArrayBase {
// Garbage collection support. // Garbage collection support.
static constexpr int SizeFor(int length) { static constexpr int SizeFor(int length) {
return kHeaderSize + length * kPointerSize; return kHeaderSize + length * kTaggedSize;
} }
// Code Generation support. // Code Generation support.
...@@ -212,14 +217,14 @@ class FixedArray : public FixedArrayBase { ...@@ -212,14 +217,14 @@ class FixedArray : public FixedArrayBase {
DECL_CAST(FixedArray) DECL_CAST(FixedArray)
// Maximally allowed length of a FixedArray. // Maximally allowed length of a FixedArray.
static const int kMaxLength = (kMaxSize - kHeaderSize) / kPointerSize; static const int kMaxLength = (kMaxSize - kHeaderSize) / kTaggedSize;
static_assert(Internals::IsValidSmi(kMaxLength), static_assert(Internals::IsValidSmi(kMaxLength),
"FixedArray maxLength not a Smi"); "FixedArray maxLength not a Smi");
// Maximally allowed length for regular (non large object space) object. // Maximally allowed length for regular (non large object space) object.
STATIC_ASSERT(kMaxRegularHeapObjectSize < kMaxSize); STATIC_ASSERT(kMaxRegularHeapObjectSize < kMaxSize);
static const int kMaxRegularLength = static const int kMaxRegularLength =
(kMaxRegularHeapObjectSize - kHeaderSize) / kPointerSize; (kMaxRegularHeapObjectSize - kHeaderSize) / kTaggedSize;
// Dispatched behavior. // Dispatched behavior.
DECL_PRINTER(FixedArray) DECL_PRINTER(FixedArray)
...@@ -307,7 +312,7 @@ class FixedArrayPtr : public FixedArrayBasePtr { ...@@ -307,7 +312,7 @@ class FixedArrayPtr : public FixedArrayBasePtr {
// Garbage collection support. // Garbage collection support.
static constexpr int SizeFor(int length) { static constexpr int SizeFor(int length) {
return kHeaderSize + length * kPointerSize; return kHeaderSize + length * kTaggedSize;
} }
// Code Generation support. // Code Generation support.
...@@ -318,14 +323,14 @@ class FixedArrayPtr : public FixedArrayBasePtr { ...@@ -318,14 +323,14 @@ class FixedArrayPtr : public FixedArrayBasePtr {
DECL_CAST2(FixedArrayPtr) DECL_CAST2(FixedArrayPtr)
// Maximally allowed length of a FixedArray. // Maximally allowed length of a FixedArray.
static const int kMaxLength = (kMaxSize - kHeaderSize) / kPointerSize; static const int kMaxLength = (kMaxSize - kHeaderSize) / kTaggedSize;
static_assert(Internals::IsValidSmi(kMaxLength), static_assert(Internals::IsValidSmi(kMaxLength),
"FixedArray maxLength not a Smi"); "FixedArray maxLength not a Smi");
// Maximally allowed length for regular (non large object space) object. // Maximally allowed length for regular (non large object space) object.
STATIC_ASSERT(kMaxRegularHeapObjectSize < kMaxSize); STATIC_ASSERT(kMaxRegularHeapObjectSize < kMaxSize);
static const int kMaxRegularLength = static const int kMaxRegularLength =
(kMaxRegularHeapObjectSize - kHeaderSize) / kPointerSize; (kMaxRegularHeapObjectSize - kHeaderSize) / kTaggedSize;
// Dispatched behavior. // Dispatched behavior.
DECL_PRINTER(FixedArrayPtr) DECL_PRINTER(FixedArrayPtr)
...@@ -411,7 +416,7 @@ class WeakFixedArray : public HeapObject { ...@@ -411,7 +416,7 @@ class WeakFixedArray : public HeapObject {
inline void Set(int index, MaybeObject value, WriteBarrierMode mode); inline void Set(int index, MaybeObject value, WriteBarrierMode mode);
static constexpr int SizeFor(int length) { static constexpr int SizeFor(int length) {
return kHeaderSize + length * kPointerSize; return kHeaderSize + length * kTaggedSize;
} }
DECL_INT_ACCESSORS(length) DECL_INT_ACCESSORS(length)
...@@ -430,17 +435,24 @@ class WeakFixedArray : public HeapObject { ...@@ -430,17 +435,24 @@ class WeakFixedArray : public HeapObject {
typedef WeakArrayBodyDescriptor BodyDescriptor; typedef WeakArrayBodyDescriptor BodyDescriptor;
static const int kLengthOffset = HeapObject::kHeaderSize; // Layout description.
static const int kHeaderSize = kLengthOffset + kPointerSize; #define WEAK_FIXED_ARRAY_FIELDS(V) \
V(kLengthOffset, kTaggedSize) \
/* Header size. */ \
V(kHeaderSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
WEAK_FIXED_ARRAY_FIELDS)
#undef WEAK_FIXED_ARRAY_FIELDS
static const int kMaxLength = static const int kMaxLength =
(FixedArray::kMaxSize - kHeaderSize) / kPointerSize; (FixedArray::kMaxSize - kHeaderSize) / kTaggedSize;
static_assert(Internals::IsValidSmi(kMaxLength), static_assert(Internals::IsValidSmi(kMaxLength),
"WeakFixedArray maxLength not a Smi"); "WeakFixedArray maxLength not a Smi");
protected: protected:
static int OffsetOfElementAt(int index) { static int OffsetOfElementAt(int index) {
return kHeaderSize + index * kPointerSize; return kHeaderSize + index * kTaggedSize;
} }
private: private:
...@@ -475,7 +487,7 @@ class WeakArrayList : public HeapObject, public NeverReadOnlySpaceObject { ...@@ -475,7 +487,7 @@ class WeakArrayList : public HeapObject, public NeverReadOnlySpaceObject {
WriteBarrierMode mode = UPDATE_WRITE_BARRIER); WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
static constexpr int SizeForCapacity(int capacity) { static constexpr int SizeForCapacity(int capacity) {
return kHeaderSize + capacity * kPointerSize; return kHeaderSize + capacity * kTaggedSize;
} }
// Gives access to raw memory which stores the array's data. // Gives access to raw memory which stores the array's data.
...@@ -492,12 +504,18 @@ class WeakArrayList : public HeapObject, public NeverReadOnlySpaceObject { ...@@ -492,12 +504,18 @@ class WeakArrayList : public HeapObject, public NeverReadOnlySpaceObject {
typedef WeakArrayBodyDescriptor BodyDescriptor; typedef WeakArrayBodyDescriptor BodyDescriptor;
static const int kCapacityOffset = HeapObject::kHeaderSize; // Layout description.
static const int kLengthOffset = kCapacityOffset + kPointerSize; #define WEAK_ARRAY_LIST_FIELDS(V) \
static const int kHeaderSize = kLengthOffset + kPointerSize; V(kCapacityOffset, kTaggedSize) \
V(kLengthOffset, kTaggedSize) \
/* Header size. */ \
V(kHeaderSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, WEAK_ARRAY_LIST_FIELDS)
#undef WEAK_ARRAY_LIST_FIELDS
static const int kMaxCapacity = static const int kMaxCapacity =
(FixedArray::kMaxSize - kHeaderSize) / kPointerSize; (FixedArray::kMaxSize - kHeaderSize) / kTaggedSize;
static Handle<WeakArrayList> EnsureSpace( static Handle<WeakArrayList> EnsureSpace(
Isolate* isolate, Handle<WeakArrayList> array, int length, Isolate* isolate, Handle<WeakArrayList> array, int length,
...@@ -529,7 +547,7 @@ class WeakArrayList : public HeapObject, public NeverReadOnlySpaceObject { ...@@ -529,7 +547,7 @@ class WeakArrayList : public HeapObject, public NeverReadOnlySpaceObject {
private: private:
static int OffsetOfElementAt(int index) { static int OffsetOfElementAt(int index) {
return kHeaderSize + index * kPointerSize; return kHeaderSize + index * kTaggedSize;
} }
DISALLOW_IMPLICIT_CONSTRUCTORS(WeakArrayList); DISALLOW_IMPLICIT_CONSTRUCTORS(WeakArrayList);
...@@ -620,7 +638,7 @@ class ByteArray : public FixedArrayBase { ...@@ -620,7 +638,7 @@ class ByteArray : public FixedArrayBase {
// array, this function returns the number of elements a byte array should // array, this function returns the number of elements a byte array should
// have. // have.
static int LengthFor(int size_in_bytes) { static int LengthFor(int size_in_bytes) {
DCHECK(IsAligned(size_in_bytes, kPointerSize)); DCHECK(IsAligned(size_in_bytes, kTaggedSize));
DCHECK_GE(size_in_bytes, kHeaderSize); DCHECK_GE(size_in_bytes, kHeaderSize);
return size_in_bytes - kHeaderSize; return size_in_bytes - kHeaderSize;
} }
...@@ -694,10 +712,17 @@ class FixedTypedArrayBase : public FixedArrayBase { ...@@ -694,10 +712,17 @@ class FixedTypedArrayBase : public FixedArrayBase {
// Dispatched behavior. // Dispatched behavior.
DECL_CAST(FixedTypedArrayBase) DECL_CAST(FixedTypedArrayBase)
static const int kBasePointerOffset = FixedArrayBase::kHeaderSize; #define FIXED_TYPED_ARRAY_BASE_FIELDS(V) \
static const int kExternalPointerOffset = kBasePointerOffset + kPointerSize; V(kBasePointerOffset, kTaggedSize) \
static const int kHeaderSize = V(kExternalPointerOffset, kSystemPointerSize) \
DOUBLE_POINTER_ALIGN(kExternalPointerOffset + kPointerSize); /* Header size. */ \
V(kHeaderSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(FixedArrayBase::kHeaderSize,
FIXED_TYPED_ARRAY_BASE_FIELDS)
#undef FIXED_TYPED_ARRAY_BASE_FIELDS
STATIC_ASSERT(IsAligned(kHeaderSize, kDoubleAlignment));
static const int kDataOffset = kHeaderSize; static const int kDataOffset = kHeaderSize;
......
...@@ -165,7 +165,7 @@ class HashTable : public HashTableBase { ...@@ -165,7 +165,7 @@ class HashTable : public HashTableBase {
STATIC_ASSERT(kEntrySize > 0); STATIC_ASSERT(kEntrySize > 0);
static const int kEntryKeyIndex = 0; static const int kEntryKeyIndex = 0;
static const int kElementsStartOffset = static const int kElementsStartOffset =
kHeaderSize + kElementsStartIndex * kPointerSize; kHeaderSize + kElementsStartIndex * kTaggedSize;
// Maximal capacity of HashTable. Based on maximal length of underlying // Maximal capacity of HashTable. Based on maximal length of underlying
// FixedArray. Staying below kMaxCapacity also ensures that EntryToIndex // FixedArray. Staying below kMaxCapacity also ensures that EntryToIndex
// cannot overflow. // cannot overflow.
......
...@@ -101,8 +101,13 @@ class JSArray : public JSObject { ...@@ -101,8 +101,13 @@ class JSArray : public JSObject {
static const int kPreallocatedArrayElements = 4; static const int kPreallocatedArrayElements = 4;
// Layout description. // Layout description.
static const int kLengthOffset = JSObject::kHeaderSize; #define JS_ARRAY_FIELDS(V) \
static const int kSize = kLengthOffset + kPointerSize; V(kLengthOffset, kTaggedSize) \
/* Header size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JS_ARRAY_FIELDS)
#undef JS_ARRAY_FIELDS
static const int kLengthDescriptorIndex = 0; static const int kLengthDescriptorIndex = 0;
...@@ -171,10 +176,16 @@ class JSArrayIterator : public JSObject { ...@@ -171,10 +176,16 @@ class JSArrayIterator : public JSObject {
inline IterationKind kind() const; inline IterationKind kind() const;
inline void set_kind(IterationKind kind); inline void set_kind(IterationKind kind);
static const int kIteratedObjectOffset = JSObject::kHeaderSize; // Layout description.
static const int kNextIndexOffset = kIteratedObjectOffset + kPointerSize; #define JS_ARRAY_ITERATOR_FIELDS(V) \
static const int kKindOffset = kNextIndexOffset + kPointerSize; V(kIteratedObjectOffset, kTaggedSize) \
static const int kSize = kKindOffset + kPointerSize; V(kNextIndexOffset, kTaggedSize) \
V(kKindOffset, kTaggedSize) \
/* Header size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JS_ARRAY_ITERATOR_FIELDS)
#undef JS_ARRAY_ITERATOR_FIELDS
private: private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSArrayIterator); DISALLOW_IMPLICIT_CONSTRUCTORS(JSArrayIterator);
......
...@@ -19,8 +19,15 @@ class JSCollection : public JSObject { ...@@ -19,8 +19,15 @@ class JSCollection : public JSObject {
// [table]: the backing hash table // [table]: the backing hash table
DECL_ACCESSORS(table, Object) DECL_ACCESSORS(table, Object)
static const int kTableOffset = JSObject::kHeaderSize; // Layout description.
static const int kSize = kTableOffset + kPointerSize; #define JS_COLLECTION_FIELDS(V) \
V(kTableOffset, kTaggedSize) \
/* Header size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JS_COLLECTION_FIELDS)
#undef JS_COLLECTION_FIELDS
static const int kAddFunctionDescriptorIndex = 3; static const int kAddFunctionDescriptorIndex = 3;
private: private:
...@@ -105,8 +112,15 @@ class JSWeakCollection : public JSObject { ...@@ -105,8 +112,15 @@ class JSWeakCollection : public JSObject {
static Handle<JSArray> GetEntries(Handle<JSWeakCollection> holder, static Handle<JSArray> GetEntries(Handle<JSWeakCollection> holder,
int max_entries); int max_entries);
static const int kTableOffset = JSObject::kHeaderSize; // Layout description.
static const int kSize = kTableOffset + kPointerSize; #define JS_WEAK_COLLECTION_FIELDS(V) \
V(kTableOffset, kTaggedSize) \
/* Header size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
JS_WEAK_COLLECTION_FIELDS)
#undef JS_WEAK_COLLECTION_FIELDS
static const int kAddFunctionDescriptorIndex = 3; static const int kAddFunctionDescriptorIndex = 3;
......
...@@ -67,15 +67,19 @@ class JSGeneratorObject : public JSObject { ...@@ -67,15 +67,19 @@ class JSGeneratorObject : public JSObject {
static const int kGeneratorClosed = -1; static const int kGeneratorClosed = -1;
// Layout description. // Layout description.
static const int kFunctionOffset = JSObject::kHeaderSize; #define JS_GENERATOR_FIELDS(V) \
static const int kContextOffset = kFunctionOffset + kPointerSize; V(kFunctionOffset, kTaggedSize) \
static const int kReceiverOffset = kContextOffset + kPointerSize; V(kContextOffset, kTaggedSize) \
static const int kInputOrDebugPosOffset = kReceiverOffset + kPointerSize; V(kReceiverOffset, kTaggedSize) \
static const int kResumeModeOffset = kInputOrDebugPosOffset + kPointerSize; V(kInputOrDebugPosOffset, kTaggedSize) \
static const int kContinuationOffset = kResumeModeOffset + kPointerSize; V(kResumeModeOffset, kTaggedSize) \
static const int kParametersAndRegistersOffset = V(kContinuationOffset, kTaggedSize) \
kContinuationOffset + kPointerSize; V(kParametersAndRegistersOffset, kTaggedSize) \
static const int kSize = kParametersAndRegistersOffset + kPointerSize; /* Header size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JS_GENERATOR_FIELDS)
#undef JS_GENERATOR_FIELDS
private: private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSGeneratorObject); DISALLOW_IMPLICIT_CONSTRUCTORS(JSGeneratorObject);
...@@ -92,8 +96,14 @@ class JSAsyncFunctionObject : public JSGeneratorObject { ...@@ -92,8 +96,14 @@ class JSAsyncFunctionObject : public JSGeneratorObject {
DECL_ACCESSORS(promise, JSPromise) DECL_ACCESSORS(promise, JSPromise)
// Layout description. // Layout description.
static const int kPromiseOffset = JSGeneratorObject::kSize; #define JS_ASYNC_FUNCTION_FIELDS(V) \
static const int kSize = kPromiseOffset + kPointerSize; V(kPromiseOffset, kTaggedSize) \
/* Header size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSGeneratorObject::kSize,
JS_ASYNC_FUNCTION_FIELDS)
#undef JS_ASYNC_FUNCTION_FIELDS
private: private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSAsyncFunctionObject); DISALLOW_IMPLICIT_CONSTRUCTORS(JSAsyncFunctionObject);
...@@ -116,9 +126,15 @@ class JSAsyncGeneratorObject : public JSGeneratorObject { ...@@ -116,9 +126,15 @@ class JSAsyncGeneratorObject : public JSGeneratorObject {
DECL_INT_ACCESSORS(is_awaiting) DECL_INT_ACCESSORS(is_awaiting)
// Layout description. // Layout description.
static const int kQueueOffset = JSGeneratorObject::kSize; #define JS_ASYNC_GENERATOR_FIELDS(V) \
static const int kIsAwaitingOffset = kQueueOffset + kPointerSize; V(kQueueOffset, kTaggedSize) \
static const int kSize = kIsAwaitingOffset + kPointerSize; V(kIsAwaitingOffset, kTaggedSize) \
/* Header size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSGeneratorObject::kSize,
JS_ASYNC_GENERATOR_FIELDS)
#undef JS_ASYNC_GENERATOR_FIELDS
private: private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSAsyncGeneratorObject); DISALLOW_IMPLICIT_CONSTRUCTORS(JSAsyncGeneratorObject);
......
...@@ -105,11 +105,16 @@ class JSListFormat : public JSObject { ...@@ -105,11 +105,16 @@ class JSListFormat : public JSObject {
DECL_VERIFIER(JSListFormat) DECL_VERIFIER(JSListFormat)
// Layout description. // Layout description.
static const int kJSListFormatOffset = JSObject::kHeaderSize; #define JS_LIST_FORMAT_FIELDS(V) \
static const int kLocaleOffset = kJSListFormatOffset + kPointerSize; V(kJSListFormatOffset, kTaggedSize) \
static const int kICUFormatterOffset = kLocaleOffset + kPointerSize; V(kLocaleOffset, kTaggedSize) \
static const int kFlagsOffset = kICUFormatterOffset + kPointerSize; V(kICUFormatterOffset, kTaggedSize) \
static const int kSize = kFlagsOffset + kPointerSize; V(kFlagsOffset, kTaggedSize) \
/* Header size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JS_LIST_FORMAT_FIELDS)
#undef JS_LIST_FORMAT_FIELDS
private: private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSListFormat); DISALLOW_IMPLICIT_CONSTRUCTORS(JSListFormat);
......
...@@ -109,20 +109,24 @@ class JSLocale : public JSObject { ...@@ -109,20 +109,24 @@ class JSLocale : public JSObject {
DECL_VERIFIER(JSLocale) DECL_VERIFIER(JSLocale)
// Layout description. // Layout description.
static const int kJSLocaleOffset = JSObject::kHeaderSize; #define JS_LOCALE_FIELDS(V) \
// Locale fields. V(kJSLocaleOffset, kTaggedSize) \
static const int kLanguageOffset = kJSLocaleOffset + kPointerSize; /* Locale fields. */ \
static const int kScriptOffset = kLanguageOffset + kPointerSize; V(kLanguageOffset, kTaggedSize) \
static const int kRegionOffset = kScriptOffset + kPointerSize; V(kScriptOffset, kTaggedSize) \
static const int kBaseNameOffset = kRegionOffset + kPointerSize; V(kRegionOffset, kTaggedSize) \
static const int kLocaleOffset = kBaseNameOffset + kPointerSize; V(kBaseNameOffset, kTaggedSize) \
// Unicode extension fields. V(kLocaleOffset, kTaggedSize) \
static const int kFlagsOffset = kLocaleOffset + kPointerSize; /* Unicode extension fields. */ \
static const int kCalendarOffset = kFlagsOffset + kPointerSize; V(kFlagsOffset, kTaggedSize) \
static const int kCollationOffset = kCalendarOffset + kPointerSize; V(kCalendarOffset, kTaggedSize) \
static const int kNumberingSystemOffset = kCollationOffset + kPointerSize; V(kCollationOffset, kTaggedSize) \
// Final size. V(kNumberingSystemOffset, kTaggedSize) \
static const int kSize = kNumberingSystemOffset + kPointerSize; /* Header size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JS_LOCALE_FIELDS)
#undef JS_LOCALE_FIELDS
private: private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSLocale); DISALLOW_IMPLICIT_CONSTRUCTORS(JSLocale);
......
...@@ -251,7 +251,7 @@ int JSObject::GetEmbedderFieldCount(const Map map) { ...@@ -251,7 +251,7 @@ int JSObject::GetEmbedderFieldCount(const Map map) {
// Internal objects do follow immediately after the header, whereas in-object // Internal objects do follow immediately after the header, whereas in-object
// properties are at the end of the object. Therefore there is no need // properties are at the end of the object. Therefore there is no need
// to adjust the index here. // to adjust the index here.
return (((instance_size - GetHeaderSize(map)) >> kPointerSizeLog2) - return (((instance_size - GetHeaderSize(map)) >> kTaggedSizeLog2) -
map->GetInObjectProperties()) / map->GetInObjectProperties()) /
kEmbedderDataSlotSizeInTaggedSlots; kEmbedderDataSlotSizeInTaggedSlots;
} }
...@@ -319,8 +319,9 @@ void JSObject::RawFastPropertyAtPut(FieldIndex index, Object* value) { ...@@ -319,8 +319,9 @@ void JSObject::RawFastPropertyAtPut(FieldIndex index, Object* value) {
void JSObject::RawFastDoublePropertyAsBitsAtPut(FieldIndex index, void JSObject::RawFastDoublePropertyAsBitsAtPut(FieldIndex index,
uint64_t bits) { uint64_t bits) {
// Double unboxing is enabled only on 64-bit platforms. // Double unboxing is enabled only on 64-bit platforms without pointer
DCHECK_EQ(kDoubleSize, kPointerSize); // compression.
DCHECK_EQ(kDoubleSize, kTaggedSize);
Address field_addr = FIELD_ADDR(this, index.offset()); Address field_addr = FIELD_ADDR(this, index.offset());
base::Relaxed_Store(reinterpret_cast<base::AtomicWord*>(field_addr), base::Relaxed_Store(reinterpret_cast<base::AtomicWord*>(field_addr),
static_cast<base::AtomicWord>(bits)); static_cast<base::AtomicWord>(bits));
...@@ -398,16 +399,16 @@ void JSObject::InitializeBody(Map map, int start_offset, ...@@ -398,16 +399,16 @@ void JSObject::InitializeBody(Map map, int start_offset,
int offset = start_offset; int offset = start_offset;
if (filler_value != pre_allocated_value) { if (filler_value != pre_allocated_value) {
int end_of_pre_allocated_offset = int end_of_pre_allocated_offset =
size - (map->UnusedPropertyFields() * kPointerSize); size - (map->UnusedPropertyFields() * kTaggedSize);
DCHECK_LE(kHeaderSize, end_of_pre_allocated_offset); DCHECK_LE(kHeaderSize, end_of_pre_allocated_offset);
while (offset < end_of_pre_allocated_offset) { while (offset < end_of_pre_allocated_offset) {
WRITE_FIELD(this, offset, pre_allocated_value); WRITE_FIELD(this, offset, pre_allocated_value);
offset += kPointerSize; offset += kTaggedSize;
} }
} }
while (offset < size) { while (offset < size) {
WRITE_FIELD(this, offset, filler_value); WRITE_FIELD(this, offset, filler_value);
offset += kPointerSize; offset += kTaggedSize;
} }
} }
......
...@@ -68,10 +68,15 @@ class JSPromise : public JSObject { ...@@ -68,10 +68,15 @@ class JSPromise : public JSObject {
DECL_PRINTER(JSPromise) DECL_PRINTER(JSPromise)
DECL_VERIFIER(JSPromise) DECL_VERIFIER(JSPromise)
// Layout description. #define JS_PROMISE_FIELDS(V) \
static const int kReactionsOrResultOffset = JSObject::kHeaderSize; V(kReactionsOrResultOffset, kTaggedSize) \
static const int kFlagsOffset = kReactionsOrResultOffset + kPointerSize; V(kFlagsOffset, kTaggedSize) \
static const int kSize = kFlagsOffset + kPointerSize; /* Header size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JS_PROMISE_FIELDS)
#undef JS_PROMISE_FIELDS
static const int kSizeWithEmbedderFields = static const int kSizeWithEmbedderFields =
kSize + v8::Promise::kEmbedderFieldCount * kEmbedderDataSlotSize; kSize + v8::Promise::kEmbedderFieldCount * kEmbedderDataSlotSize;
......
...@@ -106,9 +106,14 @@ class JSProxy : public JSReceiver { ...@@ -106,9 +106,14 @@ class JSProxy : public JSReceiver {
static const int kMaxIterationLimit = 100 * 1024; static const int kMaxIterationLimit = 100 * 1024;
// Layout description. // Layout description.
static const int kTargetOffset = JSReceiver::kHeaderSize; #define JS_PROXY_FIELDS(V) \
static const int kHandlerOffset = kTargetOffset + kPointerSize; V(kTargetOffset, kTaggedSize) \
static const int kSize = kHandlerOffset + kPointerSize; V(kHandlerOffset, kTaggedSize) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSReceiver::kHeaderSize, JS_PROXY_FIELDS)
#undef JS_PROXY_FIELDS
// kTargetOffset aliases with the elements of JSObject. The fact that // kTargetOffset aliases with the elements of JSObject. The fact that
// JSProxy::target is a Javascript value which cannot be confused with an // JSProxy::target is a Javascript value which cannot be confused with an
...@@ -133,10 +138,17 @@ class JSProxy : public JSReceiver { ...@@ -133,10 +138,17 @@ class JSProxy : public JSReceiver {
// See https://tc39.github.io/ecma262/#sec-proxy.revocable // See https://tc39.github.io/ecma262/#sec-proxy.revocable
class JSProxyRevocableResult : public JSObject { class JSProxyRevocableResult : public JSObject {
public: public:
// Offsets of object fields. // Layout description.
static const int kProxyOffset = JSObject::kHeaderSize; #define JS_PROXY_REVOCATABLE_RESULT_FIELDS(V) \
static const int kRevokeOffset = kProxyOffset + kPointerSize; V(kProxyOffset, kTaggedSize) \
static const int kSize = kRevokeOffset + kPointerSize; V(kRevokeOffset, kTaggedSize) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
JS_PROXY_REVOCATABLE_RESULT_FIELDS)
#undef JS_PROXY_REVOCATABLE_RESULT_FIELDS
// Indices of in-object properties. // Indices of in-object properties.
static const int kProxyIndex = 0; static const int kProxyIndex = 0;
static const int kRevokeIndex = 1; static const int kRevokeIndex = 1;
......
...@@ -36,12 +36,17 @@ class JSRegExpStringIterator : public JSObject { ...@@ -36,12 +36,17 @@ class JSRegExpStringIterator : public JSObject {
DECL_PRINTER(JSRegExpStringIterator) DECL_PRINTER(JSRegExpStringIterator)
DECL_VERIFIER(JSRegExpStringIterator) DECL_VERIFIER(JSRegExpStringIterator)
static const int kIteratingRegExpOffset = JSObject::kHeaderSize; // Layout description.
static const int kIteratedStringOffset = #define JS_REGEXP_STRING_ITERATOR_FIELDS(V) \
kIteratingRegExpOffset + kPointerSize; V(kIteratingRegExpOffset, kTaggedSize) \
static const int kFlagsOffset = kIteratedStringOffset + kPointerSize; V(kIteratedStringOffset, kTaggedSize) \
V(kFlagsOffset, kTaggedSize) \
static const int kSize = kFlagsOffset + kPointerSize; /* Header size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
JS_REGEXP_STRING_ITERATOR_FIELDS)
#undef JS_REGEXP_STRING_ITERATOR_FIELDS
static const int kDoneBit = 0; static const int kDoneBit = 0;
static const int kGlobalBit = 1; static const int kGlobalBit = 1;
......
...@@ -106,11 +106,17 @@ class JSRelativeTimeFormat : public JSObject { ...@@ -106,11 +106,17 @@ class JSRelativeTimeFormat : public JSObject {
DECL_VERIFIER(JSRelativeTimeFormat) DECL_VERIFIER(JSRelativeTimeFormat)
// Layout description. // Layout description.
static const int kJSRelativeTimeFormatOffset = JSObject::kHeaderSize; #define JS_RELATIVE_TIME_FORMAT_FIELDS(V) \
static const int kLocaleOffset = kJSRelativeTimeFormatOffset + kPointerSize; V(kJSRelativeTimeFormatOffset, kTaggedSize) \
static const int kICUFormatterOffset = kLocaleOffset + kPointerSize; V(kLocaleOffset, kTaggedSize) \
static const int kFlagsOffset = kICUFormatterOffset + kPointerSize; V(kICUFormatterOffset, kTaggedSize) \
static const int kSize = kFlagsOffset + kPointerSize; V(kFlagsOffset, kTaggedSize) \
/* Header size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
JS_RELATIVE_TIME_FORMAT_FIELDS)
#undef JS_RELATIVE_TIME_FORMAT_FIELDS
private: private:
static Style getStyle(const char* str); static Style getStyle(const char* str);
......
...@@ -103,11 +103,16 @@ class JSSegmenter : public JSObject { ...@@ -103,11 +103,16 @@ class JSSegmenter : public JSObject {
DECL_VERIFIER(JSSegmenter) DECL_VERIFIER(JSSegmenter)
// Layout description. // Layout description.
static const int kJSSegmenterOffset = JSObject::kHeaderSize; #define JS_SEGMENTER_FIELDS(V) \
static const int kLocaleOffset = kJSSegmenterOffset + kPointerSize; V(kJSSegmenterOffset, kTaggedSize) \
static const int kICUBreakIteratorOffset = kLocaleOffset + kPointerSize; V(kLocaleOffset, kTaggedSize) \
static const int kFlagsOffset = kICUBreakIteratorOffset + kPointerSize; V(kICUBreakIteratorOffset, kTaggedSize) \
static const int kSize = kFlagsOffset + kPointerSize; V(kFlagsOffset, kTaggedSize) \
/* Header size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JS_SEGMENTER_FIELDS)
#undef JS_SEGMENTER_FIELDS
private: private:
static LineBreakStyle GetLineBreakStyle(const char* str); static LineBreakStyle GetLineBreakStyle(const char* str);
......
...@@ -176,9 +176,14 @@ class Symbol : public Name { ...@@ -176,9 +176,14 @@ class Symbol : public Name {
DECL_VERIFIER(Symbol) DECL_VERIFIER(Symbol)
// Layout description. // Layout description.
static const int kFlagsOffset = Name::kHeaderSize; #define SYMBOL_FIELDS(V) \
static const int kNameOffset = kFlagsOffset + kInt32Size; V(kFlagsOffset, kInt32Size) \
static const int kSize = kNameOffset + kPointerSize; V(kNameOffset, kTaggedSize) \
/* Header size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(Name::kHeaderSize, SYMBOL_FIELDS)
#undef SYMBOL_FIELDS
// Flags layout. // Flags layout.
#define FLAGS_BIT_FIELDS(V, _) \ #define FLAGS_BIT_FIELDS(V, _) \
......
...@@ -27,7 +27,7 @@ INT_ACCESSORS(PreParsedScopeData, length, kLengthOffset) ...@@ -27,7 +27,7 @@ INT_ACCESSORS(PreParsedScopeData, length, kLengthOffset)
Object* PreParsedScopeData::child_data(int index) const { Object* PreParsedScopeData::child_data(int index) const {
DCHECK_GE(index, 0); DCHECK_GE(index, 0);
DCHECK_LT(index, this->length()); DCHECK_LT(index, this->length());
int offset = kChildDataStartOffset + index * kPointerSize; int offset = kChildDataStartOffset + index * kTaggedSize;
return RELAXED_READ_FIELD(this, offset); return RELAXED_READ_FIELD(this, offset);
} }
...@@ -35,7 +35,7 @@ void PreParsedScopeData::set_child_data(int index, Object* value, ...@@ -35,7 +35,7 @@ void PreParsedScopeData::set_child_data(int index, Object* value,
WriteBarrierMode mode) { WriteBarrierMode mode) {
DCHECK_GE(index, 0); DCHECK_GE(index, 0);
DCHECK_LT(index, this->length()); DCHECK_LT(index, this->length());
int offset = kChildDataStartOffset + index * kPointerSize; int offset = kChildDataStartOffset + index * kTaggedSize;
RELAXED_WRITE_FIELD(this, offset, value); RELAXED_WRITE_FIELD(this, offset, value);
CONDITIONAL_WRITE_BARRIER(this, offset, value, mode); CONDITIONAL_WRITE_BARRIER(this, offset, value, mode);
} }
...@@ -45,11 +45,10 @@ ObjectSlot PreParsedScopeData::child_data_start() const { ...@@ -45,11 +45,10 @@ ObjectSlot PreParsedScopeData::child_data_start() const {
} }
void PreParsedScopeData::clear_padding() { void PreParsedScopeData::clear_padding() {
// For archs where kIntSize < kPointerSize, there will be padding between the if (FIELD_SIZE(kOptionalPaddingOffset)) {
// length field and the start of the child data. DCHECK_EQ(4, FIELD_SIZE(kOptionalPaddingOffset));
if (kUnalignedChildDataStartOffset < kChildDataStartOffset) { memset(reinterpret_cast<void*>(address() + kOptionalPaddingOffset), 0,
memset(reinterpret_cast<void*>(address() + kUnalignedChildDataStartOffset), FIELD_SIZE(kOptionalPaddingOffset));
0, kChildDataStartOffset - kUnalignedChildDataStartOffset);
} }
} }
...@@ -60,11 +59,10 @@ INT32_ACCESSORS(UncompiledData, end_position, kEndPositionOffset) ...@@ -60,11 +59,10 @@ INT32_ACCESSORS(UncompiledData, end_position, kEndPositionOffset)
INT32_ACCESSORS(UncompiledData, function_literal_id, kFunctionLiteralIdOffset) INT32_ACCESSORS(UncompiledData, function_literal_id, kFunctionLiteralIdOffset)
void UncompiledData::clear_padding() { void UncompiledData::clear_padding() {
// For archs where kIntSize < kPointerSize, there will be padding at the end if (FIELD_SIZE(kOptionalPaddingOffset)) {
// of the data. DCHECK_EQ(4, FIELD_SIZE(kOptionalPaddingOffset));
if (kUnalignedSize < kSize) { memset(reinterpret_cast<void*>(address() + kOptionalPaddingOffset), 0,
memset(reinterpret_cast<void*>(address() + kUnalignedSize), 0, FIELD_SIZE(kOptionalPaddingOffset));
kSize - kUnalignedSize);
} }
} }
......
...@@ -44,18 +44,17 @@ class PreParsedScopeData : public HeapObject { ...@@ -44,18 +44,17 @@ class PreParsedScopeData : public HeapObject {
DECL_VERIFIER(PreParsedScopeData) DECL_VERIFIER(PreParsedScopeData)
// Layout description. // Layout description.
#define PRE_PARSED_SCOPE_DATA_FIELDS(V) \ #define PRE_PARSED_SCOPE_DATA_FIELDS(V) \
V(kScopeDataOffset, kTaggedSize) \ V(kScopeDataOffset, kTaggedSize) \
V(kLengthOffset, kIntSize) \ V(kLengthOffset, kIntSize) \
V(kUnalignedChildDataStartOffset, 0) V(kOptionalPaddingOffset, POINTER_SIZE_PADDING(kOptionalPaddingOffset)) \
/* Header size. */ \
V(kChildDataStartOffset, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
PRE_PARSED_SCOPE_DATA_FIELDS) PRE_PARSED_SCOPE_DATA_FIELDS)
#undef PRE_PARSED_SCOPE_DATA_FIELDS #undef PRE_PARSED_SCOPE_DATA_FIELDS
static const int kChildDataStartOffset =
POINTER_SIZE_ALIGN(kUnalignedChildDataStartOffset);
class BodyDescriptor; class BodyDescriptor;
static constexpr int SizeFor(int length) { static constexpr int SizeFor(int length) {
...@@ -78,22 +77,21 @@ class UncompiledData : public HeapObject { ...@@ -78,22 +77,21 @@ class UncompiledData : public HeapObject {
DECL_CAST(UncompiledData) DECL_CAST(UncompiledData)
// Layout description. // Layout description.
#define UNCOMPILED_DATA_FIELDS(V) \ #define UNCOMPILED_DATA_FIELDS(V) \
V(kStartOfPointerFieldsOffset, 0) \ V(kStartOfPointerFieldsOffset, 0) \
V(kInferredNameOffset, kTaggedSize) \ V(kInferredNameOffset, kTaggedSize) \
V(kEndOfTaggedFieldsOffset, 0) \ V(kEndOfTaggedFieldsOffset, 0) \
/* Raw data fields. */ \ /* Raw data fields. */ \
V(kStartPositionOffset, kInt32Size) \ V(kStartPositionOffset, kInt32Size) \
V(kEndPositionOffset, kInt32Size) \ V(kEndPositionOffset, kInt32Size) \
V(kFunctionLiteralIdOffset, kInt32Size) \ V(kFunctionLiteralIdOffset, kInt32Size) \
/* Total size. */ \ V(kOptionalPaddingOffset, POINTER_SIZE_PADDING(kOptionalPaddingOffset)) \
V(kUnalignedSize, 0) /* Header size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, UNCOMPILED_DATA_FIELDS) DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, UNCOMPILED_DATA_FIELDS)
#undef UNCOMPILED_DATA_FIELDS #undef UNCOMPILED_DATA_FIELDS
static const int kSize = POINTER_SIZE_ALIGN(kUnalignedSize);
typedef FixedBodyDescriptor<kStartOfPointerFieldsOffset, typedef FixedBodyDescriptor<kStartOfPointerFieldsOffset,
kEndOfTaggedFieldsOffset, kSize> kEndOfTaggedFieldsOffset, kSize>
BodyDescriptor; BodyDescriptor;
......
...@@ -33,17 +33,21 @@ class StackFrameInfo : public Struct, public NeverReadOnlySpaceObject { ...@@ -33,17 +33,21 @@ class StackFrameInfo : public Struct, public NeverReadOnlySpaceObject {
DECL_PRINTER(StackFrameInfo) DECL_PRINTER(StackFrameInfo)
DECL_VERIFIER(StackFrameInfo) DECL_VERIFIER(StackFrameInfo)
static const int kLineNumberIndex = Struct::kHeaderSize; // Layout description.
static const int kColumnNumberIndex = kLineNumberIndex + kPointerSize; #define STACK_FRAME_INFO_FIELDS(V) \
static const int kScriptIdIndex = kColumnNumberIndex + kPointerSize; V(kLineNumberIndex, kTaggedSize) \
static const int kScriptNameIndex = kScriptIdIndex + kPointerSize; V(kColumnNumberIndex, kTaggedSize) \
static const int kScriptNameOrSourceUrlIndex = V(kScriptIdIndex, kTaggedSize) \
kScriptNameIndex + kPointerSize; V(kScriptNameIndex, kTaggedSize) \
static const int kFunctionNameIndex = V(kScriptNameOrSourceUrlIndex, kTaggedSize) \
kScriptNameOrSourceUrlIndex + kPointerSize; V(kFunctionNameIndex, kTaggedSize) \
static const int kFlagIndex = kFunctionNameIndex + kPointerSize; V(kFlagIndex, kTaggedSize) \
static const int kIdIndex = kFlagIndex + kPointerSize; V(kIdIndex, kTaggedSize) \
static const int kSize = kIdIndex + kPointerSize; /* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(Struct::kHeaderSize, STACK_FRAME_INFO_FIELDS)
#undef STACK_FRAME_INFO_FIELDS
private: private:
// Bit position in the flag, from least significant bit position. // Bit position in the flag, from least significant bit position.
......
...@@ -25,13 +25,18 @@ class TemplateInfo : public Struct, public NeverReadOnlySpaceObject { ...@@ -25,13 +25,18 @@ class TemplateInfo : public Struct, public NeverReadOnlySpaceObject {
DECL_CAST(TemplateInfo) DECL_CAST(TemplateInfo)
static const int kTagOffset = HeapObject::kHeaderSize; // Layout description.
static const int kSerialNumberOffset = kTagOffset + kPointerSize; #define TEMPLATE_INFO_FIELDS(V) \
static const int kNumberOfProperties = kSerialNumberOffset + kPointerSize; V(kTagOffset, kTaggedSize) \
static const int kPropertyListOffset = kNumberOfProperties + kPointerSize; V(kSerialNumberOffset, kTaggedSize) \
static const int kPropertyAccessorsOffset = V(kNumberOfProperties, kTaggedSize) \
kPropertyListOffset + kPointerSize; V(kPropertyListOffset, kTaggedSize) \
static const int kHeaderSize = kPropertyAccessorsOffset + kPointerSize; V(kPropertyAccessorsOffset, kTaggedSize) \
/* Header size. */ \
V(kHeaderSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, TEMPLATE_INFO_FIELDS)
#undef TEMPLATE_INFO_FIELDS
static const int kFastTemplateInstantiationsCacheSize = 1 * KB; static const int kFastTemplateInstantiationsCacheSize = 1 * KB;
...@@ -63,22 +68,21 @@ class FunctionTemplateRareData : public Struct { ...@@ -63,22 +68,21 @@ class FunctionTemplateRareData : public Struct {
DECL_PRINTER(FunctionTemplateRareData) DECL_PRINTER(FunctionTemplateRareData)
DECL_VERIFIER(FunctionTemplateRareData) DECL_VERIFIER(FunctionTemplateRareData)
static const int kPrototypeTemplateOffset = HeapObject::kHeaderSize; // Layout description.
static const int kPrototypeProviderTemplateOffset = #define SYMBOL_FIELDS(V) \
kPrototypeTemplateOffset + kPointerSize; V(kPrototypeTemplateOffset, kTaggedSize) \
static const int kParentTemplateOffset = V(kPrototypeProviderTemplateOffset, kTaggedSize) \
kPrototypeProviderTemplateOffset + kPointerSize; V(kParentTemplateOffset, kTaggedSize) \
static const int kNamedPropertyHandlerOffset = V(kNamedPropertyHandlerOffset, kTaggedSize) \
kParentTemplateOffset + kPointerSize; V(kIndexedPropertyHandlerOffset, kTaggedSize) \
static const int kIndexedPropertyHandlerOffset = V(kInstanceTemplateOffset, kTaggedSize) \
kNamedPropertyHandlerOffset + kPointerSize; V(kInstanceCallHandlerOffset, kTaggedSize) \
static const int kInstanceTemplateOffset = V(kAccessCheckInfoOffset, kTaggedSize) \
kIndexedPropertyHandlerOffset + kPointerSize; /* Total size. */ \
static const int kInstanceCallHandlerOffset = V(kSize, 0)
kInstanceTemplateOffset + kPointerSize;
static const int kAccessCheckInfoOffset = DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, SYMBOL_FIELDS)
kInstanceCallHandlerOffset + kPointerSize; #undef SYMBOL_FIELDS
static const int kSize = kAccessCheckInfoOffset + kPointerSize;
private: private:
DISALLOW_IMPLICIT_CONSTRUCTORS(FunctionTemplateRareData); DISALLOW_IMPLICIT_CONSTRUCTORS(FunctionTemplateRareData);
...@@ -188,17 +192,22 @@ class FunctionTemplateInfo : public TemplateInfo { ...@@ -188,17 +192,22 @@ class FunctionTemplateInfo : public TemplateInfo {
static const int kInvalidSerialNumber = 0; static const int kInvalidSerialNumber = 0;
static const int kCallCodeOffset = TemplateInfo::kHeaderSize; // Layout description.
static const int kClassNameOffset = kCallCodeOffset + kPointerSize; #define FUNCTION_TEMPLATE_INFO_FIELDS(V) \
static const int kSignatureOffset = kClassNameOffset + kPointerSize; V(kCallCodeOffset, kTaggedSize) \
static const int kFunctionTemplateRareDataOffset = V(kClassNameOffset, kTaggedSize) \
kSignatureOffset + kPointerSize; V(kSignatureOffset, kTaggedSize) \
static const int kSharedFunctionInfoOffset = V(kFunctionTemplateRareDataOffset, kTaggedSize) \
kFunctionTemplateRareDataOffset + kPointerSize; V(kSharedFunctionInfoOffset, kTaggedSize) \
static const int kFlagOffset = kSharedFunctionInfoOffset + kPointerSize; V(kFlagOffset, kTaggedSize) \
static const int kLengthOffset = kFlagOffset + kPointerSize; V(kLengthOffset, kTaggedSize) \
static const int kCachedPropertyNameOffset = kLengthOffset + kPointerSize; V(kCachedPropertyNameOffset, kTaggedSize) \
static const int kSize = kCachedPropertyNameOffset + kPointerSize; /* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(TemplateInfo::kHeaderSize,
FUNCTION_TEMPLATE_INFO_FIELDS)
#undef FUNCTION_TEMPLATE_INFO_FIELDS
static Handle<SharedFunctionInfo> GetOrCreateSharedFunctionInfo( static Handle<SharedFunctionInfo> GetOrCreateSharedFunctionInfo(
Isolate* isolate, Handle<FunctionTemplateInfo> info, Isolate* isolate, Handle<FunctionTemplateInfo> info,
...@@ -248,10 +257,17 @@ class ObjectTemplateInfo : public TemplateInfo { ...@@ -248,10 +257,17 @@ class ObjectTemplateInfo : public TemplateInfo {
DECL_PRINTER(ObjectTemplateInfo) DECL_PRINTER(ObjectTemplateInfo)
DECL_VERIFIER(ObjectTemplateInfo) DECL_VERIFIER(ObjectTemplateInfo)
static const int kConstructorOffset = TemplateInfo::kHeaderSize; // Layout description.
// LSB is for immutable_proto, higher bits for embedder_field_count #define OBJECT_TEMPLATE_INFO_FIELDS(V) \
static const int kDataOffset = kConstructorOffset + kPointerSize; V(kConstructorOffset, kTaggedSize) \
static const int kSize = kDataOffset + kPointerSize; /* LSB is for immutable_proto, higher bits for embedder_field_count */ \
V(kDataOffset, kTaggedSize) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(TemplateInfo::kHeaderSize,
OBJECT_TEMPLATE_INFO_FIELDS)
#undef OBJECT_TEMPLATE_INFO_FIELDS
// Starting from given object template's constructor walk up the inheritance // Starting from given object template's constructor walk up the inheritance
// chain till a function template that has an instance template is found. // chain till a function template that has an instance template is found.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment