@@ -161,30 +161,25 @@ void FreeArrayBufferAllocator(ArrayBufferAllocator* allocator) {
161
161
delete allocator;
162
162
}
163
163
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;
167
168
168
169
double total_memory = uv_get_total_memory ();
169
170
if (total_memory > 0 ) {
170
171
// V8 defaults to 700MB or 1.4GB on 32 and 64 bit platforms respectively.
171
172
// This default is based on browser use-cases. Tell V8 to configure the
172
173
// heap based on the actual physical memory.
173
- params. constraints .ConfigureDefaults (total_memory, 0 );
174
+ params-> constraints .ConfigureDefaults (total_memory, 0 );
174
175
}
175
176
176
177
#ifdef NODE_ENABLE_VTUNE_PROFILING
177
- params. code_event_handler = vTune::GetVtuneCodeEventHandler ();
178
+ params-> code_event_handler = vTune::GetVtuneCodeEventHandler ();
178
179
#endif
180
+ }
179
181
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) {
188
183
isolate->AddMessageListenerWithErrorLevel (
189
184
OnMessage,
190
185
Isolate::MessageErrorLevel::kMessageError |
@@ -193,7 +188,29 @@ Isolate* NewIsolate(ArrayBufferAllocator* allocator, uv_loop_t* event_loop) {
193
188
isolate->SetMicrotasksPolicy (MicrotasksPolicy::kExplicit );
194
189
isolate->SetFatalErrorHandler (OnFatalError);
195
190
isolate->SetAllowWasmCodeGenerationCallback (AllowWasmCodeGenerationCallback);
191
+ isolate->SetPromiseRejectCallback (task_queue::PromiseRejectCallback);
196
192
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);
197
214
198
215
return isolate;
199
216
}
0 commit comments