@@ -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
@@ -4431,7 +4439,14 @@ int EmitExit(Environment* env) {
44314439
44324440
44334441IsolateData* CreateIsolateData (Isolate* isolate, uv_loop_t * loop) {
4434- return new IsolateData (isolate, loop);
4442+ return new IsolateData (isolate, loop, nullptr );
4443+ }
4444+
4445+ IsolateData* CreateIsolateData (
4446+ Isolate* isolate,
4447+ uv_loop_t * loop,
4448+ MultiIsolatePlatform* platform) {
4449+ return new IsolateData (isolate, loop, platform);
44354450}
44364451
44374452
@@ -4516,7 +4531,7 @@ inline int Start(Isolate* isolate, IsolateData* isolate_data,
45164531 do {
45174532 uv_run (env.event_loop (), UV_RUN_DEFAULT);
45184533
4519- v8_platform.DrainVMTasks ();
4534+ v8_platform.DrainVMTasks (isolate );
45204535
45214536 more = uv_loop_alive (env.event_loop ());
45224537 if (more)
@@ -4537,7 +4552,7 @@ inline int Start(Isolate* isolate, IsolateData* isolate_data,
45374552 RunAtExit (&env);
45384553 uv_key_delete (&thread_local_env);
45394554
4540- v8_platform.DrainVMTasks ();
4555+ v8_platform.DrainVMTasks (isolate );
45414556 WaitForInspectorDisconnect (&env);
45424557#if defined(LEAK_SANITIZER)
45434558 __lsan_do_leak_check ();
@@ -4580,7 +4595,11 @@ inline int Start(uv_loop_t* event_loop,
45804595 Locker locker (isolate);
45814596 Isolate::Scope isolate_scope (isolate);
45824597 HandleScope handle_scope (isolate);
4583- IsolateData isolate_data (isolate, event_loop, allocator.zero_fill_field ());
4598+ IsolateData isolate_data (
4599+ isolate,
4600+ event_loop,
4601+ v8_platform.Platform (),
4602+ allocator.zero_fill_field ());
45844603 exit_code = Start (isolate, &isolate_data, argc, argv, exec_argc, exec_argv);
45854604 }
45864605
@@ -4627,7 +4646,7 @@ int Start(int argc, char** argv) {
46274646 V8::SetEntropySource (crypto::EntropySource);
46284647#endif // HAVE_OPENSSL
46294648
4630- v8_platform.Initialize (v8_thread_pool_size, uv_default_loop () );
4649+ v8_platform.Initialize (v8_thread_pool_size);
46314650 // Enable tracing when argv has --trace-events-enabled.
46324651 if (trace_enabled) {
46334652 fprintf (stderr, " Warning: Trace event is an experimental feature "
0 commit comments