Skip to content

Commit 2e7dbc3

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 37ee3f0 commit 2e7dbc3

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

src/node.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3602,6 +3602,12 @@ MultiIsolatePlatform* CreatePlatform(
36023602
}
36033603

36043604

3605+
MultiIsolatePlatform* InitializeV8Platform(int thread_pool_size) {
3606+
v8_platform.Initialize(thread_pool_size);
3607+
return v8_platform.Platform();
3608+
}
3609+
3610+
36053611
void FreePlatform(MultiIsolatePlatform* platform) {
36063612
delete platform;
36073613
}
@@ -3816,7 +3822,7 @@ int Start(int argc, char** argv) {
38163822
V8::SetEntropySource(crypto::EntropySource);
38173823
#endif // HAVE_OPENSSL
38183824

3819-
v8_platform.Initialize(v8_thread_pool_size);
3825+
InitializeV8Platform(v8_thread_pool_size);
38203826
V8::Initialize();
38213827
performance::performance_v8_start = PERFORMANCE_NOW();
38223828
v8_initialized = true;

src/node.h

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

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