[static-roots] Expose static roots as symbols

Create names for each static root. This is useful for debugging. It
might also be useful to track changing names and ensure static-roots.h
agrees with the actual name of the static root.

Bug: v8:13466
Change-Id: I32e2b370d99aabe42c87e2a3db7a8e5ebaae3e04
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4151189
Reviewed-by: Jakob Linke <jgruber@chromium.org>
Commit-Queue: Olivier Flückiger <olivf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#85201}
This commit is contained in:
Olivier Flückiger 2023-01-10 11:07:09 +00:00 committed by V8 LUCI CQ
parent 355d6941d9
commit 77f99a6bb6
3 changed files with 1516 additions and 747 deletions

View File

@ -4178,6 +4178,16 @@ void Isolate::VerifyStaticRoots() {
CHECK(first_page->Contains(the_root));
++idx;
}
idx = RootIndex::kFirstReadOnlyRoot;
#define CHECK_NAME(_1, name_, _2) \
CHECK_WITH_MSG(kStaticReadOnlyRoot::name_ == \
V8HeapCompressionScheme::CompressTagged(roots[idx]), \
STATIC_ROOTS_FAILED_MSG); \
++idx;
STRONG_READ_ONLY_ROOT_LIST(CHECK_NAME)
#undef CHECK_NAME
#undef STATIC_ROOTS_FAILED_MSG
#endif // V8_STATIC_ROOTS_BOOL
}

File diff suppressed because it is too large Load Diff

View File

@ -53,19 +53,29 @@ void StaticRootsTableGen::write(Isolate* isolate, const char* file) {
<< "namespace v8 {\n"
<< "namespace internal {\n"
<< "\n"
<< "constexpr static std::array<Tagged_t, " << size
<< "> StaticReadOnlyRootsPointerTable = {\n";
auto pos = RootIndex::kFirstReadOnlyRoot;
<< "struct kStaticReadOnlyRoot {\n";
RootIndex pos = RootIndex::kFirstReadOnlyRoot;
for (; pos <= RootIndex::kLastReadOnlyRoot; ++pos) {
auto el = roots[pos];
auto n = roots.name(pos);
el = V8HeapCompressionScheme::CompressTagged(el);
out << " " << reinterpret_cast<void*>(el) << ", // " << n << "\n";
out << " static constexpr Tagged_t " << n << " =";
if (strlen(n) + 38 > 80) out << "\n ";
out << " " << reinterpret_cast<void*>(el) << ";\n";
}
CHECK_EQ(static_cast<int>(pos), size);
out << "};\n"
<< "\n"
<< "} // namespace internal\n"
<< "\nstatic constexpr std::array<Tagged_t, " << size
<< "> StaticReadOnlyRootsPointerTable = {\n";
pos = RootIndex::kFirstReadOnlyRoot;
for (; pos <= RootIndex::kLastReadOnlyRoot; ++pos) {
auto el = roots[pos];
auto n = roots.name(pos);
el = V8HeapCompressionScheme::CompressTagged(el);
out << " kStaticReadOnlyRoot::" << n << ",\n";
}
out << "};\n";
CHECK_EQ(static_cast<int>(pos), size);
out << "\n} // namespace internal\n"
<< "} // namespace v8\n"
<< "#endif // V8_STATIC_ROOTS_BOOL\n"
<< "#endif // V8_ROOTS_STATIC_ROOTS_H_\n";