forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2021 12 02 fix V8 initialization order (nodejs#133)
Fix initialization order in testrunner
- Loading branch information
1 parent
956bda1
commit 2c5d225
Showing
3 changed files
with
47 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,39 @@ | ||
#include "node_test_fixture.h" | ||
#include "cppgc/platform.h" | ||
|
||
ArrayBufferUniquePtr NodeZeroIsolateTestFixture::allocator{nullptr, nullptr}; | ||
uv_loop_t NodeZeroIsolateTestFixture::current_loop; | ||
NodePlatformUniquePtr NodeZeroIsolateTestFixture::platform; | ||
TracingAgentUniquePtr NodeZeroIsolateTestFixture::tracing_agent; | ||
bool NodeZeroIsolateTestFixture::node_initialized = false; | ||
|
||
|
||
void NodeTestEnvironment::SetUp() { | ||
NodeZeroIsolateTestFixture::tracing_agent = | ||
std::make_unique<node::tracing::Agent>(); | ||
node::tracing::TraceEventHelper::SetAgent( | ||
NodeZeroIsolateTestFixture::tracing_agent.get()); | ||
node::tracing::TracingController* tracing_controller = | ||
NodeZeroIsolateTestFixture::tracing_agent->GetTracingController(); | ||
static constexpr int kV8ThreadPoolSize = 4; | ||
NodeZeroIsolateTestFixture::platform.reset( | ||
new node::NodePlatform(kV8ThreadPoolSize, tracing_controller)); | ||
v8::V8::InitializePlatform(NodeZeroIsolateTestFixture::platform.get()); | ||
#ifdef V8_VIRTUAL_MEMORY_CAGE | ||
ASSERT_TRUE(v8::V8::InitializeVirtualMemoryCage()); | ||
#endif | ||
cppgc::InitializeProcess( | ||
NodeZeroIsolateTestFixture::platform->GetPageAllocator()); | ||
v8::V8::Initialize(); | ||
} | ||
|
||
void NodeTestEnvironment::TearDown() { | ||
v8::V8::Dispose(); | ||
v8::V8::ShutdownPlatform(); | ||
NodeZeroIsolateTestFixture::platform->Shutdown(); | ||
NodeZeroIsolateTestFixture::platform.reset(nullptr); | ||
NodeZeroIsolateTestFixture::tracing_agent.reset(nullptr); | ||
} | ||
|
||
::testing::Environment* const node_env = | ||
::testing::AddGlobalTestEnvironment(new NodeTestEnvironment()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters