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

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

Issue 2130293002: [wasm] Make print_wasm_code_size into a regular V8 counter. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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 68254a125576f734d0181117cbfcacee22d6e1a0..a58269657a935aa82a13339d987fdb4b814048e8 100644
--- a/src/wasm/wasm-module.cc
+++ b/src/wasm/wasm-module.cc
@@ -546,43 +546,23 @@ class WasmCompilationTask : public CancelableTask {
base::AtomicNumber<size_t>* next_unit_;
};
-// Records statistics on the code generated by compiling WASM functions.
-struct CodeStats {
- size_t code_size;
- size_t reloc_size;
-
- inline CodeStats() : code_size(0), reloc_size(0) {}
-
- inline void Record(Code* code) {
- if (FLAG_print_wasm_code_size) {
- code_size += code->body_size();
- reloc_size += code->relocation_info()->length();
- }
- }
-
- void Record(const std::vector<Handle<Code>>& functions) {
- if (FLAG_print_wasm_code_size) {
- for (Handle<Code> c : functions) Record(*c);
- }
- }
+static void RecordStats(Isolate* isolate, Code* code) {
+ isolate->counters()->wasm_generated_code_size()->Increment(code->body_size());
+ isolate->counters()->wasm_reloc_size()->Increment(
+ code->relocation_info()->length());
+}
- void Record(Handle<FixedArray> functions) {
- if (FLAG_print_wasm_code_size) {
- DisallowHeapAllocation no_gc;
- for (int i = 0; i < functions->length(); ++i) {
- Code* code = Code::cast(functions->get(i));
- Record(code);
- }
- }
- }
+static void RecordStats(Isolate* isolate,
+ const std::vector<Handle<Code>>& functions) {
+ for (Handle<Code> c : functions) RecordStats(isolate, *c);
+}
- inline void Report() {
- if (FLAG_print_wasm_code_size) {
- PrintF("Total generated wasm code: %zu bytes\n", code_size);
- PrintF("Total generated wasm reloc: %zu bytes\n", reloc_size);
- }
+static void RecordStats(Isolate* isolate, Handle<FixedArray> functions) {
+ DisallowHeapAllocation no_gc;
+ for (int i = 0; i < functions->length(); ++i) {
+ RecordStats(isolate, Code::cast(functions->get(i)));
}
-};
+}
Handle<FixedArray> GetImportsMetadata(Factory* factory,
const WasmModule* module) {
@@ -914,7 +894,7 @@ bool SetupInstanceHeap(Isolate* isolate, Handle<FixedArray> compiled_module,
bool SetupImports(Isolate* isolate, Handle<FixedArray> compiled_module,
Handle<JSObject> instance, ErrorThrower* thrower,
- Handle<JSReceiver> ffi, CodeStats* stats) {
+ Handle<JSReceiver> ffi) {
//-------------------------------------------------------------------------
// Compile wrappers to imported functions.
//-------------------------------------------------------------------------
@@ -929,7 +909,7 @@ bool SetupImports(Isolate* isolate, Handle<FixedArray> compiled_module,
}
}
- stats->Record(import_code);
+ RecordStats(isolate, import_code);
Handle<FixedArray> code_table = Handle<FixedArray>(
FixedArray::cast(instance->GetInternalField(kWasmModuleCodeTable)));
@@ -947,8 +927,7 @@ bool SetupImports(Isolate* isolate, Handle<FixedArray> compiled_module,
}
bool SetupExportsObject(Handle<FixedArray> compiled_module, Isolate* isolate,
- Handle<JSObject> instance, ErrorThrower* thrower,
- CodeStats* stats) {
+ Handle<JSObject> instance, ErrorThrower* thrower) {
Factory* factory = isolate->factory();
bool mem_export =
static_cast<bool>(Smi::cast(compiled_module->get(kExportMem))->value());
@@ -977,7 +956,7 @@ bool SetupExportsObject(Handle<FixedArray> compiled_module, Isolate* isolate,
for (int i = 0; i < exports_size; ++i) {
if (thrower->error()) return false;
Handle<JSFunction> function = exports->GetValueChecked<JSFunction>(i);
- stats->Record(function->code());
+ RecordStats(isolate, function->code());
Handle<String> name =
Handle<String>(String::cast(function->shared()->name()));
function->SetInternalField(0, *instance);
@@ -1143,12 +1122,11 @@ MaybeHandle<JSObject> WasmModule::Instantiate(
ErrorThrower thrower(isolate, "WasmModule::Instantiate()");
Factory* factory = isolate->factory();
- CodeStats code_stats;
// These fields are compulsory.
Handle<FixedArray> code_table =
compiled_module->GetValueChecked<FixedArray>(kFunctions);
- code_stats.Record(code_table);
+ RecordStats(isolate, code_table);
MaybeHandle<JSObject> nothing;
@@ -1161,10 +1139,8 @@ MaybeHandle<JSObject> WasmModule::Instantiate(
if (!(SetupInstanceHeap(isolate, compiled_module, js_object, memory,
&thrower) &&
SetupGlobals(isolate, compiled_module, js_object, &thrower) &&
- SetupImports(isolate, compiled_module, js_object, &thrower, ffi,
- &code_stats) &&
- SetupExportsObject(compiled_module, isolate, js_object, &thrower,
- &code_stats))) {
+ SetupImports(isolate, compiled_module, js_object, &thrower, ffi) &&
+ SetupExportsObject(compiled_module, isolate, js_object, &thrower))) {
return nothing;
}
@@ -1176,7 +1152,7 @@ MaybeHandle<JSObject> WasmModule::Instantiate(
if (!maybe_startup_fct.is_null()) {
HandleScope scope(isolate);
Handle<JSFunction> startup_fct = maybe_startup_fct.ToHandleChecked();
- code_stats.Record(startup_fct->code());
+ RecordStats(isolate, startup_fct->code());
startup_fct->SetInternalField(0, *js_object);
// Call the JS function.
Handle<Object> undefined = isolate->factory()->undefined_value();
@@ -1189,8 +1165,6 @@ MaybeHandle<JSObject> WasmModule::Instantiate(
}
}
- code_stats.Report();
-
DCHECK(wasm::IsWasmObject(*js_object));
return js_object;
}
« 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