| 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 1661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1672 ASSERT(sample != NULL); | 1672 ASSERT(sample != NULL); |
| 1673 | 1673 |
| 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 next page may be a guard page. | 1682 // Windows. The marker is below fp and the previous page may be a guard |
| 1683 // page. |
| 1683 const intptr_t kPageMask = VirtualMemory::PageSize() - 1; | 1684 const intptr_t kPageMask = VirtualMemory::PageSize() - 1; |
| 1684 if ((sample->fp() & kPageMask) == 0) { | 1685 if ((sample->fp() & kPageMask) == 0) { |
| 1685 return; | 1686 return; |
| 1686 } | 1687 } |
| 1687 #endif | 1688 #endif |
| 1688 const uword pc_marker = *(fp + kPcMarkerSlotFromFp); | 1689 const uword pc_marker = *(fp + kPcMarkerSlotFromFp); |
| 1689 sample->set_pc_marker(pc_marker); | 1690 sample->set_pc_marker(pc_marker); |
| 1690 } | 1691 } |
| 1691 } | 1692 } |
| 1692 | 1693 |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2040 ASSERT(counters != NULL); | 2041 ASSERT(counters != NULL); |
| 2041 counters->Increment(isolate->vm_tag()); | 2042 counters->Increment(isolate->vm_tag()); |
| 2042 | 2043 |
| 2043 // Setup sample. | 2044 // Setup sample. |
| 2044 Sample* sample = sample_buffer->ReserveSample(); | 2045 Sample* sample = sample_buffer->ReserveSample(); |
| 2045 sample->Init(isolate, OS::GetCurrentTimeMicros(), state.tid); | 2046 sample->Init(isolate, OS::GetCurrentTimeMicros(), state.tid); |
| 2046 sample->set_vm_tag(isolate->vm_tag()); | 2047 sample->set_vm_tag(isolate->vm_tag()); |
| 2047 sample->set_user_tag(isolate->user_tag()); | 2048 sample->set_user_tag(isolate->user_tag()); |
| 2048 sample->set_sp(state.sp); | 2049 sample->set_sp(state.sp); |
| 2049 sample->set_fp(state.fp); | 2050 sample->set_fp(state.fp); |
| 2051 #if !(defined(TARGET_OS_WINDOWS) && defined(TARGET_ARCH_X64)) |
| 2052 // It is never safe to read other thread's stack unless on Win64 |
| 2053 // other thread is inside Dart code. |
| 2050 SetPCMarkerIfSafe(sample); | 2054 SetPCMarkerIfSafe(sample); |
| 2055 #endif |
| 2051 | 2056 |
| 2052 // Walk the call stack. | 2057 // Walk the call stack. |
| 2053 if (FLAG_profile_vm) { | 2058 if (FLAG_profile_vm) { |
| 2054 // Always walk the native stack collecting both native and Dart frames. | 2059 // Always walk the native stack collecting both native and Dart frames. |
| 2055 ProfilerNativeStackWalker stackWalker(sample, | 2060 ProfilerNativeStackWalker stackWalker(sample, |
| 2056 stack_lower, | 2061 stack_lower, |
| 2057 stack_upper, | 2062 stack_upper, |
| 2058 state.pc, | 2063 state.pc, |
| 2059 state.fp, | 2064 state.fp, |
| 2060 state.sp); | 2065 state.sp); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2087 stack_upper, | 2092 stack_upper, |
| 2088 state.pc, | 2093 state.pc, |
| 2089 state.fp, | 2094 state.fp, |
| 2090 state.sp); | 2095 state.sp); |
| 2091 stackWalker.walk(); | 2096 stackWalker.walk(); |
| 2092 } | 2097 } |
| 2093 } | 2098 } |
| 2094 } | 2099 } |
| 2095 | 2100 |
| 2096 } // namespace dart | 2101 } // namespace dart |
| OLD | NEW |