Commit fe0323d4 authored by Karl Schimpf's avatar Karl Schimpf Committed by Commit Bot

Fix counting number of functions in Wasm Modules

This CL moves the recording of the number of functions in a Wasm
module to the size read in the "functions" section of the module. The
advantage is that all modules read this section once, making it a good
target for collecting the data.

The previous code was also broken because in one code path, it did not
distinguish between asm.js and Wasm modules.

Bug: v8:6361
Change-Id: I6c49e91975c1730608e791036d15622d538bce77
Reviewed-on: https://chromium-review.googlesource.com/600837Reviewed-by: 's avatarBill Budge <bbudge@chromium.org>
Commit-Queue: Karl Schimpf <kschimpf@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47168}
parent 46c89e66
......@@ -576,10 +576,6 @@ MaybeHandle<WasmModuleObject> ModuleCompiler::CompileToModuleObjectInternal(
temp_instance->function_code[i] = init_builtin;
}
(module_->is_wasm() ? counters()->wasm_functions_per_wasm_module()
: counters()->wasm_functions_per_asm_module())
->AddSample(static_cast<int>(module_->functions.size()));
if (!lazy_compile) {
size_t funcs_to_compile =
module_->functions.size() - module_->num_imported_functions;
......@@ -2082,9 +2078,6 @@ class AsyncCompileJob::PrepareAndStartCompile : public CompileStep {
job_->temp_instance_->function_code[i] = illegal_builtin;
}
job_->counters()->wasm_functions_per_wasm_module()->AddSample(
static_cast<int>(module_->functions.size()));
// Transfer ownership of the {WasmModule} to the {ModuleCompiler}, but
// keep a pointer.
WasmModule* module = module_.get();
......
......@@ -503,6 +503,9 @@ class ModuleDecoder : public Decoder {
void DecodeFunctionSection() {
uint32_t functions_count =
consume_count("functions count", kV8MaxWasmFunctions);
(IsWasm() ? GetCounters()->wasm_functions_per_wasm_module()
: GetCounters()->wasm_functions_per_asm_module())
->AddSample(static_cast<int>(functions_count));
module_->functions.reserve(functions_count);
module_->num_declared_functions = functions_count;
for (uint32_t i = 0; ok() && i < functions_count; ++i) {
......
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