[wasm] Add stack guard for logging code
Benchmarks or worker threads might never return to the event queue, hence they will never execute the scheduled foreground task to log compiled and published wasm code. This CL adds a stack guard to log the code, to ensure that we also log it for wasm code that never returns to the event queue. R=mstarzinger@chromium.org Bug: v8:9104 Change-Id: I176959cadb4ab3a60153d0717530c032272ad3e8 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1561073 Commit-Queue: Clemens Hammacher <clemensh@chromium.org> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> Cr-Commit-Position: refs/heads/master@{#60879}
This commit is contained in:
parent
e654b5d804
commit
067ba2a0c6
@ -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();
|
||||
|
@ -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); } \
|
||||
|
@ -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<WasmCode*> 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<NativeModule> WasmEngine::NewNativeModule(
|
||||
|
@ -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
|
||||
|
||||
##############################################################################
|
||||
|
Loading…
Reference in New Issue
Block a user