@@ -273,17 +273,17 @@ node::DebugOptions debug_options;
273
273
274
274
static struct {
275
275
#if NODE_USE_V8_PLATFORM
276
- void Initialize (int thread_pool_size, uv_loop_t * loop ) {
276
+ void Initialize (int thread_pool_size) {
277
277
if (trace_enabled) {
278
278
tracing_agent_.reset (new tracing::Agent (trace_file_pattern));
279
- platform_ = new NodePlatform (thread_pool_size, loop,
279
+ platform_ = new NodePlatform (thread_pool_size,
280
280
tracing_agent_->GetTracingController ());
281
281
V8::InitializePlatform (platform_);
282
282
tracing::TraceEventHelper::SetTracingController (
283
283
tracing_agent_->GetTracingController ());
284
284
} else {
285
285
tracing_agent_.reset (nullptr );
286
- platform_ = new NodePlatform (thread_pool_size, loop, nullptr );
286
+ platform_ = new NodePlatform (thread_pool_size, nullptr );
287
287
V8::InitializePlatform (platform_);
288
288
tracing::TraceEventHelper::SetTracingController (
289
289
new v8::TracingController ());
@@ -297,8 +297,8 @@ static struct {
297
297
tracing_agent_.reset (nullptr );
298
298
}
299
299
300
- void DrainVMTasks () {
301
- platform_->DrainBackgroundTasks ();
300
+ void DrainVMTasks (Isolate* isolate ) {
301
+ platform_->DrainBackgroundTasks (isolate );
302
302
}
303
303
304
304
#if HAVE_INSPECTOR
@@ -323,12 +323,16 @@ static struct {
323
323
tracing_agent_->Stop ();
324
324
}
325
325
326
+ NodePlatform* Platform () {
327
+ return platform_;
328
+ }
329
+
326
330
std::unique_ptr<tracing::Agent> tracing_agent_;
327
331
NodePlatform* platform_;
328
332
#else // !NODE_USE_V8_PLATFORM
329
- void Initialize (int thread_pool_size, uv_loop_t * loop ) {}
333
+ void Initialize (int thread_pool_size) {}
330
334
void Dispose () {}
331
- void DrainVMTasks () {}
335
+ void DrainVMTasks (Isolate* isolate ) {}
332
336
bool StartInspector (Environment *env, const char * script_path,
333
337
const node::DebugOptions& options) {
334
338
env->ThrowError (" Node compiled with NODE_USE_V8_PLATFORM=0" );
@@ -340,6 +344,10 @@ static struct {
340
344
" so event tracing is not available.\n " );
341
345
}
342
346
void StopTracingAgent () {}
347
+
348
+ NodePlatform* Platform () {
349
+ return nullptr ;
350
+ }
343
351
#endif // !NODE_USE_V8_PLATFORM
344
352
345
353
#if !NODE_USE_V8_PLATFORM || !HAVE_INSPECTOR
@@ -4733,7 +4741,14 @@ int EmitExit(Environment* env) {
4733
4741
4734
4742
4735
4743
IsolateData* CreateIsolateData (Isolate* isolate, uv_loop_t * loop) {
4736
- return new IsolateData (isolate, loop);
4744
+ return new IsolateData (isolate, loop, nullptr );
4745
+ }
4746
+
4747
+ IsolateData* CreateIsolateData (
4748
+ Isolate* isolate,
4749
+ uv_loop_t * loop,
4750
+ MultiIsolatePlatform* platform) {
4751
+ return new IsolateData (isolate, loop, platform);
4737
4752
}
4738
4753
4739
4754
@@ -4801,7 +4816,7 @@ inline int Start(Isolate* isolate, IsolateData* isolate_data,
4801
4816
do {
4802
4817
uv_run (env.event_loop (), UV_RUN_DEFAULT);
4803
4818
4804
- v8_platform.DrainVMTasks ();
4819
+ v8_platform.DrainVMTasks (isolate );
4805
4820
4806
4821
more = uv_loop_alive (env.event_loop ());
4807
4822
if (more)
@@ -4822,7 +4837,7 @@ inline int Start(Isolate* isolate, IsolateData* isolate_data,
4822
4837
RunAtExit (&env);
4823
4838
uv_key_delete (&thread_local_env);
4824
4839
4825
- v8_platform.DrainVMTasks ();
4840
+ v8_platform.DrainVMTasks (isolate );
4826
4841
WaitForInspectorDisconnect (&env);
4827
4842
#if defined(LEAK_SANITIZER)
4828
4843
__lsan_do_leak_check ();
@@ -4865,7 +4880,11 @@ inline int Start(uv_loop_t* event_loop,
4865
4880
Locker locker (isolate);
4866
4881
Isolate::Scope isolate_scope (isolate);
4867
4882
HandleScope handle_scope (isolate);
4868
- IsolateData isolate_data (isolate, event_loop, allocator.zero_fill_field ());
4883
+ IsolateData isolate_data (
4884
+ isolate,
4885
+ event_loop,
4886
+ v8_platform.Platform (),
4887
+ allocator.zero_fill_field ());
4869
4888
exit_code = Start (isolate, &isolate_data, argc, argv, exec_argc, exec_argv);
4870
4889
}
4871
4890
@@ -4912,7 +4931,7 @@ int Start(int argc, char** argv) {
4912
4931
V8::SetEntropySource (crypto::EntropySource);
4913
4932
#endif // HAVE_OPENSSL
4914
4933
4915
- v8_platform.Initialize (v8_thread_pool_size, uv_default_loop () );
4934
+ v8_platform.Initialize (v8_thread_pool_size);
4916
4935
// Enable tracing when argv has --trace-events-enabled.
4917
4936
if (trace_enabled) {
4918
4937
fprintf (stderr, " Warning: Trace event is an experimental feature "
0 commit comments