Skip to content

Commit a45b041

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 923ba99 commit a45b041

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
@@ -3499,6 +3499,12 @@ MultiIsolatePlatform* CreatePlatform(
34993499
}
35003500

35013501

3502+
MultiIsolatePlatform* InitializeV8Platform(int thread_pool_size) {
3503+
v8_platform.Initialize(thread_pool_size);
3504+
return v8_platform.Platform();
3505+
}
3506+
3507+
35023508
void FreePlatform(MultiIsolatePlatform* platform) {
35033509
delete platform;
35043510
}
@@ -3724,7 +3730,7 @@ int Start(int argc, char** argv) {
37243730
V8::SetEntropySource(crypto::EntropySource);
37253731
#endif // HAVE_OPENSSL
37263732

3727-
v8_platform.Initialize(v8_thread_pool_size);
3733+
InitializeV8Platform(v8_thread_pool_size);
37283734
V8::Initialize();
37293735
performance::performance_v8_start = PERFORMANCE_NOW();
37303736
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)