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