src: remove Environment::tracing_agent_writer()
As per the conversation in https://github.com/nodejs/node/issues/22513, this is essentially global, and adding this on the Environment is generally just confusing. Refs: https://github.com/nodejs/node/issues/22513 Fixes: https://github.com/nodejs/node/issues/22767 PR-URL: https://github.com/nodejs/node/pull/23781 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Matheus Marchini <mat@mmarchini.me>
This commit is contained in:
parent
d568b53931
commit
036fbdb63d
@ -334,10 +334,6 @@ inline v8::Isolate* Environment::isolate() const {
|
|||||||
return isolate_;
|
return isolate_;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline tracing::AgentWriterHandle* Environment::tracing_agent_writer() const {
|
|
||||||
return tracing_agent_writer_;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Environment* Environment::from_timer_handle(uv_timer_t* handle) {
|
inline Environment* Environment::from_timer_handle(uv_timer_t* handle) {
|
||||||
return ContainerOf(&Environment::timer_handle_, handle);
|
return ContainerOf(&Environment::timer_handle_, handle);
|
||||||
}
|
}
|
||||||
|
16
src/env.cc
16
src/env.cc
@ -143,11 +143,9 @@ void Environment::TrackingTraceStateObserver::UpdateTraceCategoryState() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Environment::Environment(IsolateData* isolate_data,
|
Environment::Environment(IsolateData* isolate_data,
|
||||||
Local<Context> context,
|
Local<Context> context)
|
||||||
tracing::AgentWriterHandle* tracing_agent_writer)
|
|
||||||
: isolate_(context->GetIsolate()),
|
: isolate_(context->GetIsolate()),
|
||||||
isolate_data_(isolate_data),
|
isolate_data_(isolate_data),
|
||||||
tracing_agent_writer_(tracing_agent_writer),
|
|
||||||
immediate_info_(context->GetIsolate()),
|
immediate_info_(context->GetIsolate()),
|
||||||
tick_info_(context->GetIsolate()),
|
tick_info_(context->GetIsolate()),
|
||||||
timer_base_(uv_now(isolate_data->event_loop())),
|
timer_base_(uv_now(isolate_data->event_loop())),
|
||||||
@ -183,10 +181,9 @@ Environment::Environment(IsolateData* isolate_data,
|
|||||||
|
|
||||||
AssignToContext(context, ContextInfo(""));
|
AssignToContext(context, ContextInfo(""));
|
||||||
|
|
||||||
if (tracing_agent_writer_ != nullptr) {
|
if (tracing::AgentWriterHandle* writer = GetTracingAgentWriter()) {
|
||||||
trace_state_observer_.reset(new TrackingTraceStateObserver(this));
|
trace_state_observer_.reset(new TrackingTraceStateObserver(this));
|
||||||
v8::TracingController* tracing_controller =
|
v8::TracingController* tracing_controller = writer->GetTracingController();
|
||||||
tracing_agent_writer_->GetTracingController();
|
|
||||||
if (tracing_controller != nullptr)
|
if (tracing_controller != nullptr)
|
||||||
tracing_controller->AddTraceStateObserver(trace_state_observer_.get());
|
tracing_controller->AddTraceStateObserver(trace_state_observer_.get());
|
||||||
}
|
}
|
||||||
@ -235,9 +232,10 @@ Environment::~Environment() {
|
|||||||
context()->SetAlignedPointerInEmbedderData(
|
context()->SetAlignedPointerInEmbedderData(
|
||||||
ContextEmbedderIndex::kEnvironment, nullptr);
|
ContextEmbedderIndex::kEnvironment, nullptr);
|
||||||
|
|
||||||
if (tracing_agent_writer_ != nullptr) {
|
if (trace_state_observer_) {
|
||||||
v8::TracingController* tracing_controller =
|
tracing::AgentWriterHandle* writer = GetTracingAgentWriter();
|
||||||
tracing_agent_writer_->GetTracingController();
|
CHECK_NOT_NULL(writer);
|
||||||
|
v8::TracingController* tracing_controller = writer->GetTracingController();
|
||||||
if (tracing_controller != nullptr)
|
if (tracing_controller != nullptr)
|
||||||
tracing_controller->RemoveTraceStateObserver(trace_state_observer_.get());
|
tracing_controller->RemoveTraceStateObserver(trace_state_observer_.get());
|
||||||
}
|
}
|
||||||
|
@ -593,8 +593,7 @@ class Environment {
|
|||||||
static inline Environment* GetThreadLocalEnv();
|
static inline Environment* GetThreadLocalEnv();
|
||||||
|
|
||||||
Environment(IsolateData* isolate_data,
|
Environment(IsolateData* isolate_data,
|
||||||
v8::Local<v8::Context> context,
|
v8::Local<v8::Context> context);
|
||||||
tracing::AgentWriterHandle* tracing_agent_writer);
|
|
||||||
~Environment();
|
~Environment();
|
||||||
|
|
||||||
void Start(const std::vector<std::string>& args,
|
void Start(const std::vector<std::string>& args,
|
||||||
@ -630,7 +629,6 @@ class Environment {
|
|||||||
inline bool profiler_idle_notifier_started() const;
|
inline bool profiler_idle_notifier_started() const;
|
||||||
|
|
||||||
inline v8::Isolate* isolate() const;
|
inline v8::Isolate* isolate() const;
|
||||||
inline tracing::AgentWriterHandle* tracing_agent_writer() const;
|
|
||||||
inline uv_loop_t* event_loop() const;
|
inline uv_loop_t* event_loop() const;
|
||||||
inline uint32_t watched_providers() const;
|
inline uint32_t watched_providers() const;
|
||||||
|
|
||||||
@ -921,7 +919,6 @@ class Environment {
|
|||||||
|
|
||||||
v8::Isolate* const isolate_;
|
v8::Isolate* const isolate_;
|
||||||
IsolateData* const isolate_data_;
|
IsolateData* const isolate_data_;
|
||||||
tracing::AgentWriterHandle* const tracing_agent_writer_;
|
|
||||||
uv_timer_t timer_handle_;
|
uv_timer_t timer_handle_;
|
||||||
uv_check_t immediate_check_handle_;
|
uv_check_t immediate_check_handle_;
|
||||||
uv_idle_t immediate_idle_handle_;
|
uv_idle_t immediate_idle_handle_;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "tracing_agent.h"
|
#include "tracing_agent.h"
|
||||||
|
#include "node_internals.h"
|
||||||
|
|
||||||
#include "env-inl.h"
|
#include "env-inl.h"
|
||||||
#include "v8.h"
|
#include "v8.h"
|
||||||
@ -74,9 +75,9 @@ DispatchResponse TracingAgent::start(
|
|||||||
if (categories_set.empty())
|
if (categories_set.empty())
|
||||||
return DispatchResponse::Error("At least one category should be enabled");
|
return DispatchResponse::Error("At least one category should be enabled");
|
||||||
|
|
||||||
auto* writer = env_->tracing_agent_writer();
|
tracing::AgentWriterHandle* writer = GetTracingAgentWriter();
|
||||||
if (writer != nullptr) {
|
if (writer != nullptr) {
|
||||||
trace_writer_ = env_->tracing_agent_writer()->agent()->AddClient(
|
trace_writer_ = writer->agent()->AddClient(
|
||||||
categories_set,
|
categories_set,
|
||||||
std::unique_ptr<InspectorTraceWriter>(
|
std::unique_ptr<InspectorTraceWriter>(
|
||||||
new InspectorTraceWriter(frontend_.get())),
|
new InspectorTraceWriter(frontend_.get())),
|
||||||
|
@ -379,6 +379,10 @@ static struct {
|
|||||||
#endif // !NODE_USE_V8_PLATFORM || !HAVE_INSPECTOR
|
#endif // !NODE_USE_V8_PLATFORM || !HAVE_INSPECTOR
|
||||||
} v8_platform;
|
} v8_platform;
|
||||||
|
|
||||||
|
tracing::AgentWriterHandle* GetTracingAgentWriter() {
|
||||||
|
return v8_platform.GetTracingAgentWriter();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __POSIX__
|
#ifdef __POSIX__
|
||||||
static const unsigned kMaxSignal = 32;
|
static const unsigned kMaxSignal = 32;
|
||||||
#endif
|
#endif
|
||||||
@ -2763,8 +2767,7 @@ Environment* CreateEnvironment(IsolateData* isolate_data,
|
|||||||
// options than the global parse call.
|
// options than the global parse call.
|
||||||
std::vector<std::string> args(argv, argv + argc);
|
std::vector<std::string> args(argv, argv + argc);
|
||||||
std::vector<std::string> exec_args(exec_argv, exec_argv + exec_argc);
|
std::vector<std::string> exec_args(exec_argv, exec_argv + exec_argc);
|
||||||
Environment* env = new Environment(isolate_data, context,
|
Environment* env = new Environment(isolate_data, context);
|
||||||
v8_platform.GetTracingAgentWriter());
|
|
||||||
env->Start(args, exec_args, v8_is_profiling);
|
env->Start(args, exec_args, v8_is_profiling);
|
||||||
return env;
|
return env;
|
||||||
}
|
}
|
||||||
@ -2834,7 +2837,7 @@ inline int Start(Isolate* isolate, IsolateData* isolate_data,
|
|||||||
HandleScope handle_scope(isolate);
|
HandleScope handle_scope(isolate);
|
||||||
Local<Context> context = NewContext(isolate);
|
Local<Context> context = NewContext(isolate);
|
||||||
Context::Scope context_scope(context);
|
Context::Scope context_scope(context);
|
||||||
Environment env(isolate_data, context, v8_platform.GetTracingAgentWriter());
|
Environment env(isolate_data, context);
|
||||||
env.Start(args, exec_args, v8_is_profiling);
|
env.Start(args, exec_args, v8_is_profiling);
|
||||||
|
|
||||||
const char* path = args.size() > 1 ? args[1].c_str() : nullptr;
|
const char* path = args.size() > 1 ? args[1].c_str() : nullptr;
|
||||||
|
@ -538,6 +538,8 @@ int ThreadPoolWork::CancelWork() {
|
|||||||
return uv_cancel(reinterpret_cast<uv_req_t*>(&work_req_));
|
return uv_cancel(reinterpret_cast<uv_req_t*>(&work_req_));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tracing::AgentWriterHandle* GetTracingAgentWriter();
|
||||||
|
|
||||||
static inline const char* errno_string(int errorno) {
|
static inline const char* errno_string(int errorno) {
|
||||||
#define ERRNO_CASE(e) case e: return #e;
|
#define ERRNO_CASE(e) case e: return #e;
|
||||||
switch (errorno) {
|
switch (errorno) {
|
||||||
|
@ -57,7 +57,7 @@ void NodeCategorySet::New(const FunctionCallbackInfo<Value>& args) {
|
|||||||
if (!*val) return;
|
if (!*val) return;
|
||||||
categories.emplace(*val);
|
categories.emplace(*val);
|
||||||
}
|
}
|
||||||
CHECK_NOT_NULL(env->tracing_agent_writer());
|
CHECK_NOT_NULL(GetTracingAgentWriter());
|
||||||
new NodeCategorySet(env, args.This(), std::move(categories));
|
new NodeCategorySet(env, args.This(), std::move(categories));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ void NodeCategorySet::Enable(const FunctionCallbackInfo<Value>& args) {
|
|||||||
CHECK_NOT_NULL(category_set);
|
CHECK_NOT_NULL(category_set);
|
||||||
const auto& categories = category_set->GetCategories();
|
const auto& categories = category_set->GetCategories();
|
||||||
if (!category_set->enabled_ && !categories.empty()) {
|
if (!category_set->enabled_ && !categories.empty()) {
|
||||||
env->tracing_agent_writer()->Enable(categories);
|
GetTracingAgentWriter()->Enable(categories);
|
||||||
category_set->enabled_ = true;
|
category_set->enabled_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -80,7 +80,7 @@ void NodeCategorySet::Disable(const FunctionCallbackInfo<Value>& args) {
|
|||||||
CHECK_NOT_NULL(category_set);
|
CHECK_NOT_NULL(category_set);
|
||||||
const auto& categories = category_set->GetCategories();
|
const auto& categories = category_set->GetCategories();
|
||||||
if (category_set->enabled_ && !categories.empty()) {
|
if (category_set->enabled_ && !categories.empty()) {
|
||||||
env->tracing_agent_writer()->Disable(categories);
|
GetTracingAgentWriter()->Disable(categories);
|
||||||
category_set->enabled_ = false;
|
category_set->enabled_ = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ void NodeCategorySet::Disable(const FunctionCallbackInfo<Value>& args) {
|
|||||||
void GetEnabledCategories(const FunctionCallbackInfo<Value>& args) {
|
void GetEnabledCategories(const FunctionCallbackInfo<Value>& args) {
|
||||||
Environment* env = Environment::GetCurrent(args);
|
Environment* env = Environment::GetCurrent(args);
|
||||||
std::string categories =
|
std::string categories =
|
||||||
env->tracing_agent_writer()->agent()->GetEnabledCategories();
|
GetTracingAgentWriter()->agent()->GetEnabledCategories();
|
||||||
if (!categories.empty()) {
|
if (!categories.empty()) {
|
||||||
args.GetReturnValue().Set(
|
args.GetReturnValue().Set(
|
||||||
String::NewFromUtf8(env->isolate(),
|
String::NewFromUtf8(env->isolate(),
|
||||||
|
@ -116,9 +116,7 @@ Worker::Worker(Environment* env, Local<Object> wrap, const std::string& url)
|
|||||||
Context::Scope context_scope(context);
|
Context::Scope context_scope(context);
|
||||||
|
|
||||||
// TODO(addaleax): Use CreateEnvironment(), or generally another public API.
|
// TODO(addaleax): Use CreateEnvironment(), or generally another public API.
|
||||||
env_.reset(new Environment(isolate_data_.get(),
|
env_.reset(new Environment(isolate_data_.get(), context));
|
||||||
context,
|
|
||||||
nullptr));
|
|
||||||
CHECK_NE(env_, nullptr);
|
CHECK_NE(env_, nullptr);
|
||||||
env_->set_abort_on_uncaught_exception(false);
|
env_->set_abort_on_uncaught_exception(false);
|
||||||
env_->set_worker_context(this);
|
env_->set_worker_context(this);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user