Collect a single frame sample in the profiler if we can't validate stack boundaries

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1837023003 .
This commit is contained in:
John McCutchan 2016-03-29 10:46:41 -07:00
parent 5cee7ff634
commit 35773929e4
2 changed files with 35 additions and 4 deletions

View file

@ -945,6 +945,32 @@ void Profiler::SampleAllocation(Thread* thread, intptr_t cid) {
}
void Profiler::SampleThreadSingleFrame(Thread* thread, uintptr_t pc) {
ASSERT(thread != NULL);
OSThread* os_thread = thread->os_thread();
ASSERT(os_thread != NULL);
Isolate* isolate = thread->isolate();
SampleBuffer* sample_buffer = Profiler::sample_buffer();
if (sample_buffer == NULL) {
// Profiler not initialized.
return;
}
// Setup sample.
Sample* sample = SetupSample(thread, sample_buffer, os_thread->trace_id());
// Increment counter for vm tag.
VMTagCounters* counters = isolate->vm_tag_counters();
ASSERT(counters != NULL);
if (thread->IsMutatorThread()) {
counters->Increment(sample->vm_tag());
}
// Write the single pc value.
sample->SetAt(0, pc);
}
void Profiler::SampleThread(Thread* thread,
const InterruptedThreadState& state) {
ASSERT(thread != NULL);
@ -989,15 +1015,17 @@ void Profiler::SampleThread(Thread* thread,
sp = state.csp;
}
if (!InitialRegisterCheck(pc, fp, sp)) {
return;
}
if (!CheckIsolate(isolate)) {
return;
}
if (thread->IsMutatorThread() && isolate->IsDeoptimizing()) {
SampleThreadSingleFrame(thread, pc);
return;
}
if (!InitialRegisterCheck(pc, fp, sp)) {
SampleThreadSingleFrame(thread, pc);
return;
}
@ -1009,6 +1037,7 @@ void Profiler::SampleThread(Thread* thread,
&stack_lower,
&stack_upper)) {
// Could not get stack boundary.
SampleThreadSingleFrame(thread, pc);
return;
}

View file

@ -53,6 +53,8 @@ class Profiler : public AllStatic {
const InterruptedThreadState& state);
private:
// Does not walk the thread's stack.
static void SampleThreadSingleFrame(Thread* thread, uintptr_t pc);
static bool initialized_;
static SampleBuffer* sample_buffer_;