[counter] reducing the overhead of RuntimeCallTimerScope

BUG=chromium:589679
LOG=N

Review URL: https://codereview.chromium.org/1771323003

Cr-Commit-Position: refs/heads/master@{#34595}
This commit is contained in:
cbruni 2016-03-08 09:24:01 -08:00 committed by Commit bot
parent f7934b6427
commit 667b04a94a
5 changed files with 49 additions and 30 deletions

View File

@ -271,16 +271,21 @@ double ClobberDoubleRegisters(double x1, double x2, double x3, double x4);
#define CLOBBER_DOUBLE_REGISTERS()
#endif
#define RUNTIME_FUNCTION_RETURNS_TYPE(Type, Name) \
static INLINE(Type __RT_impl_##Name(Arguments args, Isolate* isolate)); \
Type Name(int args_length, Object** args_object, Isolate* isolate) { \
CLOBBER_DOUBLE_REGISTERS(); \
RuntimeCallStats* stats = isolate->counters()->runtime_call_stats(); \
RuntimeCallTimerScope timer(isolate, &stats->Name); \
Arguments args(args_length, args_object); \
Type value = __RT_impl_##Name(args, isolate); \
return value; \
} \
#define RUNTIME_FUNCTION_RETURNS_TYPE(Type, Name) \
static INLINE(Type __RT_impl_##Name(Arguments args, Isolate* isolate)); \
Type Name(int args_length, Object** args_object, Isolate* isolate) { \
CLOBBER_DOUBLE_REGISTERS(); \
Arguments args(args_length, args_object); \
Type value; \
if (FLAG_runtime_call_stats) { \
RuntimeCallStats* stats = isolate->counters()->runtime_call_stats(); \
RuntimeCallTimerScope timer(isolate, &stats->Name); \
value = __RT_impl_##Name(args, isolate); \
} else { \
value = __RT_impl_##Name(args, isolate); \
} \
return value; \
} \
static Type __RT_impl_##Name(Arguments args, Isolate* isolate)
#define RUNTIME_FUNCTION(Name) RUNTIME_FUNCTION_RETURNS_TYPE(Object*, Name)

View File

@ -273,7 +273,9 @@ void RuntimeCallCounter::Reset() {
}
void RuntimeCallStats::Enter(RuntimeCallCounter* counter) {
Enter(new RuntimeCallTimer(counter, current_timer_));
RuntimeCallTimer* timer = new RuntimeCallTimer();
timer->Initialize(counter, current_timer_);
Enter(timer);
}
void RuntimeCallStats::Enter(RuntimeCallTimer* timer_) {
@ -316,19 +318,19 @@ void RuntimeCallStats::Reset() {
#define RESET_COUNTER(name, type) this->Builtin_##name.Reset();
BUILTIN_LIST_C(RESET_COUNTER)
#undef RESET_COUNTER
this->ExternalCallback.Reset();
this->UnexpectedStubMiss.Reset();
}
RuntimeCallTimerScope::RuntimeCallTimerScope(Isolate* isolate,
RuntimeCallCounter* counter)
: isolate_(isolate),
timer_(counter,
isolate->counters()->runtime_call_stats()->current_timer()) {
if (!FLAG_runtime_call_stats) return;
isolate->counters()->runtime_call_stats()->Enter(&timer_);
void RuntimeCallTimerScope::Enter(Isolate* isolate,
RuntimeCallCounter* counter) {
isolate_ = isolate;
RuntimeCallStats* stats = isolate->counters()->runtime_call_stats();
timer_.Initialize(counter, stats->current_timer());
stats->Enter(&timer_);
}
RuntimeCallTimerScope::~RuntimeCallTimerScope() {
if (!FLAG_runtime_call_stats) return;
void RuntimeCallTimerScope::Leave() {
isolate_->counters()->runtime_call_stats()->Leave(&timer_);
}

View File

@ -492,8 +492,11 @@ struct RuntimeCallCounter {
// timers used for properly measuring the own time of a RuntimeCallCounter.
class RuntimeCallTimer {
public:
RuntimeCallTimer(RuntimeCallCounter* counter, RuntimeCallTimer* parent)
: counter_(counter), parent_(parent) {}
inline void Initialize(RuntimeCallCounter* counter,
RuntimeCallTimer* parent) {
counter_ = counter;
parent_ = parent;
}
inline void Start() {
timer_.Start();
@ -509,7 +512,9 @@ class RuntimeCallTimer {
return parent_;
}
void AdjustForSubTimer(base::TimeDelta delta) { counter_->time -= delta; }
inline void AdjustForSubTimer(base::TimeDelta delta) {
counter_->time -= delta;
}
private:
RuntimeCallCounter* counter_;
@ -557,8 +562,16 @@ struct RuntimeCallStats {
// the time of C++ scope.
class RuntimeCallTimerScope {
public:
explicit RuntimeCallTimerScope(Isolate* isolate, RuntimeCallCounter* counter);
~RuntimeCallTimerScope();
inline explicit RuntimeCallTimerScope(Isolate* isolate,
RuntimeCallCounter* counter) {
if (FLAG_runtime_call_stats) Enter(isolate, counter);
}
inline ~RuntimeCallTimerScope() {
if (FLAG_runtime_call_stats) Leave();
}
void Enter(Isolate* isolate, RuntimeCallCounter* counter);
void Leave();
private:
Isolate* isolate_;

View File

@ -1320,7 +1320,6 @@ inline bool operator<(const CounterAndKey& lhs, const CounterAndKey& rhs) {
void Shell::OnExit(v8::Isolate* isolate) {
#ifndef V8_SHARED
reinterpret_cast<i::Isolate*>(isolate)->DumpAndResetCompilationStats();
if (i::FLAG_dump_counters) {
int number_of_counters = 0;
for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) {

View File

@ -58,15 +58,15 @@ VMState<Tag>::~VMState() {
ExternalCallbackScope::ExternalCallbackScope(Isolate* isolate, Address callback)
: isolate_(isolate),
callback_(callback),
previous_scope_(isolate->external_callback_scope()),
timer_(&isolate->counters()->runtime_call_stats()->ExternalCallback,
isolate->counters()->runtime_call_stats()->current_timer()) {
previous_scope_(isolate->external_callback_scope()) {
#ifdef USE_SIMULATOR
scope_address_ = Simulator::current(isolate)->get_sp();
#endif
isolate_->set_external_callback_scope(this);
if (FLAG_runtime_call_stats) {
isolate_->counters()->runtime_call_stats()->Enter(&timer_);
RuntimeCallStats* stats = isolate->counters()->runtime_call_stats();
timer_.Initialize(&stats->ExternalCallback, stats->current_timer());
stats->Enter(&timer_);
}
}