OLD | NEW |
---|---|
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "platform/address_sanitizer.h" | 5 #include "platform/address_sanitizer.h" |
6 #include "platform/memory_sanitizer.h" | 6 #include "platform/memory_sanitizer.h" |
7 #include "platform/utils.h" | 7 #include "platform/utils.h" |
8 | 8 |
9 #include "vm/allocation.h" | 9 #include "vm/allocation.h" |
10 #include "vm/atomic.h" | 10 #include "vm/atomic.h" |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
522 return NextExit(); | 522 return NextExit(); |
523 } | 523 } |
524 // In regular Dart frame. | 524 // In regular Dart frame. |
525 uword* new_pc = CallerPC(); | 525 uword* new_pc = CallerPC(); |
526 // Check if we've moved into the invocation stub. | 526 // Check if we've moved into the invocation stub. |
527 if (StubCode::InInvocationStub(reinterpret_cast<uword>(new_pc))) { | 527 if (StubCode::InInvocationStub(reinterpret_cast<uword>(new_pc))) { |
528 // New PC is inside invocation stub, skip. | 528 // New PC is inside invocation stub, skip. |
529 return NextExit(); | 529 return NextExit(); |
530 } | 530 } |
531 uword* new_fp = CallerFP(); | 531 uword* new_fp = CallerFP(); |
532 if (new_fp <= fp_) { | 532 if (!IsCalleeFrameOf(reinterpret_cast<uword>(new_fp), |
533 reinterpret_cast<uword>(fp_))) { | |
533 // FP didn't move to a higher address. | 534 // FP didn't move to a higher address. |
Cutch
2016/08/19 13:49:31
fix comment
rmacnak
2016/08/19 23:28:16
Done.
| |
534 return false; | 535 return false; |
535 } | 536 } |
536 // Success, update fp and pc. | 537 // Success, update fp and pc. |
537 fp_ = new_fp; | 538 fp_ = new_fp; |
538 pc_ = new_pc; | 539 pc_ = new_pc; |
539 return true; | 540 return true; |
540 } | 541 } |
541 | 542 |
542 bool NextExit() { | 543 bool NextExit() { |
543 if (!ValidFramePointer()) { | 544 if (!ValidFramePointer()) { |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
830 static bool GetAndValidateIsolateStackBounds(Thread* thread, | 831 static bool GetAndValidateIsolateStackBounds(Thread* thread, |
831 uintptr_t fp, | 832 uintptr_t fp, |
832 uintptr_t sp, | 833 uintptr_t sp, |
833 uword* stack_lower, | 834 uword* stack_lower, |
834 uword* stack_upper) { | 835 uword* stack_upper) { |
835 ASSERT(thread != NULL); | 836 ASSERT(thread != NULL); |
836 OSThread* os_thread = thread->os_thread(); | 837 OSThread* os_thread = thread->os_thread(); |
837 ASSERT(os_thread != NULL); | 838 ASSERT(os_thread != NULL); |
838 ASSERT(stack_lower != NULL); | 839 ASSERT(stack_lower != NULL); |
839 ASSERT(stack_upper != NULL); | 840 ASSERT(stack_upper != NULL); |
841 const bool in_dart_code = thread->IsExecutingDartCode(); | |
840 #if defined(USING_SIMULATOR) | 842 #if defined(USING_SIMULATOR) |
841 const bool in_dart_code = thread->IsExecutingDartCode(); | |
842 if (in_dart_code) { | 843 if (in_dart_code) { |
843 Isolate* isolate = thread->isolate(); | 844 Isolate* isolate = thread->isolate(); |
844 ASSERT(isolate != NULL); | 845 ASSERT(isolate != NULL); |
845 Simulator* simulator = isolate->simulator(); | 846 Simulator* simulator = isolate->simulator(); |
846 *stack_lower = simulator->StackBase(); | 847 *stack_lower = simulator->StackBase(); |
847 *stack_upper = simulator->StackTop(); | 848 *stack_upper = simulator->StackTop(); |
848 } else if (!os_thread->GetProfilerStackBounds(stack_lower, stack_upper)) { | 849 } else if (!os_thread->GetProfilerStackBounds(stack_lower, stack_upper)) { |
849 // Could not get stack boundary. | 850 // Could not get stack boundary. |
850 return false; | 851 return false; |
851 } | 852 } |
852 if ((*stack_lower == 0) || (*stack_upper == 0)) { | 853 if ((*stack_lower == 0) || (*stack_upper == 0)) { |
853 return false; | 854 return false; |
854 } | 855 } |
855 #else | 856 #else |
856 if (!os_thread->GetProfilerStackBounds(stack_lower, stack_upper) || | 857 if (!os_thread->GetProfilerStackBounds(stack_lower, stack_upper) || |
857 (*stack_lower == 0) || (*stack_upper == 0)) { | 858 (*stack_lower == 0) || (*stack_upper == 0)) { |
858 // Could not get stack boundary. | 859 // Could not get stack boundary. |
859 return false; | 860 return false; |
860 } | 861 } |
861 #endif | 862 #endif |
862 if (sp > *stack_lower) { | 863 |
864 if (!in_dart_code && sp > *stack_lower) { | |
Cutch
2016/08/19 13:49:31
can this "!in_dart_code" be made DBC specific some
zra
2016/08/19 15:40:08
please add parens (sp > *stack_lower)
rmacnak
2016/08/19 23:28:16
Done.
| |
863 // The stack pointer gives us a tighter lower bound. | 865 // The stack pointer gives us a tighter lower bound. |
864 *stack_lower = sp; | 866 *stack_lower = sp; |
865 } | 867 } |
866 | 868 |
867 if (*stack_lower >= *stack_upper) { | 869 if (*stack_lower >= *stack_upper) { |
868 // Stack boundary is invalid. | 870 // Stack boundary is invalid. |
869 return false; | 871 return false; |
870 } | 872 } |
871 | 873 |
872 if ((sp < *stack_lower) || (sp >= *stack_upper)) { | 874 if ((sp < *stack_lower) || (sp >= *stack_upper)) { |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1118 counters->Increment(sample->vm_tag()); | 1120 counters->Increment(sample->vm_tag()); |
1119 } | 1121 } |
1120 | 1122 |
1121 // Write the single pc value. | 1123 // Write the single pc value. |
1122 sample->SetAt(0, pc); | 1124 sample->SetAt(0, pc); |
1123 } | 1125 } |
1124 | 1126 |
1125 | 1127 |
1126 void Profiler::SampleThread(Thread* thread, | 1128 void Profiler::SampleThread(Thread* thread, |
1127 const InterruptedThreadState& state) { | 1129 const InterruptedThreadState& state) { |
1128 #if defined(TARGET_ARCH_DBC) | |
1129 // TODO(vegorov) implement simulator stack sampling. | |
1130 return; | |
1131 #endif | |
1132 | |
1133 ASSERT(thread != NULL); | 1130 ASSERT(thread != NULL); |
1134 OSThread* os_thread = thread->os_thread(); | 1131 OSThread* os_thread = thread->os_thread(); |
1135 ASSERT(os_thread != NULL); | 1132 ASSERT(os_thread != NULL); |
1136 Isolate* isolate = thread->isolate(); | 1133 Isolate* isolate = thread->isolate(); |
1137 | 1134 |
1138 // Thread is not doing VM work. | 1135 // Thread is not doing VM work. |
1139 if (thread->task_kind() == Thread::kUnknownTask) { | 1136 if (thread->task_kind() == Thread::kUnknownTask) { |
1140 counters_.bail_out_unknown_task++; | 1137 counters_.bail_out_unknown_task++; |
1141 return; | 1138 return; |
1142 } | 1139 } |
1143 | 1140 |
1144 if (StubCode::HasBeenInitialized() && | 1141 if (StubCode::HasBeenInitialized() && |
1145 StubCode::InJumpToExceptionHandlerStub(state.pc)) { | 1142 StubCode::InJumpToExceptionHandlerStub(state.pc)) { |
1146 // The JumpToExceptionHandler stub manually adjusts the stack pointer, | 1143 // The JumpToExceptionHandler stub manually adjusts the stack pointer, |
1147 // frame pointer, and some isolate state before jumping to a catch entry. | 1144 // frame pointer, and some isolate state before jumping to a catch entry. |
1148 // It is not safe to walk the stack when executing this stub. | 1145 // It is not safe to walk the stack when executing this stub. |
1149 counters_.bail_out_jump_to_exception_handler++; | 1146 counters_.bail_out_jump_to_exception_handler++; |
1150 return; | 1147 return; |
1151 } | 1148 } |
1152 | 1149 |
1153 const bool in_dart_code = thread->IsExecutingDartCode(); | 1150 const bool in_dart_code = thread->IsExecutingDartCode(); |
1154 | 1151 |
1155 uintptr_t sp = 0; | 1152 uintptr_t sp = 0; |
1156 uintptr_t fp = state.fp; | 1153 uintptr_t fp = state.fp; |
1157 uintptr_t pc = state.pc; | 1154 uintptr_t pc = state.pc; |
1158 #if defined(USING_SIMULATOR) && !defined(TARGET_ARCH_DBC) | 1155 #if defined(USING_SIMULATOR) |
1159 Simulator* simulator = NULL; | 1156 Simulator* simulator = NULL; |
1160 #endif | 1157 #endif |
1161 | 1158 |
1162 if (in_dart_code) { | 1159 if (in_dart_code) { |
1163 // If we're in Dart code, use the Dart stack pointer. | 1160 // If we're in Dart code, use the Dart stack pointer. |
1164 #if defined(TARGET_ARCH_DBC) | 1161 #if defined(TARGET_ARCH_DBC) |
Cutch
2016/08/19 13:49:31
why not fold this into:
#if defined(TARGET_ARCH_D
rmacnak
2016/08/19 23:28:16
DBC doesn't define Simulator::get_register.
| |
1165 UNIMPLEMENTED(); | 1162 simulator = isolate->simulator(); |
1163 sp = simulator->get_sp(); | |
1164 fp = simulator->get_fp(); | |
1165 pc = simulator->get_pc(); | |
1166 #elif defined(USING_SIMULATOR) | 1166 #elif defined(USING_SIMULATOR) |
1167 simulator = isolate->simulator(); | 1167 simulator = isolate->simulator(); |
1168 sp = simulator->get_register(SPREG); | 1168 sp = simulator->get_register(SPREG); |
1169 fp = simulator->get_register(FPREG); | 1169 fp = simulator->get_register(FPREG); |
1170 pc = simulator->get_pc(); | 1170 pc = simulator->get_pc(); |
1171 #else | 1171 #else |
1172 sp = state.dsp; | 1172 sp = state.dsp; |
1173 #endif | 1173 #endif |
1174 } else { | 1174 } else { |
1175 // If we're in runtime code, use the C stack pointer. | 1175 // If we're in runtime code, use the C stack pointer. |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1589 | 1589 |
1590 | 1590 |
1591 ProcessedSampleBuffer::ProcessedSampleBuffer() | 1591 ProcessedSampleBuffer::ProcessedSampleBuffer() |
1592 : code_lookup_table_(new CodeLookupTable(Thread::Current())) { | 1592 : code_lookup_table_(new CodeLookupTable(Thread::Current())) { |
1593 ASSERT(code_lookup_table_ != NULL); | 1593 ASSERT(code_lookup_table_ != NULL); |
1594 } | 1594 } |
1595 | 1595 |
1596 #endif // !PRODUCT | 1596 #endif // !PRODUCT |
1597 | 1597 |
1598 } // namespace dart | 1598 } // namespace dart |
OLD | NEW |