diff --git a/src/execution.cc b/src/execution.cc index 38b88c1293..187ec46479 100644 --- a/src/execution.cc +++ b/src/execution.cc @@ -11,6 +11,7 @@ #include "src/isolate-inl.h" #include "src/runtime-profiler.h" #include "src/vm-state-inl.h" +#include "src/wasm/wasm-engine.h" namespace v8 { namespace internal { @@ -655,10 +656,15 @@ Object StackGuard::HandleInterrupts() { if (CheckAndClearInterrupt(API_INTERRUPT)) { TRACE_EVENT0("v8.execute", "V8.InvokeApiInterruptCallbacks"); - // Callbacks must be invoked outside of ExecusionAccess lock. + // Callbacks must be invoked outside of ExecutionAccess lock. isolate_->InvokeApiInterruptCallbacks(); } + if (CheckAndClearInterrupt(LOG_WASM_CODE)) { + TRACE_EVENT0("v8.wasm", "LogCode"); + isolate_->wasm_engine()->LogOutstandingCodesForIsolate(isolate_); + } + isolate_->counters()->stack_interrupts()->Increment(); isolate_->counters()->runtime_profiler_ticks()->Increment(); isolate_->runtime_profiler()->MarkCandidatesForOptimization(); diff --git a/src/execution.h b/src/execution.h index 0bac82da3d..5f7bc5e788 100644 --- a/src/execution.h +++ b/src/execution.h @@ -96,7 +96,8 @@ class V8_EXPORT_PRIVATE StackGuard final { V(INSTALL_CODE, InstallCode, 2) \ V(API_INTERRUPT, ApiInterrupt, 3) \ V(DEOPT_MARKED_ALLOCATION_SITES, DeoptMarkedAllocationSites, 4) \ - V(GROW_SHARED_MEMORY, GrowSharedMemory, 5) + V(GROW_SHARED_MEMORY, GrowSharedMemory, 5) \ + V(LOG_WASM_CODE, LogWasmCode, 6) #define V(NAME, Name, id) \ inline bool Check##Name() { return CheckInterrupt(NAME); } \ diff --git a/src/wasm/wasm-engine.cc b/src/wasm/wasm-engine.cc index 48a5e57eb5..dd29e9cf96 100644 --- a/src/wasm/wasm-engine.cc +++ b/src/wasm/wasm-engine.cc @@ -548,6 +548,7 @@ void WasmEngine::LogCode(WasmCode* code) { &mutex_, &info->log_codes_task, isolate, this); info->log_codes_task = new_task.get(); info->foreground_task_runner->PostTask(std::move(new_task)); + isolate->stack_guard()->RequestLogWasmCode(); } info->code_to_log.push_back(code); code->IncRef(); @@ -565,15 +566,19 @@ void WasmEngine::LogOutstandingCodesForIsolate(Isolate* isolate) { // If by now we should not log code any more, do not log it. if (!WasmCode::ShouldBeLogged(isolate)) return; - base::MutexGuard guard(&mutex_); - DCHECK_EQ(1, isolates_.count(isolate)); - IsolateInfo* info = isolates_[isolate].get(); - if (info->code_to_log.empty()) return; - for (WasmCode* code : info->code_to_log) { + // Under the mutex, get the vector of wasm code to log. Then log and decrement + // the ref count without holding the mutex. + std::vector code_to_log; + { + base::MutexGuard guard(&mutex_); + DCHECK_EQ(1, isolates_.count(isolate)); + code_to_log.swap(isolates_[isolate]->code_to_log); + } + if (code_to_log.empty()) return; + for (WasmCode* code : code_to_log) { code->LogCode(isolate); } - WasmCode::DecrementRefCount(VectorOf(info->code_to_log)); - info->code_to_log.clear(); + WasmCode::DecrementRefCount(VectorOf(code_to_log)); } std::shared_ptr WasmEngine::NewNativeModule( diff --git a/test/inspector/inspector.status b/test/inspector/inspector.status index 12f4370346..2e37f2126f 100644 --- a/test/inspector/inspector.status +++ b/test/inspector/inspector.status @@ -14,9 +14,6 @@ # Bad OOM timing on noembed builds (https://crbug.com/v8/8494). 'debugger/pause-on-oom': [PASS, ['embedded_builtins == False', SKIP]], - - # https://crbug.com/v8/9104 - 'cpu-profiler/console-profile-wasm': [SKIP], }], # ALWAYS ##############################################################################