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()) { |
1001 return; | 1023 return; |
sra1
2016/03/29 17:22:18
Should this be sampled as a single frame too?
Cutch
2016/03/29 17:43:18
Might as well.
| |
1002 } | 1024 } |
1003 | 1025 |
1026 if (!InitialRegisterCheck(pc, fp, sp)) { | |
1027 SampleThreadSingleFrame(thread, pc); | |
1028 return; | |
1029 } | |
1030 | |
1004 uword stack_lower = 0; | 1031 uword stack_lower = 0; |
1005 uword stack_upper = 0; | 1032 uword stack_upper = 0; |
1006 if (!GetAndValidateIsolateStackBounds(thread, | 1033 if (!GetAndValidateIsolateStackBounds(thread, |
1007 fp, | 1034 fp, |
1008 sp, | 1035 sp, |
1009 &stack_lower, | 1036 &stack_lower, |
1010 &stack_upper)) { | 1037 &stack_upper)) { |
1038 SampleThreadSingleFrame(thread, pc); | |
1011 // Could not get stack boundary. | 1039 // Could not get stack boundary. |
1012 return; | 1040 return; |
1013 } | 1041 } |
1014 | 1042 |
1015 // At this point we have a valid stack boundary for this isolate and | 1043 // 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. | 1044 // know that our initial stack and frame pointers are within the boundary. |
1017 SampleBuffer* sample_buffer = Profiler::sample_buffer(); | 1045 SampleBuffer* sample_buffer = Profiler::sample_buffer(); |
1018 if (sample_buffer == NULL) { | 1046 if (sample_buffer == NULL) { |
1019 // Profiler not initialized. | 1047 // Profiler not initialized. |
1020 return; | 1048 return; |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1396 | 1424 |
1397 | 1425 |
1398 ProcessedSampleBuffer::ProcessedSampleBuffer() | 1426 ProcessedSampleBuffer::ProcessedSampleBuffer() |
1399 : code_lookup_table_(new CodeLookupTable(Thread::Current())) { | 1427 : code_lookup_table_(new CodeLookupTable(Thread::Current())) { |
1400 ASSERT(code_lookup_table_ != NULL); | 1428 ASSERT(code_lookup_table_ != NULL); |
1401 } | 1429 } |
1402 | 1430 |
1403 #endif // !PRODUCT | 1431 #endif // !PRODUCT |
1404 | 1432 |
1405 } // namespace dart | 1433 } // namespace dart |
OLD | NEW |