Commit cdf004ad authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

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

Bug: v8:8477, v8:8238
Change-Id: If776225f8949ba84fa17de333b4f14188c93a93d
Reviewed-on: https://chromium-review.googlesource.com/c/1366615Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58086}
parent c403c561
......@@ -505,7 +505,8 @@ Node* PromiseBuiltinsAssembler::TriggerPromiseReactions(
// Morph {current} from a PromiseReaction into a PromiseReactionJobTask
// and schedule that on the microtask queue. We try to minimize the number
// of stores here to avoid screwing up the store buffer.
STATIC_ASSERT(PromiseReaction::kSize == PromiseReactionJobTask::kSize);
STATIC_ASSERT(static_cast<int>(PromiseReaction::kSize) ==
static_cast<int>(PromiseReactionJobTask::kSize));
if (type == PromiseReaction::kFulfill) {
StoreMapNoWriteBarrier(current,
RootIndex::kPromiseFulfillReactionJobTaskMap);
......@@ -513,10 +514,13 @@ Node* PromiseBuiltinsAssembler::TriggerPromiseReactions(
argument);
StoreObjectField(current, PromiseReactionJobTask::kContextOffset,
context);
STATIC_ASSERT(PromiseReaction::kFulfillHandlerOffset ==
PromiseReactionJobTask::kHandlerOffset);
STATIC_ASSERT(PromiseReaction::kPromiseOrCapabilityOffset ==
PromiseReactionJobTask::kPromiseOrCapabilityOffset);
STATIC_ASSERT(
static_cast<int>(PromiseReaction::kFulfillHandlerOffset) ==
static_cast<int>(PromiseReactionJobTask::kHandlerOffset));
STATIC_ASSERT(
static_cast<int>(PromiseReaction::kPromiseOrCapabilityOffset) ==
static_cast<int>(
PromiseReactionJobTask::kPromiseOrCapabilityOffset));
} else {
Node* handler =
LoadObjectField(current, PromiseReaction::kRejectHandlerOffset);
......@@ -528,8 +532,10 @@ Node* PromiseBuiltinsAssembler::TriggerPromiseReactions(
context);
StoreObjectField(current, PromiseReactionJobTask::kHandlerOffset,
handler);
STATIC_ASSERT(PromiseReaction::kPromiseOrCapabilityOffset ==
PromiseReactionJobTask::kPromiseOrCapabilityOffset);
STATIC_ASSERT(
static_cast<int>(PromiseReaction::kPromiseOrCapabilityOffset) ==
static_cast<int>(
PromiseReactionJobTask::kPromiseOrCapabilityOffset));
}
CallBuiltin(Builtins::kEnqueueMicrotask, context, current);
Goto(&loop);
......
......@@ -2745,7 +2745,8 @@ void CodeStubAssembler::StoreFixedArrayOrPropertyArrayElement(
DCHECK(barrier_mode == SKIP_WRITE_BARRIER ||
barrier_mode == UPDATE_WRITE_BARRIER);
DCHECK_EQ(additional_offset % kPointerSize, 0);
STATIC_ASSERT(FixedArray::kHeaderSize == PropertyArray::kHeaderSize);
STATIC_ASSERT(static_cast<int>(FixedArray::kHeaderSize) ==
static_cast<int>(PropertyArray::kHeaderSize));
int header_size =
FixedArray::kHeaderSize + additional_offset - kHeapObjectTag;
Node* offset = ElementOffsetFromIndex(index_node, HOLEY_ELEMENTS,
......@@ -13401,7 +13402,8 @@ void CodeStubAssembler::CheckPrototypeEnumCache(Node* receiver,
// The following relies on the elements only aliasing with JSProxy::target,
// which is a Javascript value and hence cannot be confused with an elements
// backing store.
STATIC_ASSERT(JSObject::kElementsOffset == JSProxy::kTargetOffset);
STATIC_ASSERT(static_cast<int>(JSObject::kElementsOffset) ==
static_cast<int>(JSProxy::kTargetOffset));
Node* object_elements = LoadObjectField(object, JSObject::kElementsOffset);
GotoIf(IsEmptyFixedArray(object_elements), &if_no_elements);
GotoIf(IsEmptySlowElementDictionary(object_elements), &if_no_elements);
......
......@@ -1784,7 +1784,8 @@ Node* JSCreateLowering::AllocateLiteralRegExp(Node* effect, Node* control,
MapRef boilerplate_map = boilerplate.map();
// Sanity check that JSRegExp object layout hasn't changed.
STATIC_ASSERT(JSRegExp::kDataOffset == JSObject::kHeaderSize);
STATIC_ASSERT(static_cast<int>(JSRegExp::kDataOffset) ==
static_cast<int>(JSObject::kHeaderSize));
STATIC_ASSERT(JSRegExp::kSourceOffset ==
JSRegExp::kDataOffset + kPointerSize);
STATIC_ASSERT(JSRegExp::kFlagsOffset ==
......
......@@ -16530,7 +16530,8 @@ Handle<Object> JSPromise::TriggerPromiseReactions(Isolate* isolate,
Handle<PromiseReaction> reaction = Handle<PromiseReaction>::cast(task);
reactions = handle(reaction->next(), isolate);
STATIC_ASSERT(PromiseReaction::kSize == PromiseReactionJobTask::kSize);
STATIC_ASSERT(static_cast<int>(PromiseReaction::kSize) ==
static_cast<int>(PromiseReactionJobTask::kSize));
if (type == PromiseReaction::kFulfill) {
task->synchronized_set_map(
ReadOnlyRoots(isolate).promise_fulfill_reaction_job_task_map());
......@@ -16538,10 +16539,13 @@ Handle<Object> JSPromise::TriggerPromiseReactions(Isolate* isolate,
*argument);
Handle<PromiseFulfillReactionJobTask>::cast(task)->set_context(
*isolate->native_context());
STATIC_ASSERT(PromiseReaction::kFulfillHandlerOffset ==
PromiseFulfillReactionJobTask::kHandlerOffset);
STATIC_ASSERT(PromiseReaction::kPromiseOrCapabilityOffset ==
PromiseFulfillReactionJobTask::kPromiseOrCapabilityOffset);
STATIC_ASSERT(
static_cast<int>(PromiseReaction::kFulfillHandlerOffset) ==
static_cast<int>(PromiseFulfillReactionJobTask::kHandlerOffset));
STATIC_ASSERT(
static_cast<int>(PromiseReaction::kPromiseOrCapabilityOffset) ==
static_cast<int>(
PromiseFulfillReactionJobTask::kPromiseOrCapabilityOffset));
} else {
DisallowHeapAllocation no_gc;
HeapObject* handler = reaction->reject_handler();
......@@ -16551,8 +16555,10 @@ Handle<Object> JSPromise::TriggerPromiseReactions(Isolate* isolate,
Handle<PromiseRejectReactionJobTask>::cast(task)->set_context(
*isolate->native_context());
Handle<PromiseRejectReactionJobTask>::cast(task)->set_handler(handler);
STATIC_ASSERT(PromiseReaction::kPromiseOrCapabilityOffset ==
PromiseRejectReactionJobTask::kPromiseOrCapabilityOffset);
STATIC_ASSERT(
static_cast<int>(PromiseReaction::kPromiseOrCapabilityOffset) ==
static_cast<int>(
PromiseRejectReactionJobTask::kPromiseOrCapabilityOffset));
}
isolate->EnqueueMicrotask(Handle<PromiseReactionJobTask>::cast(task));
......
......@@ -205,7 +205,7 @@ class DescriptorArray : public HeapObjectPtr {
DECL_INT16_ACCESSORS(filler16bits)
// Low-level per-element accessors.
static constexpr int offset(int index) {
return kHeaderSize + index * kPointerSize;
return kHeaderSize + index * kTaggedSize;
}
inline int length() const;
inline MaybeObject get(int index) const;
......
......@@ -148,11 +148,18 @@ class AsyncGeneratorRequest : public Struct {
DECL_ACCESSORS(value, Object)
DECL_ACCESSORS(promise, Object)
static const int kNextOffset = Struct::kHeaderSize;
static const int kResumeModeOffset = kNextOffset + kPointerSize;
static const int kValueOffset = kResumeModeOffset + kPointerSize;
static const int kPromiseOffset = kValueOffset + kPointerSize;
static const int kSize = kPromiseOffset + kPointerSize;
// Layout description.
#define ASYNC_GENERATOR_REQUEST_FIELDS(V) \
V(kNextOffset, kTaggedSize) \
V(kResumeModeOffset, kTaggedSize) \
V(kValueOffset, kTaggedSize) \
V(kPromiseOffset, kTaggedSize) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(Struct::kHeaderSize,
ASYNC_GENERATOR_REQUEST_FIELDS)
#undef ASYNC_GENERATOR_REQUEST_FIELDS
DECL_CAST(AsyncGeneratorRequest)
DECL_PRINTER(AsyncGeneratorRequest)
......
This diff is collapsed.
......@@ -119,7 +119,8 @@ class JSProxy : public JSReceiver {
// JSProxy::target is a Javascript value which cannot be confused with an
// elements backing store is exploited by loading from this offset from an
// unknown JSReceiver.
STATIC_ASSERT(JSObject::kElementsOffset == JSProxy::kTargetOffset);
STATIC_ASSERT(static_cast<int>(JSObject::kElementsOffset) ==
static_cast<int>(JSProxy::kTargetOffset));
typedef FixedBodyDescriptor<JSReceiver::kPropertiesOrHashOffset, kSize, kSize>
BodyDescriptor;
......
......@@ -51,13 +51,19 @@ class JSWeakFactory : public JSObject {
// calls the user's cleanup function.
static void Cleanup(Handle<JSWeakFactory> weak_factory, Isolate* isolate);
static const int kNativeContextOffset = JSObject::kHeaderSize;
static const int kCleanupOffset = kNativeContextOffset + kPointerSize;
static const int kActiveCellsOffset = kCleanupOffset + kPointerSize;
static const int kClearedCellsOffset = kActiveCellsOffset + kPointerSize;
static const int kNextOffset = kClearedCellsOffset + kPointerSize;
static const int kFlagsOffset = kNextOffset + kPointerSize;
static const int kSize = kFlagsOffset + kPointerSize;
// Layout description.
#define JS_WEAK_FACTORY_FIELDS(V) \
V(kNativeContextOffset, kTaggedSize) \
V(kCleanupOffset, kTaggedSize) \
V(kActiveCellsOffset, kTaggedSize) \
V(kClearedCellsOffset, kTaggedSize) \
V(kNextOffset, kTaggedSize) \
V(kFlagsOffset, kTaggedSize) \
/* Header size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JS_WEAK_FACTORY_FIELDS)
#undef JS_WEAK_FACTORY_FIELDS
// Bitfields in flags.
class ScheduledForCleanupField : public BitField<bool, 0, 1> {};
......@@ -81,12 +87,18 @@ class JSWeakCell : public JSObject {
DECL_ACCESSORS(prev, Object)
DECL_ACCESSORS(next, Object)
static const int kFactoryOffset = JSObject::kHeaderSize;
static const int kTargetOffset = kFactoryOffset + kPointerSize;
static const int kHoldingsOffset = kTargetOffset + kPointerSize;
static const int kPrevOffset = kHoldingsOffset + kPointerSize;
static const int kNextOffset = kPrevOffset + kPointerSize;
static const int kSize = kNextOffset + kPointerSize;
// Layout description.
#define JS_WEAK_CELL_FIELDS(V) \
V(kFactoryOffset, kTaggedSize) \
V(kTargetOffset, kTaggedSize) \
V(kHoldingsOffset, kTaggedSize) \
V(kPrevOffset, kTaggedSize) \
V(kNextOffset, kTaggedSize) \
/* Header size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JS_WEAK_CELL_FIELDS)
#undef JS_WEAK_CELL_FIELDS
class BodyDescriptor;
......@@ -120,8 +132,15 @@ class WeakFactoryCleanupJobTask : public Microtask {
DECL_VERIFIER(WeakFactoryCleanupJobTask)
DECL_PRINTER(WeakFactoryCleanupJobTask)
static const int kFactoryOffset = Microtask::kHeaderSize;
static const int kSize = kFactoryOffset + kPointerSize;
// Layout description.
#define WEAK_FACTORY_CLEANUP_JOB_TASK_FIELDS(V) \
V(kFactoryOffset, kTaggedSize) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(Microtask::kHeaderSize,
WEAK_FACTORY_CLEANUP_JOB_TASK_FIELDS)
#undef WEAK_FACTORY_CLEANUP_JOB_TASK_FIELDS
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(WeakFactoryCleanupJobTask);
......@@ -135,8 +154,15 @@ class JSWeakFactoryCleanupIterator : public JSObject {
DECL_ACCESSORS(factory, JSWeakFactory)
static const int kFactoryOffset = JSObject::kHeaderSize;
static const int kSize = kFactoryOffset + kPointerSize;
// Layout description.
#define JS_WEAK_FACTORY_CLEANUP_ITERATOR_FIELDS(V) \
V(kFactoryOffset, kTaggedSize) \
/* Header size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
JS_WEAK_FACTORY_CLEANUP_ITERATOR_FIELDS)
#undef JS_WEAK_FACTORY_CLEANUP_ITERATOR_FIELDS
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSWeakFactoryCleanupIterator);
......
......@@ -34,9 +34,15 @@ class CallbackTask : public Microtask {
DECL_ACCESSORS(callback, Foreign)
DECL_ACCESSORS(data, Foreign)
static const int kCallbackOffset = Microtask::kHeaderSize;
static const int kDataOffset = kCallbackOffset + kPointerSize;
static const int kSize = kDataOffset + kPointerSize;
// Layout description.
#define CALLBACK_TASK_FIELDS(V) \
V(kCallbackOffset, kTaggedSize) \
V(kDataOffset, kTaggedSize) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(Microtask::kHeaderSize, CALLBACK_TASK_FIELDS)
#undef CALLBACK_TASK_FIELDS
// Dispatched behavior.
DECL_CAST(CallbackTask)
......@@ -55,9 +61,15 @@ class CallableTask : public Microtask {
DECL_ACCESSORS(callable, JSReceiver)
DECL_ACCESSORS2(context, Context)
static const int kCallableOffset = Microtask::kHeaderSize;
static const int kContextOffset = kCallableOffset + kPointerSize;
static const int kSize = kContextOffset + kPointerSize;
// Layout description.
#define CALLABLE_TASK_FIELDS(V) \
V(kCallableOffset, kTaggedSize) \
V(kContextOffset, kTaggedSize) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(Microtask::kHeaderSize, CALLABLE_TASK_FIELDS)
#undef CALLABLE_TASK_FIELDS
// Dispatched behavior.
DECL_CAST(CallableTask)
......
......@@ -123,21 +123,26 @@ class Module : public Struct, public NeverReadOnlySpaceObject {
static Handle<JSModuleNamespace> GetModuleNamespace(Isolate* isolate,
Handle<Module> module);
static const int kCodeOffset = HeapObject::kHeaderSize;
static const int kExportsOffset = kCodeOffset + kPointerSize;
static const int kRegularExportsOffset = kExportsOffset + kPointerSize;
static const int kRegularImportsOffset = kRegularExportsOffset + kPointerSize;
static const int kHashOffset = kRegularImportsOffset + kPointerSize;
static const int kModuleNamespaceOffset = kHashOffset + kPointerSize;
static const int kRequestedModulesOffset =
kModuleNamespaceOffset + kPointerSize;
static const int kStatusOffset = kRequestedModulesOffset + kPointerSize;
static const int kDfsIndexOffset = kStatusOffset + kPointerSize;
static const int kDfsAncestorIndexOffset = kDfsIndexOffset + kPointerSize;
static const int kExceptionOffset = kDfsAncestorIndexOffset + kPointerSize;
static const int kScriptOffset = kExceptionOffset + kPointerSize;
static const int kImportMetaOffset = kScriptOffset + kPointerSize;
static const int kSize = kImportMetaOffset + kPointerSize;
// Layout description.
#define MODULE_FIELDS(V) \
V(kCodeOffset, kTaggedSize) \
V(kExportsOffset, kTaggedSize) \
V(kRegularExportsOffset, kTaggedSize) \
V(kRegularImportsOffset, kTaggedSize) \
V(kHashOffset, kTaggedSize) \
V(kModuleNamespaceOffset, kTaggedSize) \
V(kRequestedModulesOffset, kTaggedSize) \
V(kStatusOffset, kTaggedSize) \
V(kDfsIndexOffset, kTaggedSize) \
V(kDfsAncestorIndexOffset, kTaggedSize) \
V(kExceptionOffset, kTaggedSize) \
V(kScriptOffset, kTaggedSize) \
V(kImportMetaOffset, kTaggedSize) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(Struct::kHeaderSize, MODULE_FIELDS)
#undef MODULE_FIELDS
private:
friend class Factory;
......@@ -243,10 +248,18 @@ class JSModuleNamespace : public JSObject {
kInObjectFieldCount,
};
static const int kModuleOffset = JSObject::kHeaderSize;
static const int kHeaderSize = kModuleOffset + kPointerSize;
// Layout description.
#define JS_MODULE_NAMESPACE_FIELDS(V) \
V(kModuleOffset, kTaggedSize) \
/* Header size. */ \
V(kHeaderSize, 0) \
V(kInObjectFieldsOffset, kTaggedSize* kInObjectFieldCount) \
/* Total size. */ \
V(kSize, 0)
static const int kSize = kHeaderSize + kPointerSize * kInObjectFieldCount;
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
JS_MODULE_NAMESPACE_FIELDS)
#undef JS_MODULE_NAMESPACE_FIELDS
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSModuleNamespace);
......@@ -319,14 +332,20 @@ class ModuleInfoEntry : public Struct {
int module_request, int cell_index,
int beg_pos, int end_pos);
static const int kExportNameOffset = HeapObject::kHeaderSize;
static const int kLocalNameOffset = kExportNameOffset + kPointerSize;
static const int kImportNameOffset = kLocalNameOffset + kPointerSize;
static const int kModuleRequestOffset = kImportNameOffset + kPointerSize;
static const int kCellIndexOffset = kModuleRequestOffset + kPointerSize;
static const int kBegPosOffset = kCellIndexOffset + kPointerSize;
static const int kEndPosOffset = kBegPosOffset + kPointerSize;
static const int kSize = kEndPosOffset + kPointerSize;
// Layout description.
#define MODULE_INFO_FIELDS(V) \
V(kExportNameOffset, kTaggedSize) \
V(kLocalNameOffset, kTaggedSize) \
V(kImportNameOffset, kTaggedSize) \
V(kModuleRequestOffset, kTaggedSize) \
V(kCellIndexOffset, kTaggedSize) \
V(kBegPosOffset, kTaggedSize) \
V(kEndPosOffset, kTaggedSize) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(Struct::kHeaderSize, MODULE_INFO_FIELDS)
#undef MODULE_INFO_FIELDS
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(ModuleInfoEntry);
......
......@@ -274,7 +274,7 @@ class OrderedHashMap : public OrderedHashTable<OrderedHashMap, 2> {
// that the DataTable entries start aligned. A bucket or chain value
// of 255 is used to denote an unknown entry.
//
// The prefix size is calculated as the kPrefixSize * kPointerSize.
// The prefix size is calculated as the kPrefixSize * kTaggedSize.
//
// Memory layout: [ Prefix ] [ Header ] [ Padding ] [ DataTable ] [ HashTable ]
// [ Chains ]
......@@ -285,7 +285,7 @@ class OrderedHashMap : public OrderedHashTable<OrderedHashMap, 2> {
// [ 0 ] : Prefix
//
// Note: For the sake of brevity, the following start with index 0
// but, they actually start from kPrefixSize * kPointerSize to
// but, they actually start from kPrefixSize * kTaggedSize to
// account for the the prefix.
//
// [ Header ] :
......@@ -359,7 +359,7 @@ class SmallOrderedHashTable : public HeapObjectPtr {
int total_size = DataTableStartOffset() + data_table_size +
hash_table_size + chain_table_size;
return RoundUp(total_size, kPointerSize);
return RoundUp(total_size, kTaggedSize);
}
// Returns the number elements that can fit into the allocated table.
......@@ -500,7 +500,7 @@ class SmallOrderedHashTable : public HeapObjectPtr {
static constexpr Offset PrefixOffset() { return kHeaderSize; }
static constexpr Offset NumberOfElementsOffset() {
return PrefixOffset() + (Derived::kPrefixSize * kPointerSize);
return PrefixOffset() + (Derived::kPrefixSize * kTaggedSize);
}
static constexpr Offset NumberOfDeletedElementsOffset() {
......@@ -512,11 +512,11 @@ class SmallOrderedHashTable : public HeapObjectPtr {
}
static constexpr Offset DataTableStartOffset() {
return RoundUp<kPointerSize>(NumberOfBucketsOffset());
return RoundUp<kTaggedSize>(NumberOfBucketsOffset());
}
static constexpr int DataTableSizeFor(int capacity) {
return capacity * Derived::kEntrySize * kPointerSize;
return capacity * Derived::kEntrySize * kTaggedSize;
}
// This is used for accessing the non |DataTable| part of the
......@@ -535,8 +535,8 @@ class SmallOrderedHashTable : public HeapObjectPtr {
Offset GetDataEntryOffset(int entry, int relative_index) const {
DCHECK_LT(entry, Capacity());
int offset_in_datatable = entry * Derived::kEntrySize * kPointerSize;
int offset_in_entry = relative_index * kPointerSize;
int offset_in_datatable = entry * Derived::kEntrySize * kTaggedSize;
int offset_in_entry = relative_index * kTaggedSize;
return DataTableStartOffset() + offset_in_datatable + offset_in_entry;
}
......@@ -721,9 +721,16 @@ class JSCollectionIterator : public JSObject {
void JSCollectionIteratorPrint(std::ostream& os, const char* name);
static const int kTableOffset = JSObject::kHeaderSize;
static const int kIndexOffset = kTableOffset + kPointerSize;
static const int kSize = kIndexOffset + kPointerSize;
// Layout description.
#define JS_COLLECTION_ITERATOR_FIELDS(V) \
V(kTableOffset, kTaggedSize) \
V(kIndexOffset, kTaggedSize) \
/* Header size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
JS_COLLECTION_ITERATOR_FIELDS)
#undef JS_COLLECTION_ITERATOR_FIELDS
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSCollectionIterator);
......
......@@ -33,11 +33,18 @@ class PromiseReactionJobTask : public Microtask {
// a PromiseCapability (general case), or undefined (in case of await).
DECL_ACCESSORS(promise_or_capability, HeapObject)
static const int kArgumentOffset = Microtask::kHeaderSize;
static const int kContextOffset = kArgumentOffset + kPointerSize;
static const int kHandlerOffset = kContextOffset + kPointerSize;
static const int kPromiseOrCapabilityOffset = kHandlerOffset + kPointerSize;
static const int kSize = kPromiseOrCapabilityOffset + kPointerSize;
// Layout description.
#define PROMISE_REACTION_JOB_FIELDS(V) \
V(kArgumentOffset, kTaggedSize) \
V(kContextOffset, kTaggedSize) \
V(kHandlerOffset, kTaggedSize) \
V(kPromiseOrCapabilityOffset, kTaggedSize) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(Microtask::kHeaderSize,
PROMISE_REACTION_JOB_FIELDS)
#undef PROMISE_REACTION_JOB_FIELDS
// Dispatched behavior.
DECL_CAST(PromiseReactionJobTask)
......@@ -79,11 +86,18 @@ class PromiseResolveThenableJobTask : public Microtask {
DECL_ACCESSORS(then, JSReceiver)
DECL_ACCESSORS(thenable, JSReceiver)
static const int kContextOffset = Microtask::kHeaderSize;
static const int kPromiseToResolveOffset = kContextOffset + kPointerSize;
static const int kThenOffset = kPromiseToResolveOffset + kPointerSize;
static const int kThenableOffset = kThenOffset + kPointerSize;
static const int kSize = kThenableOffset + kPointerSize;
// Layout description.
#define PROMISE_RESOLVE_THENABLE_JOB_FIELDS(V) \
V(kContextOffset, kTaggedSize) \
V(kPromiseToResolveOffset, kTaggedSize) \
V(kThenOffset, kTaggedSize) \
V(kThenableOffset, kTaggedSize) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(Microtask::kHeaderSize,
PROMISE_RESOLVE_THENABLE_JOB_FIELDS)
#undef PROMISE_RESOLVE_THENABLE_JOB_FIELDS
// Dispatched behavior.
DECL_CAST(PromiseResolveThenableJobTask)
......@@ -101,10 +115,16 @@ class PromiseCapability : public Struct {
DECL_ACCESSORS(resolve, Object)
DECL_ACCESSORS(reject, Object)
static const int kPromiseOffset = Struct::kHeaderSize;
static const int kResolveOffset = kPromiseOffset + kPointerSize;
static const int kRejectOffset = kResolveOffset + kPointerSize;
static const int kSize = kRejectOffset + kPointerSize;
// Layout description.
#define PROMISE_CAPABILITY_FIELDS(V) \
V(kPromiseOffset, kTaggedSize) \
V(kResolveOffset, kTaggedSize) \
V(kRejectOffset, kTaggedSize) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(Struct::kHeaderSize, PROMISE_CAPABILITY_FIELDS)
#undef PROMISE_CAPABILITY_FIELDS
// Dispatched behavior.
DECL_CAST(PromiseCapability)
......@@ -143,12 +163,17 @@ class PromiseReaction : public Struct {
// a PromiseCapability (general case), or undefined (in case of await).
DECL_ACCESSORS(promise_or_capability, HeapObject)
static const int kNextOffset = Struct::kHeaderSize;
static const int kRejectHandlerOffset = kNextOffset + kPointerSize;
static const int kFulfillHandlerOffset = kRejectHandlerOffset + kPointerSize;
static const int kPromiseOrCapabilityOffset =
kFulfillHandlerOffset + kPointerSize;
static const int kSize = kPromiseOrCapabilityOffset + kPointerSize;
// Layout description.
#define PROMISE_REACTION_FIELDS(V) \
V(kNextOffset, kTaggedSize) \
V(kRejectHandlerOffset, kTaggedSize) \
V(kFulfillHandlerOffset, kTaggedSize) \
V(kPromiseOrCapabilityOffset, kTaggedSize) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(Struct::kHeaderSize, PROMISE_REACTION_FIELDS)
#undef PROMISE_REACTION_FIELDS
// Dispatched behavior.
DECL_CAST(PromiseReaction)
......
......@@ -21,24 +21,24 @@ OBJECT_CONSTRUCTORS_IMPL(PropertyArray, HeapObjectPtr)
CAST_ACCESSOR2(PropertyArray)
Object* PropertyArray::get(int index) const {
DCHECK_GE(index, 0);
DCHECK_LE(index, this->length());
return RELAXED_READ_FIELD(this, kHeaderSize + index * kPointerSize);
DCHECK_LT(static_cast<unsigned>(index),
static_cast<unsigned>(this->length()));
return RELAXED_READ_FIELD(this, OffsetOfElementAt(index));
}
void PropertyArray::set(int index, Object* value) {
DCHECK(IsPropertyArray());
DCHECK_GE(index, 0);
DCHECK_LT(index, this->length());
int offset = kHeaderSize + index * kPointerSize;
DCHECK_LT(static_cast<unsigned>(index),
static_cast<unsigned>(this->length()));
int offset = OffsetOfElementAt(index);
RELAXED_WRITE_FIELD(this, offset, value);
WRITE_BARRIER(this, offset, value);
}
void PropertyArray::set(int index, Object* value, WriteBarrierMode mode) {
DCHECK_GE(index, 0);
DCHECK_LT(index, this->length());
int offset = kHeaderSize + index * kPointerSize;
DCHECK_LT(static_cast<unsigned>(index),
static_cast<unsigned>(this->length()));
int offset = OffsetOfElementAt(index);
RELAXED_WRITE_FIELD(this, offset, value);
CONDITIONAL_WRITE_BARRIER(this, offset, value, mode);
}
......@@ -52,8 +52,8 @@ int PropertyArray::length() const {
}
void PropertyArray::initialize_length(int len) {
SLOW_DCHECK(len >= 0);
SLOW_DCHECK(len < LengthField::kMax);
DCHECK_LT(static_cast<unsigned>(len),
static_cast<unsigned>(LengthField::kMax));
WRITE_FIELD(this, kLengthAndHashOffset, Smi::FromInt(len));
}
......
......@@ -39,16 +39,22 @@ class PropertyArray : public HeapObjectPtr {
// Garbage collection support.
static constexpr int SizeFor(int length) {
return kHeaderSize + length * kPointerSize;
return kHeaderSize + length * kTaggedSize;
}
static constexpr int OffsetOfElementAt(int index) { return SizeFor(index); }
DECL_CAST2(PropertyArray)
DECL_PRINTER(PropertyArray)
DECL_VERIFIER(PropertyArray)
// Layout description.
static const int kLengthAndHashOffset = HeapObject::kHeaderSize;
static const int kHeaderSize = kLengthAndHashOffset + kPointerSize;
// Layout description.
#define PROPERTY_ARRAY_FIELDS(V) \
V(kLengthAndHashOffset, kTaggedSize) \
/* Header size. */ \
V(kHeaderSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, PROPERTY_ARRAY_FIELDS)
#undef PROPERTY_ARRAY_FIELDS
// Garbage collection support.
typedef FlexibleBodyDescriptor<kHeaderSize> BodyDescriptor;
......
......@@ -56,12 +56,17 @@ class PropertyCell : public HeapObject {
DECL_PRINTER(PropertyCell)
DECL_VERIFIER(PropertyCell)
// Layout description.
static const int kDetailsOffset = HeapObject::kHeaderSize;
static const int kNameOffset = kDetailsOffset + kPointerSize;
static const int kValueOffset = kNameOffset + kPointerSize;
static const int kDependentCodeOffset = kValueOffset + kPointerSize;
static const int kSize = kDependentCodeOffset + kPointerSize;
// Layout description.
#define PROPERTY_CELL_FIELDS(V) \
V(kDetailsOffset, kTaggedSize) \
V(kNameOffset, kTaggedSize) \
V(kValueOffset, kTaggedSize) \
V(kDependentCodeOffset, kTaggedSize) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, PROPERTY_CELL_FIELDS)
#undef PROPERTY_CELL_FIELDS
typedef FixedBodyDescriptor<kNameOffset, kSize, kSize> BodyDescriptor;
......
......@@ -52,14 +52,19 @@ class PrototypeInfo : public Struct {
DECL_PRINTER(PrototypeInfo)
DECL_VERIFIER(PrototypeInfo)
static const int kJSModuleNamespaceOffset = HeapObject::kHeaderSize;
static const int kPrototypeUsersOffset =
kJSModuleNamespaceOffset + kPointerSize;
static const int kRegistrySlotOffset = kPrototypeUsersOffset + kPointerSize;
static const int kValidityCellOffset = kRegistrySlotOffset + kPointerSize;
static const int kObjectCreateMapOffset = kValidityCellOffset + kPointerSize;
static const int kBitFieldOffset = kObjectCreateMapOffset + kPointerSize;
static const int kSize = kBitFieldOffset + kPointerSize;
// Layout description.
#define PROTOTYPE_INFO_FIELDS(V) \
V(kJSModuleNamespaceOffset, kTaggedSize) \
V(kPrototypeUsersOffset, kTaggedSize) \
V(kRegistrySlotOffset, kTaggedSize) \
V(kValidityCellOffset, kTaggedSize) \
V(kObjectCreateMapOffset, kTaggedSize) \
V(kBitFieldOffset, kTaggedSize) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, PROTOTYPE_INFO_FIELDS)
#undef PROTOTYPE_INFO_FIELDS
// Bit field usage.
static const int kShouldBeFastBit = 0;
......
......@@ -57,10 +57,16 @@ class V8_EXPORT_PRIVATE RegExpMatchInfo : NON_EXPORTED_BASE(public FixedArray) {
static const int kFirstCaptureIndex = 3;
static const int kLastMatchOverhead = kFirstCaptureIndex;
static const int kNumberOfCapturesOffset = FixedArray::kHeaderSize;
static const int kLastSubjectOffset = kNumberOfCapturesOffset + kPointerSize;
static const int kLastInputOffset = kLastSubjectOffset + kPointerSize;
static const int kFirstCaptureOffset = kLastInputOffset + kPointerSize;
// Layout description.
#define REG_EXP_MATCH_INFO_FIELDS(V) \
V(kNumberOfCapturesOffset, kTaggedSize) \
V(kLastSubjectOffset, kTaggedSize) \
V(kLastInputOffset, kTaggedSize) \
V(kFirstCaptureOffset, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(FixedArray::kHeaderSize,
REG_EXP_MATCH_INFO_FIELDS)
#undef REG_EXP_MATCH_INFO_FIELDS
// Every match info is guaranteed to have enough space to store two captures.
static const int kInitialCaptureIndices = 2;
......
......@@ -187,26 +187,28 @@ class Script : public Struct, public NeverReadOnlySpaceObject {
DECL_PRINTER(Script)
DECL_VERIFIER(Script)
static const int kSourceOffset = HeapObject::kHeaderSize;
static const int kNameOffset = kSourceOffset + kPointerSize;
static const int kLineOffsetOffset = kNameOffset + kPointerSize;
static const int kColumnOffsetOffset = kLineOffsetOffset + kPointerSize;
static const int kContextOffset = kColumnOffsetOffset + kPointerSize;
static const int kTypeOffset = kContextOffset + kPointerSize;
static const int kLineEndsOffset = kTypeOffset + kPointerSize;
static const int kIdOffset = kLineEndsOffset + kPointerSize;
static const int kEvalFromSharedOrWrappedArgumentsOffset =
kIdOffset + kPointerSize;
static const int kEvalFromPositionOffset =
kEvalFromSharedOrWrappedArgumentsOffset + kPointerSize;
static const int kSharedFunctionInfosOffset =
kEvalFromPositionOffset + kPointerSize;
static const int kFlagsOffset = kSharedFunctionInfosOffset + kPointerSize;
static const int kSourceUrlOffset = kFlagsOffset + kPointerSize;
static const int kSourceMappingUrlOffset = kSourceUrlOffset + kPointerSize;
static const int kHostDefinedOptionsOffset =
kSourceMappingUrlOffset + kPointerSize;
static const int kSize = kHostDefinedOptionsOffset + kPointerSize;
// Layout description.
#define SCRIPTS_FIELDS(V) \
V(kSourceOffset, kTaggedSize) \
V(kNameOffset, kTaggedSize) \
V(kLineOffsetOffset, kTaggedSize) \
V(kColumnOffsetOffset, kTaggedSize) \
V(kContextOffset, kTaggedSize) \
V(kTypeOffset, kTaggedSize) \
V(kLineEndsOffset, kTaggedSize) \
V(kIdOffset, kTaggedSize) \
V(kEvalFromSharedOrWrappedArgumentsOffset, kTaggedSize) \
V(kEvalFromPositionOffset, kTaggedSize) \
V(kSharedFunctionInfosOffset, kTaggedSize) \
V(kFlagsOffset, kTaggedSize) \
V(kSourceUrlOffset, kTaggedSize) \
V(kSourceMappingUrlOffset, kTaggedSize) \
V(kHostDefinedOptionsOffset, kTaggedSize) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, SCRIPTS_FIELDS)
#undef SCRIPTS_FIELDS
private:
// Bit positions in the flags field.
......
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