Index: src/profiler/sampler.cc |
diff --git a/src/profiler/sampler.cc b/src/profiler/sampler.cc |
index 3e9ec55a935058f3c22b206c8dcea02adcb5e6e9..019f6cfeecd612ab723d325ec75dd8b5a7aedc69 100644 |
--- a/src/profiler/sampler.cc |
+++ b/src/profiler/sampler.cc |
@@ -731,7 +731,18 @@ void TickSample::GetStackSample(Isolate* isolate, const v8::RegisterState& regs, |
frames[i++] = isolate->c_function(); |
} |
while (!it.done() && i < frames_limit) { |
- frames[i++] = it.frame()->pc(); |
+ if (it.frame()->is_interpreted()) { |
+ // For interpreted frames use the bytecode array pointer as the pc. |
+ InterpretedFrame* frame = static_cast<InterpretedFrame*>(it.frame()); |
+ // Since the sampler can interrupt execution at any point the |
+ // bytecode_array might be garbage, so don't dereference it. |
+ Address bytecode_array = |
+ reinterpret_cast<Address>(frame->GetBytecodeArray()) - kHeapObjectTag; |
+ frames[i++] = bytecode_array + BytecodeArray::kHeaderSize + |
+ frame->GetBytecodeOffset(); |
+ } else { |
+ frames[i++] = it.frame()->pc(); |
+ } |
it.Advance(); |
} |
sample_info->frames_count = i; |