File tree Expand file tree Collapse file tree 4 files changed +28
-8
lines changed Expand file tree Collapse file tree 4 files changed +28
-8
lines changed Original file line number Diff line number Diff line change @@ -464,8 +464,11 @@ MultiIsolatePlatform* CreatePlatform(
464
464
465
465
MultiIsolatePlatform* CreatePlatform (
466
466
int thread_pool_size,
467
- v8::TracingController* tracing_controller) {
468
- return MultiIsolatePlatform::Create (thread_pool_size, tracing_controller)
467
+ v8::TracingController* tracing_controller,
468
+ v8::PageAllocator* page_allocator) {
469
+ return MultiIsolatePlatform::Create (thread_pool_size,
470
+ tracing_controller,
471
+ page_allocator)
469
472
.release ();
470
473
}
471
474
@@ -475,8 +478,11 @@ void FreePlatform(MultiIsolatePlatform* platform) {
475
478
476
479
std::unique_ptr<MultiIsolatePlatform> MultiIsolatePlatform::Create (
477
480
int thread_pool_size,
478
- v8::TracingController* tracing_controller) {
479
- return std::make_unique<NodePlatform>(thread_pool_size, tracing_controller);
481
+ v8::TracingController* tracing_controller,
482
+ v8::PageAllocator* page_allocator) {
483
+ return std::make_unique<NodePlatform>(thread_pool_size,
484
+ tracing_controller,
485
+ page_allocator);
480
486
}
481
487
482
488
MaybeLocal<Object> GetPerContextExports (Local<Context> context) {
Original file line number Diff line number Diff line change @@ -310,7 +310,8 @@ class NODE_EXTERN MultiIsolatePlatform : public v8::Platform {
310
310
311
311
static std::unique_ptr<MultiIsolatePlatform> Create (
312
312
int thread_pool_size,
313
- v8::TracingController* tracing_controller = nullptr );
313
+ v8::TracingController* tracing_controller = nullptr ,
314
+ v8::PageAllocator* page_allocator = nullptr );
314
315
};
315
316
316
317
enum IsolateSettingsFlags {
@@ -485,7 +486,8 @@ NODE_EXTERN MultiIsolatePlatform* GetMultiIsolatePlatform(IsolateData* env);
485
486
NODE_DEPRECATED (" Use MultiIsolatePlatform::Create() instead" ,
486
487
NODE_EXTERN MultiIsolatePlatform* CreatePlatform (
487
488
int thread_pool_size,
488
- v8::TracingController* tracing_controller));
489
+ v8::TracingController* tracing_controller,
490
+ v8::PageAllocator* = nullptr ));
489
491
NODE_DEPRECATED (" Use MultiIsolatePlatform::Create() instead" ,
490
492
NODE_EXTERN void FreePlatform (MultiIsolatePlatform* platform));
491
493
Original file line number Diff line number Diff line change @@ -324,12 +324,17 @@ void PerIsolatePlatformData::DecreaseHandleCount() {
324
324
}
325
325
326
326
NodePlatform::NodePlatform (int thread_pool_size,
327
- v8::TracingController* tracing_controller) {
327
+ v8::TracingController* tracing_controller,
328
+ v8::PageAllocator* page_allocator) {
328
329
if (tracing_controller != nullptr ) {
329
330
tracing_controller_ = tracing_controller;
330
331
} else {
331
332
tracing_controller_ = new v8::TracingController ();
332
333
}
334
+
335
+ // V8 will default to its built in allocator if none is provided.
336
+ page_allocator_ = page_allocator;
337
+
333
338
// TODO(addaleax): It's a bit icky that we use global state here, but we can't
334
339
// really do anything about it unless V8 starts exposing a way to access the
335
340
// current v8::Platform instance.
@@ -550,6 +555,10 @@ Platform::StackTracePrinter NodePlatform::GetStackTracePrinter() {
550
555
};
551
556
}
552
557
558
+ v8::PageAllocator* NodePlatform::GetPageAllocator () {
559
+ return page_allocator_;
560
+ }
561
+
553
562
template <class T >
554
563
TaskQueue<T>::TaskQueue()
555
564
: lock_(), tasks_available_(), tasks_drained_(),
Original file line number Diff line number Diff line change @@ -138,7 +138,8 @@ class WorkerThreadsTaskRunner {
138
138
class NodePlatform : public MultiIsolatePlatform {
139
139
public:
140
140
NodePlatform (int thread_pool_size,
141
- v8::TracingController* tracing_controller);
141
+ v8::TracingController* tracing_controller,
142
+ v8::PageAllocator* page_allocator = nullptr );
142
143
~NodePlatform () override ;
143
144
144
145
void DrainTasks (v8::Isolate* isolate) override ;
@@ -170,6 +171,7 @@ class NodePlatform : public MultiIsolatePlatform {
170
171
v8::Isolate* isolate) override ;
171
172
172
173
Platform::StackTracePrinter GetStackTracePrinter () override ;
174
+ v8::PageAllocator* GetPageAllocator () override ;
173
175
174
176
private:
175
177
IsolatePlatformDelegate* ForIsolate (v8::Isolate* isolate);
@@ -181,6 +183,7 @@ class NodePlatform : public MultiIsolatePlatform {
181
183
std::unordered_map<v8::Isolate*, DelegatePair> per_isolate_;
182
184
183
185
v8::TracingController* tracing_controller_;
186
+ v8::PageAllocator* page_allocator_;
184
187
std::shared_ptr<WorkerThreadsTaskRunner> worker_thread_task_runner_;
185
188
bool has_shut_down_ = false ;
186
189
};
You can’t perform that action at this time.
0 commit comments