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/utils.h" | 5 #include "platform/utils.h" |
6 | 6 |
7 #include "vm/allocation.h" | 7 #include "vm/allocation.h" |
8 #include "vm/atomic.h" | 8 #include "vm/atomic.h" |
9 #include "vm/code_patcher.h" | 9 #include "vm/code_patcher.h" |
10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
11 #include "vm/json_stream.h" | 11 #include "vm/json_stream.h" |
12 #include "vm/lockers.h" | 12 #include "vm/lockers.h" |
13 #include "vm/native_symbol.h" | 13 #include "vm/native_symbol.h" |
14 #include "vm/object.h" | 14 #include "vm/object.h" |
15 #include "vm/os.h" | 15 #include "vm/os.h" |
16 #include "vm/profiler.h" | 16 #include "vm/profiler.h" |
17 #include "vm/reusable_handles.h" | 17 #include "vm/reusable_handles.h" |
18 #include "vm/signal_handler.h" | 18 #include "vm/signal_handler.h" |
19 #include "vm/simulator.h" | 19 #include "vm/simulator.h" |
20 #include "vm/stack_frame.h" | 20 #include "vm/stack_frame.h" |
21 | 21 |
22 namespace dart { | 22 namespace dart { |
23 | 23 |
24 | 24 |
25 #if defined(USING_SIMULATOR) || defined(TARGET_OS_ANDROID) || \ | 25 #if defined(TARGET_OS_ANDROID) || defined(HOST_ARCH_ARM64) |
26 defined(HOST_ARCH_ARM64) | |
27 DEFINE_FLAG(bool, profile, false, "Enable Sampling Profiler"); | 26 DEFINE_FLAG(bool, profile, false, "Enable Sampling Profiler"); |
28 #else | 27 #else |
29 DEFINE_FLAG(bool, profile, true, "Enable Sampling Profiler"); | 28 DEFINE_FLAG(bool, profile, true, "Enable Sampling Profiler"); |
30 #endif | 29 #endif |
31 DEFINE_FLAG(bool, trace_profiled_isolates, false, "Trace profiled isolates."); | 30 DEFINE_FLAG(bool, trace_profiled_isolates, false, "Trace profiled isolates."); |
32 DEFINE_FLAG(charp, profile_dir, NULL, | 31 DEFINE_FLAG(charp, profile_dir, NULL, |
33 "Enable writing profile data into specified directory."); | 32 "Enable writing profile data into specified directory."); |
34 DEFINE_FLAG(int, profile_period, 1000, | 33 DEFINE_FLAG(int, profile_period, 1000, |
35 "Time between profiler samples in microseconds. Minimum 50."); | 34 "Time between profiler samples in microseconds. Minimum 50."); |
36 DEFINE_FLAG(int, profile_depth, 8, | 35 DEFINE_FLAG(int, profile_depth, 8, |
37 "Maximum number stack frames walked. Minimum 1. Maximum 255."); | 36 "Maximum number stack frames walked. Minimum 1. Maximum 255."); |
38 #if defined(PROFILE_NATIVE_CODE) | 37 #if defined(PROFILE_NATIVE_CODE) || defined(USING_SIMULATOR) |
39 DEFINE_FLAG(bool, profile_vm, true, | 38 DEFINE_FLAG(bool, profile_vm, true, |
40 "Always collect native stack traces."); | 39 "Always collect native stack traces."); |
41 #else | 40 #else |
42 DEFINE_FLAG(bool, profile_vm, false, | 41 DEFINE_FLAG(bool, profile_vm, false, |
43 "Always collect native stack traces."); | 42 "Always collect native stack traces."); |
44 #endif | 43 #endif |
45 | 44 |
46 bool Profiler::initialized_ = false; | 45 bool Profiler::initialized_ = false; |
47 SampleBuffer* Profiler::sample_buffer_ = NULL; | 46 SampleBuffer* Profiler::sample_buffer_ = NULL; |
48 | 47 |
(...skipping 1984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2033 } | 2032 } |
2034 | 2033 |
2035 if ((state.fp < stack_lower) || (state.fp >= stack_upper)) { | 2034 if ((state.fp < stack_lower) || (state.fp >= stack_upper)) { |
2036 // Frame pointer is outside isolate stack boundary. | 2035 // Frame pointer is outside isolate stack boundary. |
2037 return; | 2036 return; |
2038 } | 2037 } |
2039 | 2038 |
2040 // At this point we have a valid stack boundary for this isolate and | 2039 // At this point we have a valid stack boundary for this isolate and |
2041 // know that our initial stack and frame pointers are within the boundary. | 2040 // know that our initial stack and frame pointers are within the boundary. |
2042 | 2041 |
2043 // Increment counter for vm tag. | |
2044 VMTagCounters* counters = isolate->vm_tag_counters(); | |
2045 ASSERT(counters != NULL); | |
2046 counters->Increment(isolate->vm_tag()); | |
2047 | |
2048 // Setup sample. | 2042 // Setup sample. |
2049 Sample* sample = sample_buffer->ReserveSample(); | 2043 Sample* sample = sample_buffer->ReserveSample(); |
2050 sample->Init(isolate, OS::GetCurrentTimeMicros(), state.tid); | 2044 sample->Init(isolate, OS::GetCurrentTimeMicros(), state.tid); |
2051 sample->set_vm_tag(isolate->vm_tag()); | 2045 uword vm_tag = isolate->vm_tag(); |
| 2046 #if defined(USING_SIMULATOR) |
| 2047 // When running in the simulator, the runtime entry function address |
| 2048 // (stored as the vm tag) is the address of a redirect function. |
| 2049 // Attempt to find the real runtime entry function address and use that. |
| 2050 uword redirect_vm_tag = Simulator::FunctionForRedirect(vm_tag); |
| 2051 if (redirect_vm_tag != 0) { |
| 2052 vm_tag = redirect_vm_tag; |
| 2053 } |
| 2054 #endif |
| 2055 // Increment counter for vm tag. |
| 2056 VMTagCounters* counters = isolate->vm_tag_counters(); |
| 2057 ASSERT(counters != NULL); |
| 2058 counters->Increment(vm_tag); |
| 2059 sample->set_vm_tag(vm_tag); |
2052 sample->set_user_tag(isolate->user_tag()); | 2060 sample->set_user_tag(isolate->user_tag()); |
2053 sample->set_sp(sp); | 2061 sample->set_sp(sp); |
2054 sample->set_fp(state.fp); | 2062 sample->set_fp(state.fp); |
2055 #if !(defined(TARGET_OS_WINDOWS) && defined(TARGET_ARCH_X64)) | 2063 #if !(defined(TARGET_OS_WINDOWS) && defined(TARGET_ARCH_X64)) |
2056 // It is never safe to read other thread's stack unless on Win64 | 2064 // It is never safe to read other thread's stack unless on Win64 |
2057 // other thread is inside Dart code. | 2065 // other thread is inside Dart code. |
2058 SetPCMarkerIfSafe(sample); | 2066 SetPCMarkerIfSafe(sample); |
2059 #endif | 2067 #endif |
2060 | 2068 |
2061 // Walk the call stack. | 2069 // Walk the call stack. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2102 state.pc, | 2110 state.pc, |
2103 state.fp, | 2111 state.fp, |
2104 sp); | 2112 sp); |
2105 stackWalker.walk(); | 2113 stackWalker.walk(); |
2106 #endif | 2114 #endif |
2107 } | 2115 } |
2108 } | 2116 } |
2109 } | 2117 } |
2110 | 2118 |
2111 } // namespace dart | 2119 } // namespace dart |
OLD | NEW |