@@ -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
@@ -4769,7 +4777,14 @@ int EmitExit(Environment* env) {
47694777
47704778
47714779IsolateData* CreateIsolateData (Isolate* isolate, uv_loop_t * loop) {
4772- return new IsolateData (isolate, loop);
4780+ return new IsolateData (isolate, loop, nullptr );
4781+ }
4782+
4783+ IsolateData* CreateIsolateData (
4784+ Isolate* isolate,
4785+ uv_loop_t * loop,
4786+ MultiIsolatePlatform* platform) {
4787+ return new IsolateData (isolate, loop, platform);
47734788}
47744789
47754790
@@ -4854,7 +4869,7 @@ inline int Start(Isolate* isolate, IsolateData* isolate_data,
48544869 do {
48554870 uv_run (env.event_loop (), UV_RUN_DEFAULT);
48564871
4857- v8_platform.DrainVMTasks ();
4872+ v8_platform.DrainVMTasks (isolate );
48584873
48594874 more = uv_loop_alive (env.event_loop ());
48604875 if (more)
@@ -4875,7 +4890,7 @@ inline int Start(Isolate* isolate, IsolateData* isolate_data,
48754890 RunAtExit (&env);
48764891 uv_key_delete (&thread_local_env);
48774892
4878- v8_platform.DrainVMTasks ();
4893+ v8_platform.DrainVMTasks (isolate );
48794894 WaitForInspectorDisconnect (&env);
48804895#if defined(LEAK_SANITIZER)
48814896 __lsan_do_leak_check ();
@@ -4918,7 +4933,11 @@ inline int Start(uv_loop_t* event_loop,
49184933 Locker locker (isolate);
49194934 Isolate::Scope isolate_scope (isolate);
49204935 HandleScope handle_scope (isolate);
4921- IsolateData isolate_data (isolate, event_loop, allocator.zero_fill_field ());
4936+ IsolateData isolate_data (
4937+ isolate,
4938+ event_loop,
4939+ v8_platform.Platform (),
4940+ allocator.zero_fill_field ());
49224941 exit_code = Start (isolate, &isolate_data, argc, argv, exec_argc, exec_argv);
49234942 }
49244943
@@ -4965,7 +4984,7 @@ int Start(int argc, char** argv) {
49654984 V8::SetEntropySource (crypto::EntropySource);
49664985#endif // HAVE_OPENSSL
49674986
4968- v8_platform.Initialize (v8_thread_pool_size, uv_default_loop () );
4987+ v8_platform.Initialize (v8_thread_pool_size);
49694988 // Enable tracing when argv has --trace-events-enabled.
49704989 if (trace_enabled) {
49714990 fprintf (stderr, " Warning: Trace event is an experimental feature "
0 commit comments