Make sure function size UMA stat is collected.
This fixes the collection of function sizes (see comment #1 of v8:6361). This was done by adding a wrapper function around VerifyWasmCode() that updates UMA stats for function size (as well as decode time when validating). Bug: v8:6361 Change-Id: Ia2597db22cbed5b0429d9c8514e96cdea5d7323a Reviewed-on: https://chromium-review.googlesource.com/600530 Commit-Queue: Karl Schimpf <kschimpf@chromium.org> Reviewed-by: Bill Budge <bbudge@chromium.org> Cr-Commit-Position: refs/heads/master@{#47147}
This commit is contained in:
parent
c6b8b4b56c
commit
8b865c8db4
@ -2184,6 +2184,21 @@ DecodeResult VerifyWasmCode(AccountingAllocator* allocator,
|
||||
return decoder.toResult(nullptr);
|
||||
}
|
||||
|
||||
DecodeResult VerifyWasmCodeWithStats(AccountingAllocator* allocator,
|
||||
const wasm::WasmModule* module,
|
||||
FunctionBody& body, bool is_wasm,
|
||||
Counters* counters) {
|
||||
auto size_histogram = is_wasm ? counters->wasm_wasm_function_size_bytes()
|
||||
: counters->wasm_asm_function_size_bytes();
|
||||
// TODO(bradnelson): Improve histogram handling of ptrdiff_t.
|
||||
CHECK((body.end - body.start) >= 0);
|
||||
size_histogram->AddSample(static_cast<int>(body.end - body.start));
|
||||
auto time_counter = is_wasm ? counters->wasm_decode_wasm_function_time()
|
||||
: counters->wasm_decode_asm_function_time();
|
||||
TimedHistogramScope wasm_decode_function_time_scope(time_counter);
|
||||
return VerifyWasmCode(allocator, module, body);
|
||||
}
|
||||
|
||||
DecodeResult BuildTFGraph(AccountingAllocator* allocator, TFBuilder* builder,
|
||||
FunctionBody& body) {
|
||||
Zone zone(allocator, ZONE_NAME);
|
||||
|
@ -17,6 +17,7 @@ namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
class BitVector; // forward declaration
|
||||
class Counters;
|
||||
|
||||
namespace compiler { // external declarations from compiler.
|
||||
class WasmGraphBuilder;
|
||||
@ -49,6 +50,14 @@ using DecodeResult = Result<std::nullptr_t>;
|
||||
V8_EXPORT_PRIVATE DecodeResult VerifyWasmCode(AccountingAllocator* allocator,
|
||||
const wasm::WasmModule* module,
|
||||
FunctionBody& body);
|
||||
|
||||
// Note: If run in the background thread, must follow protocol using
|
||||
// isolate::async_counters() to guarantee usability of counters argument.
|
||||
DecodeResult VerifyWasmCodeWithStats(AccountingAllocator* allocator,
|
||||
const wasm::WasmModule* module,
|
||||
FunctionBody& body, bool is_wasm,
|
||||
Counters* counters);
|
||||
|
||||
DecodeResult BuildTFGraph(AccountingAllocator* allocator, TFBuilder* builder,
|
||||
FunctionBody& body);
|
||||
bool PrintRawWasmCode(AccountingAllocator* allocator, const FunctionBody& body,
|
||||
|
@ -311,15 +311,9 @@ void ModuleCompiler::ValidateSequentially(ModuleBytesEnv* module_env,
|
||||
const byte* base = module_env->wire_bytes.start();
|
||||
FunctionBody body{func.sig, func.code.offset(), base + func.code.offset(),
|
||||
base + func.code.end_offset()};
|
||||
DecodeResult result;
|
||||
{
|
||||
auto time_counter = module->is_wasm()
|
||||
? counters()->wasm_decode_wasm_function_time()
|
||||
: counters()->wasm_decode_asm_function_time();
|
||||
TimedHistogramScope wasm_decode_function_time_scope(time_counter);
|
||||
result = VerifyWasmCode(isolate_->allocator(),
|
||||
module_env->module_env.module, body);
|
||||
}
|
||||
DecodeResult result = VerifyWasmCodeWithStats(
|
||||
isolate_->allocator(), module_env->module_env.module, body,
|
||||
module->is_wasm(), counters());
|
||||
if (result.failed()) {
|
||||
WasmName str = module_env->wire_bytes.GetName(&func);
|
||||
thrower->CompileError("Compiling function #%d:%.*s failed: %s @+%u", i,
|
||||
|
@ -702,11 +702,6 @@ class ModuleDecoder : public Decoder {
|
||||
for (uint32_t i = 0; i < functions_count; ++i) {
|
||||
uint32_t size = consume_u32v("body size");
|
||||
uint32_t offset = pc_offset();
|
||||
auto size_histogram = IsWasm()
|
||||
? GetCounters()->wasm_wasm_function_size_bytes()
|
||||
: GetCounters()->wasm_asm_function_size_bytes();
|
||||
// TODO(bradnelson): Improve histogram handling of size_t.
|
||||
size_histogram->AddSample(static_cast<int>(size));
|
||||
consume_bytes(size, "function body");
|
||||
if (failed()) break;
|
||||
WasmFunction* function =
|
||||
@ -1014,15 +1009,9 @@ class ModuleDecoder : public Decoder {
|
||||
function->sig, function->code.offset(),
|
||||
start_ + GetBufferRelativeOffset(function->code.offset()),
|
||||
start_ + GetBufferRelativeOffset(function->code.end_offset())};
|
||||
DecodeResult result;
|
||||
{
|
||||
auto time_counter = IsWasm()
|
||||
? GetCounters()->wasm_decode_wasm_function_time()
|
||||
: GetCounters()->wasm_decode_asm_function_time();
|
||||
TimedHistogramScope wasm_decode_function_time_scope(time_counter);
|
||||
result = VerifyWasmCode(
|
||||
allocator, menv == nullptr ? nullptr : menv->module_env.module, body);
|
||||
}
|
||||
DecodeResult result = VerifyWasmCodeWithStats(
|
||||
allocator, menv == nullptr ? nullptr : menv->module_env.module, body,
|
||||
IsWasm(), GetCounters());
|
||||
if (result.failed()) {
|
||||
// Wrap the error message from the function decoder.
|
||||
std::ostringstream wrapped;
|
||||
|
Loading…
Reference in New Issue
Block a user