From 73bdb66f265a9f09fd24424822f94133557673fe Mon Sep 17 00:00:00 2001 From: Kanika Singhal Date: Sat, 17 Nov 2018 17:10:27 +0530 Subject: [PATCH] src: elevate v8 namespaces of referenced artifacts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/24424 Reviewed-By: Michaƫl Zasso Reviewed-By: Anna Henningsen Reviewed-By: Refael Ackermann --- src/node_perf.cc | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/src/node_perf.cc b/src/node_perf.cc index 4aa5da03d7a7e4..3af5e6d5094a4c 100644 --- a/src/node_perf.cc +++ b/src/node_perf.cc @@ -10,17 +10,24 @@ namespace performance { using v8::Array; using v8::Context; +using v8::DontDelete; using v8::Function; using v8::FunctionCallbackInfo; using v8::FunctionTemplate; +using v8::GCCallbackFlags; +using v8::GCType; using v8::HandleScope; using v8::Integer; using v8::Isolate; using v8::Local; using v8::Name; +using v8::NewStringType; using v8::Number; using v8::Object; +using v8::PropertyAttribute; +using v8::ReadOnly; using v8::String; +using v8::Uint32Array; using v8::Value; // Microseconds in a second, as a float. @@ -36,7 +43,7 @@ uint64_t performance_node_start; uint64_t performance_v8_start; uint64_t performance_last_gc_start_mark_ = 0; -v8::GCType performance_last_gc_type_ = v8::GCType::kGCTypeAll; +GCType performance_last_gc_type_ = GCType::kGCTypeAll; void performance_state::Mark(enum PerformanceMilestone milestone, uint64_t ts) { @@ -69,13 +76,13 @@ inline void InitObject(const PerformanceEntry& entry, Local obj) { Environment* env = entry.env(); Isolate* isolate = env->isolate(); Local context = env->context(); - v8::PropertyAttribute attr = - static_cast(v8::ReadOnly | v8::DontDelete); + PropertyAttribute attr = + static_cast(ReadOnly | DontDelete); obj->DefineOwnProperty(context, env->name_string(), String::NewFromUtf8(isolate, entry.name().c_str(), - v8::NewStringType::kNormal) + NewStringType::kNormal) .ToLocalChecked(), attr) .FromJust(); @@ -83,7 +90,7 @@ inline void InitObject(const PerformanceEntry& entry, Local obj) { env->entry_type_string(), String::NewFromUtf8(isolate, entry.type().c_str(), - v8::NewStringType::kNormal) + NewStringType::kNormal) .ToLocalChecked(), attr) .FromJust(); @@ -124,7 +131,7 @@ void PerformanceEntry::Notify(Environment* env, PerformanceEntryType type, Local object) { Context::Scope scope(env->context()); - AliasedBuffer& observers = + AliasedBuffer& observers = env->performance_state()->observers; if (type != NODE_PERFORMANCE_ENTRY_TYPE_INVALID && observers[type]) { @@ -242,12 +249,12 @@ void PerformanceGCCallback(Environment* env, void* ptr) { HandleScope scope(env->isolate()); Local context = env->context(); - AliasedBuffer& observers = + AliasedBuffer& observers = env->performance_state()->observers; if (observers[NODE_PERFORMANCE_ENTRY_TYPE_GC]) { Local obj = entry->ToObject(); - v8::PropertyAttribute attr = - static_cast(v8::ReadOnly | v8::DontDelete); + PropertyAttribute attr = + static_cast(ReadOnly | DontDelete); obj->DefineOwnProperty(context, env->kind_string(), Integer::New(env->isolate(), entry->gckind()), @@ -260,16 +267,16 @@ void PerformanceGCCallback(Environment* env, void* ptr) { // Marks the start of a GC cycle void MarkGarbageCollectionStart(Isolate* isolate, - v8::GCType type, - v8::GCCallbackFlags flags) { + GCType type, + GCCallbackFlags flags) { performance_last_gc_start_mark_ = PERFORMANCE_NOW(); performance_last_gc_type_ = type; } // Marks the end of a GC cycle void MarkGarbageCollectionEnd(Isolate* isolate, - v8::GCType type, - v8::GCCallbackFlags flags, + GCType type, + GCCallbackFlags flags, void* data) { Environment* env = static_cast(data); // If no one is listening to gc performance entries, do not create them. @@ -341,7 +348,7 @@ void TimerFunctionCall(const FunctionCallbackInfo& args) { return; args.GetReturnValue().Set(ret.ToLocalChecked()); - AliasedBuffer& observers = + AliasedBuffer& observers = env->performance_state()->observers; if (!observers[NODE_PERFORMANCE_ENTRY_TYPE_FUNCTION]) return; @@ -414,18 +421,18 @@ void Initialize(Local target, NODE_PERFORMANCE_MILESTONES(V) #undef V - v8::PropertyAttribute attr = - static_cast(v8::ReadOnly | v8::DontDelete); + PropertyAttribute attr = + static_cast(ReadOnly | DontDelete); target->DefineOwnProperty(context, FIXED_ONE_BYTE_STRING(isolate, "timeOrigin"), - v8::Number::New(isolate, timeOrigin / 1e6), + Number::New(isolate, timeOrigin / 1e6), attr).ToChecked(); target->DefineOwnProperty( context, FIXED_ONE_BYTE_STRING(isolate, "timeOriginTimestamp"), - v8::Number::New(isolate, timeOriginTimestamp / MICROS_PER_MILLIS), + Number::New(isolate, timeOriginTimestamp / MICROS_PER_MILLIS), attr).ToChecked(); target->DefineOwnProperty(context,