Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: runtime/vm/profiler.cc

Issue 2250823002: Partially implement DBC profiler. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: sync Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | runtime/vm/signal_handler_macos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // FP didn't move to a higher address. 533 reinterpret_cast<uword>(fp_))) {
534 // FP didn't move to a caller (higher address on most architectures).
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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
863
864 #if defined(TARGET_ARCH_DBC)
865 if (!in_dart_code && (sp > *stack_lower)) {
866 // The stack pointer gives us a tighter lower bound.
867 *stack_lower = sp;
868 }
869 #else
862 if (sp > *stack_lower) { 870 if (sp > *stack_lower) {
863 // The stack pointer gives us a tighter lower bound. 871 // The stack pointer gives us a tighter lower bound.
864 *stack_lower = sp; 872 *stack_lower = sp;
865 } 873 }
874 #endif
866 875
867 if (*stack_lower >= *stack_upper) { 876 if (*stack_lower >= *stack_upper) {
868 // Stack boundary is invalid. 877 // Stack boundary is invalid.
869 return false; 878 return false;
870 } 879 }
871 880
872 if ((sp < *stack_lower) || (sp >= *stack_upper)) { 881 if ((sp < *stack_lower) || (sp >= *stack_upper)) {
873 // Stack pointer is outside thread's stack boundary. 882 // Stack pointer is outside thread's stack boundary.
874 return false; 883 return false;
875 } 884 }
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 counters->Increment(sample->vm_tag()); 1127 counters->Increment(sample->vm_tag());
1119 } 1128 }
1120 1129
1121 // Write the single pc value. 1130 // Write the single pc value.
1122 sample->SetAt(0, pc); 1131 sample->SetAt(0, pc);
1123 } 1132 }
1124 1133
1125 1134
1126 void Profiler::SampleThread(Thread* thread, 1135 void Profiler::SampleThread(Thread* thread,
1127 const InterruptedThreadState& state) { 1136 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); 1137 ASSERT(thread != NULL);
1134 OSThread* os_thread = thread->os_thread(); 1138 OSThread* os_thread = thread->os_thread();
1135 ASSERT(os_thread != NULL); 1139 ASSERT(os_thread != NULL);
1136 Isolate* isolate = thread->isolate(); 1140 Isolate* isolate = thread->isolate();
1137 1141
1138 // Thread is not doing VM work. 1142 // Thread is not doing VM work.
1139 if (thread->task_kind() == Thread::kUnknownTask) { 1143 if (thread->task_kind() == Thread::kUnknownTask) {
1140 counters_.bail_out_unknown_task++; 1144 counters_.bail_out_unknown_task++;
1141 return; 1145 return;
1142 } 1146 }
1143 1147
1144 if (StubCode::HasBeenInitialized() && 1148 if (StubCode::HasBeenInitialized() &&
1145 StubCode::InJumpToExceptionHandlerStub(state.pc)) { 1149 StubCode::InJumpToExceptionHandlerStub(state.pc)) {
1146 // The JumpToExceptionHandler stub manually adjusts the stack pointer, 1150 // The JumpToExceptionHandler stub manually adjusts the stack pointer,
1147 // frame pointer, and some isolate state before jumping to a catch entry. 1151 // 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. 1152 // It is not safe to walk the stack when executing this stub.
1149 counters_.bail_out_jump_to_exception_handler++; 1153 counters_.bail_out_jump_to_exception_handler++;
1150 return; 1154 return;
1151 } 1155 }
1152 1156
1153 const bool in_dart_code = thread->IsExecutingDartCode(); 1157 const bool in_dart_code = thread->IsExecutingDartCode();
1154 1158
1155 uintptr_t sp = 0; 1159 uintptr_t sp = 0;
1156 uintptr_t fp = state.fp; 1160 uintptr_t fp = state.fp;
1157 uintptr_t pc = state.pc; 1161 uintptr_t pc = state.pc;
1158 #if defined(USING_SIMULATOR) && !defined(TARGET_ARCH_DBC) 1162 #if defined(USING_SIMULATOR)
1159 Simulator* simulator = NULL; 1163 Simulator* simulator = NULL;
1160 #endif 1164 #endif
1161 1165
1162 if (in_dart_code) { 1166 if (in_dart_code) {
1163 // If we're in Dart code, use the Dart stack pointer. 1167 // If we're in Dart code, use the Dart stack pointer.
1164 #if defined(TARGET_ARCH_DBC) 1168 #if defined(TARGET_ARCH_DBC)
1165 UNIMPLEMENTED(); 1169 simulator = isolate->simulator();
1170 sp = simulator->get_sp();
1171 fp = simulator->get_fp();
1172 pc = simulator->get_pc();
1166 #elif defined(USING_SIMULATOR) 1173 #elif defined(USING_SIMULATOR)
1167 simulator = isolate->simulator(); 1174 simulator = isolate->simulator();
1168 sp = simulator->get_register(SPREG); 1175 sp = simulator->get_register(SPREG);
1169 fp = simulator->get_register(FPREG); 1176 fp = simulator->get_register(FPREG);
1170 pc = simulator->get_pc(); 1177 pc = simulator->get_pc();
1171 #else 1178 #else
1172 sp = state.dsp; 1179 sp = state.dsp;
1173 #endif 1180 #endif
1174 } else { 1181 } else {
1175 // If we're in runtime code, use the C stack pointer. 1182 // If we're in runtime code, use the C stack pointer.
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
1589 1596
1590 1597
1591 ProcessedSampleBuffer::ProcessedSampleBuffer() 1598 ProcessedSampleBuffer::ProcessedSampleBuffer()
1592 : code_lookup_table_(new CodeLookupTable(Thread::Current())) { 1599 : code_lookup_table_(new CodeLookupTable(Thread::Current())) {
1593 ASSERT(code_lookup_table_ != NULL); 1600 ASSERT(code_lookup_table_ != NULL);
1594 } 1601 }
1595 1602
1596 #endif // !PRODUCT 1603 #endif // !PRODUCT
1597 1604
1598 } // namespace dart 1605 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/signal_handler_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698