Commit 57af86a1 authored by Eric Holk's avatar Eric Holk Committed by Commit Bot

[wasm] Add counter for time spent executing Wasm

Bug: v8:6514
Change-Id: Ifda1b80a80fc0b077e982005d9493e0fe7ced471
Reviewed-on: https://chromium-review.googlesource.com/599021Reviewed-by: 's avatarBrad Nelson <bradnelson@chromium.org>
Commit-Queue: Eric Holk <eholk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47176}
parent 51fa1d91
......@@ -2989,6 +2989,10 @@ void WasmGraphBuilder::EnsureFunctionTableNodes() {
Node* WasmGraphBuilder::BuildModifyThreadInWasmFlag(bool new_value) {
// TODO(eholk): generate code to modify the thread-local storage directly,
// rather than calling the runtime.
//
// Note that the runtime functions also toggle the wasm_execution_time
// counters. Make sure this behavior is preserved if we avoid the runtime
// call.
if (!trap_handler::UseTrapHandler()) {
return *control_;
}
......
......@@ -1062,6 +1062,8 @@ class RuntimeCallTimerScope {
HT(asm_wasm_translation_time, V8.AsmWasmTranslationMicroSeconds, 1000000, \
MICROSECOND) \
HT(wasm_lazy_compilation_time, V8.WasmLazyCompilationMicroSeconds, 1000000, \
MICROSECOND) \
HT(wasm_execution_time, V8.WasmExecutionTimeMicroSeconds, 10000000, \
MICROSECOND)
#define TIMED_HISTOGRAM_LIST(HT) \
......
......@@ -1224,8 +1224,10 @@ Object* Isolate::UnwindAndFindHandler() {
trap_handler::ClearThreadInWasm();
}
if (!FLAG_experimental_wasm_eh || !is_catchable_by_wasm(exception))
if (!FLAG_experimental_wasm_eh || !is_catchable_by_wasm(exception)) {
counters()->wasm_execution_time()->Stop();
break;
}
int stack_slots = 0; // Will contain stack slot count of frame.
WasmCompiledFrame* wasm_frame = static_cast<WasmCompiledFrame*>(frame);
int offset = wasm_frame->LookupExceptionHandlerInTable(&stack_slots);
......
......@@ -180,11 +180,17 @@ RUNTIME_FUNCTION(Runtime_WasmSetCaughtExceptionValue) {
RUNTIME_FUNCTION(Runtime_SetThreadInWasm) {
trap_handler::SetThreadInWasm();
if (!isolate->counters()->wasm_execution_time()->Running()) {
isolate->counters()->wasm_execution_time()->Start();
}
return isolate->heap()->undefined_value();
}
RUNTIME_FUNCTION(Runtime_ClearThreadInWasm) {
trap_handler::ClearThreadInWasm();
if (isolate->counters()->wasm_execution_time()->Running()) {
isolate->counters()->wasm_execution_time()->Stop();
}
return isolate->heap()->undefined_value();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment