mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
src: remove uses of node::InitializeV8Platform()
This requires minor changes to src/env.cc to deal with `node::tracing::AgentWriterHandle::GetTracingController()` now possibly returning a nullptr, because the cctest doesn't set one. It seems plausible to me that embedders won't set one either so that seems like an okay change to make. It avoids embedders having to track down nullptr segfaults. PR-URL: https://github.com/nodejs/node/pull/31245 Refs: https://github.com/nodejs/node/pull/31217 Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
1 parent
8973209ad0
commit
fe1ac496f7
3 files changed
+13
-8
No files matched your search
+4
-4
@@ -332,8 +332,8 @@ Environment::Environment(IsolateData* isolate_data,
|
||||
|
||||
if (tracing::AgentWriterHandle* writer = GetTracingAgentWriter()) {
|
||||
trace_state_observer_ = std::make_unique<TrackingTraceStateObserver>(this);
|
||||
TracingController* tracing_controller = writer->GetTracingController();
|
||||
tracing_controller->AddTraceStateObserver(trace_state_observer_.get());
|
||||
if (TracingController* tracing_controller = writer->GetTracingController())
|
||||
tracing_controller->AddTraceStateObserver(trace_state_observer_.get());
|
||||
}
|
||||
|
||||
destroy_async_id_list_.reserve(512);
|
||||
@@ -409,8 +409,8 @@ Environment::~Environment() {
|
||||
if (trace_state_observer_) {
|
||||
tracing::AgentWriterHandle* writer = GetTracingAgentWriter();
|
||||
CHECK_NOT_NULL(writer);
|
||||
TracingController* tracing_controller = writer->GetTracingController();
|
||||
tracing_controller->RemoveTraceStateObserver(trace_state_observer_.get());
|
||||
if (TracingController* tracing_controller = writer->GetTracingController())
|
||||
tracing_controller->RemoveTraceStateObserver(trace_state_observer_.get());
|
||||
}
|
||||
|
||||
delete[] heap_statistics_buffer_;
|
||||
|
||||
+2
-1
@@ -1015,7 +1015,8 @@ InitializationResult InitializeOncePerProcess(int argc, char** argv) {
|
||||
V8::SetEntropySource(crypto::EntropySource);
|
||||
#endif // HAVE_OPENSSL
|
||||
|
||||
InitializeV8Platform(per_process::cli_options->v8_thread_pool_size);
|
||||
per_process::v8_platform.Initialize(
|
||||
per_process::cli_options->v8_thread_pool_size);
|
||||
V8::Initialize();
|
||||
performance::performance_v8_start = PERFORMANCE_NOW();
|
||||
per_process::v8_initialized = true;
|
||||
|
||||
@@ -81,9 +81,13 @@ class NodeTestFixture : public ::testing::Test {
|
||||
|
||||
tracing_agent = std::make_unique<node::tracing::Agent>();
|
||||
node::tracing::TraceEventHelper::SetAgent(tracing_agent.get());
|
||||
node::tracing::TracingController* tracing_controller =
|
||||
tracing_agent->GetTracingController();
|
||||
CHECK_EQ(0, uv_loop_init(¤t_loop));
|
||||
platform.reset(static_cast<node::NodePlatform*>(
|
||||
node::InitializeV8Platform(4)));
|
||||
static constexpr int kV8ThreadPoolSize = 4;
|
||||
platform.reset(
|
||||
new node::NodePlatform(kV8ThreadPoolSize, tracing_controller));
|
||||
v8::V8::InitializePlatform(platform.get());
|
||||
v8::V8::Initialize();
|
||||
}
|
||||
|
||||
@@ -99,7 +103,7 @@ class NodeTestFixture : public ::testing::Test {
|
||||
void SetUp() override {
|
||||
allocator = ArrayBufferUniquePtr(node::CreateArrayBufferAllocator(),
|
||||
&node::FreeArrayBufferAllocator);
|
||||
isolate_ = NewIsolate(allocator.get(), ¤t_loop);
|
||||
isolate_ = NewIsolate(allocator.get(), ¤t_loop, platform.get());
|
||||
CHECK_NE(isolate_, nullptr);
|
||||
isolate_->Enter();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user