Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1101)

Unified Diff: src/wasm/wasm-module.cc

Issue 1933513003: [wasm] Add a flag to output the generated code size (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: add TODO and switch to uint32_t Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/flag-definitions.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/wasm-module.cc
diff --git a/src/wasm/wasm-module.cc b/src/wasm/wasm-module.cc
index eef5f8e86bb913484cdefd802fd53018ab554ff1..a02bb2a3c32796b8e4ee758345df288674502c44 100644
--- a/src/wasm/wasm-module.cc
+++ b/src/wasm/wasm-module.cc
@@ -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);
« no previous file with comments | « src/flag-definitions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698