| 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" |
| (...skipping 1663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1674 uword* fp = reinterpret_cast<uword*>(sample->fp()); | 1674 uword* fp = reinterpret_cast<uword*>(sample->fp()); |
| 1675 uword* sp = reinterpret_cast<uword*>(sample->sp()); | 1675 uword* sp = reinterpret_cast<uword*>(sample->sp()); |
| 1676 | 1676 |
| 1677 // If FP == SP, the pc marker hasn't been pushed. | 1677 // If FP == SP, the pc marker hasn't been pushed. |
| 1678 if (fp > sp) { | 1678 if (fp > sp) { |
| 1679 #if defined(TARGET_OS_WINDOWS) | 1679 #if defined(TARGET_OS_WINDOWS) |
| 1680 // If the fp is at the beginning of a page, it may be unsafe to access | 1680 // If the fp is at the beginning of a page, it may be unsafe to access |
| 1681 // the pc marker, because we are reading it from a different thread on | 1681 // the pc marker, because we are reading it from a different thread on |
| 1682 // Windows. The marker is below fp and the previous page may be a guard | 1682 // Windows. The marker is below fp and the previous page may be a guard |
| 1683 // page. | 1683 // page. |
| 1684 COMPILE_ASSERT(kPcMarkerSlotFromFp < 0); |
| 1684 const intptr_t kPageMask = VirtualMemory::PageSize() - 1; | 1685 const intptr_t kPageMask = VirtualMemory::PageSize() - 1; |
| 1685 if ((sample->fp() & kPageMask) == 0) { | 1686 if ((sample->fp() & kPageMask) == 0) { |
| 1686 return; | 1687 return; |
| 1687 } | 1688 } |
| 1688 #endif | 1689 #endif |
| 1689 const uword pc_marker = *(fp + kPcMarkerSlotFromFp); | 1690 const uword pc_marker = *(fp + kPcMarkerSlotFromFp); |
| 1690 sample->set_pc_marker(pc_marker); | 1691 sample->set_pc_marker(pc_marker); |
| 1691 } | 1692 } |
| 1692 } | 1693 } |
| 1693 | 1694 |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2041 ASSERT(counters != NULL); | 2042 ASSERT(counters != NULL); |
| 2042 counters->Increment(isolate->vm_tag()); | 2043 counters->Increment(isolate->vm_tag()); |
| 2043 | 2044 |
| 2044 // Setup sample. | 2045 // Setup sample. |
| 2045 Sample* sample = sample_buffer->ReserveSample(); | 2046 Sample* sample = sample_buffer->ReserveSample(); |
| 2046 sample->Init(isolate, OS::GetCurrentTimeMicros(), state.tid); | 2047 sample->Init(isolate, OS::GetCurrentTimeMicros(), state.tid); |
| 2047 sample->set_vm_tag(isolate->vm_tag()); | 2048 sample->set_vm_tag(isolate->vm_tag()); |
| 2048 sample->set_user_tag(isolate->user_tag()); | 2049 sample->set_user_tag(isolate->user_tag()); |
| 2049 sample->set_sp(state.sp); | 2050 sample->set_sp(state.sp); |
| 2050 sample->set_fp(state.fp); | 2051 sample->set_fp(state.fp); |
| 2051 #if !(defined(TARGET_OS_WINDOWS) && defined(TARGET_ARCH_X64)) | 2052 if (isolate->vm_tag() == VMTag::kDartTagId) { |
| 2052 // It is never safe to read other thread's stack unless on Win64 | 2053 // We should only read the PC marker when executing Dart code. |
| 2053 // other thread is inside Dart code. | 2054 SetPCMarkerIfSafe(sample); |
| 2054 SetPCMarkerIfSafe(sample); | 2055 } |
| 2055 #endif | |
| 2056 | |
| 2057 // Walk the call stack. | 2056 // Walk the call stack. |
| 2058 if (FLAG_profile_vm) { | 2057 if (FLAG_profile_vm) { |
| 2059 // Always walk the native stack collecting both native and Dart frames. | 2058 // Always walk the native stack collecting both native and Dart frames. |
| 2060 ProfilerNativeStackWalker stackWalker(sample, | 2059 ProfilerNativeStackWalker stackWalker(sample, |
| 2061 stack_lower, | 2060 stack_lower, |
| 2062 stack_upper, | 2061 stack_upper, |
| 2063 state.pc, | 2062 state.pc, |
| 2064 state.fp, | 2063 state.fp, |
| 2065 state.sp); | 2064 state.sp); |
| 2066 stackWalker.walk(); | 2065 stackWalker.walk(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2092 stack_upper, | 2091 stack_upper, |
| 2093 state.pc, | 2092 state.pc, |
| 2094 state.fp, | 2093 state.fp, |
| 2095 state.sp); | 2094 state.sp); |
| 2096 stackWalker.walk(); | 2095 stackWalker.walk(); |
| 2097 } | 2096 } |
| 2098 } | 2097 } |
| 2099 } | 2098 } |
| 2100 | 2099 |
| 2101 } // namespace dart | 2100 } // namespace dart |
| OLD | NEW |