5 #ifndef V8_ISOLATE_DATA_H_ 6 #define V8_ISOLATE_DATA_H_ 8 #include "src/builtins/builtins.h" 9 #include "src/constants-arch.h" 10 #include "src/external-reference-table.h" 11 #include "src/roots.h" 12 #include "src/utils.h" 30 static constexpr intptr_t kIsolateRootBias = kRootRegisterBias;
34 return reinterpret_cast<Address>(
this) + kIsolateRootBias;
38 static constexpr
int roots_table_offset() {
39 return kRootsTableOffset - kIsolateRootBias;
43 static constexpr
int root_slot_offset(RootIndex root_index) {
44 return roots_table_offset() + RootsTable::offset_of(root_index);
48 static constexpr
int external_reference_table_offset() {
49 return kExternalReferenceTableOffset - kIsolateRootBias;
53 static constexpr
int builtins_table_offset() {
54 return kBuiltinsTableOffset - kIsolateRootBias;
59 static int builtin_slot_offset(
int builtin_index) {
60 DCHECK(Builtins::IsBuiltinId(builtin_index));
61 return builtins_table_offset() + builtin_index * kPointerSize;
65 static int builtin_slot_offset(Builtins::Name
id) {
66 return builtins_table_offset() +
id * kPointerSize;
70 static constexpr
int virtual_call_target_register_offset() {
71 return kVirtualCallTargetRegisterOffset - kIsolateRootBias;
77 bool contains(
Address address)
const {
78 STATIC_ASSERT(std::is_unsigned<Address>::value);
80 return (address - start) <
sizeof(*this);
84 const RootsTable& roots()
const {
return roots_; }
87 return &external_reference_table_;
90 Address* builtins() {
return builtins_; }
95 V(kEmbedderDataOffset, Internals::kNumIsolateDataSlots* kPointerSize) \ 96 V(kExternalMemoryOffset, kInt64Size) \ 97 V(kExternalMemoryLlimitOffset, kInt64Size) \ 98 V(kExternalMemoryAtLastMarkCompactOffset, kInt64Size) \ 99 V(kRootsTableOffset, RootsTable::kEntriesCount* kPointerSize) \ 100 V(kExternalReferenceTableOffset, ExternalReferenceTable::SizeInBytes()) \ 101 V(kBuiltinsTableOffset, Builtins::builtin_count* kPointerSize) \ 102 V(kVirtualCallTargetRegisterOffset, kPointerSize) \ 105 8 + RoundUp<8>(static_cast<int>(kPaddingOffset)) - kPaddingOffset) \ 109 DEFINE_FIELD_OFFSET_CONSTANTS(0, FIELDS)
116 void* embedder_data_[Internals::kNumIsolateDataSlots] = {};
124 int64_t external_memory_limit_ = kExternalAllocationSoftLimit;
127 int64_t external_memory_at_last_mark_compact_ = 0;
134 Address builtins_[Builtins::builtin_count] = {};
139 void* virtual_call_target_register_ =
nullptr;
147 STATIC_ASSERT(kPaddingOffsetEnd + 1 - kPaddingOffset >= 8);
148 char padding_[kPaddingOffsetEnd + 1 - kPaddingOffset];
150 V8_INLINE
static void AssertPredictableLayout();
154 FRIEND_TEST(HeapTest, ExternalLimitDefault);
155 FRIEND_TEST(HeapTest, ExternalLimitStaysAboveDefaultForExplicitHandling);
164 void IsolateData::AssertPredictableLayout() {
165 STATIC_ASSERT(std::is_standard_layout<RootsTable>::value);
166 STATIC_ASSERT(std::is_standard_layout<ExternalReferenceTable>::value);
167 STATIC_ASSERT(std::is_standard_layout<IsolateData>::value);
168 STATIC_ASSERT(offsetof(
IsolateData, roots_) == kRootsTableOffset);
169 STATIC_ASSERT(offsetof(
IsolateData, external_reference_table_) ==
170 kExternalReferenceTableOffset);
171 STATIC_ASSERT(offsetof(
IsolateData, builtins_) == kBuiltinsTableOffset);
172 STATIC_ASSERT(offsetof(
IsolateData, virtual_call_target_register_) ==
173 kVirtualCallTargetRegisterOffset);
174 STATIC_ASSERT(offsetof(
IsolateData, external_memory_) ==
175 kExternalMemoryOffset);
176 STATIC_ASSERT(offsetof(
IsolateData, external_memory_limit_) ==
177 kExternalMemoryLlimitOffset);
178 STATIC_ASSERT(offsetof(
IsolateData, external_memory_at_last_mark_compact_) ==
179 kExternalMemoryAtLastMarkCompactOffset);
180 STATIC_ASSERT(
sizeof(
IsolateData) == IsolateData::kSize);
186 #endif // V8_ISOLATE_DATA_H_