summaryrefslogtreecommitdiff
path: root/src/env.h
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2018-07-29 13:16:45 -0700
committerJames M Snell <jasnell@gmail.com>2018-08-17 09:08:05 -0700
commit4b7cd4bd60623b9c69d791112f4500575a3e9e7d (patch)
treeaf178bce561ac6c86289cca200460c35a5ebd230 /src/env.h
parent2ce03804a6a2e55a034814ca40fafac654321e33 (diff)
downloadandroid-node-v8-4b7cd4bd60623b9c69d791112f4500575a3e9e7d.tar.gz
android-node-v8-4b7cd4bd60623b9c69d791112f4500575a3e9e7d.tar.bz2
android-node-v8-4b7cd4bd60623b9c69d791112f4500575a3e9e7d.zip
trace_events: add trace category enabled tracking
Track state of async_hooks trace event category enablement. Enable/disable the async_hooks trace event dynamically. PR-URL: https://github.com/nodejs/node/pull/22128 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
Diffstat (limited to 'src/env.h')
-rw-r--r--src/env.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/env.h b/src/env.h
index 7a4804cdd4..28aa936c24 100644
--- a/src/env.h
+++ b/src/env.h
@@ -344,6 +344,7 @@ struct PackageConfig {
V(tick_callback_function, v8::Function) \
V(timers_callback_function, v8::Function) \
V(tls_wrap_constructor_function, v8::Function) \
+ V(trace_category_state_function, v8::Function) \
V(tty_constructor_template, v8::FunctionTemplate) \
V(udp_constructor_function, v8::Function) \
V(url_constructor_function, v8::Function) \
@@ -649,6 +650,8 @@ class Environment {
inline AliasedBuffer<uint32_t, v8::Uint32Array>&
should_abort_on_uncaught_toggle();
+ inline AliasedBuffer<uint8_t, v8::Uint8Array>& trace_category_state();
+
// The necessary API for async_hooks.
inline double new_async_id();
inline double execution_async_id();
@@ -830,6 +833,25 @@ class Environment {
// This needs to be available for the JS-land setImmediate().
void ToggleImmediateRef(bool ref);
+ class TrackingTraceStateObserver :
+ public v8::TracingController::TraceStateObserver {
+ public:
+ explicit TrackingTraceStateObserver(Environment* env) : env_(env) {}
+
+ void OnTraceEnabled() override {
+ UpdateTraceCategoryState();
+ }
+
+ void OnTraceDisabled() override {
+ UpdateTraceCategoryState();
+ }
+
+ private:
+ void UpdateTraceCategoryState();
+
+ Environment* env_;
+ };
+
class ShouldNotAbortOnUncaughtScope {
public:
explicit inline ShouldNotAbortOnUncaughtScope(Environment* env);
@@ -889,6 +911,10 @@ class Environment {
AliasedBuffer<uint32_t, v8::Uint32Array> should_abort_on_uncaught_toggle_;
int should_not_abort_scope_counter_ = 0;
+ // Attached to a Uint8Array that tracks the state of trace category
+ AliasedBuffer<uint8_t, v8::Uint8Array> trace_category_state_;
+ std::unique_ptr<TrackingTraceStateObserver> trace_state_observer_;
+
std::unique_ptr<performance::performance_state> performance_state_;
std::unordered_map<std::string, uint64_t> performance_marks_;