[wasm] Add a flag to output the generated code size
The output is once per module, and includes the size of relocation information. R=titzer@chromium.org Review-Url: https://codereview.chromium.org/1933513003 Cr-Commit-Position: refs/heads/master@{#35900}
This commit is contained in:
parent
1095835a61
commit
9763806ae6
@ -481,6 +481,8 @@ DEFINE_BOOL(enable_simd_asmjs, false, "enable SIMD.js in asm.js stdlib")
|
||||
|
||||
DEFINE_BOOL(dump_wasm_module, false, "dump WASM module bytes")
|
||||
DEFINE_STRING(dump_wasm_module_path, NULL, "directory to dump wasm modules to")
|
||||
DEFINE_BOOL(print_wasm_code_size, false,
|
||||
"print the generated code size for each wasm module")
|
||||
|
||||
DEFINE_INT(typed_array_max_size_in_heap, 64,
|
||||
"threshold for in-heap typed array")
|
||||
|
@ -413,6 +413,15 @@ MaybeHandle<JSObject> WasmModule::Instantiate(Isolate* isolate,
|
||||
PropertyDescriptor desc;
|
||||
desc.set_writable(false);
|
||||
|
||||
// If FLAG_print_wasm_code_size is set, this aggregates the sum of all code
|
||||
// objects created for this module.
|
||||
// TODO(titzer): switch this to TRACE_EVENT
|
||||
uint32_t total_code_size = 0;
|
||||
auto record_code_size = [&total_code_size](Code* code) {
|
||||
if (FLAG_print_wasm_code_size)
|
||||
total_code_size += code->body_size() + code->relocation_info()->length();
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Allocate the instance and its JS counterpart.
|
||||
//-------------------------------------------------------------------------
|
||||
@ -484,6 +493,7 @@ MaybeHandle<JSObject> WasmModule::Instantiate(Isolate* isolate,
|
||||
isolate, &module_env, function.ToHandleChecked(), import.sig,
|
||||
module_name, function_name);
|
||||
instance.import_code.push_back(code);
|
||||
record_code_size(*code);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
@ -556,12 +566,14 @@ MaybeHandle<JSObject> WasmModule::Instantiate(Isolate* isolate,
|
||||
if (func.exported) {
|
||||
function = compiler::CompileJSToWasmWrapper(
|
||||
isolate, &module_env, name, code, instance.js_object, i);
|
||||
record_code_size(function->code());
|
||||
}
|
||||
}
|
||||
if (!code.is_null()) {
|
||||
// Install the code into the linker table.
|
||||
linker.Finish(i, code);
|
||||
code_table->set(i, *code);
|
||||
record_code_size(*code);
|
||||
}
|
||||
if (func.exported) {
|
||||
// Exported functions are installed as read-only properties on the
|
||||
@ -601,6 +613,7 @@ MaybeHandle<JSObject> WasmModule::Instantiate(Isolate* isolate,
|
||||
Handle<JSFunction> function = compiler::CompileJSToWasmWrapper(
|
||||
isolate, &module_env, name, code, instance.js_object,
|
||||
exp.func_index);
|
||||
record_code_size(function->code());
|
||||
desc.set_value(function);
|
||||
Maybe<bool> status = JSReceiver::DefineOwnProperty(
|
||||
isolate, exports_object, name, &desc, Object::THROW_ON_ERROR);
|
||||
@ -617,6 +630,9 @@ MaybeHandle<JSObject> WasmModule::Instantiate(Isolate* isolate,
|
||||
}
|
||||
}
|
||||
|
||||
if (FLAG_print_wasm_code_size)
|
||||
printf("Total generated wasm code: %u bytes\n", total_code_size);
|
||||
|
||||
// Run the start function if one was specified.
|
||||
if (this->start_function_index >= 0) {
|
||||
HandleScope scope(isolate);
|
||||
|
Loading…
Reference in New Issue
Block a user