diff options
author | Anna Henningsen <anna@addaleax.net> | 2018-10-20 11:02:37 +0200 |
---|---|---|
committer | Matheus Marchini <mat@mmarchini.me> | 2018-10-24 11:18:47 -0300 |
commit | 036fbdb63d603a64bd8562ec9331dfb7a5c5075c (patch) | |
tree | 074fd39f0951479bb0daac154c4a9e291b917804 /src | |
parent | d568b53931958075be962ce79d23c24307af66f5 (diff) | |
download | android-node-v8-036fbdb63d603a64bd8562ec9331dfb7a5c5075c.tar.gz android-node-v8-036fbdb63d603a64bd8562ec9331dfb7a5c5075c.tar.bz2 android-node-v8-036fbdb63d603a64bd8562ec9331dfb7a5c5075c.zip |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/env-inl.h | 4 | ||||
-rw-r--r-- | src/env.cc | 16 | ||||
-rw-r--r-- | src/env.h | 5 | ||||
-rw-r--r-- | src/inspector/tracing_agent.cc | 5 | ||||
-rw-r--r-- | src/node.cc | 9 | ||||
-rw-r--r-- | src/node_internals.h | 2 | ||||
-rw-r--r-- | src/node_trace_events.cc | 8 | ||||
-rw-r--r-- | src/node_worker.cc | 4 |
8 files changed, 24 insertions, 29 deletions
diff --git a/src/env-inl.h b/src/env-inl.h index 9d369d492c..4f99bc9ec0 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -334,10 +334,6 @@ inline v8::Isolate* Environment::isolate() const { return isolate_; } -inline tracing::AgentWriterHandle* Environment::tracing_agent_writer() const { - return tracing_agent_writer_; -} - inline Environment* Environment::from_timer_handle(uv_timer_t* handle) { return ContainerOf(&Environment::timer_handle_, handle); } diff --git a/src/env.cc b/src/env.cc index 9d8fd967a4..5da673b3e0 100644 --- a/src/env.cc +++ b/src/env.cc @@ -143,11 +143,9 @@ void Environment::TrackingTraceStateObserver::UpdateTraceCategoryState() { } Environment::Environment(IsolateData* isolate_data, - Local<Context> context, - tracing::AgentWriterHandle* tracing_agent_writer) + Local<Context> context) : isolate_(context->GetIsolate()), isolate_data_(isolate_data), - tracing_agent_writer_(tracing_agent_writer), immediate_info_(context->GetIsolate()), tick_info_(context->GetIsolate()), timer_base_(uv_now(isolate_data->event_loop())), @@ -183,10 +181,9 @@ Environment::Environment(IsolateData* isolate_data, AssignToContext(context, ContextInfo("")); - if (tracing_agent_writer_ != nullptr) { + if (tracing::AgentWriterHandle* writer = GetTracingAgentWriter()) { trace_state_observer_.reset(new TrackingTraceStateObserver(this)); - v8::TracingController* tracing_controller = - tracing_agent_writer_->GetTracingController(); + v8::TracingController* tracing_controller = writer->GetTracingController(); if (tracing_controller != nullptr) tracing_controller->AddTraceStateObserver(trace_state_observer_.get()); } @@ -235,9 +232,10 @@ Environment::~Environment() { context()->SetAlignedPointerInEmbedderData( ContextEmbedderIndex::kEnvironment, nullptr); - if (tracing_agent_writer_ != nullptr) { - v8::TracingController* tracing_controller = - tracing_agent_writer_->GetTracingController(); + if (trace_state_observer_) { + tracing::AgentWriterHandle* writer = GetTracingAgentWriter(); + CHECK_NOT_NULL(writer); + v8::TracingController* tracing_controller = writer->GetTracingController(); if (tracing_controller != nullptr) tracing_controller->RemoveTraceStateObserver(trace_state_observer_.get()); } @@ -593,8 +593,7 @@ class Environment { static inline Environment* GetThreadLocalEnv(); Environment(IsolateData* isolate_data, - v8::Local<v8::Context> context, - tracing::AgentWriterHandle* tracing_agent_writer); + v8::Local<v8::Context> context); ~Environment(); void Start(const std::vector<std::string>& args, @@ -630,7 +629,6 @@ class Environment { inline bool profiler_idle_notifier_started() const; inline v8::Isolate* isolate() const; - inline tracing::AgentWriterHandle* tracing_agent_writer() const; inline uv_loop_t* event_loop() const; inline uint32_t watched_providers() const; @@ -921,7 +919,6 @@ class Environment { v8::Isolate* const isolate_; IsolateData* const isolate_data_; - tracing::AgentWriterHandle* const tracing_agent_writer_; uv_timer_t timer_handle_; uv_check_t immediate_check_handle_; uv_idle_t immediate_idle_handle_; diff --git a/src/inspector/tracing_agent.cc b/src/inspector/tracing_agent.cc index fe69e6f863..1ad67d9b9e 100644 --- a/src/inspector/tracing_agent.cc +++ b/src/inspector/tracing_agent.cc @@ -1,4 +1,5 @@ #include "tracing_agent.h" +#include "node_internals.h" #include "env-inl.h" #include "v8.h" @@ -74,9 +75,9 @@ DispatchResponse TracingAgent::start( if (categories_set.empty()) return DispatchResponse::Error("At least one category should be enabled"); - auto* writer = env_->tracing_agent_writer(); + tracing::AgentWriterHandle* writer = GetTracingAgentWriter(); if (writer != nullptr) { - trace_writer_ = env_->tracing_agent_writer()->agent()->AddClient( + trace_writer_ = writer->agent()->AddClient( categories_set, std::unique_ptr<InspectorTraceWriter>( new InspectorTraceWriter(frontend_.get())), diff --git a/src/node.cc b/src/node.cc index a71ae26ef6..0764adc10b 100644 --- a/src/node.cc +++ b/src/node.cc @@ -379,6 +379,10 @@ static struct { #endif // !NODE_USE_V8_PLATFORM || !HAVE_INSPECTOR } v8_platform; +tracing::AgentWriterHandle* GetTracingAgentWriter() { + return v8_platform.GetTracingAgentWriter(); +} + #ifdef __POSIX__ static const unsigned kMaxSignal = 32; #endif @@ -2763,8 +2767,7 @@ Environment* CreateEnvironment(IsolateData* isolate_data, // options than the global parse call. std::vector<std::string> args(argv, argv + argc); std::vector<std::string> exec_args(exec_argv, exec_argv + exec_argc); - Environment* env = new Environment(isolate_data, context, - v8_platform.GetTracingAgentWriter()); + Environment* env = new Environment(isolate_data, context); env->Start(args, exec_args, v8_is_profiling); return env; } @@ -2834,7 +2837,7 @@ inline int Start(Isolate* isolate, IsolateData* isolate_data, HandleScope handle_scope(isolate); Local<Context> context = NewContext(isolate); 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); const char* path = args.size() > 1 ? args[1].c_str() : nullptr; diff --git a/src/node_internals.h b/src/node_internals.h index d934d0f109..d0209fedc5 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -538,6 +538,8 @@ int ThreadPoolWork::CancelWork() { return uv_cancel(reinterpret_cast<uv_req_t*>(&work_req_)); } +tracing::AgentWriterHandle* GetTracingAgentWriter(); + static inline const char* errno_string(int errorno) { #define ERRNO_CASE(e) case e: return #e; switch (errorno) { diff --git a/src/node_trace_events.cc b/src/node_trace_events.cc index 6530bdb04c..ce60cde2d0 100644 --- a/src/node_trace_events.cc +++ b/src/node_trace_events.cc @@ -57,7 +57,7 @@ void NodeCategorySet::New(const FunctionCallbackInfo<Value>& args) { if (!*val) return; categories.emplace(*val); } - CHECK_NOT_NULL(env->tracing_agent_writer()); + CHECK_NOT_NULL(GetTracingAgentWriter()); new NodeCategorySet(env, args.This(), std::move(categories)); } @@ -68,7 +68,7 @@ void NodeCategorySet::Enable(const FunctionCallbackInfo<Value>& args) { CHECK_NOT_NULL(category_set); const auto& categories = category_set->GetCategories(); if (!category_set->enabled_ && !categories.empty()) { - env->tracing_agent_writer()->Enable(categories); + GetTracingAgentWriter()->Enable(categories); category_set->enabled_ = true; } } @@ -80,7 +80,7 @@ void NodeCategorySet::Disable(const FunctionCallbackInfo<Value>& args) { CHECK_NOT_NULL(category_set); const auto& categories = category_set->GetCategories(); if (category_set->enabled_ && !categories.empty()) { - env->tracing_agent_writer()->Disable(categories); + GetTracingAgentWriter()->Disable(categories); category_set->enabled_ = false; } } @@ -88,7 +88,7 @@ void NodeCategorySet::Disable(const FunctionCallbackInfo<Value>& args) { void GetEnabledCategories(const FunctionCallbackInfo<Value>& args) { Environment* env = Environment::GetCurrent(args); std::string categories = - env->tracing_agent_writer()->agent()->GetEnabledCategories(); + GetTracingAgentWriter()->agent()->GetEnabledCategories(); if (!categories.empty()) { args.GetReturnValue().Set( String::NewFromUtf8(env->isolate(), diff --git a/src/node_worker.cc b/src/node_worker.cc index debec3078c..cb6adbeba3 100644 --- a/src/node_worker.cc +++ b/src/node_worker.cc @@ -116,9 +116,7 @@ Worker::Worker(Environment* env, Local<Object> wrap, const std::string& url) Context::Scope context_scope(context); // TODO(addaleax): Use CreateEnvironment(), or generally another public API. - env_.reset(new Environment(isolate_data_.get(), - context, - nullptr)); + env_.reset(new Environment(isolate_data_.get(), context)); CHECK_NE(env_, nullptr); env_->set_abort_on_uncaught_exception(false); env_->set_worker_context(this); |