@@ -164,21 +164,17 @@ void FreeArrayBufferAllocator(ArrayBufferAllocator* allocator) {
164164 delete allocator;
165165}
166166
167- Isolate* NewIsolate (ArrayBufferAllocator* allocator, uv_loop_t * event_loop) {
168- Isolate::CreateParams params;
169- params.array_buffer_allocator = allocator;
167+ void SetIsolateCreateParams (Isolate::CreateParams* params,
168+ ArrayBufferAllocator* allocator) {
169+ if (allocator != nullptr )
170+ params->array_buffer_allocator = allocator;
171+
170172#ifdef NODE_ENABLE_VTUNE_PROFILING
171- params. code_event_handler = vTune::GetVtuneCodeEventHandler ();
173+ params-> code_event_handler = vTune::GetVtuneCodeEventHandler ();
172174#endif
175+ }
173176
174- Isolate* isolate = Isolate::Allocate ();
175- if (isolate == nullptr ) return nullptr ;
176-
177- // Register the isolate on the platform before the isolate gets initialized,
178- // so that the isolate can access the platform during initialization.
179- per_process::v8_platform.Platform ()->RegisterIsolate (isolate, event_loop);
180- Isolate::Initialize (isolate, params);
181-
177+ void SetIsolateUpForNode (v8::Isolate* isolate) {
182178 isolate->AddMessageListenerWithErrorLevel (
183179 OnMessage,
184180 Isolate::MessageErrorLevel::kMessageError |
@@ -187,7 +183,29 @@ Isolate* NewIsolate(ArrayBufferAllocator* allocator, uv_loop_t* event_loop) {
187183 isolate->SetMicrotasksPolicy (MicrotasksPolicy::kExplicit );
188184 isolate->SetFatalErrorHandler (OnFatalError);
189185 isolate->SetAllowWasmCodeGenerationCallback (AllowWasmCodeGenerationCallback);
186+ isolate->SetPromiseRejectCallback (task_queue::PromiseRejectCallback);
190187 v8::CpuProfiler::UseDetailedSourcePositionsForProfiling (isolate);
188+ }
189+
190+ Isolate* NewIsolate (ArrayBufferAllocator* allocator, uv_loop_t * event_loop) {
191+ return NewIsolate (allocator, event_loop, GetMainThreadMultiIsolatePlatform ());
192+ }
193+
194+ Isolate* NewIsolate (ArrayBufferAllocator* allocator,
195+ uv_loop_t * event_loop,
196+ MultiIsolatePlatform* platform) {
197+ Isolate::CreateParams params;
198+ SetIsolateCreateParams (¶ms, allocator);
199+
200+ Isolate* isolate = Isolate::Allocate ();
201+ if (isolate == nullptr ) return nullptr ;
202+
203+ // Register the isolate on the platform before the isolate gets initialized,
204+ // so that the isolate can access the platform during initialization.
205+ platform->RegisterIsolate (isolate, event_loop);
206+ Isolate::Initialize (isolate, params);
207+
208+ SetIsolateUpForNode (isolate);
191209
192210 return isolate;
193211}
0 commit comments