@@ -161,30 +161,25 @@ void FreeArrayBufferAllocator(ArrayBufferAllocator* allocator) {
161161 delete allocator;
162162}
163163
164- Isolate* NewIsolate (ArrayBufferAllocator* allocator, uv_loop_t * event_loop) {
165- Isolate::CreateParams params;
166- params.array_buffer_allocator = allocator;
164+ void SetIsolateCreateParams (Isolate::CreateParams* params,
165+ ArrayBufferAllocator* allocator) {
166+ if (allocator != nullptr )
167+ params->array_buffer_allocator = allocator;
167168
168169 double total_memory = uv_get_total_memory ();
169170 if (total_memory > 0 ) {
170171 // V8 defaults to 700MB or 1.4GB on 32 and 64 bit platforms respectively.
171172 // This default is based on browser use-cases. Tell V8 to configure the
172173 // heap based on the actual physical memory.
173- params. constraints .ConfigureDefaults (total_memory, 0 );
174+ params-> constraints .ConfigureDefaults (total_memory, 0 );
174175 }
175176
176177#ifdef NODE_ENABLE_VTUNE_PROFILING
177- params. code_event_handler = vTune::GetVtuneCodeEventHandler ();
178+ params-> code_event_handler = vTune::GetVtuneCodeEventHandler ();
178179#endif
180+ }
179181
180- Isolate* isolate = Isolate::Allocate ();
181- if (isolate == nullptr ) return nullptr ;
182-
183- // Register the isolate on the platform before the isolate gets initialized,
184- // so that the isolate can access the platform during initialization.
185- per_process::v8_platform.Platform ()->RegisterIsolate (isolate, event_loop);
186- Isolate::Initialize (isolate, params);
187-
182+ void SetIsolateUpForNode (v8::Isolate* isolate) {
188183 isolate->AddMessageListenerWithErrorLevel (
189184 OnMessage,
190185 Isolate::MessageErrorLevel::kMessageError |
@@ -193,7 +188,29 @@ Isolate* NewIsolate(ArrayBufferAllocator* allocator, uv_loop_t* event_loop) {
193188 isolate->SetMicrotasksPolicy (MicrotasksPolicy::kExplicit );
194189 isolate->SetFatalErrorHandler (OnFatalError);
195190 isolate->SetAllowWasmCodeGenerationCallback (AllowWasmCodeGenerationCallback);
191+ isolate->SetPromiseRejectCallback (task_queue::PromiseRejectCallback);
196192 v8::CpuProfiler::UseDetailedSourcePositionsForProfiling (isolate);
193+ }
194+
195+ Isolate* NewIsolate (ArrayBufferAllocator* allocator, uv_loop_t * event_loop) {
196+ return NewIsolate (allocator, event_loop, GetMainThreadMultiIsolatePlatform ());
197+ }
198+
199+ Isolate* NewIsolate (ArrayBufferAllocator* allocator,
200+ uv_loop_t * event_loop,
201+ MultiIsolatePlatform* platform) {
202+ Isolate::CreateParams params;
203+ SetIsolateCreateParams (¶ms, allocator);
204+
205+ Isolate* isolate = Isolate::Allocate ();
206+ if (isolate == nullptr ) return nullptr ;
207+
208+ // Register the isolate on the platform before the isolate gets initialized,
209+ // so that the isolate can access the platform during initialization.
210+ platform->RegisterIsolate (isolate, event_loop);
211+ Isolate::Initialize (isolate, params);
212+
213+ SetIsolateUpForNode (isolate);
197214
198215 return isolate;
199216}
0 commit comments