| 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 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 new_protect, | 813 new_protect, |
| 814 &old_protect); | 814 &old_protect); |
| 815 USE(success); | 815 USE(success); |
| 816 ASSERT(success); | 816 ASSERT(success); |
| 817 ASSERT(old_protect == PAGE_READWRITE); | 817 ASSERT(old_protect == PAGE_READWRITE); |
| 818 } | 818 } |
| 819 #endif | 819 #endif |
| 820 } | 820 } |
| 821 | 821 |
| 822 | 822 |
| 823 void Profiler::RecordAllocation(Isolate* isolate, intptr_t cid) { |
| 824 if ((isolate == NULL) || (Dart::vm_isolate() == NULL)) { |
| 825 // No isolate. |
| 826 return; |
| 827 } |
| 828 ASSERT(isolate != Dart::vm_isolate()); |
| 829 |
| 830 const bool exited_dart_code = (isolate->stub_code() != NULL) && |
| 831 (isolate->top_exit_frame_info() != 0) && |
| 832 (isolate->vm_tag() != VMTag::kDartTagId); |
| 833 |
| 834 if (!exited_dart_code) { |
| 835 // No Dart frames on stack. |
| 836 // TODO(johnmccutchan): Support collecting native stack. |
| 837 return; |
| 838 } |
| 839 |
| 840 IsolateProfilerData* profiler_data = isolate->profiler_data(); |
| 841 if (profiler_data == NULL) { |
| 842 // Profiler not initialized. |
| 843 return; |
| 844 } |
| 845 |
| 846 SampleBuffer* sample_buffer = profiler_data->sample_buffer(); |
| 847 if (sample_buffer == NULL) { |
| 848 // Profiler not initialized. |
| 849 return; |
| 850 } |
| 851 |
| 852 const ThreadId thread_id = OSThread::GetCurrentThreadId(); |
| 853 // Setup sample. |
| 854 Sample* sample = sample_buffer->ReserveSample(); |
| 855 sample->Init(isolate, OS::GetCurrentTimeMicros(), thread_id); |
| 856 uword vm_tag = isolate->vm_tag(); |
| 857 #if defined(USING_SIMULATOR) |
| 858 // When running in the simulator, the runtime entry function address |
| 859 // (stored as the vm tag) is the address of a redirect function. |
| 860 // Attempt to find the real runtime entry function address and use that. |
| 861 uword redirect_vm_tag = Simulator::FunctionForRedirect(vm_tag); |
| 862 if (redirect_vm_tag != 0) { |
| 863 vm_tag = redirect_vm_tag; |
| 864 } |
| 865 #endif |
| 866 sample->set_vm_tag(vm_tag); |
| 867 sample->set_user_tag(isolate->user_tag()); |
| 868 sample->SetAllocationCid(cid); |
| 869 |
| 870 ProfilerDartExitStackWalker dart_exit_stack_walker(isolate, sample); |
| 871 dart_exit_stack_walker.walk(); |
| 872 } |
| 873 |
| 874 |
| 823 void Profiler::RecordSampleInterruptCallback( | 875 void Profiler::RecordSampleInterruptCallback( |
| 824 const InterruptedThreadState& state, | 876 const InterruptedThreadState& state, |
| 825 void* data) { | 877 void* data) { |
| 826 Isolate* isolate = reinterpret_cast<Isolate*>(data); | 878 Isolate* isolate = reinterpret_cast<Isolate*>(data); |
| 827 if ((isolate == NULL) || (Dart::vm_isolate() == NULL)) { | 879 if ((isolate == NULL) || (Dart::vm_isolate() == NULL)) { |
| 828 // No isolate. | 880 // No isolate. |
| 829 return; | 881 return; |
| 830 } | 882 } |
| 831 | 883 |
| 832 ASSERT(isolate != Dart::vm_isolate()); | 884 ASSERT(isolate != Dart::vm_isolate()); |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1180 uword pc) { | 1232 uword pc) { |
| 1181 return vm_isolate->heap()->CodeContains(pc) | 1233 return vm_isolate->heap()->CodeContains(pc) |
| 1182 || isolate->heap()->CodeContains(pc); | 1234 || isolate->heap()->CodeContains(pc); |
| 1183 } | 1235 } |
| 1184 | 1236 |
| 1185 | 1237 |
| 1186 ProcessedSampleBuffer::ProcessedSampleBuffer() { | 1238 ProcessedSampleBuffer::ProcessedSampleBuffer() { |
| 1187 } | 1239 } |
| 1188 | 1240 |
| 1189 } // namespace dart | 1241 } // namespace dart |
| OLD | NEW |