| 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/memory_sanitizer.h" | 6 #include "platform/memory_sanitizer.h" |
| 6 #include "platform/utils.h" | 7 #include "platform/utils.h" |
| 7 | 8 |
| 8 #include "vm/allocation.h" | 9 #include "vm/allocation.h" |
| 9 #include "vm/atomic.h" | 10 #include "vm/atomic.h" |
| 10 #include "vm/code_patcher.h" | 11 #include "vm/code_patcher.h" |
| 11 #include "vm/isolate.h" | 12 #include "vm/isolate.h" |
| 12 #include "vm/json_stream.h" | 13 #include "vm/json_stream.h" |
| 13 #include "vm/lockers.h" | 14 #include "vm/lockers.h" |
| 14 #include "vm/native_symbol.h" | 15 #include "vm/native_symbol.h" |
| (...skipping 1657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1672 #if defined(TARGET_OS_WINDOWS) | 1673 #if defined(TARGET_OS_WINDOWS) |
| 1673 // If the fp is at the beginning of a page, it may be unsafe to access | 1674 // If the fp is at the beginning of a page, it may be unsafe to access |
| 1674 // the pc marker, because we are reading it from a different thread on | 1675 // the pc marker, because we are reading it from a different thread on |
| 1675 // Windows. The marker is below fp and the previous page may be a guard | 1676 // Windows. The marker is below fp and the previous page may be a guard |
| 1676 // page. | 1677 // page. |
| 1677 const intptr_t kPageMask = VirtualMemory::PageSize() - 1; | 1678 const intptr_t kPageMask = VirtualMemory::PageSize() - 1; |
| 1678 if ((sample->fp() & kPageMask) == 0) { | 1679 if ((sample->fp() & kPageMask) == 0) { |
| 1679 return; | 1680 return; |
| 1680 } | 1681 } |
| 1681 #endif | 1682 #endif |
| 1682 const uword pc_marker = *(fp + kPcMarkerSlotFromFp); | 1683 uword* pc_marker_ptr = fp + kPcMarkerSlotFromFp; |
| 1683 sample->set_pc_marker(pc_marker); | 1684 // MSan/ASan are unaware of frames initialized by generated code. |
| 1685 MSAN_UNPOISON(pc_marker_ptr, kWordSize); |
| 1686 ASAN_UNPOISON(pc_marker_ptr, kWordSize); |
| 1687 sample->set_pc_marker(*pc_marker_ptr); |
| 1684 } | 1688 } |
| 1685 } | 1689 } |
| 1686 | 1690 |
| 1687 | 1691 |
| 1688 // Given an exit frame, walk the Dart stack. | 1692 // Given an exit frame, walk the Dart stack. |
| 1689 class ProfilerDartExitStackWalker : public ValueObject { | 1693 class ProfilerDartExitStackWalker : public ValueObject { |
| 1690 public: | 1694 public: |
| 1691 ProfilerDartExitStackWalker(Isolate* isolate, Sample* sample) | 1695 ProfilerDartExitStackWalker(Isolate* isolate, Sample* sample) |
| 1692 : sample_(sample), | 1696 : sample_(sample), |
| 1693 frame_iterator_(isolate) { | 1697 frame_iterator_(isolate) { |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1923 } | 1927 } |
| 1924 | 1928 |
| 1925 // Move the lower bound up. | 1929 // Move the lower bound up. |
| 1926 lower_bound_ = reinterpret_cast<uword>(fp); | 1930 lower_bound_ = reinterpret_cast<uword>(fp); |
| 1927 } | 1931 } |
| 1928 } | 1932 } |
| 1929 | 1933 |
| 1930 private: | 1934 private: |
| 1931 uword* CallerPC(uword* fp) const { | 1935 uword* CallerPC(uword* fp) const { |
| 1932 ASSERT(fp != NULL); | 1936 ASSERT(fp != NULL); |
| 1933 return reinterpret_cast<uword*>(*(fp + kSavedCallerPcSlotFromFp)); | 1937 uword* caller_pc_ptr = fp + kSavedCallerPcSlotFromFp; |
| 1938 // This may actually be uninitialized, by design (see class comment above). |
| 1939 MSAN_UNPOISON(caller_pc_ptr, kWordSize); |
| 1940 ASAN_UNPOISON(caller_pc_ptr, kWordSize); |
| 1941 return reinterpret_cast<uword*>(*caller_pc_ptr); |
| 1934 } | 1942 } |
| 1935 | 1943 |
| 1936 uword* CallerFP(uword* fp) const { | 1944 uword* CallerFP(uword* fp) const { |
| 1937 ASSERT(fp != NULL); | 1945 ASSERT(fp != NULL); |
| 1938 uword* caller_fp_ptr = fp + kSavedCallerFpSlotFromFp; | 1946 uword* caller_fp_ptr = fp + kSavedCallerFpSlotFromFp; |
| 1939 // This may actually be uninitialized, by design (see class comment above). | 1947 // This may actually be uninitialized, by design (see class comment above). |
| 1940 MSAN_UNPOISON(caller_fp_ptr, kWordSize); | 1948 MSAN_UNPOISON(caller_fp_ptr, kWordSize); |
| 1949 ASAN_UNPOISON(caller_fp_ptr, kWordSize); |
| 1941 return reinterpret_cast<uword*>(*caller_fp_ptr); | 1950 return reinterpret_cast<uword*>(*caller_fp_ptr); |
| 1942 } | 1951 } |
| 1943 | 1952 |
| 1944 bool ValidFramePointer(uword* fp) const { | 1953 bool ValidFramePointer(uword* fp) const { |
| 1945 if (fp == NULL) { | 1954 if (fp == NULL) { |
| 1946 return false; | 1955 return false; |
| 1947 } | 1956 } |
| 1948 uword cursor = reinterpret_cast<uword>(fp); | 1957 uword cursor = reinterpret_cast<uword>(fp); |
| 1949 cursor += sizeof(fp); | 1958 cursor += sizeof(fp); |
| 1950 bool r = (cursor >= lower_bound_) && (cursor < stack_upper_); | 1959 bool r = (cursor >= lower_bound_) && (cursor < stack_upper_); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2007 | 2016 |
| 2008 if (StubCode::InJumpToExceptionHandlerStub(state.pc)) { | 2017 if (StubCode::InJumpToExceptionHandlerStub(state.pc)) { |
| 2009 // The JumpToExceptionHandler stub manually adjusts the stack pointer, | 2018 // The JumpToExceptionHandler stub manually adjusts the stack pointer, |
| 2010 // frame pointer, and some isolate state before jumping to a catch entry. | 2019 // frame pointer, and some isolate state before jumping to a catch entry. |
| 2011 // It is not safe to walk the stack when executing this stub. | 2020 // It is not safe to walk the stack when executing this stub. |
| 2012 return; | 2021 return; |
| 2013 } | 2022 } |
| 2014 | 2023 |
| 2015 uword stack_lower = 0; | 2024 uword stack_lower = 0; |
| 2016 uword stack_upper = 0; | 2025 uword stack_upper = 0; |
| 2017 isolate->GetProfilerStackBounds(&stack_lower, &stack_upper); | 2026 if (!isolate->GetProfilerStackBounds(&stack_lower, &stack_upper) || |
| 2018 if ((stack_lower == 0) || (stack_upper == 0)) { | 2027 (stack_lower == 0) || (stack_upper == 0)) { |
| 2019 // Could not get stack boundary. | 2028 // Could not get stack boundary. |
| 2020 return; | 2029 return; |
| 2021 } | 2030 } |
| 2022 | 2031 |
| 2023 if (sp > stack_lower) { | 2032 if (sp > stack_lower) { |
| 2024 // The stack pointer gives us a tighter lower bound. | 2033 // The stack pointer gives us a tighter lower bound. |
| 2025 stack_lower = sp; | 2034 stack_lower = sp; |
| 2026 } | 2035 } |
| 2027 | 2036 |
| 2028 if (stack_lower >= stack_upper) { | 2037 if (stack_lower >= stack_upper) { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2114 state.pc, | 2123 state.pc, |
| 2115 state.fp, | 2124 state.fp, |
| 2116 sp); | 2125 sp); |
| 2117 stackWalker.walk(); | 2126 stackWalker.walk(); |
| 2118 #endif | 2127 #endif |
| 2119 } | 2128 } |
| 2120 } | 2129 } |
| 2121 } | 2130 } |
| 2122 | 2131 |
| 2123 } // namespace dart | 2132 } // namespace dart |
| OLD | NEW |