diff --git a/common.gypi b/common.gypi index 2e59636b1718f1..4fd333a45de84b 100644 --- a/common.gypi +++ b/common.gypi @@ -39,7 +39,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.20', + 'v8_embedder_string': '-node.21', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/src/heap/factory.cc b/deps/v8/src/heap/factory.cc index 721682f00f26de..7e434ea041866f 100644 --- a/deps/v8/src/heap/factory.cc +++ b/deps/v8/src/heap/factory.cc @@ -3070,20 +3070,22 @@ Handle Factory::NewSyntheticModule( Handle module_name, Handle export_names, v8::Module::SyntheticModuleEvaluationSteps evaluation_steps) { ReadOnlyRoots roots(isolate()); - Handle module( - SyntheticModule::cast(New(synthetic_module_map(), AllocationType::kOld)), - isolate()); + Handle exports = ObjectHashTable::New(isolate(), static_cast(export_names->length())); Handle evaluation_steps_foreign = NewForeign(reinterpret_cast(evaluation_steps)); - module->set_exports(*exports); + + Handle module( + SyntheticModule::cast(New(synthetic_module_map(), AllocationType::kOld)), + isolate()); module->set_hash(isolate()->GenerateIdentityHash(Smi::kMaxValue)); module->set_module_namespace(roots.undefined_value()); module->set_status(Module::kUninstantiated); module->set_exception(roots.the_hole_value()); module->set_name(*module_name); module->set_export_names(*export_names); + module->set_exports(*exports); module->set_evaluation_steps(*evaluation_steps_foreign); return module; } diff --git a/deps/v8/test/cctest/test-api.cc b/deps/v8/test/cctest/test-api.cc index 12faaff39cbfcb..bafdd6ce3b7194 100644 --- a/deps/v8/test/cctest/test-api.cc +++ b/deps/v8/test/cctest/test-api.cc @@ -23918,6 +23918,31 @@ TEST(CreateSyntheticModule) { CHECK_EQ(i_module->status(), i::Module::kInstantiated); } +TEST(CreateSyntheticModuleGC) { + // Try to make sure that CreateSyntheticModule() deals well with a GC + // happening during its execution. + i::FLAG_gc_interval = 10; + i::FLAG_inline_new = false; + + LocalContext env; + v8::Isolate* isolate = env->GetIsolate(); + v8::Isolate::Scope iscope(isolate); + v8::HandleScope scope(isolate); + v8::Local context = v8::Context::New(isolate); + v8::Context::Scope cscope(context); + + std::vector> export_names{v8_str("default")}; + v8::Local module_name = + v8_str("CreateSyntheticModule-TestSyntheticModuleGC"); + + for (int i = 0; i < 200; i++) { + Local module = v8::Module::CreateSyntheticModule( + isolate, module_name, export_names, + UnexpectedSyntheticModuleEvaluationStepsCallback); + USE(module); + } +} + TEST(SyntheticModuleSetExports) { LocalContext env; v8::Isolate* isolate = env->GetIsolate();