[static-roots] Test to ensure mksnapshot creates a predictable r/o heap

To replace the test that ensured it accidentally and was removed in
https://chromium-review.googlesource.com/c/v8/v8/+/4178814

Bug: v8:13466
Change-Id: Ie5b123af94d12ffc444358f6631d67334e46b711
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4178826
Reviewed-by: Jakob Linke <jgruber@chromium.org>
Auto-Submit: Olivier Flückiger <olivf@chromium.org>
Commit-Queue: Olivier Flückiger <olivf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#85407}
This commit is contained in:
Olivier Flückiger 2023-01-19 16:21:58 +00:00 committed by V8 LUCI CQ
parent 5628a2be90
commit 2670e3d0cc
2 changed files with 34 additions and 0 deletions

View File

@ -114,6 +114,7 @@
'test-serialize/SnapshotCompression': [PASS, HEAVY],
'test-serialize/StartupSerializerOnceRunScript': [PASS, HEAVY],
'test-serialize/StartupSerializerTwiceRunScript': [PASS, HEAVY],
'test-serialize/StaticRootsPredictableSnapshot': [PASS, HEAVY],
'test-strings/StringOOMNewStringFromOneByte': [PASS, HEAVY],
'test-strings/StringOOMNewStringFromUtf8': [PASS, HEAVY],
'test-strings/Traverse': [PASS, HEAVY],
@ -300,6 +301,7 @@
'test-serialize/StartupSerializerOnce': [SKIP],
'test-serialize/StartupSerializerOnceRunScript': [SKIP],
'test-serialize/StartupSerializerTwiceRunScript': [SKIP],
'test-serialize/StaticRootsPredictableSnapshot': [SKIP],
'test-serialize/StartupSerializerTwice': [SKIP],
}], # 'system == windows and arch == x64 and mode == debug'
@ -780,6 +782,7 @@
'test-serialize/StartupSerializerOnceRunScript': [SKIP],
'test-serialize/StartupSerializerTwice': [SKIP],
'test-serialize/StartupSerializerTwiceRunScript': [SKIP],
'test-serialize/StaticRootsPredictableSnapshot': [SKIP],
'test-serialize/WeakArraySerializationInSnapshot': [SKIP],
'test-typedarrays/SpeciesConstructor': [SKIP],
'test-typedarrays/SpeciesConstructorAccessor': [SKIP],

View File

@ -5298,5 +5298,36 @@ UNINITIALIZED_TEST(BreakPointAccessorContextSnapshot) {
FreeCurrentEmbeddedBlob();
}
// These two flags are preconditions for static roots to work. We don't check
// for V8_STATIC_ROOTS_BOOL since the test targets mksnapshot built without
// static roots, to be able to generate the static-roots.h file.
#if defined(V8_COMPRESS_POINTERS_IN_SHARED_CAGE) && defined(V8_SHARED_RO_HEAP)
UNINITIALIZED_TEST(StaticRootsPredictableSnapshot) {
if (v8_flags.random_seed == 0) {
return;
}
v8::Isolate* isolate1 = TestSerializer::NewIsolateInitialized();
StartupBlobs blobs1 = Serialize(isolate1);
isolate1->Dispose();
v8::Isolate* isolate2 = TestSerializer::NewIsolateInitialized();
StartupBlobs blobs2 = Serialize(isolate2);
isolate2->Dispose();
// We want to ensure that setup-heap-internal.cc creates a predictable heap.
// For static roots it would be sufficient to check that the root pointers
// relative to the cage base are identical. However, we can't test this, since
// when we create two isolates in the same process, the offsets will actually
// be different.
CHECK_EQ(blobs1.read_only, blobs2.read_only);
blobs1.Dispose();
blobs2.Dispose();
FreeCurrentEmbeddedBlob();
}
#endif // defined(V8_COMPRESS_POINTERS_IN_SHARED_CAGE) &&
// defined(V8_SHARED_RO_HEAP)
} // namespace internal
} // namespace v8