refactor: use node::tracing::Agent() directly (35-x-y) (#45619)

* refactor: use node::tracing::Agent()

* chore: e patches all

---------

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
Charles Kerr 2025-02-14 04:02:19 -06:00 committed by GitHub
parent cd1186a116
commit b52917c380
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 14 additions and 55 deletions

View file

@ -1,7 +1,6 @@
expose_get_builtin_module_function.patch
build_add_gn_build_files.patch
fix_add_default_values_for_variables_in_common_gypi.patch
fix_expose_tracing_agent_and_use_tracing_tracingcontroller_instead.patch
pass_all_globals_through_require.patch
build_modify_js2c_py_to_allow_injection_of_original-fs_and_custom_embedder_js.patch
refactor_allow_embedder_overriding_of_internal_fs_calls.patch

View file

@ -52,7 +52,7 @@ index d03db1970fd7a1629a7a7719a5ff267402ab4a66..ce055fb5dfc84c75c486b99f01fea6b9
o['variables']['v8_enable_javascript_promise_hooks'] = 1
o['variables']['v8_enable_lite_mode'] = 1 if options.v8_lite_mode else 0
diff --git a/src/node.h b/src/node.h
index 0fec9477fd0f2a3c2aa68284131c510b0da0e025..c16204ad2a4787eeffe61eedda254d3a5509df8c 100644
index 60598f54114b2424f10706e57d8aa50c4634bcb0..40880ccaca694f28ae47676254b1c0cc36de0d93 100644
--- a/src/node.h
+++ b/src/node.h
@@ -22,6 +22,12 @@

View file

@ -44,7 +44,7 @@ index 59b5a16f1309a5e4055bccfdb7a529045ad30402..bfdaf6211466a01b64b7942f7b16c480
let filename = call.getFileName();
const line = call.getLineNumber() - 1;
diff --git a/src/api/environment.cc b/src/api/environment.cc
index f59abcb21d64b910d8d42eb23c03109f62558813..1b6613d1de8c89c8271066a652afd1024988362d 100644
index a3c5697ef5b20a9dc43bfcd3513e703989f64d2d..837fdc8c79c6d80393b0c8ac9a18e4dd5e5a8dba 100644
--- a/src/api/environment.cc
+++ b/src/api/environment.cc
@@ -244,6 +244,9 @@ void SetIsolateErrorHandlers(v8::Isolate* isolate, const IsolateSettings& s) {

View file

@ -1,44 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <sattard@atlassian.com>
Date: Fri, 26 Oct 2018 15:35:13 +1100
Subject: fix: expose tracing::Agent and use tracing::TracingController instead
of v8::TracingController
This API is used by Electron to create Node's tracing controller.
diff --git a/src/api/environment.cc b/src/api/environment.cc
index 77c20a4b6b9db414444974f68c5def8788386d2b..5fc1b6f2446d7c786024eb60800e2edab613dcd1 100644
--- a/src/api/environment.cc
+++ b/src/api/environment.cc
@@ -564,6 +564,10 @@ MultiIsolatePlatform* GetMultiIsolatePlatform(IsolateData* env) {
return env->platform();
}
+node::tracing::Agent* CreateAgent() {
+ return new node::tracing::Agent();
+}
+
MultiIsolatePlatform* CreatePlatform(
int thread_pool_size,
node::tracing::TracingController* tracing_controller) {
diff --git a/src/node.h b/src/node.h
index 60598f54114b2424f10706e57d8aa50c4634bcb0..0fec9477fd0f2a3c2aa68284131c510b0da0e025 100644
--- a/src/node.h
+++ b/src/node.h
@@ -133,6 +133,7 @@ struct SnapshotData;
namespace tracing {
+class Agent;
class TracingController;
}
@@ -832,6 +833,8 @@ NODE_EXTERN void GetNodeReport(Environment* env,
NODE_EXTERN MultiIsolatePlatform* GetMultiIsolatePlatform(Environment* env);
NODE_EXTERN MultiIsolatePlatform* GetMultiIsolatePlatform(IsolateData* env);
+NODE_EXTERN node::tracing::Agent* CreateAgent();
+
NODE_DEPRECATED("Use MultiIsolatePlatform::Create() instead",
NODE_EXTERN MultiIsolatePlatform* CreatePlatform(
int thread_pool_size,

View file

@ -161,10 +161,10 @@ index 49ca9c0042ccf22ad1fffa54f05fd443cbc681ba..945535d0dc40f1a32f7e3ecf7d50361e
inline MultiIsolatePlatform* platform() const;
inline const SnapshotData* snapshot_data() const;
diff --git a/src/node.h b/src/node.h
index c16204ad2a4787eeffe61eedda254d3a5509df8c..c39f586e9c5e7e9db75d922d244ea8e4d6d56841 100644
index 40880ccaca694f28ae47676254b1c0cc36de0d93..8e1114148bf5e961620726183f4979977dc14714 100644
--- a/src/node.h
+++ b/src/node.h
@@ -1561,24 +1561,14 @@ void RegisterSignalHandler(int signal,
@@ -1558,24 +1558,14 @@ void RegisterSignalHandler(int signal,
bool reset_handler = false);
#endif // _WIN32

View file

@ -7,7 +7,7 @@ This refactors several allocators to allocate within the V8 memory cage,
allowing them to be compatible with the V8_SANDBOXED_POINTERS feature.
diff --git a/src/api/environment.cc b/src/api/environment.cc
index 5fc1b6f2446d7c786024eb60800e2edab613dcd1..f59abcb21d64b910d8d42eb23c03109f62558813 100644
index 77c20a4b6b9db414444974f68c5def8788386d2b..a3c5697ef5b20a9dc43bfcd3513e703989f64d2d 100644
--- a/src/api/environment.cc
+++ b/src/api/environment.cc
@@ -101,6 +101,14 @@ MaybeLocal<Value> PrepareStackTraceCallback(Local<Context> context,

View file

@ -90,7 +90,7 @@ v8::Isolate* JavascriptEnvironment::Initialize(uv_loop_t* event_loop,
// The V8Platform of gin relies on Chromium's task schedule, which has not
// been started at this point, so we have to rely on Node's V8Platform.
auto* tracing_agent = node::CreateAgent();
auto* tracing_agent = new node::tracing::Agent();
auto* tracing_controller = tracing_agent->GetTracingController();
node::tracing::TraceEventHelper::SetAgent(tracing_agent);
platform_ = node::MultiIsolatePlatform::Create(

View file

@ -92,8 +92,10 @@ void ElectronRendererClient::DidCreateScriptContext(
}
// Setup node tracing controller.
if (!node::tracing::TraceEventHelper::GetAgent())
node::tracing::TraceEventHelper::SetAgent(node::CreateAgent());
if (!node::tracing::TraceEventHelper::GetAgent()) {
auto* tracing_agent = new node::tracing::Agent();
node::tracing::TraceEventHelper::SetAgent(tracing_agent);
}
// Setup node environment for each window.
v8::Maybe<bool> initialized = node::InitializeContext(renderer_context);

View file

@ -54,8 +54,10 @@ void WebWorkerObserver::WorkerScriptReadyForEvaluation(
node_bindings_->PrepareEmbedThread();
// Setup node tracing controller.
if (!node::tracing::TraceEventHelper::GetAgent())
node::tracing::TraceEventHelper::SetAgent(node::CreateAgent());
if (!node::tracing::TraceEventHelper::GetAgent()) {
auto* tracing_agent = new node::tracing::Agent();
node::tracing::TraceEventHelper::SetAgent(tracing_agent);
}
// Setup node environment for each window.
v8::Maybe<bool> initialized = node::InitializeContext(worker_context);