summaryrefslogtreecommitdiff
path: root/src/node_trace_events.cc
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2018-08-09 13:44:44 -0700
committerJames M Snell <jasnell@gmail.com>2018-08-10 07:44:08 -0700
commitb85460498fc24b855efbc2516f8e7cc629e24bb6 (patch)
tree1be29060003b4b5b6fa0a827f550d62da9ab9f13 /src/node_trace_events.cc
parentc85933cbd07ec3e32fdb27c4c4ef1aeadc609345 (diff)
downloadnode-new-b85460498fc24b855efbc2516f8e7cc629e24bb6.tar.gz
src: remove old process.binding('trace_events').emit
Remove the older emit and categoryGroupEnabled bindings in favor of the new intrinsics PR-URL: https://github.com/nodejs/node/pull/22127 Reviewed-By: Andreas Madsen <amwebdk@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Diffstat (limited to 'src/node_trace_events.cc')
-rw-r--r--src/node_trace_events.cc126
1 files changed, 0 insertions, 126 deletions
diff --git a/src/node_trace_events.cc b/src/node_trace_events.cc
index 8413620e3f..219e142a31 100644
--- a/src/node_trace_events.cc
+++ b/src/node_trace_events.cc
@@ -13,7 +13,6 @@ using v8::Array;
using v8::Context;
using v8::FunctionCallbackInfo;
using v8::FunctionTemplate;
-using v8::Int32;
using v8::Local;
using v8::Object;
using v8::String;
@@ -99,137 +98,12 @@ void GetEnabledCategories(const FunctionCallbackInfo<Value>& args) {
}
}
-// The tracing APIs require category groups to be pointers to long-lived
-// strings. Those strings are stored here.
-static std::unordered_set<std::string> category_groups;
-static Mutex category_groups_mutex;
-
-// Gets a pointer to the category-enabled flags for a tracing category group,
-// if tracing is enabled for it.
-static const uint8_t* GetCategoryGroupEnabled(const char* category_group) {
- CHECK_NOT_NULL(category_group);
- return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(category_group);
-}
-
-static const char* GetCategoryGroup(Environment* env,
- const Local<Value> category_value) {
- CHECK(category_value->IsString());
-
- Utf8Value category(env->isolate(), category_value);
- Mutex::ScopedLock lock(category_groups_mutex);
- // If the value already exists in the set, insertion.first will point
- // to the existing value. Thus, this will maintain a long lived pointer
- // to the category c-string.
- auto insertion = category_groups.insert(category.out());
-
- // The returned insertion is a pair whose first item is the object that was
- // inserted or that blocked the insertion and second item is a boolean
- // indicating whether it was inserted.
- return insertion.first->c_str();
-}
-
-static void Emit(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args);
- Local<Context> context = env->context();
-
- // Args: [type, category, name, id, argName, argValue]
- CHECK_GE(args.Length(), 3);
-
- // Check the category group first, to avoid doing more work if it's not
- // enabled.
- const char* category_group = GetCategoryGroup(env, args[1]);
- const uint8_t* category_group_enabled =
- GetCategoryGroupEnabled(category_group);
- if (*category_group_enabled == 0) return;
-
- // get trace_event phase
- CHECK(args[0]->IsNumber());
- char phase = static_cast<char>(args[0]->Int32Value(context).ToChecked());
-
- // get trace_event name
- CHECK(args[2]->IsString());
- Utf8Value name_value(env->isolate(), args[2]);
- const char* name = name_value.out();
-
- // get trace_event id
- int64_t id = 0;
- bool has_id = false;
- if (args.Length() >= 4 && !args[3]->IsUndefined() && !args[3]->IsNull()) {
- has_id = true;
- CHECK(args[3]->IsNumber());
- id = args[3]->IntegerValue(context).ToChecked();
- }
-
- // TODO(AndreasMadsen): String values are not supported.
- int32_t num_args = 0;
- const char* arg_names[2];
- uint8_t arg_types[2];
- uint64_t arg_values[2];
-
- // Create Utf8Value in the function scope to prevent deallocation.
- // The c-string will be copied by TRACE_EVENT_API_ADD_TRACE_EVENT at the end.
- Utf8Value arg1NameValue(env->isolate(), args[4]);
- Utf8Value arg2NameValue(env->isolate(), args[6]);
-
- if (args.Length() >= 6 &&
- (!args[4]->IsUndefined() || !args[5]->IsUndefined())) {
- num_args = 1;
- arg_types[0] = TRACE_VALUE_TYPE_INT;
-
- CHECK(args[4]->IsString());
- arg_names[0] = arg1NameValue.out();
-
- CHECK(args[5]->IsNumber());
- arg_values[0] = args[5]->IntegerValue(context).ToChecked();
- }
-
- if (args.Length() >= 8 &&
- (!args[6]->IsUndefined() || !args[7]->IsUndefined())) {
- num_args = 2;
- arg_types[1] = TRACE_VALUE_TYPE_INT;
-
- CHECK(args[6]->IsString());
- arg_names[1] = arg2NameValue.out();
-
- CHECK(args[7]->IsNumber());
- arg_values[1] = args[7]->IntegerValue(context).ToChecked();
- }
-
- // The TRACE_EVENT_FLAG_COPY flag indicates that the name and argument
- // name should be copied thus they don't need to long-lived pointers.
- // The category name still won't be copied and thus need to be a long-lived
- // pointer.
- uint32_t flags = TRACE_EVENT_FLAG_COPY;
- if (has_id) {
- flags |= TRACE_EVENT_FLAG_HAS_ID;
- }
-
- const char* scope = node::tracing::kGlobalScope;
- uint64_t bind_id = node::tracing::kNoId;
-
- TRACE_EVENT_API_ADD_TRACE_EVENT(
- phase, category_group_enabled, name, scope, id, bind_id,
- num_args, arg_names, arg_types, arg_values,
- flags);
-}
-
-static void CategoryGroupEnabled(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args);
-
- const char* category_group = GetCategoryGroup(env, args[0]);
- const uint8_t* category_group_enabled =
- GetCategoryGroupEnabled(category_group);
- args.GetReturnValue().Set(*category_group_enabled > 0);
-}
-
void Initialize(Local<Object> target,
Local<Value> unused,
Local<Context> context,
void* priv) {
Environment* env = Environment::GetCurrent(context);
- env->SetMethod(target, "emit", Emit);
- env->SetMethod(target, "categoryGroupEnabled", CategoryGroupEnabled);
env->SetMethod(target, "getEnabledCategories", GetEnabledCategories);
Local<FunctionTemplate> category_set =