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 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 } | 958 } |
959 #endif | 959 #endif |
960 | 960 |
961 void Profiler::RecordAllocation(Isolate* isolate, intptr_t cid) { | 961 void Profiler::RecordAllocation(Isolate* isolate, intptr_t cid) { |
962 if (!CheckIsolate(isolate)) { | 962 if (!CheckIsolate(isolate)) { |
963 return; | 963 return; |
964 } | 964 } |
965 | 965 |
966 const bool exited_dart_code = ExitedDart(isolate); | 966 const bool exited_dart_code = ExitedDart(isolate); |
967 | 967 |
968 if (!exited_dart_code && !FLAG_profile_vm) { | |
969 // No Dart frames on stack and we are not profiling the vm. | |
970 return; | |
971 } | |
972 | |
973 SampleBuffer* sample_buffer = GetSampleBuffer(isolate); | 968 SampleBuffer* sample_buffer = GetSampleBuffer(isolate); |
974 if (sample_buffer == NULL) { | 969 if (sample_buffer == NULL) { |
975 // Profiler not initialized. | 970 // Profiler not initialized. |
976 return; | 971 return; |
977 } | 972 } |
978 | 973 |
979 if (FLAG_profile_vm) { | 974 if (FLAG_profile_vm) { |
980 uintptr_t sp = Isolate::GetCurrentStackPointer(); | 975 uintptr_t sp = Isolate::GetCurrentStackPointer(); |
981 uintptr_t fp = 0; | 976 uintptr_t fp = 0; |
982 uintptr_t pc = GetProgramCounter(); | 977 uintptr_t pc = GetProgramCounter(); |
(...skipping 20 matching lines...) Expand all Loading... |
1003 sample_buffer, | 998 sample_buffer, |
1004 OSThread::GetCurrentThreadId()); | 999 OSThread::GetCurrentThreadId()); |
1005 sample->SetAllocationCid(cid); | 1000 sample->SetAllocationCid(cid); |
1006 ProfilerNativeStackWalker native_stack_walker(sample, | 1001 ProfilerNativeStackWalker native_stack_walker(sample, |
1007 stack_lower, | 1002 stack_lower, |
1008 stack_upper, | 1003 stack_upper, |
1009 pc, | 1004 pc, |
1010 fp, | 1005 fp, |
1011 sp); | 1006 sp); |
1012 native_stack_walker.walk(); | 1007 native_stack_walker.walk(); |
1013 } else { | 1008 } else if (exited_dart_code) { |
1014 ASSERT(exited_dart_code); | |
1015 Sample* sample = SetupSample(isolate, | 1009 Sample* sample = SetupSample(isolate, |
1016 sample_buffer, | 1010 sample_buffer, |
1017 OSThread::GetCurrentThreadId()); | 1011 OSThread::GetCurrentThreadId()); |
1018 sample->SetAllocationCid(cid); | 1012 sample->SetAllocationCid(cid); |
1019 ProfilerDartExitStackWalker dart_exit_stack_walker(isolate, sample); | 1013 ProfilerDartExitStackWalker dart_exit_stack_walker(isolate, sample); |
1020 dart_exit_stack_walker.walk(); | 1014 dart_exit_stack_walker.walk(); |
| 1015 } else { |
| 1016 // Fall back. |
| 1017 uintptr_t pc = GetProgramCounter(); |
| 1018 Sample* sample = SetupSample(isolate, |
| 1019 sample_buffer, |
| 1020 OSThread::GetCurrentThreadId()); |
| 1021 sample->SetAllocationCid(cid); |
| 1022 sample->set_vm_tag(VMTag::kEmbedderTagId); |
| 1023 sample->SetAt(0, pc); |
1021 } | 1024 } |
1022 } | 1025 } |
1023 | 1026 |
1024 | 1027 |
1025 void Profiler::RecordSampleInterruptCallback( | 1028 void Profiler::RecordSampleInterruptCallback( |
1026 const InterruptedThreadState& state, | 1029 const InterruptedThreadState& state, |
1027 void* data) { | 1030 void* data) { |
1028 Isolate* isolate = reinterpret_cast<Isolate*>(data); | 1031 Isolate* isolate = reinterpret_cast<Isolate*>(data); |
1029 if ((isolate == NULL) || (Dart::vm_isolate() == NULL)) { | 1032 if ((isolate == NULL) || (Dart::vm_isolate() == NULL)) { |
1030 // No isolate. | 1033 // No isolate. |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1319 uword pc) { | 1322 uword pc) { |
1320 return vm_isolate->heap()->CodeContains(pc) | 1323 return vm_isolate->heap()->CodeContains(pc) |
1321 || isolate->heap()->CodeContains(pc); | 1324 || isolate->heap()->CodeContains(pc); |
1322 } | 1325 } |
1323 | 1326 |
1324 | 1327 |
1325 ProcessedSampleBuffer::ProcessedSampleBuffer() { | 1328 ProcessedSampleBuffer::ProcessedSampleBuffer() { |
1326 } | 1329 } |
1327 | 1330 |
1328 } // namespace dart | 1331 } // namespace dart |
OLD | NEW |