| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/profiler/sampler.h" | 5 #include "src/profiler/sampler.h" |
| 6 | 6 |
| 7 #if V8_OS_POSIX && !V8_OS_CYGWIN | 7 #if V8_OS_POSIX && !V8_OS_CYGWIN |
| 8 | 8 |
| 9 #define USE_SIGNALS | 9 #define USE_SIGNALS |
| 10 | 10 |
| (...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 if (js_entry_sp == 0) return; // Not executing JS now. | 724 if (js_entry_sp == 0) return; // Not executing JS now. |
| 725 | 725 |
| 726 SafeStackFrameIterator it(isolate, reinterpret_cast<Address>(regs.fp), | 726 SafeStackFrameIterator it(isolate, reinterpret_cast<Address>(regs.fp), |
| 727 reinterpret_cast<Address>(regs.sp), js_entry_sp); | 727 reinterpret_cast<Address>(regs.sp), js_entry_sp); |
| 728 size_t i = 0; | 728 size_t i = 0; |
| 729 if (record_c_entry_frame == kIncludeCEntryFrame && !it.done() && | 729 if (record_c_entry_frame == kIncludeCEntryFrame && !it.done() && |
| 730 it.top_frame_type() == StackFrame::EXIT) { | 730 it.top_frame_type() == StackFrame::EXIT) { |
| 731 frames[i++] = isolate->c_function(); | 731 frames[i++] = isolate->c_function(); |
| 732 } | 732 } |
| 733 while (!it.done() && i < frames_limit) { | 733 while (!it.done() && i < frames_limit) { |
| 734 frames[i++] = it.frame()->pc(); | 734 if (it.frame()->is_interpreted()) { |
| 735 // For interpreted frames use the bytecode array pointer as the pc. |
| 736 InterpretedFrame* frame = static_cast<InterpretedFrame*>(it.frame()); |
| 737 // Since the sampler can interrupt execution at any point the |
| 738 // bytecode_array might be garbage, so don't dereference it. |
| 739 Address bytecode_array = |
| 740 reinterpret_cast<Address>(frame->GetBytecodeArray()) - kHeapObjectTag; |
| 741 frames[i++] = bytecode_array + BytecodeArray::kHeaderSize + |
| 742 frame->GetBytecodeOffset(); |
| 743 } else { |
| 744 frames[i++] = it.frame()->pc(); |
| 745 } |
| 735 it.Advance(); | 746 it.Advance(); |
| 736 } | 747 } |
| 737 sample_info->frames_count = i; | 748 sample_info->frames_count = i; |
| 738 } | 749 } |
| 739 | 750 |
| 740 | 751 |
| 741 void Sampler::SetUp() { | 752 void Sampler::SetUp() { |
| 742 #if defined(USE_SIGNALS) | 753 #if defined(USE_SIGNALS) |
| 743 SignalHandler::SetUp(); | 754 SignalHandler::SetUp(); |
| 744 #endif | 755 #endif |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 SampleStack(state); | 870 SampleStack(state); |
| 860 } | 871 } |
| 861 ResumeThread(profiled_thread); | 872 ResumeThread(profiled_thread); |
| 862 } | 873 } |
| 863 | 874 |
| 864 #endif // USE_SIGNALS | 875 #endif // USE_SIGNALS |
| 865 | 876 |
| 866 | 877 |
| 867 } // namespace internal | 878 } // namespace internal |
| 868 } // namespace v8 | 879 } // namespace v8 |
| OLD | NEW |