| 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 1647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1658 ASSERT(samples_ != NULL); | 1658 ASSERT(samples_ != NULL); |
| 1659 uintptr_t cursor = AtomicOperations::FetchAndIncrement(&cursor_); | 1659 uintptr_t cursor = AtomicOperations::FetchAndIncrement(&cursor_); |
| 1660 // Map back into sample buffer range. | 1660 // Map back into sample buffer range. |
| 1661 cursor = cursor % capacity_; | 1661 cursor = cursor % capacity_; |
| 1662 return At(cursor); | 1662 return At(cursor); |
| 1663 } | 1663 } |
| 1664 | 1664 |
| 1665 | 1665 |
| 1666 class ProfilerDartStackWalker : public ValueObject { | 1666 class ProfilerDartStackWalker : public ValueObject { |
| 1667 public: | 1667 public: |
| 1668 explicit ProfilerDartStackWalker(Sample* sample) | 1668 ProfilerDartStackWalker(Isolate* isolate, Sample* sample) |
| 1669 : sample_(sample), | 1669 : sample_(sample), |
| 1670 frame_iterator_() { | 1670 frame_iterator_(isolate) { |
| 1671 ASSERT(sample_ != NULL); | 1671 ASSERT(sample_ != NULL); |
| 1672 } | 1672 } |
| 1673 | 1673 |
| 1674 ProfilerDartStackWalker(Sample* sample, uword fp) | 1674 ProfilerDartStackWalker(Isolate* isolate, Sample* sample, uword fp) |
| 1675 : sample_(sample), | 1675 : sample_(sample), |
| 1676 frame_iterator_(fp) { | 1676 frame_iterator_(fp, isolate) { |
| 1677 ASSERT(sample_ != NULL); | 1677 ASSERT(sample_ != NULL); |
| 1678 } | 1678 } |
| 1679 | 1679 |
| 1680 int walk() { | 1680 int walk() { |
| 1681 intptr_t frame_index = 0; | 1681 intptr_t frame_index = 0; |
| 1682 StackFrame* frame = frame_iterator_.NextFrame(); | 1682 StackFrame* frame = frame_iterator_.NextFrame(); |
| 1683 while (frame != NULL) { | 1683 while (frame != NULL) { |
| 1684 sample_->SetAt(frame_index, frame->pc()); | 1684 sample_->SetAt(frame_index, frame->pc()); |
| 1685 frame_index++; | 1685 frame_index++; |
| 1686 if (frame_index >= FLAG_profile_depth) { | 1686 if (frame_index >= FLAG_profile_depth) { |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1885 } | 1885 } |
| 1886 if (FLAG_profile_vm) { | 1886 if (FLAG_profile_vm) { |
| 1887 // Collect native and Dart frames. | 1887 // Collect native and Dart frames. |
| 1888 ProfilerNativeStackWalker stackWalker(sample, stack_lower, stack_upper, | 1888 ProfilerNativeStackWalker stackWalker(sample, stack_lower, stack_upper, |
| 1889 state.pc, state.fp, state.sp); | 1889 state.pc, state.fp, state.sp); |
| 1890 stackWalker.walk(isolate->heap()); | 1890 stackWalker.walk(isolate->heap()); |
| 1891 } else { | 1891 } else { |
| 1892 if ((isolate->stub_code() != NULL) && | 1892 if ((isolate->stub_code() != NULL) && |
| 1893 (isolate->top_exit_frame_info() != 0)) { | 1893 (isolate->top_exit_frame_info() != 0)) { |
| 1894 // Collect only Dart frames. | 1894 // Collect only Dart frames. |
| 1895 ProfilerDartStackWalker stackWalker(sample); | 1895 ProfilerDartStackWalker stackWalker(isolate, sample); |
| 1896 stackWalker.walk(); | 1896 stackWalker.walk(); |
| 1897 } else { | 1897 } else { |
| 1898 // Collect native and Dart frames. | 1898 // Collect native and Dart frames. |
| 1899 ProfilerNativeStackWalker stackWalker(sample, stack_lower, stack_upper, | 1899 ProfilerNativeStackWalker stackWalker(sample, stack_lower, stack_upper, |
| 1900 state.pc, state.fp, state.sp); | 1900 state.pc, state.fp, state.sp); |
| 1901 stackWalker.walk(isolate->heap()); | 1901 stackWalker.walk(isolate->heap()); |
| 1902 } | 1902 } |
| 1903 } | 1903 } |
| 1904 } | 1904 } |
| 1905 | 1905 |
| 1906 } // namespace dart | 1906 } // namespace dart |
| OLD | NEW |