| 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 1669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1680 // Not walking the stack, only took exclusive sample. | 1680 // Not walking the stack, only took exclusive sample. |
| 1681 return 1; | 1681 return 1; |
| 1682 } | 1682 } |
| 1683 uword* pc = reinterpret_cast<uword*>(original_pc_); | 1683 uword* pc = reinterpret_cast<uword*>(original_pc_); |
| 1684 uword* fp = reinterpret_cast<uword*>(original_fp_); | 1684 uword* fp = reinterpret_cast<uword*>(original_fp_); |
| 1685 uword* previous_fp = fp; | 1685 uword* previous_fp = fp; |
| 1686 if (original_sp_ > original_fp_) { | 1686 if (original_sp_ > original_fp_) { |
| 1687 // Stack pointer should not be above frame pointer. | 1687 // Stack pointer should not be above frame pointer. |
| 1688 return 1; | 1688 return 1; |
| 1689 } | 1689 } |
| 1690 intptr_t gap = original_fp_ - original_sp_; | 1690 const intptr_t gap = original_fp_ - original_sp_; |
| 1691 if (gap >= kMaxStep) { | 1691 if (gap >= kMaxStep) { |
| 1692 // Gap between frame pointer and stack pointer is | 1692 // Gap between frame pointer and stack pointer is |
| 1693 // too large. | 1693 // too large. |
| 1694 return 1; | 1694 return 1; |
| 1695 } | 1695 } |
| 1696 if (original_sp_ < lower_bound_) { | 1696 if (original_sp_ < lower_bound_) { |
| 1697 // The stack pointer gives us a better lower bound than | 1697 // The stack pointer gives us a better lower bound than |
| 1698 // the isolates stack limit. | 1698 // the isolates stack limit. |
| 1699 lower_bound_ = original_sp_; | 1699 lower_bound_ = original_sp_; |
| 1700 } | 1700 } |
| 1701 // Store the PC marker for the top frame. | 1701 #if defined(TARGET_OS_WINDOWS) |
| 1702 sample_->set_pc_marker(GetCurrentFramePcMarker(fp)); | 1702 // If the original_fp_ is at the beginning of a page, it may be unsafe |
| 1703 // to access the pc marker, because we are reading it from a different |
| 1704 // thread on Windows. The next page may be a guard page. |
| 1705 const intptr_t kPageMask = kMaxStep - 1; |
| 1706 bool safe_to_read_pc_marker = (original_fp_ & kPageMask) != 0; |
| 1707 #else |
| 1708 bool safe_to_read_pc_marker = true; |
| 1709 #endif |
| 1710 if (safe_to_read_pc_marker && (gap > 0)) { |
| 1711 // Store the PC marker for the top frame. |
| 1712 sample_->set_pc_marker(GetCurrentFramePcMarker(fp)); |
| 1713 } |
| 1703 int i = 0; | 1714 int i = 0; |
| 1704 for (; i < FLAG_profile_depth; i++) { | 1715 for (; i < FLAG_profile_depth; i++) { |
| 1705 if (FLAG_profile_verify_stack_walk) { | 1716 if (FLAG_profile_verify_stack_walk) { |
| 1706 VerifyCodeAddress(heap, i, reinterpret_cast<uword>(pc)); | 1717 VerifyCodeAddress(heap, i, reinterpret_cast<uword>(pc)); |
| 1707 } | 1718 } |
| 1708 sample_->SetAt(i, reinterpret_cast<uword>(pc)); | 1719 sample_->SetAt(i, reinterpret_cast<uword>(pc)); |
| 1709 if (fp == NULL) { | 1720 if (fp == NULL) { |
| 1710 return i + 1; | 1721 return i + 1; |
| 1711 } | 1722 } |
| 1712 if (!ValidFramePointer(fp)) { | 1723 if (!ValidFramePointer(fp)) { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1831 ProfilerDartStackWalker stackWalker(sample); | 1842 ProfilerDartStackWalker stackWalker(sample); |
| 1832 stackWalker.walk(); | 1843 stackWalker.walk(); |
| 1833 } else { | 1844 } else { |
| 1834 // TODO(johnmccutchan): Support collecting only Dart frames with | 1845 // TODO(johnmccutchan): Support collecting only Dart frames with |
| 1835 // ProfilerNativeStackWalker. | 1846 // ProfilerNativeStackWalker. |
| 1836 } | 1847 } |
| 1837 } | 1848 } |
| 1838 } | 1849 } |
| 1839 | 1850 |
| 1840 } // namespace dart | 1851 } // namespace dart |
| OLD | NEW |