diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2019-02-10 18:39:45 +0800 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2019-02-21 10:47:28 +0800 |
commit | c435f069ebb3b8a1c6fb0d983db7f1b799715627 (patch) | |
tree | b133acb7f191d15e9ef46531220b389938ea2a8c /src/env.cc | |
parent | 435eea6400522189c9e521bde32134b03791a576 (diff) | |
download | android-node-v8-c435f069ebb3b8a1c6fb0d983db7f1b799715627.tar.gz android-node-v8-c435f069ebb3b8a1c6fb0d983db7f1b799715627.tar.bz2 android-node-v8-c435f069ebb3b8a1c6fb0d983db7f1b799715627.zip |
process: simplify the setup of async hooks trace events
- Remove `trace_category_state` from `Environment` - since this is
only accessed in the bootstrap process and later in the
trace category update handler, we could just pass the initial
values into JS land via the trace_events binding, and pass
the dynamic values directly to the handler later, instead of
accessing them out-of-band via the AliasedBuffer.
- Instead of creating the hooks directly in
`trace_events_async_hooks.js`, export the hook factory and
create the hooks in trace category state toggle.
PR-URL: https://github.com/nodejs/node/pull/26062
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/env.cc')
-rw-r--r-- | src/env.cc | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/env.cc b/src/env.cc index d882838ed0..01aee46440 100644 --- a/src/env.cc +++ b/src/env.cc @@ -21,6 +21,7 @@ namespace node { using errors::TryCatchScope; +using v8::Boolean; using v8::Context; using v8::EmbedderGraph; using v8::External; @@ -152,9 +153,8 @@ void Environment::TrackingTraceStateObserver::UpdateTraceCategoryState() { return; } - env_->trace_category_state()[0] = - *TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED( - TRACING_CATEGORY_NODE1(async_hooks)); + bool async_hooks_enabled = (*(TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED( + TRACING_CATEGORY_NODE1(async_hooks)))) != 0; Isolate* isolate = env_->isolate(); HandleScope handle_scope(isolate); @@ -163,8 +163,9 @@ void Environment::TrackingTraceStateObserver::UpdateTraceCategoryState() { return; TryCatchScope try_catch(env_); try_catch.SetVerbose(true); - cb->Call(env_->context(), Undefined(isolate), - 0, nullptr).ToLocalChecked(); + Local<Value> args[] = {Boolean::New(isolate, async_hooks_enabled)}; + cb->Call(env_->context(), Undefined(isolate), arraysize(args), args) + .ToLocalChecked(); } static std::atomic<uint64_t> next_thread_id{0}; @@ -183,7 +184,6 @@ Environment::Environment(IsolateData* isolate_data, tick_info_(context->GetIsolate()), timer_base_(uv_now(isolate_data->event_loop())), should_abort_on_uncaught_toggle_(isolate_, 1), - trace_category_state_(isolate_, kTraceCategoryCount), stream_base_state_(isolate_, StreamBase::kNumStreamBaseStateFields), flags_(flags), thread_id_(thread_id == kNoThreadId ? AllocateThreadId() : thread_id), |