Reduce false-positives in profiler tick filtering

When collecting stack frame information during a profiler tick event, we
apply a filter on the instructions at the current pc to avoid collecting
(wrong) stack frames while a frame is being setup/torn down. While this
detection makes sense for compiled JavaScript code, it also filters out
ticks in the C++ code base of v8.

This change only applies the filter if the pc lies within a region that
could potentially contain compiled JavaScript code.

Change-Id: I8c8d8d70823abcdc2c5ae0ebf78a5198ec855a79
Reviewed-on: https://chromium-review.googlesource.com/912470
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Stephan Herhut <herhut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51238}
This commit is contained in:
Stephan Herhut 2018-02-12 10:24:56 +01:00 committed by Commit Bot
parent 713c5c8cd9
commit 7a76e6d36c

View File

@ -204,7 +204,12 @@ bool TickSample::GetStackSample(Isolate* v8_isolate, RegisterState* regs,
#endif
DCHECK(regs->sp);
if (regs->pc && IsNoFrameRegion(static_cast<i::Address>(regs->pc))) {
// Check whether we interrupted setup/teardown of a stack frame in JS code.
// Avoid this check for C++ code, as that would trigger false positives.
if (regs->pc &&
isolate->heap()->memory_allocator()->code_range()->contains(
static_cast<i::Address>(regs->pc)) &&
IsNoFrameRegion(static_cast<i::Address>(regs->pc))) {
// The frame is not setup, so it'd be hard to iterate the stack. Bailout.
return false;
}