Commit c1994e68 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] Record stats for each code individually.

This changes recording of compilation stats (i.e. code and reloc info
size) for each code object individually after it is finished, instead of
for the entire module. It avoids needed to iterate the code table which
would race with background tasks performing tier-up.

R=clemensh@chromium.org

Change-Id: Ic196fccb38b069a07e79fed4633d01dfc2639cd7
Reviewed-on: https://chromium-review.googlesource.com/1156396
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54816}
parent 4a339958
......@@ -15,6 +15,7 @@ namespace internal {
namespace wasm {
namespace {
const char* GetCompilationModeAsString(
WasmCompilationUnit::CompilationMode mode) {
switch (mode) {
......@@ -25,6 +26,14 @@ const char* GetCompilationModeAsString(
}
UNREACHABLE();
}
void RecordStats(const wasm::WasmCode* code, Counters* counters) {
counters->wasm_generated_code_size()->Increment(
static_cast<int>(code->instructions().size()));
counters->wasm_reloc_size()->Increment(
static_cast<int>(code->reloc_info().size()));
}
} // namespace
// static
......@@ -103,6 +112,8 @@ wasm::WasmCode* WasmCompilationUnit::FinishCompilation(
}
if (ret == nullptr) {
thrower->RuntimeError("Error finalizing code.");
} else {
RecordStats(ret, counters_);
}
return ret;
}
......
......@@ -379,11 +379,6 @@ wasm::WasmCode* LazyCompileFunction(Isolate* isolate,
auto counters = isolate->counters();
counters->wasm_lazily_compiled_functions()->Increment();
counters->wasm_generated_code_size()->Increment(
static_cast<int>(wasm_code->instructions().size()));
counters->wasm_reloc_size()->Increment(
static_cast<int>(wasm_code->reloc_info().size()));
counters->wasm_lazy_compilation_throughput()->AddSample(
compilation_time != 0 ? static_cast<int>(func_size / compilation_time)
: 0);
......@@ -423,22 +418,6 @@ void RecordStats(const Code* code, Counters* counters) {
counters->wasm_reloc_size()->Increment(code->relocation_info()->length());
}
void RecordStats(const wasm::WasmCode* code, Counters* counters) {
counters->wasm_generated_code_size()->Increment(
static_cast<int>(code->instructions().size()));
counters->wasm_reloc_size()->Increment(
static_cast<int>(code->reloc_info().size()));
}
void RecordStats(const wasm::NativeModule* native_module, Counters* counters) {
for (uint32_t i = native_module->num_imported_functions(),
e = native_module->num_functions();
i < e; ++i) {
const wasm::WasmCode* code = native_module->code(i);
if (code != nullptr) RecordStats(code, counters);
}
}
bool in_bounds(uint32_t offset, size_t size, size_t upper) {
return offset + size <= upper && offset + size >= offset;
}
......@@ -753,8 +732,6 @@ void CompileNativeModule(Isolate* isolate, ErrorThrower* thrower,
CompileSequentially(isolate, native_module, env, thrower);
}
if (thrower->error()) return;
RecordStats(native_module, isolate->counters());
}
}
......@@ -817,10 +794,6 @@ class FinishCompileTask : public CancelableTask {
DCHECK(!result->is_liftoff());
if (wasm::WasmCode::ShouldBeLogged(isolate)) result->LogCode(isolate);
// Update the counters to include the top-tier code.
RecordStats(result,
compilation_state_->isolate()->async_counters().get());
}
// Update the compilation state, and possibly notify
......@@ -2204,8 +2177,6 @@ AsyncCompileJob::~AsyncCompileJob() {
}
void AsyncCompileJob::FinishCompile() {
RecordStats(native_module_, counters());
// Finish the wasm script now and make it public to the debugger.
Handle<Script> script(module_object_->script(), isolate_);
isolate_->debug()->OnAfterCompile(script);
......
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