Skip to content

Commit f43da03

Browse files
danbevnodejs-ci
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: #69
1 parent d200a62 commit f43da03

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
@@ -2979,6 +2979,12 @@ MultiIsolatePlatform* CreatePlatform(
29792979
}
29802980

29812981

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

3201-
v8_platform.Initialize(
3202-
per_process_opts->v8_thread_pool_size);
3207+
InitializeV8Platform(per_process_opts->v8_thread_pool_size);
32033208
V8::Initialize();
32043209
performance::performance_v8_start = PERFORMANCE_NOW();
32053210
v8_initialized = true;

src/node.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ NODE_EXTERN MultiIsolatePlatform* GetMainThreadMultiIsolatePlatform();
285285
NODE_EXTERN MultiIsolatePlatform* CreatePlatform(
286286
int thread_pool_size,
287287
v8::TracingController* tracing_controller);
288+
MultiIsolatePlatform* InitializeV8Platform(int thread_pool_size);
288289
NODE_EXTERN void FreePlatform(MultiIsolatePlatform* platform);
289290

290291
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)