Commit d09fc540 authored by Jakob Gruber's avatar Jakob Gruber Committed by V8 LUCI CQ

[isolate-data] Consistent field names

This is a refactor-only change in preparation for the upcoming
builtins table split.

- Define fields through a macro list to avoid some manual boilerplate
  code.
- Consistent names for builtin_entry_table_ and builtin_table_, and
  update names of related methods as well.
- Add Builtins::ToInt to replace manual static_casts.
- Move around IsolateData methods s.t. they're in the same order as
  the underlying fields.

Bug: v8:12203
Change-Id: I68cd036b8de1dd2708e2d4579d76bb3baaea5e1c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3162128Reviewed-by: 's avatarDominik Inführ <dinfuehr@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/main@{#76874}
parent b01d2f45
......@@ -314,7 +314,7 @@ void Builtins::EmitCodeCreateEvents(Isolate* isolate) {
return; // No need to iterate the entire table in this case.
}
Address* builtins = isolate->builtins_table();
Address* builtins = isolate->builtin_table();
int i = 0;
HandleScope scope(isolate);
for (; i < static_cast<int>(Builtin::kFirstBytecodeHandler); i++) {
......
......@@ -101,6 +101,10 @@ class Builtins {
DCHECK(IsBuiltinId(id));
return static_cast<Builtin>(id);
}
static constexpr int ToInt(Builtin id) {
DCHECK(IsBuiltinId(id));
return static_cast<int>(id);
}
// The different builtin kinds are documented in builtins-definitions.h.
enum Kind { CPP, TFJ, TFC, TFS, TFH, BCH, ASM };
......
......@@ -128,8 +128,8 @@ const char* V8NameConverter::RootRelativeName(int offset) const {
const unsigned kRootsTableSize = sizeof(RootsTable);
const int kExtRefsTableStart = IsolateData::external_reference_table_offset();
const unsigned kExtRefsTableSize = ExternalReferenceTable::kSizeInBytes;
const int kBuiltinsTableStart = IsolateData::builtins_table_offset();
const unsigned kBuiltinsTableSize =
const int kBuiltinTableStart = IsolateData::builtin_table_offset();
const unsigned kBuiltinTableSize =
Builtins::kBuiltinCount * kSystemPointerSize;
if (static_cast<unsigned>(offset - kRootsTableStart) < kRootsTableSize) {
......@@ -163,9 +163,9 @@ const char* V8NameConverter::RootRelativeName(int offset) const {
offset_in_extref_table));
return v8_buffer_.begin();
} else if (static_cast<unsigned>(offset - kBuiltinsTableStart) <
kBuiltinsTableSize) {
uint32_t offset_in_builtins_table = (offset - kBuiltinsTableStart);
} else if (static_cast<unsigned>(offset - kBuiltinTableStart) <
kBuiltinTableSize) {
uint32_t offset_in_builtins_table = (offset - kBuiltinTableStart);
Builtin builtin =
Builtins::FromInt(offset_in_builtins_table / kSystemPointerSize);
......
......@@ -346,7 +346,8 @@ SafeStackFrameIterator::SafeStackFrameIterator(Isolate* isolate, Address pc,
top_frame_type_ = type;
state.fp = fast_c_fp;
state.sp = sp;
state.pc_address = isolate->isolate_data()->fast_c_call_caller_pc_address();
state.pc_address = reinterpret_cast<Address*>(
isolate->isolate_data()->fast_c_call_caller_pc_address());
advance_frame = false;
} else if (IsValidTop(top)) {
type = ExitFrame::GetStateForFramePointer(Isolate::c_entry_fp(top), &state);
......
This diff is collapsed.
......@@ -2675,10 +2675,10 @@ void Isolate::ReleaseSharedPtrs() {
}
}
bool Isolate::IsBuiltinsTableHandleLocation(Address* handle_location) {
bool Isolate::IsBuiltinTableHandleLocation(Address* handle_location) {
FullObjectSlot location(handle_location);
FullObjectSlot first_root(builtins_table());
FullObjectSlot last_root(builtins_table() + Builtins::kBuiltinCount);
FullObjectSlot first_root(builtin_table());
FullObjectSlot last_root(builtin_table() + Builtins::kBuiltinCount);
if (location >= last_root) return false;
if (location < first_root) return false;
return true;
......@@ -3049,7 +3049,7 @@ void Isolate::CheckIsolateLayout() {
Internals::kIsolateLongTaskStatsCounterOffset);
CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, isolate_data_.stack_guard_)),
Internals::kIsolateStackGuardOffset);
CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, isolate_data_.roots_)),
CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, isolate_data_.roots_table_)),
Internals::kIsolateRootsOffset);
#ifdef V8_HEAP_SANDBOX
......
......@@ -1123,9 +1123,9 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory {
}
Address* builtin_entry_table() { return isolate_data_.builtin_entry_table(); }
V8_INLINE Address* builtins_table() { return isolate_data_.builtins(); }
V8_INLINE Address* builtin_table() { return isolate_data_.builtin_table(); }
bool IsBuiltinsTableHandleLocation(Address* handle_location);
bool IsBuiltinTableHandleLocation(Address* handle_location);
StubCache* load_stub_cache() const { return load_stub_cache_; }
StubCache* store_stub_cache() const { return store_stub_cache_; }
......
......@@ -43,7 +43,7 @@ bool HandleBase::IsDereferenceAllowed() const {
RootsTable::IsImmortalImmovable(root_index)) {
return true;
}
if (isolate->IsBuiltinsTableHandleLocation(location_)) return true;
if (isolate->IsBuiltinTableHandleLocation(location_)) return true;
if (!AllowHandleDereference::IsAllowed()) return false;
LocalHeap* local_heap = isolate->CurrentLocalHeap();
......
......@@ -4653,21 +4653,20 @@ void Heap::ZapCodeObject(Address start_address, int size_in_bytes) {
Code Heap::builtin(Builtin builtin) {
DCHECK(Builtins::IsBuiltinId(builtin));
return Code::cast(
Object(isolate()->builtins_table()[static_cast<int>(builtin)]));
Object(isolate()->builtin_table()[static_cast<int>(builtin)]));
}
Address Heap::builtin_address(Builtin builtin) {
const int index = static_cast<int>(builtin);
const int index = Builtins::ToInt(builtin);
DCHECK(Builtins::IsBuiltinId(builtin) || index == Builtins::kBuiltinCount);
return reinterpret_cast<Address>(&isolate()->builtins_table()[index]);
return reinterpret_cast<Address>(&isolate()->builtin_table()[index]);
}
void Heap::set_builtin(Builtin builtin, Code code) {
DCHECK(Builtins::IsBuiltinId(builtin));
DCHECK(Internals::HasHeapObjectTag(code.ptr()));
// The given builtin may be completely uninitialized thus we cannot check its
// type here.
isolate()->builtins_table()[static_cast<int>(builtin)] = code.ptr();
// The given builtin may be uninitialized thus we cannot check its type here.
isolate()->builtin_table()[Builtins::ToInt(builtin)] = code.ptr();
}
void Heap::IterateWeakRoots(RootVisitor* v, base::EnumSet<SkipRoot> options) {
......
......@@ -217,7 +217,8 @@ inline T RoundingAverageUnsigned(T a, T b) {
//
// DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, MAP_FIELDS)
//
#define DEFINE_ONE_FIELD_OFFSET(Name, Size) Name, Name##End = Name + (Size)-1,
#define DEFINE_ONE_FIELD_OFFSET(Name, Size, ...) \
Name, Name##End = Name + (Size)-1,
#define DEFINE_FIELD_OFFSET_CONSTANTS(StartOffset, LIST_MACRO) \
enum { \
......
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