Commit 301b0560 authored by Thibaud Michaud's avatar Thibaud Michaud Committed by Commit Bot

[wasm] Sample EH event count at each event

The main thread isolate may live until the end of the process, in which
case we would not record the counts. Sample at each event instead.

R=ahaas@chromium.org

Bug: v8:8091
Change-Id: I5b1eb023e4ca5410c7d8f4212ff20410044bf4f2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2710433
Commit-Queue: Thibaud Michaud <thibaudm@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72947}
parent 7705ab1f
...@@ -91,8 +91,6 @@ namespace internal { ...@@ -91,8 +91,6 @@ namespace internal {
HR(wasm_rethrow_count, V8.WasmReThrowCount, 0, 100000, 30) \ HR(wasm_rethrow_count, V8.WasmReThrowCount, 0, 100000, 30) \
/* number of caught exceptions per isolate */ \ /* number of caught exceptions per isolate */ \
HR(wasm_catch_count, V8.WasmCatchCount, 0, 100000, 30) \ HR(wasm_catch_count, V8.WasmCatchCount, 0, 100000, 30) \
/* number of uncaught exceptions per isolate */ \
HR(wasm_uncaught_count, V8.WasmUncaughtCount, 0, 100000, 30) \
/* Ticks observed in a single Turbofan compilation, in 1K */ \ /* Ticks observed in a single Turbofan compilation, in 1K */ \
HR(turbofan_ticks, V8.TurboFan1KTicks, 0, 100000, 200) \ HR(turbofan_ticks, V8.TurboFan1KTicks, 0, 100000, 200) \
/* Backtracks observed in a single regexp interpreter execution */ \ /* Backtracks observed in a single regexp interpreter execution */ \
......
...@@ -1016,11 +1016,6 @@ void WasmEngine::RemoveIsolate(Isolate* isolate) { ...@@ -1016,11 +1016,6 @@ void WasmEngine::RemoveIsolate(Isolate* isolate) {
info->code_to_log.clear(); info->code_to_log.clear();
} }
DCHECK(info->code_to_log.empty()); DCHECK(info->code_to_log.empty());
isolate->counters()->wasm_throw_count()->AddSample(info->throw_count);
isolate->counters()->wasm_rethrow_count()->AddSample(info->rethrow_count);
isolate->counters()->wasm_catch_count()->AddSample(info->catch_count);
isolate->counters()->wasm_uncaught_count()->AddSample(
info->throw_count + info->rethrow_count - info->catch_count);
} }
void WasmEngine::LogCode(Vector<WasmCode*> code_vec) { void WasmEngine::LogCode(Vector<WasmCode*> code_vec) {
...@@ -1403,31 +1398,37 @@ void SampleExceptionEvent(base::ElapsedTimer* timer, TimedHistogram* counter) { ...@@ -1403,31 +1398,37 @@ void SampleExceptionEvent(base::ElapsedTimer* timer, TimedHistogram* counter) {
void WasmEngine::SampleThrowEvent(Isolate* isolate) { void WasmEngine::SampleThrowEvent(Isolate* isolate) {
base::MutexGuard guard(&mutex_); base::MutexGuard guard(&mutex_);
int& throw_count = isolates_[isolate]->throw_count; IsolateInfo* isolate_info = isolates_[isolate].get();
int& throw_count = isolate_info->throw_count;
// To avoid an int overflow, clip the count to the histogram's max value. // To avoid an int overflow, clip the count to the histogram's max value.
throw_count = throw_count =
std::min(throw_count + 1, isolate->counters()->wasm_throw_count()->max()); std::min(throw_count + 1, isolate->counters()->wasm_throw_count()->max());
SampleExceptionEvent(&isolates_[isolate]->throw_timer, isolate->counters()->wasm_throw_count()->AddSample(throw_count);
SampleExceptionEvent(&isolate_info->throw_timer,
isolate->counters()->wasm_time_between_throws()); isolate->counters()->wasm_time_between_throws());
} }
void WasmEngine::SampleRethrowEvent(Isolate* isolate) { void WasmEngine::SampleRethrowEvent(Isolate* isolate) {
base::MutexGuard guard(&mutex_); base::MutexGuard guard(&mutex_);
int& rethrow_count = isolates_[isolate]->rethrow_count; IsolateInfo* isolate_info = isolates_[isolate].get();
int& rethrow_count = isolate_info->rethrow_count;
// To avoid an int overflow, clip the count to the histogram's max value. // To avoid an int overflow, clip the count to the histogram's max value.
rethrow_count = std::min(rethrow_count + 1, rethrow_count = std::min(rethrow_count + 1,
isolate->counters()->wasm_rethrow_count()->max()); isolate->counters()->wasm_rethrow_count()->max());
SampleExceptionEvent(&isolates_[isolate]->rethrow_timer, isolate->counters()->wasm_rethrow_count()->AddSample(rethrow_count);
SampleExceptionEvent(&isolate_info->rethrow_timer,
isolate->counters()->wasm_time_between_rethrows()); isolate->counters()->wasm_time_between_rethrows());
} }
void WasmEngine::SampleCatchEvent(Isolate* isolate) { void WasmEngine::SampleCatchEvent(Isolate* isolate) {
base::MutexGuard guard(&mutex_); base::MutexGuard guard(&mutex_);
int& catch_count = isolates_[isolate]->catch_count; IsolateInfo* isolate_info = isolates_[isolate].get();
int& catch_count = isolate_info->catch_count;
// To avoid an int overflow, clip the count to the histogram's max value. // To avoid an int overflow, clip the count to the histogram's max value.
catch_count = catch_count =
std::min(catch_count + 1, isolate->counters()->wasm_catch_count()->max()); std::min(catch_count + 1, isolate->counters()->wasm_catch_count()->max());
SampleExceptionEvent(&isolates_[isolate]->catch_timer, isolate->counters()->wasm_catch_count()->AddSample(catch_count);
SampleExceptionEvent(&isolate_info->catch_timer,
isolate->counters()->wasm_time_between_catch()); isolate->counters()->wasm_time_between_catch());
} }
......
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