[static-roots] Fix gen-static-roots for some build configurations

Fixes running gen-static-roots for:

* debug builds: need to access the value unchecked when generating the
  table as the shared r/o root table is uninitialized.
* different architectures: to generate the static-roots.h file we must
  have the same predictable heap layout in mksnapshot as in the actual
  static roots enabled build.

Bug: v8:13466
Change-Id: I87e087987d735bf3368085db2e977542978a88e4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4194204
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: Jakob Linke <jgruber@chromium.org>
Auto-Submit: Olivier Flückiger <olivf@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/main@{#85497}
This commit is contained in:
Olivier Flückiger 2023-01-25 15:14:34 +00:00 committed by V8 LUCI CQ
parent 5bff98a677
commit c97e61eaa3
2 changed files with 17 additions and 17 deletions

View File

@ -732,20 +732,20 @@ void Heap::CreateInitialReadOnlyObjects() {
// For static roots we need the r/o space to have identical layout on all
// compile targets. Varying objects are padded to their biggest size.
auto StaticRootsEnsureAllocatedSize = [&](HeapObject obj, int required) {
#ifdef V8_STATIC_ROOTS_BOOL
if (V8_STATIC_ROOTS_BOOL || v8_flags.static_roots_src) {
if (required == obj.Size()) return;
CHECK_LT(obj.Size(), required);
int filler_size = required - obj.Size();
HeapObject filler =
allocator()->AllocateRawWith<HeapAllocator::kRetryOrFail>(
filler_size, AllocationType::kReadOnly, AllocationOrigin::kRuntime,
AllocationAlignment::kTaggedAligned);
filler_size, AllocationType::kReadOnly,
AllocationOrigin::kRuntime, AllocationAlignment::kTaggedAligned);
CreateFillerObjectAt(filler.address(), filler_size,
ClearFreedMemoryMode::kClearFreedMemory);
CHECK_EQ(filler.address() + filler.Size(), obj.address() + required);
#endif
}
};
// The -0 value must be set before NewNumber works.

View File

@ -61,8 +61,8 @@ void StaticRootsTableGen::write(Isolate* isolate, const char* file) {
std::map<Tagged_t, std::list<std::string>> sorted_roots;
#define ADD_ROOT(_, value, CamelName) \
{ \
Tagged_t ptr = \
V8HeapCompressionScheme::CompressTagged(ro_roots.value().ptr()); \
Tagged_t ptr = V8HeapCompressionScheme::CompressTagged( \
ro_roots.unchecked_##value().ptr()); \
sorted_roots[ptr].push_back(#CamelName); \
}
READ_ONLY_ROOT_LIST(ADD_ROOT)