Commit dba80657 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] Make {InstanceBuilder} use regular foreground counters.

R=clemensh@chromium.org

Change-Id: Ia5f1d52df1b2ebbe4ea4d38464fc59b0d128426d
Reviewed-on: https://chromium-review.googlesource.com/1119924Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54111}
parent 5863c0b6
...@@ -244,7 +244,6 @@ class InstanceBuilder { ...@@ -244,7 +244,6 @@ class InstanceBuilder {
Isolate* isolate_; Isolate* isolate_;
const WasmModule* const module_; const WasmModule* const module_;
const std::shared_ptr<Counters> async_counters_;
ErrorThrower* thrower_; ErrorThrower* thrower_;
Handle<WasmModuleObject> module_object_; Handle<WasmModuleObject> module_object_;
MaybeHandle<JSReceiver> ffi_; MaybeHandle<JSReceiver> ffi_;
...@@ -256,12 +255,6 @@ class InstanceBuilder { ...@@ -256,12 +255,6 @@ class InstanceBuilder {
JSToWasmWrapperCache js_to_wasm_cache_; JSToWasmWrapperCache js_to_wasm_cache_;
std::vector<SanitizedImport> sanitized_imports_; std::vector<SanitizedImport> sanitized_imports_;
const std::shared_ptr<Counters>& async_counters() const {
return async_counters_;
}
Counters* counters() const { return async_counters().get(); }
wasm::UseTrapHandler use_trap_handler() const { wasm::UseTrapHandler use_trap_handler() const {
return module_object_->native_module()->use_trap_handler() ? kUseTrapHandler return module_object_->native_module()->use_trap_handler() ? kUseTrapHandler
: kNoTrapHandler; : kNoTrapHandler;
...@@ -799,7 +792,7 @@ void CompileNativeModule(Isolate* isolate, ErrorThrower* thrower, ...@@ -799,7 +792,7 @@ void CompileNativeModule(Isolate* isolate, ErrorThrower* thrower,
} }
if (thrower->error()) return; if (thrower->error()) return;
RecordStats(native_module, isolate->async_counters().get()); RecordStats(native_module, isolate->counters());
} }
} }
...@@ -918,9 +911,8 @@ MaybeHandle<WasmModuleObject> CompileToModuleObject( ...@@ -918,9 +911,8 @@ MaybeHandle<WasmModuleObject> CompileToModuleObject(
Handle<Script> asm_js_script, Handle<Script> asm_js_script,
Vector<const byte> asm_js_offset_table_bytes) { Vector<const byte> asm_js_offset_table_bytes) {
const WasmModule* wasm_module = module.get(); const WasmModule* wasm_module = module.get();
TimedHistogramScope wasm_compile_module_time_scope( TimedHistogramScope wasm_compile_module_time_scope(SELECT_WASM_COUNTER(
SELECT_WASM_COUNTER(isolate->async_counters(), wasm_module->origin, isolate->counters(), wasm_module->origin, wasm_compile, module_time));
wasm_compile, module_time));
// TODO(6792): No longer needed once WebAssembly code is off heap. Use // TODO(6792): No longer needed once WebAssembly code is off heap. Use
// base::Optional to be able to close the scope before notifying the debugger. // base::Optional to be able to close the scope before notifying the debugger.
base::Optional<CodeSpaceMemoryModificationScope> modification_scope( base::Optional<CodeSpaceMemoryModificationScope> modification_scope(
...@@ -971,8 +963,7 @@ MaybeHandle<WasmModuleObject> CompileToModuleObject( ...@@ -971,8 +963,7 @@ MaybeHandle<WasmModuleObject> CompileToModuleObject(
if (thrower->error()) return {}; if (thrower->error()) return {};
// Compile JS->wasm wrappers for exported functions. // Compile JS->wasm wrappers for exported functions.
CompileJsToWasmWrappers(isolate, module_object, CompileJsToWasmWrappers(isolate, module_object);
isolate->async_counters().get());
// If we created a wasm script, finish it now and make it public to the // If we created a wasm script, finish it now and make it public to the
// debugger. // debugger.
...@@ -995,7 +986,6 @@ InstanceBuilder::InstanceBuilder(Isolate* isolate, ErrorThrower* thrower, ...@@ -995,7 +986,6 @@ InstanceBuilder::InstanceBuilder(Isolate* isolate, ErrorThrower* thrower,
MaybeHandle<JSArrayBuffer> memory) MaybeHandle<JSArrayBuffer> memory)
: isolate_(isolate), : isolate_(isolate),
module_(module_object->module()), module_(module_object->module()),
async_counters_(isolate->async_counters()),
thrower_(thrower), thrower_(thrower),
module_object_(module_object), module_object_(module_object),
ffi_(ffi), ffi_(ffi),
...@@ -1022,7 +1012,7 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() { ...@@ -1022,7 +1012,7 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() {
DisallowJavascriptExecution no_js(isolate_); DisallowJavascriptExecution no_js(isolate_);
// Record build time into correct bucket, then build instance. // Record build time into correct bucket, then build instance.
TimedHistogramScope wasm_instantiate_module_time_scope(SELECT_WASM_COUNTER( TimedHistogramScope wasm_instantiate_module_time_scope(SELECT_WASM_COUNTER(
counters(), module_->origin, wasm_instantiate, module_time)); isolate_->counters(), module_->origin, wasm_instantiate, module_time));
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// Allocate the memory array buffer. // Allocate the memory array buffer.
...@@ -1030,8 +1020,8 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() { ...@@ -1030,8 +1020,8 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() {
// We allocate the memory buffer before cloning or reusing the compiled module // We allocate the memory buffer before cloning or reusing the compiled module
// so we will know whether we need to recompile with bounds checks. // so we will know whether we need to recompile with bounds checks.
uint32_t initial_pages = module_->initial_pages; uint32_t initial_pages = module_->initial_pages;
auto initial_pages_counter = SELECT_WASM_COUNTER(counters(), module_->origin, auto initial_pages_counter = SELECT_WASM_COUNTER(
wasm, min_mem_pages_count); isolate_->counters(), module_->origin, wasm, min_mem_pages_count);
initial_pages_counter->AddSample(initial_pages); initial_pages_counter->AddSample(initial_pages);
// Asm.js has memory_ already set at this point, so we don't want to // Asm.js has memory_ already set at this point, so we don't want to
// overwrite it. // overwrite it.
...@@ -1582,7 +1572,7 @@ int InstanceBuilder::ProcessImports(Handle<WasmInstanceObject> instance) { ...@@ -1582,7 +1572,7 @@ int InstanceBuilder::ProcessImports(Handle<WasmInstanceObject> instance) {
isolate_, js_receiver, expected_sig, func_index, isolate_, js_receiver, expected_sig, func_index,
module_->origin, use_trap_handler()) module_->origin, use_trap_handler())
.ToHandleChecked(); .ToHandleChecked();
RecordStats(*wrapper_code, counters()); RecordStats(*wrapper_code, isolate_->counters());
WasmCode* wasm_code = native_module->AddCodeCopy( WasmCode* wasm_code = native_module->AddCodeCopy(
wrapper_code, wasm::WasmCode::kWasmToJsWrapper, func_index); wrapper_code, wasm::WasmCode::kWasmToJsWrapper, func_index);
...@@ -2599,8 +2589,7 @@ class AsyncCompileJob::CompileWrappers : public CompileStep { ...@@ -2599,8 +2589,7 @@ class AsyncCompileJob::CompileWrappers : public CompileStep {
// TODO(6792): No longer needed once WebAssembly code is off heap. // TODO(6792): No longer needed once WebAssembly code is off heap.
CodeSpaceMemoryModificationScope modification_scope(job_->isolate_->heap()); CodeSpaceMemoryModificationScope modification_scope(job_->isolate_->heap());
// Compile JS->wasm wrappers for exported functions. // Compile JS->wasm wrappers for exported functions.
CompileJsToWasmWrappers(job_->isolate_, job_->module_object_, CompileJsToWasmWrappers(job_->isolate_, job_->module_object_);
job_->counters());
job_->DoSync<FinishModule>(); job_->DoSync<FinishModule>();
} }
}; };
...@@ -3066,8 +3055,7 @@ void CompilationState::NotifyOnEvent(CompilationEvent event, ...@@ -3066,8 +3055,7 @@ void CompilationState::NotifyOnEvent(CompilationEvent event,
} }
void CompileJsToWasmWrappers(Isolate* isolate, void CompileJsToWasmWrappers(Isolate* isolate,
Handle<WasmModuleObject> module_object, Handle<WasmModuleObject> module_object) {
Counters* counters) {
JSToWasmWrapperCache js_to_wasm_cache; JSToWasmWrapperCache js_to_wasm_cache;
int wrapper_index = 0; int wrapper_index = 0;
Handle<FixedArray> export_wrappers(module_object->export_wrappers(), isolate); Handle<FixedArray> export_wrappers(module_object->export_wrappers(), isolate);
...@@ -3084,7 +3072,7 @@ void CompileJsToWasmWrappers(Isolate* isolate, ...@@ -3084,7 +3072,7 @@ void CompileJsToWasmWrappers(Isolate* isolate,
Handle<Code> wrapper_code = js_to_wasm_cache.CloneOrCompileJSToWasmWrapper( Handle<Code> wrapper_code = js_to_wasm_cache.CloneOrCompileJSToWasmWrapper(
isolate, module, call_target, exp.index, use_trap_handler); isolate, module, call_target, exp.index, use_trap_handler);
export_wrappers->set(wrapper_index, *wrapper_code); export_wrappers->set(wrapper_index, *wrapper_code);
RecordStats(*wrapper_code, counters); RecordStats(*wrapper_code, isolate->counters());
++wrapper_index; ++wrapper_index;
} }
} }
......
...@@ -59,8 +59,7 @@ MaybeHandle<WasmInstanceObject> InstantiateToInstanceObject( ...@@ -59,8 +59,7 @@ MaybeHandle<WasmInstanceObject> InstantiateToInstanceObject(
V8_EXPORT_PRIVATE V8_EXPORT_PRIVATE
void CompileJsToWasmWrappers(Isolate* isolate, void CompileJsToWasmWrappers(Isolate* isolate,
Handle<WasmModuleObject> module_object, Handle<WasmModuleObject> module_object);
Counters* counters);
V8_EXPORT_PRIVATE Handle<Script> CreateWasmScript( V8_EXPORT_PRIVATE Handle<Script> CreateWasmScript(
Isolate* isolate, const ModuleWireBytes& wire_bytes); Isolate* isolate, const ModuleWireBytes& wire_bytes);
......
...@@ -552,7 +552,7 @@ MaybeHandle<WasmModuleObject> DeserializeNativeModule( ...@@ -552,7 +552,7 @@ MaybeHandle<WasmModuleObject> DeserializeNativeModule(
// requires unlocking the code space here. This should eventually be moved // requires unlocking the code space here. This should eventually be moved
// into the allocator. // into the allocator.
CodeSpaceMemoryModificationScope modification_scope(isolate->heap()); CodeSpaceMemoryModificationScope modification_scope(isolate->heap());
CompileJsToWasmWrappers(isolate, module_object, isolate->counters()); CompileJsToWasmWrappers(isolate, module_object);
// Log the code within the generated module for profiling. // Log the code within the generated module for profiling.
native_module->LogWasmCodes(isolate); native_module->LogWasmCodes(isolate);
......
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