@@ -5203,6 +5203,77 @@ UNINITIALIZED_TEST(SnapshotCreatorIncludeGlobalProxy) {
52035203 FreeCurrentEmbeddedBlob ();
52045204}
52055205
5206+ UNINITIALIZED_TEST (SnapshotCreatorSerializeInterceptorInOldSpace) {
5207+ DisableAlwaysOpt ();
5208+ DisableEmbeddedBlobRefcounting ();
5209+ v8::StartupData blob;
5210+
5211+ {
5212+ SnapshotCreatorParams testing_params (original_external_references);
5213+ v8::SnapshotCreator creator (testing_params.create_params );
5214+ v8::Isolate* isolate = creator.GetIsolate ();
5215+
5216+ {
5217+ v8::HandleScope handle_scope (isolate);
5218+
5219+ v8::Local<v8::ObjectTemplate> global_template =
5220+ v8::ObjectTemplate::New (isolate);
5221+
5222+ NamedPropertyHandlerConfiguration config (
5223+ NamedPropertyGetterForSerialization, {}, {}, {}, {}, {}, {},
5224+ v8_str (" test" ), // Stop it from being promoted to RO space.
5225+ PropertyHandlerFlags::kHasNoSideEffect );
5226+
5227+ global_template->SetHandler (config);
5228+
5229+ v8::Local<v8::Context> context =
5230+ v8::Context::New (isolate, nullptr , global_template);
5231+ v8::Context::Scope context_scope (context);
5232+ ExpectInt32 (" x" , 2016 );
5233+ creator.SetDefaultContext (context);
5234+ }
5235+
5236+ blob =
5237+ creator.CreateBlob (v8::SnapshotCreator::FunctionCodeHandling::kClear );
5238+ }
5239+
5240+ {
5241+ v8::Isolate::CreateParams params;
5242+ params.snapshot_blob = &blob;
5243+ params.array_buffer_allocator = CcTest::array_buffer_allocator ();
5244+ params.external_references = original_external_references;
5245+ // Test-appropriate equivalent of v8::Isolate::New.
5246+ v8::Isolate* isolate = TestSerializer::NewIsolate (params);
5247+ {
5248+ v8::Isolate::Scope isolate_scope (isolate);
5249+ v8::HandleScope handle_scope (isolate);
5250+
5251+ v8::Local<v8::Context> context = v8::Context::New (isolate);
5252+ v8::Context::Scope context_scope (context);
5253+
5254+ // Check that the InterceptorInfo is not promoted to RO space after
5255+ // deserialization.
5256+ i::Isolate* i_isolate = reinterpret_cast <i::Isolate*>(isolate);
5257+ CHECK (i_isolate->global_object ()->map ()->has_named_interceptor ());
5258+ CHECK (i_isolate->heap ()->InOldSpace (
5259+ i_isolate->global_object ()->GetNamedInterceptor ()));
5260+
5261+ ExpectInt32 (" x" , 2016 ); // Check deserialized getter.
5262+ // Check the unset interceptors.
5263+ CompileRun (
5264+ " Object.defineProperty(globalThis, 'test', {"
5265+ " value: 0, enumerable: true"
5266+ " })" );
5267+ ExpectFalse (" delete globalThis.test" );
5268+ ExpectTrue (" Object.keys(globalThis).includes('test')" );
5269+ }
5270+
5271+ isolate->Dispose ();
5272+ }
5273+ delete[] blob.data ;
5274+ FreeCurrentEmbeddedBlob ();
5275+ }
5276+
52065277UNINITIALIZED_TEST (ReinitializeHashSeedJSCollectionRehashable) {
52075278 DisableAlwaysOpt ();
52085279 i::v8_flags.rehash_snapshot = true ;
0 commit comments