@@ -4199,17 +4199,22 @@ bool AllowWasmCodeGenerationCallback(
41994199 return wasm_code_gen->IsUndefined () || wasm_code_gen->IsTrue ();
42004200}
42014201
4202- Isolate* NewIsolate (ArrayBufferAllocator* allocator) {
4202+ Isolate* NewIsolate (ArrayBufferAllocator* allocator, uv_loop_t * event_loop ) {
42034203 Isolate::CreateParams params;
42044204 params.array_buffer_allocator = allocator;
42054205#ifdef NODE_ENABLE_VTUNE_PROFILING
42064206 params.code_event_handler = vTune::GetVtuneCodeEventHandler ();
42074207#endif
42084208
4209- Isolate* isolate = Isolate::New (params );
4209+ Isolate* isolate = Isolate::Allocate ( );
42104210 if (isolate == nullptr )
42114211 return nullptr ;
42124212
4213+ // Register the isolate on the platform before the isolate gets initialized,
4214+ // so that the isolate can access the platform during initialization.
4215+ v8_platform.Platform ()->RegisterIsolate (isolate, event_loop);
4216+ Isolate::Initialize (isolate, params);
4217+
42134218 isolate->AddMessageListener (OnMessage);
42144219 isolate->SetAbortOnUncaughtExceptionCallback (ShouldAbortOnUncaughtException);
42154220 isolate->SetMicrotasksPolicy (v8::MicrotasksPolicy::kExplicit );
@@ -4224,7 +4229,7 @@ inline int Start(uv_loop_t* event_loop,
42244229 int exec_argc, const char * const * exec_argv) {
42254230 std::unique_ptr<ArrayBufferAllocator, decltype (&FreeArrayBufferAllocator)>
42264231 allocator (CreateArrayBufferAllocator (), &FreeArrayBufferAllocator);
4227- Isolate* const isolate = NewIsolate (allocator.get ());
4232+ Isolate* const isolate = NewIsolate (allocator.get (), event_loop );
42284233 if (isolate == nullptr )
42294234 return 12 ; // Signal internal error.
42304235
@@ -4260,6 +4265,7 @@ inline int Start(uv_loop_t* event_loop,
42604265 }
42614266
42624267 isolate->Dispose ();
4268+ v8_platform.Platform ()->UnregisterIsolate (isolate);
42634269
42644270 return exit_code;
42654271}
0 commit comments