[runtime] Refactor RuntimeCallStats counters to use enums.

Currently RuntimeCallStats stores CounterIds as inner pointers.
This patch replaces them with enums and removes static table.

Bug: chromium:758183
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng
Change-Id: Icb4030fc3ad3dd02e9c2648ce7c43b6f2d47fa9d
Reviewed-on: https://chromium-review.googlesource.com/796477
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: Adam Klein <adamk@chromium.org>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49743}
This commit is contained in:
Ulan Degenbaev 2017-11-29 16:50:22 +01:00 committed by Commit Bot
parent 603d52f393
commit cf7fa2eb08
30 changed files with 234 additions and 226 deletions

View File

@ -102,7 +102,7 @@ void Accessors::ReconfigureToDataProperty(
const v8::PropertyCallbackInfo<v8::Boolean>& info) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
RuntimeCallTimerScope stats_scope(
isolate, &RuntimeCallStats::ReconfigureToDataProperty);
isolate, RuntimeCallCounterId::kReconfigureToDataProperty);
HandleScope scope(isolate);
Handle<Object> receiver = Utils::OpenHandle(*info.This());
Handle<JSObject> holder =
@ -147,7 +147,8 @@ void Accessors::ArrayLengthGetter(
v8::Local<v8::Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
RuntimeCallTimerScope timer(isolate, &RuntimeCallStats::ArrayLengthGetter);
RuntimeCallTimerScope timer(isolate,
RuntimeCallCounterId::kArrayLengthGetter);
DisallowHeapAllocation no_allocation;
HandleScope scope(isolate);
JSArray* holder = JSArray::cast(*Utils::OpenHandle(*info.Holder()));
@ -159,7 +160,8 @@ void Accessors::ArrayLengthSetter(
v8::Local<v8::Name> name, v8::Local<v8::Value> val,
const v8::PropertyCallbackInfo<v8::Boolean>& info) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
RuntimeCallTimerScope timer(isolate, &RuntimeCallStats::ArrayLengthSetter);
RuntimeCallTimerScope timer(isolate,
RuntimeCallCounterId::kArrayLengthSetter);
HandleScope scope(isolate);
DCHECK(Utils::OpenHandle(*name)->SameValue(isolate->heap()->length_string()));
@ -272,7 +274,8 @@ void Accessors::StringLengthGetter(
v8::Local<v8::Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
RuntimeCallTimerScope timer(isolate, &RuntimeCallStats::StringLengthGetter);
RuntimeCallTimerScope timer(isolate,
RuntimeCallCounterId::kStringLengthGetter);
DisallowHeapAllocation no_allocation;
HandleScope scope(isolate);
@ -644,7 +647,7 @@ void Accessors::FunctionPrototypeGetter(
const v8::PropertyCallbackInfo<v8::Value>& info) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
RuntimeCallTimerScope timer(isolate,
&RuntimeCallStats::FunctionPrototypeGetter);
RuntimeCallCounterId::kFunctionPrototypeGetter);
HandleScope scope(isolate);
Handle<JSFunction> function =
Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder()));
@ -657,7 +660,7 @@ void Accessors::FunctionPrototypeSetter(
const v8::PropertyCallbackInfo<v8::Boolean>& info) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
RuntimeCallTimerScope timer(isolate,
&RuntimeCallStats::FunctionPrototypeSetter);
RuntimeCallCounterId::kFunctionPrototypeSetter);
HandleScope scope(isolate);
Handle<Object> value = Utils::OpenHandle(*val);
Handle<JSFunction> object =
@ -681,7 +684,8 @@ void Accessors::FunctionLengthGetter(
v8::Local<v8::Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
RuntimeCallTimerScope timer(isolate, &RuntimeCallStats::FunctionLengthGetter);
RuntimeCallTimerScope timer(isolate,
RuntimeCallCounterId::kFunctionLengthGetter);
HandleScope scope(isolate);
Handle<JSFunction> function =
Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder()));
@ -1057,7 +1061,7 @@ void Accessors::BoundFunctionLengthGetter(
v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
RuntimeCallTimerScope timer(isolate,
&RuntimeCallStats::BoundFunctionLengthGetter);
RuntimeCallCounterId::kBoundFunctionLengthGetter);
HandleScope scope(isolate);
Handle<JSBoundFunction> function =
Handle<JSBoundFunction>::cast(Utils::OpenHandle(*info.Holder()));
@ -1084,7 +1088,7 @@ void Accessors::BoundFunctionNameGetter(
v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
RuntimeCallTimerScope timer(isolate,
&RuntimeCallStats::BoundFunctionNameGetter);
RuntimeCallCounterId::kBoundFunctionNameGetter);
HandleScope scope(isolate);
Handle<JSBoundFunction> function =
Handle<JSBoundFunction>::cast(Utils::OpenHandle(*info.Holder()));

View File

@ -31,7 +31,7 @@ namespace internal {
Handle<Name> name) { \
Isolate* isolate = this->isolate(); \
SIDE_EFFECT_CHECK(isolate, f, InternalReturn); \
RuntimeCallTimerScope timer(isolate, &RuntimeCallStats::Function); \
RuntimeCallTimerScope timer(isolate, RuntimeCallCounterId::k##Function); \
VMState<EXTERNAL> state(isolate); \
ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \
PropertyCallbackInfo<ApiReturn> info(begin()); \
@ -51,19 +51,19 @@ FOR_EACH_CALLBACK_TABLE_MAPPING_1_NAME(WRITE_CALL_1_NAME)
F(IndexedPropertyQueryCallback, "has", v8::Integer, Object) \
F(IndexedPropertyDeleterCallback, "delete", v8::Boolean, Object)
#define WRITE_CALL_1_INDEX(Function, type, ApiReturn, InternalReturn) \
Handle<InternalReturn> PropertyCallbackArguments::Call(Function f, \
uint32_t index) { \
Isolate* isolate = this->isolate(); \
SIDE_EFFECT_CHECK(isolate, f, InternalReturn); \
RuntimeCallTimerScope timer(isolate, &RuntimeCallStats::Function); \
VMState<EXTERNAL> state(isolate); \
ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \
PropertyCallbackInfo<ApiReturn> info(begin()); \
LOG(isolate, ApiIndexedPropertyAccess("interceptor-indexed-" type, \
holder(), index)); \
f(index, info); \
return GetReturnValue<InternalReturn>(isolate); \
#define WRITE_CALL_1_INDEX(Function, type, ApiReturn, InternalReturn) \
Handle<InternalReturn> PropertyCallbackArguments::Call(Function f, \
uint32_t index) { \
Isolate* isolate = this->isolate(); \
SIDE_EFFECT_CHECK(isolate, f, InternalReturn); \
RuntimeCallTimerScope timer(isolate, RuntimeCallCounterId::k##Function); \
VMState<EXTERNAL> state(isolate); \
ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \
PropertyCallbackInfo<ApiReturn> info(begin()); \
LOG(isolate, ApiIndexedPropertyAccess("interceptor-indexed-" type, \
holder(), index)); \
f(index, info); \
return GetReturnValue<InternalReturn>(isolate); \
}
FOR_EACH_CALLBACK_TABLE_MAPPING_1_INDEX(WRITE_CALL_1_INDEX)
@ -77,7 +77,7 @@ Handle<Object> PropertyCallbackArguments::Call(
Isolate* isolate = this->isolate();
SIDE_EFFECT_CHECK(isolate, f, Object);
RuntimeCallTimerScope timer(
isolate, &RuntimeCallStats::GenericNamedPropertySetterCallback);
isolate, RuntimeCallCounterId::kGenericNamedPropertySetterCallback);
VMState<EXTERNAL> state(isolate);
ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f));
PropertyCallbackInfo<v8::Value> info(begin());
@ -93,7 +93,7 @@ Handle<Object> PropertyCallbackArguments::Call(
Isolate* isolate = this->isolate();
SIDE_EFFECT_CHECK(isolate, f, Object);
RuntimeCallTimerScope timer(
isolate, &RuntimeCallStats::GenericNamedPropertyDefinerCallback);
isolate, RuntimeCallCounterId::kGenericNamedPropertyDefinerCallback);
VMState<EXTERNAL> state(isolate);
ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f));
PropertyCallbackInfo<v8::Value> info(begin());
@ -108,8 +108,8 @@ Handle<Object> PropertyCallbackArguments::Call(IndexedPropertySetterCallback f,
Handle<Object> value) {
Isolate* isolate = this->isolate();
SIDE_EFFECT_CHECK(isolate, f, Object);
RuntimeCallTimerScope timer(isolate,
&RuntimeCallStats::IndexedPropertySetterCallback);
RuntimeCallTimerScope timer(
isolate, RuntimeCallCounterId::kIndexedPropertySetterCallback);
VMState<EXTERNAL> state(isolate);
ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f));
PropertyCallbackInfo<v8::Value> info(begin());
@ -125,7 +125,7 @@ Handle<Object> PropertyCallbackArguments::Call(
Isolate* isolate = this->isolate();
SIDE_EFFECT_CHECK(isolate, f, Object);
RuntimeCallTimerScope timer(
isolate, &RuntimeCallStats::IndexedPropertyDefinerCallback);
isolate, RuntimeCallCounterId::kIndexedPropertyDefinerCallback);
VMState<EXTERNAL> state(isolate);
ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f));
PropertyCallbackInfo<v8::Value> info(begin());
@ -142,8 +142,8 @@ void PropertyCallbackArguments::Call(AccessorNameSetterCallback f,
!PerformSideEffectCheck(isolate, FUNCTION_ADDR(f))) {
return;
}
RuntimeCallTimerScope timer(isolate,
&RuntimeCallStats::AccessorNameSetterCallback);
RuntimeCallTimerScope timer(
isolate, RuntimeCallCounterId::kAccessorNameSetterCallback);
VMState<EXTERNAL> state(isolate);
ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f));
PropertyCallbackInfo<void> info(begin());

View File

@ -18,7 +18,7 @@ Handle<Object> FunctionCallbackArguments::Call(FunctionCallback f) {
!isolate->debug()->PerformSideEffectCheckForCallback(FUNCTION_ADDR(f))) {
return Handle<Object>();
}
RuntimeCallTimerScope timer(isolate, &RuntimeCallStats::FunctionCallback);
RuntimeCallTimerScope timer(isolate, RuntimeCallCounterId::kFunctionCallback);
VMState<EXTERNAL> state(isolate);
ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f));
FunctionCallbackInfo<v8::Value> info(begin(), argv_, argc_);
@ -33,7 +33,7 @@ Handle<JSObject> PropertyCallbackArguments::Call(
!isolate->debug()->PerformSideEffectCheckForCallback(FUNCTION_ADDR(f))) {
return Handle<JSObject>();
}
RuntimeCallTimerScope timer(isolate, &RuntimeCallStats::PropertyCallback);
RuntimeCallTimerScope timer(isolate, RuntimeCallCounterId::kPropertyCallback);
VMState<EXTERNAL> state(isolate);
ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f));
PropertyCallbackInfo<v8::Array> info(begin());

View File

@ -110,9 +110,9 @@ namespace v8 {
* TODO(jochen): Remove calls form API methods to DO_NOT_USE macros.
*/
#define LOG_API(isolate, class_name, function_name) \
i::RuntimeCallTimerScope _runtime_timer( \
isolate, &i::RuntimeCallStats::API_##class_name##_##function_name); \
#define LOG_API(isolate, class_name, function_name) \
i::RuntimeCallTimerScope _runtime_timer( \
isolate, i::RuntimeCallCounterId::kAPI_##class_name##_##function_name); \
LOG(isolate, ApiEntryCall("v8::" #class_name "::" #function_name))
#define ENTER_V8_DO_NOT_USE(isolate) i::VMState<v8::OTHER> __state__((isolate))
@ -10913,7 +10913,7 @@ void InvokeAccessorGetterCallback(
// Leaving JavaScript.
Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
RuntimeCallTimerScope timer(isolate,
&RuntimeCallStats::AccessorGetterCallback);
RuntimeCallCounterId::kAccessorGetterCallback);
Address getter_address = reinterpret_cast<Address>(reinterpret_cast<intptr_t>(
getter));
VMState<EXTERNAL> state(isolate);
@ -10926,7 +10926,7 @@ void InvokeFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>& info,
v8::FunctionCallback callback) {
Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
RuntimeCallTimerScope timer(isolate,
&RuntimeCallStats::InvokeFunctionCallback);
RuntimeCallCounterId::kInvokeFunctionCallback);
Address callback_address =
reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
VMState<EXTERNAL> state(isolate);
@ -10934,6 +10934,25 @@ void InvokeFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>& info,
callback(info);
}
// Undefine macros for jumbo build.
#undef LOG_API
#undef ENTER_V8_DO_NOT_USE
#undef ENTER_V8_HELPER_DO_NOT_USE
#undef PREPARE_FOR_DEBUG_INTERFACE_EXECUTION_WITH_ISOLATE
#undef PREPARE_FOR_EXECUTION_WITH_CONTEXT
#undef PREPARE_FOR_EXECUTION
#undef ENTER_V8
#undef ENTER_V8_NO_SCRIPT
#undef ENTER_V8_NO_SCRIPT_NO_EXCEPTION
#undef ENTER_V8_FOR_NEW_CONTEXT
#undef EXCEPTION_BAILOUT_CHECK_SCOPED_DO_NOT_USE
#undef RETURN_ON_FAILED_EXECUTION
#undef RETURN_ON_FAILED_EXECUTION_PRIMITIVE
#undef RETURN_TO_LOCAL_UNCHECKED
#undef RETURN_ESCAPED
#undef SET_FIELD_WRAPPED
#undef NEW_STRING
#undef CALLBACK_SETTER
} // namespace internal
} // namespace v8

View File

@ -85,7 +85,7 @@ double ClobberDoubleRegisters(double x1, double x2, double x3, double x4);
\
V8_NOINLINE static Type Stats_##Name(int args_length, Object** args_object, \
Isolate* isolate) { \
RuntimeCallTimerScope timer(isolate, &RuntimeCallStats::Name); \
RuntimeCallTimerScope timer(isolate, RuntimeCallCounterId::k##Name); \
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.runtime"), \
"V8.Runtime_" #Name); \
Arguments args(args_length, args_object); \

View File

@ -649,8 +649,8 @@ void DeclarationScope::Analyze(ParseInfo* info) {
RuntimeCallTimerScope runtimeTimer(
info->runtime_call_stats(),
info->on_background_thread()
? &RuntimeCallStats::CompileBackgroundScopeAnalysis
: &RuntimeCallStats::CompileScopeAnalysis);
? RuntimeCallCounterId::kCompileBackgroundScopeAnalysis
: RuntimeCallCounterId::kCompileScopeAnalysis);
DCHECK_NOT_NULL(info->literal());
DeclarationScope* scope = info->literal()->scope();

View File

@ -85,7 +85,8 @@ class BuiltinArguments : public Arguments {
V8_NOINLINE static Object* Builtin_Impl_Stats_##name( \
int args_length, Object** args_object, Isolate* isolate) { \
BuiltinArguments args(args_length, args_object); \
RuntimeCallTimerScope timer(isolate, &RuntimeCallStats::Builtin_##name); \
RuntimeCallTimerScope timer(isolate, \
RuntimeCallCounterId::kBuiltin_##name); \
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.runtime"), \
"V8.Builtin_" #name); \
return Builtin_Impl_##name(args, isolate); \

View File

@ -305,7 +305,7 @@ void CompilerDispatcher::WaitForJobIfRunningOnBackground(
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"),
"V8.CompilerDispatcherWaitForBackgroundJob");
RuntimeCallTimerScope runtimeTimer(
isolate_, &RuntimeCallStats::CompileWaitForDispatcher);
isolate_, RuntimeCallCounterId::kCompileWaitForDispatcher);
base::LockGuard<base::Mutex> lock(&mutex_);
if (running_background_jobs_.find(job) == running_background_jobs_.end()) {

View File

@ -375,8 +375,8 @@ bool Renumber(ParseInfo* parse_info,
RuntimeCallTimerScope runtimeTimer(
parse_info->runtime_call_stats(),
parse_info->on_background_thread()
? &RuntimeCallStats::CompileBackgroundRenumber
: &RuntimeCallStats::CompileRenumber);
? RuntimeCallCounterId::kCompileBackgroundRenumber
: RuntimeCallCounterId::kCompileRenumber);
return AstNumbering::Renumber(parse_info->stack_limit(), parse_info->zone(),
parse_info->literal(), eager_literals);
}
@ -487,7 +487,7 @@ MUST_USE_RESULT MaybeHandle<Code> GetCodeFromOptimizedCodeCache(
Handle<JSFunction> function, BailoutId osr_offset) {
RuntimeCallTimerScope runtimeTimer(
function->GetIsolate(),
&RuntimeCallStats::CompileGetFromOptimizedCodeMap);
RuntimeCallCounterId::kCompileGetFromOptimizedCodeMap);
Handle<SharedFunctionInfo> shared(function->shared());
DisallowHeapAllocation no_gc;
if (osr_offset.IsNone()) {
@ -543,8 +543,8 @@ void InsertCodeIntoOptimizedCodeCache(CompilationInfo* compilation_info) {
bool GetOptimizedCodeNow(CompilationJob* job, Isolate* isolate) {
TimerEventScope<TimerEventRecompileSynchronous> timer(isolate);
RuntimeCallTimerScope runtimeTimer(isolate,
&RuntimeCallStats::RecompileSynchronous);
RuntimeCallTimerScope runtimeTimer(
isolate, RuntimeCallCounterId::kRecompileSynchronous);
CompilationInfo* compilation_info = job->compilation_info();
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"),
"V8.RecompileSynchronous");
@ -590,8 +590,8 @@ bool GetOptimizedCodeLater(CompilationJob* job, Isolate* isolate) {
}
TimerEventScope<TimerEventRecompileSynchronous> timer(isolate);
RuntimeCallTimerScope runtimeTimer(isolate,
&RuntimeCallStats::RecompileSynchronous);
RuntimeCallTimerScope runtimeTimer(
isolate, RuntimeCallCounterId::kRecompileSynchronous);
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"),
"V8.RecompileSynchronous");
@ -672,7 +672,8 @@ MaybeHandle<Code> GetOptimizedCode(Handle<JSFunction> function,
}
TimerEventScope<TimerEventOptimizeCode> optimize_code_timer(isolate);
RuntimeCallTimerScope runtimeTimer(isolate, &RuntimeCallStats::OptimizeCode);
RuntimeCallTimerScope runtimeTimer(isolate,
RuntimeCallCounterId::kOptimizeCode);
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.OptimizeCode");
// In case of concurrent recompilation, all handles below this point will be
@ -716,8 +717,8 @@ CompilationJob::Status FinalizeOptimizedCompilationJob(CompilationJob* job,
CompilationInfo* compilation_info = job->compilation_info();
TimerEventScope<TimerEventRecompileSynchronous> timer(isolate);
RuntimeCallTimerScope runtimeTimer(isolate,
&RuntimeCallStats::RecompileSynchronous);
RuntimeCallTimerScope runtimeTimer(
isolate, RuntimeCallCounterId::kRecompileSynchronous);
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"),
"V8.RecompileSynchronous");
@ -809,8 +810,8 @@ MaybeHandle<SharedFunctionInfo> CompileToplevel(ParseInfo* parse_info,
PostponeInterruptsScope postpone(isolate);
DCHECK(!isolate->native_context().is_null());
RuntimeCallTimerScope runtimeTimer(
isolate, parse_info->is_eval() ? &RuntimeCallStats::CompileEval
: &RuntimeCallStats::CompileScript);
isolate, parse_info->is_eval() ? RuntimeCallCounterId::kCompileEval
: RuntimeCallCounterId::kCompileScript);
VMState<BYTECODE_COMPILER> state(isolate);
if (parse_info->literal() == nullptr &&
!parsing::ParseProgram(parse_info, isolate)) {
@ -860,8 +861,8 @@ bool Compiler::Analyze(ParseInfo* parse_info,
RuntimeCallTimerScope runtimeTimer(
parse_info->runtime_call_stats(),
parse_info->on_background_thread()
? &RuntimeCallStats::CompileBackgroundAnalyse
: &RuntimeCallStats::CompileAnalyse);
? RuntimeCallCounterId::kCompileBackgroundAnalyse
: RuntimeCallCounterId::kCompileAnalyse);
if (!Rewriter::Rewrite(parse_info)) return false;
DeclarationScope::Analyze(parse_info);
if (!Renumber(parse_info, eager_literals)) return false;
@ -890,7 +891,7 @@ bool Compiler::Compile(Handle<SharedFunctionInfo> shared_info,
PostponeInterruptsScope postpone(isolate);
TimerEventScope<TimerEventCompileCode> compile_timer(isolate);
RuntimeCallTimerScope runtimeTimer(isolate,
&RuntimeCallStats::CompileFunction);
RuntimeCallCounterId::kCompileFunction);
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileCode");
AggregatedHistogramTimerScope timer(isolate->counters()->compile_lazy());
@ -1477,8 +1478,8 @@ MaybeHandle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript(
compile_timer.set_consuming_code_cache();
// Then check cached code provided by embedder.
HistogramTimerScope timer(isolate->counters()->compile_deserialize());
RuntimeCallTimerScope runtimeTimer(isolate,
&RuntimeCallStats::CompileDeserialize);
RuntimeCallTimerScope runtimeTimer(
isolate, RuntimeCallCounterId::kCompileDeserialize);
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"),
"V8.CompileDeserialize");
Handle<SharedFunctionInfo> inner_result;
@ -1577,8 +1578,8 @@ MaybeHandle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript(
HistogramTimerScope histogram_timer(
isolate->counters()->compile_serialize());
RuntimeCallTimerScope runtimeTimer(isolate,
&RuntimeCallStats::CompileSerialize);
RuntimeCallTimerScope runtimeTimer(
isolate, RuntimeCallCounterId::kCompileSerialize);
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"),
"V8.CompileSerialize");
*cached_data = CodeSerializer::Serialize(isolate, result, source);
@ -1610,8 +1611,8 @@ std::unique_ptr<CompilationJob> Compiler::CompileTopLevelOnBackgroundThread(
"V8.CompileCodeBackground");
RuntimeCallTimerScope runtimeTimer(
parse_info->runtime_call_stats(),
parse_info->is_eval() ? &RuntimeCallStats::CompileBackgroundEval
: &RuntimeCallStats::CompileBackgroundScript);
parse_info->is_eval() ? RuntimeCallCounterId::kCompileBackgroundEval
: RuntimeCallCounterId::kCompileBackgroundScript);
LanguageMode language_mode = construct_language_mode(FLAG_use_strict);
parse_info->set_language_mode(

View File

@ -57,8 +57,8 @@ void RuntimeCallTimer::CommitTimeToCounter() {
bool RuntimeCallTimer::IsStarted() { return start_ticks_ != base::TimeTicks(); }
RuntimeCallTimerScope::RuntimeCallTimerScope(
HeapObject* heap_object, RuntimeCallStats::CounterId counter_id)
RuntimeCallTimerScope::RuntimeCallTimerScope(HeapObject* heap_object,
RuntimeCallCounterId counter_id)
: RuntimeCallTimerScope(heap_object->GetIsolate(), counter_id) {}
} // namespace internal

View File

@ -444,43 +444,16 @@ RuntimeCallStats::RuntimeCallStats() : in_use_(false) {
FOR_EACH_HANDLER_COUNTER(CALL_BUILTIN_COUNTER) //
#undef CALL_BUILTIN_COUNTER
};
for (int i = 0; i < counters_count; i++) {
this->*(counters[i]) = RuntimeCallCounter(kNames[i]);
for (int i = 0; i < kNumberOfCounters; i++) {
this->counters_[i] = RuntimeCallCounter(kNames[i]);
}
}
// static
const RuntimeCallStats::CounterId RuntimeCallStats::counters[] = {
#define CALL_BUILTIN_COUNTER(name) &RuntimeCallStats::GC_##name,
FOR_EACH_GC_COUNTER(CALL_BUILTIN_COUNTER) //
#undef CALL_BUILTIN_COUNTER
#define CALL_RUNTIME_COUNTER(name) &RuntimeCallStats::name,
FOR_EACH_MANUAL_COUNTER(CALL_RUNTIME_COUNTER) //
#undef CALL_RUNTIME_COUNTER
#define CALL_RUNTIME_COUNTER(name, nargs, ressize) \
&RuntimeCallStats::Runtime_##name, //
FOR_EACH_INTRINSIC(CALL_RUNTIME_COUNTER) //
#undef CALL_RUNTIME_COUNTER
#define CALL_BUILTIN_COUNTER(name) &RuntimeCallStats::Builtin_##name,
BUILTIN_LIST_C(CALL_BUILTIN_COUNTER) //
#undef CALL_BUILTIN_COUNTER
#define CALL_BUILTIN_COUNTER(name) &RuntimeCallStats::API_##name,
FOR_EACH_API_COUNTER(CALL_BUILTIN_COUNTER) //
#undef CALL_BUILTIN_COUNTER
#define CALL_BUILTIN_COUNTER(name) &RuntimeCallStats::Handler_##name,
FOR_EACH_HANDLER_COUNTER(CALL_BUILTIN_COUNTER) //
#undef CALL_BUILTIN_COUNTER
};
// static
const int RuntimeCallStats::counters_count =
arraysize(RuntimeCallStats::counters);
// static
void RuntimeCallStats::Enter(RuntimeCallStats* stats, RuntimeCallTimer* timer,
CounterId counter_id) {
RuntimeCallCounterId counter_id) {
DCHECK(stats->IsCalledOnTheSameThread());
RuntimeCallCounter* counter = &(stats->*counter_id);
RuntimeCallCounter* counter = stats->GetCounter(counter_id);
DCHECK_NOT_NULL(counter->name());
timer->Start(counter, stats->current_timer());
stats->current_timer_.SetValue(timer);
@ -499,23 +472,20 @@ void RuntimeCallStats::Leave(RuntimeCallStats* stats, RuntimeCallTimer* timer) {
}
void RuntimeCallStats::Add(RuntimeCallStats* other) {
for (const RuntimeCallStats::CounterId counter_id :
RuntimeCallStats::counters) {
RuntimeCallCounter* counter = &(this->*counter_id);
RuntimeCallCounter* other_counter = &(other->*counter_id);
counter->Add(other_counter);
for (int i = 0; i < kNumberOfCounters; i++) {
GetCounter(i)->Add(other->GetCounter(i));
}
}
// static
void RuntimeCallStats::CorrectCurrentCounterId(RuntimeCallStats* stats,
CounterId counter_id) {
void RuntimeCallStats::CorrectCurrentCounterId(
RuntimeCallStats* stats, RuntimeCallCounterId counter_id) {
DCHECK(stats->IsCalledOnTheSameThread());
// When RCS are enabled dynamically there might be no stats or timer set up.
if (stats == nullptr) return;
RuntimeCallTimer* timer = stats->current_timer_.Value();
if (timer == nullptr) return;
RuntimeCallCounter* counter = &(stats->*counter_id);
RuntimeCallCounter* counter = stats->GetCounter(counter_id);
timer->set_counter(counter);
stats->current_counter_.SetValue(counter);
}
@ -537,10 +507,8 @@ void RuntimeCallStats::Print(std::ostream& os) {
if (current_timer_.Value() != nullptr) {
current_timer_.Value()->Snapshot();
}
for (const RuntimeCallStats::CounterId counter_id :
RuntimeCallStats::counters) {
RuntimeCallCounter* counter = &(this->*counter_id);
entries.Add(counter);
for (int i = 0; i < kNumberOfCounters; i++) {
entries.Add(GetCounter(i));
}
entries.Print(os);
}
@ -556,22 +524,17 @@ void RuntimeCallStats::Reset() {
current_timer_.SetValue(current_timer_.Value()->Stop());
}
for (const RuntimeCallStats::CounterId counter_id :
RuntimeCallStats::counters) {
RuntimeCallCounter* counter = &(this->*counter_id);
counter->Reset();
for (int i = 0; i < kNumberOfCounters; i++) {
GetCounter(i)->Reset();
}
in_use_ = true;
}
void RuntimeCallStats::Dump(v8::tracing::TracedValue* value) {
for (const RuntimeCallStats::CounterId counter_id :
RuntimeCallStats::counters) {
RuntimeCallCounter* counter = &(this->*counter_id);
if (counter->count() > 0) counter->Dump(value);
for (int i = 0; i < kNumberOfCounters; i++) {
if (GetCounter(i)->count() > 0) GetCounter(i)->Dump(value);
}
in_use_ = false;
}

View File

@ -922,39 +922,37 @@ class RuntimeCallTimer final {
V(StoreIC_StoreScriptContextFieldStub) \
V(StoreIC_StoreTransitionDH)
class RuntimeCallStats final : public ZoneObject {
public:
typedef RuntimeCallCounter RuntimeCallStats::*CounterId;
V8_EXPORT_PRIVATE RuntimeCallStats();
#define CALL_RUNTIME_COUNTER(name) RuntimeCallCounter GC_##name;
enum RuntimeCallCounterId {
#define CALL_RUNTIME_COUNTER(name) kGC_##name,
FOR_EACH_GC_COUNTER(CALL_RUNTIME_COUNTER)
#undef CALL_RUNTIME_COUNTER
#define CALL_RUNTIME_COUNTER(name) RuntimeCallCounter name;
FOR_EACH_MANUAL_COUNTER(CALL_RUNTIME_COUNTER)
#define CALL_RUNTIME_COUNTER(name) k##name,
FOR_EACH_MANUAL_COUNTER(CALL_RUNTIME_COUNTER)
#undef CALL_RUNTIME_COUNTER
#define CALL_RUNTIME_COUNTER(name, nargs, ressize) \
RuntimeCallCounter Runtime_##name;
FOR_EACH_INTRINSIC(CALL_RUNTIME_COUNTER)
#define CALL_RUNTIME_COUNTER(name, nargs, ressize) kRuntime_##name,
FOR_EACH_INTRINSIC(CALL_RUNTIME_COUNTER)
#undef CALL_RUNTIME_COUNTER
#define CALL_BUILTIN_COUNTER(name) RuntimeCallCounter Builtin_##name;
BUILTIN_LIST_C(CALL_BUILTIN_COUNTER)
#define CALL_BUILTIN_COUNTER(name) kBuiltin_##name,
BUILTIN_LIST_C(CALL_BUILTIN_COUNTER)
#undef CALL_BUILTIN_COUNTER
#define CALL_BUILTIN_COUNTER(name) RuntimeCallCounter API_##name;
FOR_EACH_API_COUNTER(CALL_BUILTIN_COUNTER)
#define CALL_BUILTIN_COUNTER(name) kAPI_##name,
FOR_EACH_API_COUNTER(CALL_BUILTIN_COUNTER)
#undef CALL_BUILTIN_COUNTER
#define CALL_BUILTIN_COUNTER(name) RuntimeCallCounter Handler_##name;
FOR_EACH_HANDLER_COUNTER(CALL_BUILTIN_COUNTER)
#define CALL_BUILTIN_COUNTER(name) kHandler_##name,
FOR_EACH_HANDLER_COUNTER(CALL_BUILTIN_COUNTER)
#undef CALL_BUILTIN_COUNTER
kNumberOfCounters
};
static const CounterId counters[];
static const int counters_count;
class RuntimeCallStats final : public ZoneObject {
public:
V8_EXPORT_PRIVATE RuntimeCallStats();
// Starting measuring the time for a function. This will establish the
// connection to the parent counter for properly calculating the own times.
V8_EXPORT_PRIVATE static void Enter(RuntimeCallStats* stats,
RuntimeCallTimer* timer,
CounterId counter_id);
RuntimeCallCounterId counter_id);
// Leave a scope for a measured runtime function. This will properly add
// the time delta to the current_counter and subtract the delta from its
@ -964,8 +962,8 @@ class RuntimeCallStats final : public ZoneObject {
// Set counter id for the innermost measurement. It can be used to refine
// event kind when a runtime entry counter is too generic.
V8_EXPORT_PRIVATE static void CorrectCurrentCounterId(RuntimeCallStats* stats,
CounterId counter_id);
V8_EXPORT_PRIVATE static void CorrectCurrentCounterId(
RuntimeCallStats* stats, RuntimeCallCounterId counter_id);
V8_EXPORT_PRIVATE void Reset();
// Add all entries from another stats object.
@ -980,6 +978,15 @@ class RuntimeCallStats final : public ZoneObject {
bool InUse() { return in_use_; }
bool IsCalledOnTheSameThread();
static const int kNumberOfCounters =
static_cast<int>(RuntimeCallCounterId::kNumberOfCounters);
RuntimeCallCounter* GetCounter(RuntimeCallCounterId counter_id) {
return &counters_[static_cast<int>(counter_id)];
}
RuntimeCallCounter* GetCounter(int counter_id) {
return &counters_[counter_id];
}
private:
// Top of a stack of active timers.
base::AtomicValue<RuntimeCallTimer*> current_timer_;
@ -988,32 +995,34 @@ class RuntimeCallStats final : public ZoneObject {
// Used to track nested tracing scopes.
bool in_use_;
ThreadId thread_id_;
RuntimeCallCounter counters_[kNumberOfCounters];
};
#define CHANGE_CURRENT_RUNTIME_COUNTER(runtime_call_stats, counter_name) \
do { \
if (V8_UNLIKELY(FLAG_runtime_stats)) { \
RuntimeCallStats::CorrectCurrentCounterId( \
runtime_call_stats, &RuntimeCallStats::counter_name); \
} \
#define CHANGE_CURRENT_RUNTIME_COUNTER(runtime_call_stats, counter_id) \
do { \
if (V8_UNLIKELY(FLAG_runtime_stats)) { \
RuntimeCallStats::CorrectCurrentCounterId(runtime_call_stats, \
counter_id); \
} \
} while (false)
#define TRACE_HANDLER_STATS(isolate, counter_name) \
CHANGE_CURRENT_RUNTIME_COUNTER(isolate->counters()->runtime_call_stats(), \
Handler_##counter_name)
#define TRACE_HANDLER_STATS(isolate, counter_name) \
CHANGE_CURRENT_RUNTIME_COUNTER( \
isolate->counters()->runtime_call_stats(), \
RuntimeCallCounterId::kHandler_##counter_name)
// A RuntimeCallTimerScopes wraps around a RuntimeCallTimer to measure the
// the time of C++ scope.
class RuntimeCallTimerScope {
public:
inline RuntimeCallTimerScope(Isolate* isolate,
RuntimeCallStats::CounterId counter_id);
RuntimeCallCounterId counter_id);
// This constructor is here just to avoid calling GetIsolate() when the
// stats are disabled and the isolate is not directly available.
inline RuntimeCallTimerScope(HeapObject* heap_object,
RuntimeCallStats::CounterId counter_id);
RuntimeCallCounterId counter_id);
inline RuntimeCallTimerScope(RuntimeCallStats* stats,
RuntimeCallStats::CounterId counter_id) {
RuntimeCallCounterId counter_id) {
if (V8_LIKELY(!FLAG_runtime_stats || stats == nullptr)) return;
stats_ = stats;
RuntimeCallStats::Enter(stats_, &timer_, counter_id);
@ -1541,8 +1550,8 @@ void HistogramTimer::Stop() {
TimedHistogram::Stop(&timer_, counters()->isolate());
}
RuntimeCallTimerScope::RuntimeCallTimerScope(
Isolate* isolate, RuntimeCallStats::CounterId counter_id) {
RuntimeCallTimerScope::RuntimeCallTimerScope(Isolate* isolate,
RuntimeCallCounterId counter_id) {
if (V8_LIKELY(!FLAG_runtime_stats)) return;
stats_ = isolate->counters()->runtime_call_stats();
RuntimeCallStats::Enter(stats_, &timer_, counter_id);

View File

@ -267,7 +267,7 @@ void Deoptimizer::DeoptimizeMarkedCodeForContext(Context* context) {
void Deoptimizer::DeoptimizeAll(Isolate* isolate) {
RuntimeCallTimerScope runtimeTimer(isolate,
&RuntimeCallStats::DeoptimizeCode);
RuntimeCallCounterId::kDeoptimizeCode);
TimerEventScope<TimerEventDeoptimizeCode> timer(isolate);
TRACE_EVENT0("v8", "V8.DeoptimizeCode");
if (FLAG_trace_deopt) {
@ -288,7 +288,7 @@ void Deoptimizer::DeoptimizeAll(Isolate* isolate) {
void Deoptimizer::DeoptimizeMarkedCode(Isolate* isolate) {
RuntimeCallTimerScope runtimeTimer(isolate,
&RuntimeCallStats::DeoptimizeCode);
RuntimeCallCounterId::kDeoptimizeCode);
TimerEventScope<TimerEventDeoptimizeCode> timer(isolate);
TRACE_EVENT0("v8", "V8.DeoptimizeCode");
if (FLAG_trace_deopt) {
@ -319,7 +319,7 @@ void Deoptimizer::MarkAllCodeForContext(Context* context) {
void Deoptimizer::DeoptimizeFunction(JSFunction* function, Code* code) {
Isolate* isolate = function->GetIsolate();
RuntimeCallTimerScope runtimeTimer(isolate,
&RuntimeCallStats::DeoptimizeCode);
RuntimeCallCounterId::kDeoptimizeCode);
TimerEventScope<TimerEventDeoptimizeCode> timer(isolate);
TRACE_EVENT0("v8", "V8.DeoptimizeCode");
if (code == nullptr) code = function->code();

View File

@ -138,7 +138,7 @@ MUST_USE_RESULT MaybeHandle<Object> Invoke(
if (FLAG_profile_deserialization && target->IsJSFunction()) {
PrintDeserializedCodeInfo(Handle<JSFunction>::cast(target));
}
RuntimeCallTimerScope timer(isolate, &RuntimeCallStats::JS_Execution);
RuntimeCallTimerScope timer(isolate, RuntimeCallCounterId::kJS_Execution);
value = CALL_GENERATED_CODE(isolate, stub_entry, orig_func, func, recv,
argc, argv);
}

View File

@ -24,9 +24,11 @@ static size_t CountTotalHolesSize(Heap* heap) {
return holes_size;
}
RuntimeCallStats::CounterId GCTracer::RCSCounterFromScope(Scope::ScopeId id) {
return RuntimeCallStats::counters[kFirstGCIndexInRuntimeCallStats +
static_cast<int>(id)];
RuntimeCallCounterId GCTracer::RCSCounterFromScope(Scope::ScopeId id) {
STATIC_ASSERT(Scope::FIRST_SCOPE == Scope::MC_INCREMENTAL);
return static_cast<RuntimeCallCounterId>(
static_cast<int>(RuntimeCallCounterId::kGC_MC_INCREMENTAL) +
static_cast<int>(id));
}
GCTracer::Scope::Scope(GCTracer* tracer, ScopeId scope)
@ -120,8 +122,6 @@ GCTracer::GCTracer(Heap* heap)
// We assume that MC_INCREMENTAL is the first scope so that we can properly
// map it to RuntimeCallStats.
STATIC_ASSERT(0 == Scope::MC_INCREMENTAL);
CHECK(&RuntimeCallStats::GC_MC_INCREMENTAL ==
RuntimeCallStats::counters[GCTracer::kFirstGCIndexInRuntimeCallStats]);
current_.end_time = heap_->MonotonicallyIncreasingTimeInMs();
}

View File

@ -159,9 +159,8 @@ class V8_EXPORT_PRIVATE GCTracer {
};
static const int kThroughputTimeFrameMs = 5000;
static const int kFirstGCIndexInRuntimeCallStats = 0;
static RuntimeCallStats::CounterId RCSCounterFromScope(Scope::ScopeId id);
static RuntimeCallCounterId RCSCounterFromScope(Scope::ScopeId id);
explicit GCTracer(Heap* heap);

View File

@ -1129,7 +1129,7 @@ void Heap::CollectAllAvailableGarbage(GarbageCollectionReason gc_reason) {
InvokeOutOfMemoryCallback();
}
RuntimeCallTimerScope runtime_timer(
isolate(), &RuntimeCallStats::GC_Custom_AllAvailableGarbage);
isolate(), RuntimeCallCounterId::kGC_Custom_AllAvailableGarbage);
if (isolate()->concurrent_recompilation_enabled()) {
// The optimizing compiler may be unnecessarily holding on to memory.
DisallowHeapAllocation no_recursive_gc;
@ -1673,8 +1673,8 @@ bool Heap::PerformGarbageCollection(
void Heap::CallGCPrologueCallbacks(GCType gc_type, GCCallbackFlags flags) {
RuntimeCallTimerScope runtime_timer(isolate(),
&RuntimeCallStats::GCPrologueCallback);
RuntimeCallTimerScope runtime_timer(
isolate(), RuntimeCallCounterId::kGCPrologueCallback);
for (const GCCallbackTuple& info : gc_prologue_callbacks_) {
if (gc_type & info.gc_type) {
v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this->isolate());
@ -1684,8 +1684,8 @@ void Heap::CallGCPrologueCallbacks(GCType gc_type, GCCallbackFlags flags) {
}
void Heap::CallGCEpilogueCallbacks(GCType gc_type, GCCallbackFlags flags) {
RuntimeCallTimerScope runtime_timer(isolate(),
&RuntimeCallStats::GCEpilogueCallback);
RuntimeCallTimerScope runtime_timer(
isolate(), RuntimeCallCounterId::kGCEpilogueCallback);
for (const GCCallbackTuple& info : gc_epilogue_callbacks_) {
if (gc_type & info.gc_type) {
v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this->isolate());

View File

@ -34,7 +34,8 @@ void IncrementalMarking::Observer::Step(int bytes_allocated, Address addr,
Heap* heap = incremental_marking_.heap();
VMState<GC> state(heap->isolate());
RuntimeCallTimerScope runtime_timer(
heap->isolate(), &RuntimeCallStats::GC_Custom_IncrementalMarkingObserver);
heap->isolate(),
RuntimeCallCounterId::kGC_Custom_IncrementalMarkingObserver);
incremental_marking_.AdvanceIncrementalMarkingOnAllocation();
if (incremental_marking_.black_allocation() && addr != nullptr) {
// AdvanceIncrementalMarkingOnAllocation can start black allocation.

View File

@ -3212,7 +3212,7 @@ bool CompactionSpace::SweepAndRetryAllocation(int size_in_bytes) {
bool PagedSpace::SlowAllocateRaw(int size_in_bytes) {
VMState<GC> state(heap()->isolate());
RuntimeCallTimerScope runtime_timer(
heap()->isolate(), &RuntimeCallStats::GC_Custom_SlowAllocateRaw);
heap()->isolate(), RuntimeCallCounterId::kGC_Custom_SlowAllocateRaw);
return RawSlowAllocateRaw(size_in_bytes);
}

View File

@ -180,8 +180,8 @@ InterpreterCompilationJob::Status InterpreterCompilationJob::ExecuteJobImpl() {
RuntimeCallTimerScope runtimeTimerScope(
parse_info()->runtime_call_stats(),
parse_info()->on_background_thread()
? &RuntimeCallStats::CompileBackgroundIgnition
: &RuntimeCallStats::CompileIgnition);
? RuntimeCallCounterId::kCompileBackgroundIgnition
: RuntimeCallCounterId::kCompileIgnition);
// TODO(lpy): add support for background compilation RCS trace.
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileIgnition");
@ -201,7 +201,7 @@ InterpreterCompilationJob::Status InterpreterCompilationJob::FinalizeJobImpl(
Isolate* isolate) {
RuntimeCallTimerScope runtimeTimerScope(
parse_info()->runtime_call_stats(),
&RuntimeCallStats::CompileIgnitionFinalization);
RuntimeCallCounterId::kCompileIgnitionFinalization);
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"),
"V8.CompileIgnitionFinalization");

View File

@ -1029,7 +1029,7 @@ void Isolate::RequestInterrupt(InterruptCallback callback, void* data) {
void Isolate::InvokeApiInterruptCallbacks() {
RuntimeCallTimerScope runtimeTimer(
this, &RuntimeCallStats::InvokeApiInterruptCallbacks);
this, RuntimeCallCounterId::kInvokeApiInterruptCallbacks);
// Note: callback below should be called outside of execution access lock.
while (true) {
InterruptEntry entry;

View File

@ -521,8 +521,8 @@ void LookupIterator::Delete() {
bool is_prototype_map = holder->map()->is_prototype_map();
RuntimeCallTimerScope stats_scope(
isolate_, is_prototype_map
? &RuntimeCallStats::PrototypeObject_DeleteProperty
: &RuntimeCallStats::Object_DeleteProperty);
? RuntimeCallCounterId::kPrototypeObject_DeleteProperty
: RuntimeCallCounterId::kObject_DeleteProperty);
PropertyNormalizationMode mode =
is_prototype_map ? KEEP_INOBJECT_PROPERTIES : CLEAR_INOBJECT_PROPERTIES;

View File

@ -9689,8 +9689,8 @@ Handle<Map> Map::TransitionToDataProperty(Handle<Map> map, Handle<Name> name,
bool* created_new_map) {
RuntimeCallTimerScope stats_scope(
*map, map->is_prototype_map()
? &RuntimeCallStats::PrototypeMap_TransitionToDataProperty
: &RuntimeCallStats::Map_TransitionToDataProperty);
? RuntimeCallCounterId::kPrototypeMap_TransitionToDataProperty
: RuntimeCallCounterId::kMap_TransitionToDataProperty);
DCHECK(name->IsUniqueName());
DCHECK(!map->is_dictionary_map());
@ -9805,8 +9805,8 @@ Handle<Map> Map::TransitionToAccessorProperty(Isolate* isolate, Handle<Map> map,
RuntimeCallTimerScope stats_scope(
isolate,
map->is_prototype_map()
? &RuntimeCallStats::PrototypeMap_TransitionToAccessorProperty
: &RuntimeCallStats::Map_TransitionToAccessorProperty);
? RuntimeCallCounterId::kPrototypeMap_TransitionToAccessorProperty
: RuntimeCallCounterId::kMap_TransitionToAccessorProperty);
// At least one of the accessors needs to be a new value.
DCHECK(!getter->IsNull(isolate) || !setter->IsNull(isolate));
@ -12654,7 +12654,8 @@ Handle<WeakCell> Map::GetOrCreatePrototypeWeakCell(Handle<JSReceiver> prototype,
// static
void Map::SetPrototype(Handle<Map> map, Handle<Object> prototype,
bool enable_prototype_setup_mode) {
RuntimeCallTimerScope stats_scope(*map, &RuntimeCallStats::Map_SetPrototype);
RuntimeCallTimerScope stats_scope(*map,
RuntimeCallCounterId::kMap_SetPrototype);
bool is_hidden = false;
if (prototype->IsJSObject()) {

View File

@ -4298,11 +4298,11 @@ typename ParserBase<Impl>::ExpressionT
ParserBase<Impl>::ParseArrowFunctionLiteral(
bool accept_IN, const FormalParametersT& formal_parameters,
int rewritable_length, bool* ok) {
const RuntimeCallStats::CounterId counters[2][2] = {
{&RuntimeCallStats::ParseBackgroundArrowFunctionLiteral,
&RuntimeCallStats::ParseArrowFunctionLiteral},
{&RuntimeCallStats::PreParseBackgroundArrowFunctionLiteral,
&RuntimeCallStats::PreParseArrowFunctionLiteral}};
const RuntimeCallCounterId counters[2][2] = {
{RuntimeCallCounterId::kParseBackgroundArrowFunctionLiteral,
RuntimeCallCounterId::kParseArrowFunctionLiteral},
{RuntimeCallCounterId::kPreParseBackgroundArrowFunctionLiteral,
RuntimeCallCounterId::kPreParseArrowFunctionLiteral}};
RuntimeCallTimerScope runtime_timer(
runtime_call_stats_,
counters[Impl::IsPreParser()][parsing_on_main_thread_]);

View File

@ -592,8 +592,9 @@ FunctionLiteral* Parser::ParseProgram(Isolate* isolate, ParseInfo* info) {
// called in the main thread.
DCHECK(parsing_on_main_thread_);
RuntimeCallTimerScope runtime_timer(
runtime_call_stats_, info->is_eval() ? &RuntimeCallStats::ParseEval
: &RuntimeCallStats::ParseProgram);
runtime_call_stats_, info->is_eval()
? RuntimeCallCounterId::kParseEval
: RuntimeCallCounterId::kParseProgram);
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.ParseProgram");
base::ElapsedTimer timer;
if (V8_UNLIKELY(FLAG_log_function_events)) timer.Start();
@ -757,7 +758,7 @@ FunctionLiteral* Parser::ParseFunction(Isolate* isolate, ParseInfo* info,
// called in the main thread.
DCHECK(parsing_on_main_thread_);
RuntimeCallTimerScope runtime_timer(runtime_call_stats_,
&RuntimeCallStats::ParseFunction);
RuntimeCallCounterId::kParseFunction);
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.ParseFunction");
base::ElapsedTimer timer;
if (V8_UNLIKELY(FLAG_log_function_events)) timer.Start();
@ -2587,8 +2588,8 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
RuntimeCallTimerScope runtime_timer(
runtime_call_stats_,
parsing_on_main_thread_
? &RuntimeCallStats::ParseFunctionLiteral
: &RuntimeCallStats::ParseBackgroundFunctionLiteral);
? RuntimeCallCounterId::kParseFunctionLiteral
: RuntimeCallCounterId::kParseBackgroundFunctionLiteral);
base::ElapsedTimer timer;
if (V8_UNLIKELY(FLAG_log_function_events)) timer.Start();
@ -2705,15 +2706,16 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
}
if (V8_UNLIKELY(FLAG_runtime_stats)) {
if (should_preparse) {
RuntimeCallStats::CounterId counter_id =
RuntimeCallCounterId counter_id =
parsing_on_main_thread_
? &RuntimeCallStats::PreParseWithVariableResolution
: &RuntimeCallStats::PreParseBackgroundWithVariableResolution;
? RuntimeCallCounterId::kPreParseWithVariableResolution
: RuntimeCallCounterId::
kPreParseBackgroundWithVariableResolution;
if (is_top_level) {
counter_id =
parsing_on_main_thread_
? &RuntimeCallStats::PreParseNoVariableResolution
: &RuntimeCallStats::PreParseBackgroundNoVariableResolution;
counter_id = parsing_on_main_thread_
? RuntimeCallCounterId::kPreParseNoVariableResolution
: RuntimeCallCounterId::
kPreParseBackgroundNoVariableResolution;
}
RuntimeCallStats::CorrectCurrentCounterId(runtime_call_stats_,
counter_id);
@ -3450,8 +3452,8 @@ void Parser::UpdateStatistics(Isolate* isolate, Handle<Script> script) {
}
void Parser::ParseOnBackground(ParseInfo* info) {
RuntimeCallTimerScope runtimeTimer(runtime_call_stats_,
&RuntimeCallStats::ParseBackgroundProgram);
RuntimeCallTimerScope runtimeTimer(
runtime_call_stats_, RuntimeCallCounterId::kParseBackgroundProgram);
parsing_on_main_thread_ = false;
if (!info->script().is_null()) {
set_script_id(info->script()->id());

View File

@ -269,11 +269,11 @@ PreParser::Expression PreParser::ParseFunctionLiteral(
LanguageMode language_mode, bool* ok) {
// Function ::
// '(' FormalParameterList? ')' '{' FunctionBody '}'
const RuntimeCallStats::CounterId counters[2][2] = {
{&RuntimeCallStats::PreParseBackgroundNoVariableResolution,
&RuntimeCallStats::PreParseNoVariableResolution},
{&RuntimeCallStats::PreParseBackgroundWithVariableResolution,
&RuntimeCallStats::PreParseWithVariableResolution}};
const RuntimeCallCounterId counters[2][2] = {
{RuntimeCallCounterId::kPreParseBackgroundNoVariableResolution,
RuntimeCallCounterId::kPreParseNoVariableResolution},
{RuntimeCallCounterId::kPreParseBackgroundWithVariableResolution,
RuntimeCallCounterId::kPreParseWithVariableResolution}};
RuntimeCallTimerScope runtime_timer(
runtime_call_stats_,
counters[track_unresolved_variables_][parsing_on_main_thread_]);

View File

@ -367,8 +367,8 @@ bool Rewriter::Rewrite(ParseInfo* info) {
RuntimeCallTimerScope runtimeTimer(
info->runtime_call_stats(),
info->on_background_thread()
? &RuntimeCallStats::CompileBackgroundRewriteReturnResult
: &RuntimeCallStats::CompileRewriteReturnResult);
? RuntimeCallCounterId::kCompileBackgroundRewriteReturnResult
: RuntimeCallCounterId::kCompileRewriteReturnResult);
FunctionLiteral* function = info->literal();
DCHECK_NOT_NULL(function);

View File

@ -347,7 +347,8 @@ void Utf8ExternalStreamingStream::FillBufferFromCurrentChunk() {
}
bool Utf8ExternalStreamingStream::FetchChunk() {
RuntimeCallTimerScope scope(stats_, &RuntimeCallStats::GetMoreDataCallback);
RuntimeCallTimerScope scope(stats_,
RuntimeCallCounterId::kGetMoreDataCallback);
DCHECK_EQ(current_.chunk_no, chunks_.size());
DCHECK(chunks_.empty() || chunks_.back().length != 0);
@ -491,7 +492,8 @@ size_t FindChunk(Chunks& chunks, ScriptCompiler::ExternalSourceStream* source,
// Get more data if needed. We usually won't enter the loop body.
bool out_of_data = !chunks.empty() && chunks.back().byte_length == 0;
{
RuntimeCallTimerScope scope(stats, &RuntimeCallStats::GetMoreDataCallback);
RuntimeCallTimerScope scope(stats,
RuntimeCallCounterId::kGetMoreDataCallback);
while (!out_of_data && end_pos <= position + 1) {
const uint8_t* chunk = nullptr;
size_t len = source->GetMoreData(&chunk);

View File

@ -322,8 +322,8 @@ void CpuProfiler::CreateEntriesForRuntimeCallStats() {
static_entries_.clear();
RuntimeCallStats* rcs = isolate_->counters()->runtime_call_stats();
CodeMap* code_map = generator_->code_map();
for (int i = 0; i < RuntimeCallStats::counters_count; ++i) {
RuntimeCallCounter* counter = &(rcs->*(RuntimeCallStats::counters[i]));
for (int i = 0; i < RuntimeCallStats::kNumberOfCounters; ++i) {
RuntimeCallCounter* counter = rcs->GetCounter(i);
DCHECK(counter->name());
std::unique_ptr<CodeEntry> entry(
new CodeEntry(CodeEventListener::FUNCTION_TAG, counter->name(),

View File

@ -89,22 +89,24 @@ class RuntimeCallStatsTest : public TestWithNativeContext {
// Print current RuntimeCallStats table. For debugging purposes.
void PrintStats() { stats()->Print(); }
RuntimeCallStats::CounterId counter_id() {
return &RuntimeCallStats::TestCounter1;
RuntimeCallCounterId counter_id() {
return RuntimeCallCounterId::kTestCounter1;
}
RuntimeCallStats::CounterId counter_id2() {
return &RuntimeCallStats::TestCounter2;
RuntimeCallCounterId counter_id2() {
return RuntimeCallCounterId::kTestCounter2;
}
RuntimeCallStats::CounterId counter_id3() {
return &RuntimeCallStats::TestCounter3;
RuntimeCallCounterId counter_id3() {
return RuntimeCallCounterId::kTestCounter3;
}
RuntimeCallCounter* js_counter() { return &stats()->JS_Execution; }
RuntimeCallCounter* counter() { return &(stats()->*counter_id()); }
RuntimeCallCounter* counter2() { return &(stats()->*counter_id2()); }
RuntimeCallCounter* counter3() { return &(stats()->*counter_id3()); }
RuntimeCallCounter* js_counter() {
return stats()->GetCounter(RuntimeCallCounterId::kJS_Execution);
}
RuntimeCallCounter* counter() { return stats()->GetCounter(counter_id()); }
RuntimeCallCounter* counter2() { return stats()->GetCounter(counter_id2()); }
RuntimeCallCounter* counter3() { return stats()->GetCounter(counter_id3()); }
void Sleep(int64_t microseconds) {
base::TimeDelta delta = base::TimeDelta::FromMicroseconds(microseconds);
@ -439,7 +441,8 @@ TEST_F(RuntimeCallStatsTest, RenameTimer) {
RuntimeCallTimerScope scope(stats(), counter_id());
Sleep(100);
}
CHANGE_CURRENT_RUNTIME_COUNTER(stats(), TestCounter2);
CHANGE_CURRENT_RUNTIME_COUNTER(stats(),
RuntimeCallCounterId::kTestCounter2);
EXPECT_EQ(1, counter()->count());
EXPECT_EQ(0, counter2()->count());
EXPECT_EQ(100, counter()->time().InMicroseconds());
@ -558,7 +561,8 @@ TEST_F(RuntimeCallStatsTest, NestedScopes) {
}
TEST_F(RuntimeCallStatsTest, BasicJavaScript) {
RuntimeCallCounter* counter = &stats()->JS_Execution;
RuntimeCallCounter* counter =
stats()->GetCounter(RuntimeCallCounterId::kJS_Execution);
EXPECT_EQ(0, counter->count());
EXPECT_EQ(0, counter->time().InMicroseconds());
@ -579,8 +583,10 @@ TEST_F(RuntimeCallStatsTest, BasicJavaScript) {
}
TEST_F(RuntimeCallStatsTest, FunctionLengthGetter) {
RuntimeCallCounter* getter_counter = &stats()->FunctionLengthGetter;
RuntimeCallCounter* js_counter = &stats()->JS_Execution;
RuntimeCallCounter* getter_counter =
stats()->GetCounter(RuntimeCallCounterId::kFunctionLengthGetter);
RuntimeCallCounter* js_counter =
stats()->GetCounter(RuntimeCallCounterId::kJS_Execution);
EXPECT_EQ(0, getter_counter->count());
EXPECT_EQ(0, js_counter->count());
EXPECT_EQ(0, getter_counter->time().InMicroseconds());