[runtime] reduce runtime function and builtins overhead
All the counters, trace events and runtime call stats roughly create a 30% overhead when calling into the runtime. This CL factors out the counters into separate non-inlined functions. This way we can reduce the overhead to a minimum and still have some useful stats without a compile-time flag. BUG=chromium:596055 LOG=n Review URL: https://codereview.chromium.org/1868513002 Cr-Commit-Position: refs/heads/master@{#35308}
This commit is contained in:
parent
4b86e6e321
commit
ceb14f8c31
@ -79,22 +79,30 @@ 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(); \
|
||||
Type value; \
|
||||
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.runtime"), "V8." #Name); \
|
||||
Arguments args(args_length, args_object); \
|
||||
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; \
|
||||
} \
|
||||
// TODO(cbruni): add global flag to check whether any tracing events have been
|
||||
// enabled.
|
||||
#define RUNTIME_FUNCTION_RETURNS_TYPE(Type, Name) \
|
||||
static INLINE(Type __RT_impl_##Name(Arguments args, Isolate* isolate)); \
|
||||
\
|
||||
V8_NOINLINE static Type Stats_##Name(int args_length, Object** args_object, \
|
||||
Isolate* isolate) { \
|
||||
RuntimeCallStats* stats = isolate->counters()->runtime_call_stats(); \
|
||||
RuntimeCallTimerScope timer(isolate, &stats->Name); \
|
||||
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.runtime"), \
|
||||
"V8.Runtime_" #Name); \
|
||||
Arguments args(args_length, args_object); \
|
||||
return __RT_impl_##Name(args, isolate); \
|
||||
} \
|
||||
\
|
||||
Type Name(int args_length, Object** args_object, Isolate* isolate) { \
|
||||
CLOBBER_DOUBLE_REGISTERS(); \
|
||||
if (FLAG_runtime_call_stats) { \
|
||||
return Stats_##Name(args_length, args_object, isolate); \
|
||||
} \
|
||||
Arguments args(args_length, args_object); \
|
||||
return __RT_impl_##Name(args, isolate); \
|
||||
} \
|
||||
\
|
||||
static Type __RT_impl_##Name(Arguments args, Isolate* isolate)
|
||||
|
||||
#define RUNTIME_FUNCTION(Name) RUNTIME_FUNCTION_RETURNS_TYPE(Object*, Name)
|
||||
|
@ -138,25 +138,29 @@ BUILTIN_LIST_C(DEF_ARG_TYPE)
|
||||
//
|
||||
// In the body of the builtin function the arguments can be accessed
|
||||
// through the BuiltinArguments object args.
|
||||
|
||||
// TODO(cbruni): add global flag to check whether any tracing events have been
|
||||
// enabled.
|
||||
#define BUILTIN(name) \
|
||||
MUST_USE_RESULT static Object* Builtin_Impl_##name(name##ArgumentsType args, \
|
||||
Isolate* isolate); \
|
||||
MUST_USE_RESULT static Object* Builtin_##name( \
|
||||
\
|
||||
V8_NOINLINE static Object* Builtin_Impl_Stats_##name( \
|
||||
int args_length, Object** args_object, Isolate* isolate) { \
|
||||
Object* value; \
|
||||
isolate->counters()->runtime_calls()->Increment(); \
|
||||
name##ArgumentsType args(args_length, args_object); \
|
||||
RuntimeCallStats* stats = isolate->counters()->runtime_call_stats(); \
|
||||
RuntimeCallTimerScope timer(isolate, &stats->Builtin_##name); \
|
||||
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.runtime"), \
|
||||
"V8.Builtin_" #name); \
|
||||
name##ArgumentsType args(args_length, args_object); \
|
||||
return Builtin_Impl_##name(args, isolate); \
|
||||
} \
|
||||
\
|
||||
MUST_USE_RESULT static Object* Builtin_##name( \
|
||||
int args_length, Object** args_object, Isolate* isolate) { \
|
||||
if (FLAG_runtime_call_stats) { \
|
||||
RuntimeCallStats* stats = isolate->counters()->runtime_call_stats(); \
|
||||
RuntimeCallTimerScope timer(isolate, &stats->Builtin_##name); \
|
||||
value = Builtin_Impl_##name(args, isolate); \
|
||||
} else { \
|
||||
value = Builtin_Impl_##name(args, isolate); \
|
||||
return Builtin_Impl_Stats_##name(args_length, args_object, isolate); \
|
||||
} \
|
||||
return value; \
|
||||
name##ArgumentsType args(args_length, args_object); \
|
||||
return Builtin_Impl_##name(args, isolate); \
|
||||
} \
|
||||
\
|
||||
MUST_USE_RESULT static Object* Builtin_Impl_##name(name##ArgumentsType args, \
|
||||
@ -164,7 +168,6 @@ BUILTIN_LIST_C(DEF_ARG_TYPE)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
#define CHECK_RECEIVER(Type, name, method) \
|
||||
if (!args.receiver()->Is##Type()) { \
|
||||
THROW_NEW_ERROR_RETURN_FAILURE( \
|
||||
|
Loading…
Reference in New Issue
Block a user