@@ -262,10 +262,10 @@ node::DebugOptions debug_options;
262262
263263static struct {
264264#if NODE_USE_V8_PLATFORM
265- void Initialize (int thread_pool_size, uv_loop_t * loop ) {
265+ void Initialize (int thread_pool_size) {
266266 tracing_agent_ =
267267 trace_enabled ? new tracing::Agent () : nullptr ;
268- platform_ = new NodePlatform (thread_pool_size, loop,
268+ platform_ = new NodePlatform (thread_pool_size,
269269 trace_enabled ? tracing_agent_->GetTracingController () : nullptr );
270270 V8::InitializePlatform (platform_);
271271 tracing::TraceEventHelper::SetTracingController (
@@ -280,8 +280,8 @@ static struct {
280280 tracing_agent_ = nullptr ;
281281 }
282282
283- void DrainVMTasks () {
284- platform_->DrainBackgroundTasks ();
283+ void DrainVMTasks (Isolate* isolate ) {
284+ platform_->DrainBackgroundTasks (isolate );
285285 }
286286
287287#if HAVE_INSPECTOR
@@ -306,12 +306,16 @@ static struct {
306306 tracing_agent_->Stop ();
307307 }
308308
309+ NodePlatform* Platform () {
310+ return platform_;
311+ }
312+
309313 tracing::Agent* tracing_agent_;
310314 NodePlatform* platform_;
311315#else // !NODE_USE_V8_PLATFORM
312- void Initialize (int thread_pool_size, uv_loop_t * loop ) {}
316+ void Initialize (int thread_pool_size) {}
313317 void Dispose () {}
314- void DrainVMTasks () {}
318+ void DrainVMTasks (Isolate* isolate ) {}
315319 bool StartInspector (Environment *env, const char * script_path,
316320 const node::DebugOptions& options) {
317321 env->ThrowError (" Node compiled with NODE_USE_V8_PLATFORM=0" );
@@ -323,6 +327,10 @@ static struct {
323327 " so event tracing is not available.\n " );
324328 }
325329 void StopTracingAgent () {}
330+
331+ NodePlatform* Platform () {
332+ return nullptr ;
333+ }
326334#endif // !NODE_USE_V8_PLATFORM
327335
328336#if !NODE_USE_V8_PLATFORM || !HAVE_INSPECTOR
@@ -4441,7 +4449,14 @@ int EmitExit(Environment* env) {
44414449
44424450
44434451IsolateData* CreateIsolateData (Isolate* isolate, uv_loop_t * loop) {
4444- return new IsolateData (isolate, loop);
4452+ return new IsolateData (isolate, loop, nullptr );
4453+ }
4454+
4455+ IsolateData* CreateIsolateData (
4456+ Isolate* isolate,
4457+ uv_loop_t * loop,
4458+ MultiIsolatePlatform* platform) {
4459+ return new IsolateData (isolate, loop, platform);
44454460}
44464461
44474462
@@ -4526,7 +4541,7 @@ inline int Start(Isolate* isolate, IsolateData* isolate_data,
45264541 do {
45274542 uv_run (env.event_loop (), UV_RUN_DEFAULT);
45284543
4529- v8_platform.DrainVMTasks ();
4544+ v8_platform.DrainVMTasks (isolate );
45304545
45314546 more = uv_loop_alive (env.event_loop ());
45324547 if (more)
@@ -4547,7 +4562,7 @@ inline int Start(Isolate* isolate, IsolateData* isolate_data,
45474562 RunAtExit (&env);
45484563 uv_key_delete (&thread_local_env);
45494564
4550- v8_platform.DrainVMTasks ();
4565+ v8_platform.DrainVMTasks (isolate );
45514566 WaitForInspectorDisconnect (&env);
45524567#if defined(LEAK_SANITIZER)
45534568 __lsan_do_leak_check ();
@@ -4590,7 +4605,11 @@ inline int Start(uv_loop_t* event_loop,
45904605 Locker locker (isolate);
45914606 Isolate::Scope isolate_scope (isolate);
45924607 HandleScope handle_scope (isolate);
4593- IsolateData isolate_data (isolate, event_loop, allocator.zero_fill_field ());
4608+ IsolateData isolate_data (
4609+ isolate,
4610+ event_loop,
4611+ v8_platform.Platform (),
4612+ allocator.zero_fill_field ());
45944613 exit_code = Start (isolate, &isolate_data, argc, argv, exec_argc, exec_argv);
45954614 }
45964615
@@ -4637,7 +4656,7 @@ int Start(int argc, char** argv) {
46374656 V8::SetEntropySource (crypto::EntropySource);
46384657#endif // HAVE_OPENSSL
46394658
4640- v8_platform.Initialize (v8_thread_pool_size, uv_default_loop () );
4659+ v8_platform.Initialize (v8_thread_pool_size);
46414660 // Enable tracing when argv has --trace-events-enabled.
46424661 if (trace_enabled) {
46434662 fprintf (stderr, " Warning: Trace event is an experimental feature "
0 commit comments