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 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 } else { | 938 } else { |
939 // Fall back. | 939 // Fall back. |
940 uintptr_t pc = GetProgramCounter(); | 940 uintptr_t pc = GetProgramCounter(); |
941 Sample* sample = SetupSample(thread, sample_buffer, os_thread->trace_id()); | 941 Sample* sample = SetupSample(thread, sample_buffer, os_thread->trace_id()); |
942 sample->SetAllocationCid(cid); | 942 sample->SetAllocationCid(cid); |
943 sample->SetAt(0, pc); | 943 sample->SetAt(0, pc); |
944 } | 944 } |
945 } | 945 } |
946 | 946 |
947 | 947 |
| 948 void Profiler::SampleThreadSingleFrame(Thread* thread, uintptr_t pc) { |
| 949 ASSERT(thread != NULL); |
| 950 OSThread* os_thread = thread->os_thread(); |
| 951 ASSERT(os_thread != NULL); |
| 952 Isolate* isolate = thread->isolate(); |
| 953 |
| 954 SampleBuffer* sample_buffer = Profiler::sample_buffer(); |
| 955 if (sample_buffer == NULL) { |
| 956 // Profiler not initialized. |
| 957 return; |
| 958 } |
| 959 |
| 960 // Setup sample. |
| 961 Sample* sample = SetupSample(thread, sample_buffer, os_thread->trace_id()); |
| 962 // Increment counter for vm tag. |
| 963 VMTagCounters* counters = isolate->vm_tag_counters(); |
| 964 ASSERT(counters != NULL); |
| 965 if (thread->IsMutatorThread()) { |
| 966 counters->Increment(sample->vm_tag()); |
| 967 } |
| 968 |
| 969 // Write the single pc value. |
| 970 sample->SetAt(0, pc); |
| 971 } |
| 972 |
| 973 |
948 void Profiler::SampleThread(Thread* thread, | 974 void Profiler::SampleThread(Thread* thread, |
949 const InterruptedThreadState& state) { | 975 const InterruptedThreadState& state) { |
950 ASSERT(thread != NULL); | 976 ASSERT(thread != NULL); |
951 OSThread* os_thread = thread->os_thread(); | 977 OSThread* os_thread = thread->os_thread(); |
952 ASSERT(os_thread != NULL); | 978 ASSERT(os_thread != NULL); |
953 Isolate* isolate = thread->isolate(); | 979 Isolate* isolate = thread->isolate(); |
954 | 980 |
955 // Thread is not doing VM work. | 981 // Thread is not doing VM work. |
956 if (thread->task_kind() == Thread::kUnknownTask) { | 982 if (thread->task_kind() == Thread::kUnknownTask) { |
957 return; | 983 return; |
(...skipping 24 matching lines...) Expand all Loading... |
982 fp = simulator->get_register(FPREG); | 1008 fp = simulator->get_register(FPREG); |
983 pc = simulator->get_pc(); | 1009 pc = simulator->get_pc(); |
984 #else | 1010 #else |
985 sp = state.dsp; | 1011 sp = state.dsp; |
986 #endif | 1012 #endif |
987 } else { | 1013 } else { |
988 // If we're in runtime code, use the C stack pointer. | 1014 // If we're in runtime code, use the C stack pointer. |
989 sp = state.csp; | 1015 sp = state.csp; |
990 } | 1016 } |
991 | 1017 |
992 if (!InitialRegisterCheck(pc, fp, sp)) { | |
993 return; | |
994 } | |
995 | |
996 if (!CheckIsolate(isolate)) { | 1018 if (!CheckIsolate(isolate)) { |
997 return; | 1019 return; |
998 } | 1020 } |
999 | 1021 |
1000 if (thread->IsMutatorThread() && isolate->IsDeoptimizing()) { | 1022 if (thread->IsMutatorThread() && isolate->IsDeoptimizing()) { |
| 1023 SampleThreadSingleFrame(thread, pc); |
1001 return; | 1024 return; |
1002 } | 1025 } |
1003 | 1026 |
| 1027 if (!InitialRegisterCheck(pc, fp, sp)) { |
| 1028 SampleThreadSingleFrame(thread, pc); |
| 1029 return; |
| 1030 } |
| 1031 |
1004 uword stack_lower = 0; | 1032 uword stack_lower = 0; |
1005 uword stack_upper = 0; | 1033 uword stack_upper = 0; |
1006 if (!GetAndValidateIsolateStackBounds(thread, | 1034 if (!GetAndValidateIsolateStackBounds(thread, |
1007 fp, | 1035 fp, |
1008 sp, | 1036 sp, |
1009 &stack_lower, | 1037 &stack_lower, |
1010 &stack_upper)) { | 1038 &stack_upper)) { |
1011 // Could not get stack boundary. | 1039 // Could not get stack boundary. |
| 1040 SampleThreadSingleFrame(thread, pc); |
1012 return; | 1041 return; |
1013 } | 1042 } |
1014 | 1043 |
1015 // At this point we have a valid stack boundary for this isolate and | 1044 // At this point we have a valid stack boundary for this isolate and |
1016 // know that our initial stack and frame pointers are within the boundary. | 1045 // know that our initial stack and frame pointers are within the boundary. |
1017 SampleBuffer* sample_buffer = Profiler::sample_buffer(); | 1046 SampleBuffer* sample_buffer = Profiler::sample_buffer(); |
1018 if (sample_buffer == NULL) { | 1047 if (sample_buffer == NULL) { |
1019 // Profiler not initialized. | 1048 // Profiler not initialized. |
1020 return; | 1049 return; |
1021 } | 1050 } |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1396 | 1425 |
1397 | 1426 |
1398 ProcessedSampleBuffer::ProcessedSampleBuffer() | 1427 ProcessedSampleBuffer::ProcessedSampleBuffer() |
1399 : code_lookup_table_(new CodeLookupTable(Thread::Current())) { | 1428 : code_lookup_table_(new CodeLookupTable(Thread::Current())) { |
1400 ASSERT(code_lookup_table_ != NULL); | 1429 ASSERT(code_lookup_table_ != NULL); |
1401 } | 1430 } |
1402 | 1431 |
1403 #endif // !PRODUCT | 1432 #endif // !PRODUCT |
1404 | 1433 |
1405 } // namespace dart | 1434 } // namespace dart |
OLD | NEW |