Skip to content

Commit 82cd956

Browse files
danbevtargos
authored andcommitted
src: add InitializeV8Platform function
This commit adds an InitializeV8Platform function which calls v8_platform's Initialize to create the NodePlatform and also set the structs members. When running cctests this functions was not being called (it is called from the Start function but that function is not called by the test fixture. The motivation for adding this is that I'm guessing that embedders would might need the ability to do the same thing. Refs: nodejs/node-v8#69
1 parent 29183f7 commit 82cd956

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

src/node.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2980,6 +2980,12 @@ MultiIsolatePlatform* CreatePlatform(
29802980
}
29812981

29822982

2983+
MultiIsolatePlatform* InitializeV8Platform(int thread_pool_size) {
2984+
v8_platform.Initialize(thread_pool_size);
2985+
return v8_platform.Platform();
2986+
}
2987+
2988+
29832989
void FreePlatform(MultiIsolatePlatform* platform) {
29842990
delete platform;
29852991
}
@@ -3199,8 +3205,7 @@ int Start(int argc, char** argv) {
31993205
V8::SetEntropySource(crypto::EntropySource);
32003206
#endif // HAVE_OPENSSL
32013207

3202-
v8_platform.Initialize(
3203-
per_process_opts->v8_thread_pool_size);
3208+
InitializeV8Platform(per_process_opts->v8_thread_pool_size);
32043209
V8::Initialize();
32053210
performance::performance_v8_start = PERFORMANCE_NOW();
32063211
v8_initialized = true;

src/node.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ NODE_EXTERN MultiIsolatePlatform* GetMainThreadMultiIsolatePlatform();
288288
NODE_EXTERN MultiIsolatePlatform* CreatePlatform(
289289
int thread_pool_size,
290290
v8::TracingController* tracing_controller);
291+
MultiIsolatePlatform* InitializeV8Platform(int thread_pool_size);
291292
NODE_EXTERN void FreePlatform(MultiIsolatePlatform* platform);
292293

293294
NODE_EXTERN void EmitBeforeExit(Environment* env);

test/cctest/node_test_fixture.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ class NodeTestFixture : public ::testing::Test {
7070
tracing_controller.reset(new v8::TracingController());
7171
node::tracing::TraceEventHelper::SetTracingController(
7272
tracing_controller.get());
73-
platform.reset(new node::NodePlatform(4, nullptr));
7473
CHECK_EQ(0, uv_loop_init(&current_loop));
75-
v8::V8::InitializePlatform(platform.get());
74+
platform.reset(static_cast<node::NodePlatform*>(
75+
node::InitializeV8Platform(4)));
7676
v8::V8::Initialize();
7777
}
7878

@@ -88,10 +88,8 @@ class NodeTestFixture : public ::testing::Test {
8888
virtual void SetUp() {
8989
allocator = ArrayBufferUniquePtr(node::CreateArrayBufferAllocator(),
9090
&node::FreeArrayBufferAllocator);
91-
isolate_ = NewIsolate(allocator.get());
91+
isolate_ = NewIsolate(allocator.get(), &current_loop);
9292
CHECK_NE(isolate_, nullptr);
93-
platform->RegisterIsolate(isolate_, &current_loop);
94-
v8::Isolate::Initialize(isolate_, params);
9593
}
9694

9795
virtual void TearDown() {

0 commit comments

Comments
 (0)