| 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 1487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1498 | 1498 |
| 1499 | 1499 |
| 1500 Sample* SampleBuffer::ReserveSample() { | 1500 Sample* SampleBuffer::ReserveSample() { |
| 1501 ASSERT(samples_ != NULL); | 1501 ASSERT(samples_ != NULL); |
| 1502 uintptr_t cursor = AtomicOperations::FetchAndIncrement(&cursor_); | 1502 uintptr_t cursor = AtomicOperations::FetchAndIncrement(&cursor_); |
| 1503 // Map back into sample buffer range. | 1503 // Map back into sample buffer range. |
| 1504 cursor = cursor % capacity_; | 1504 cursor = cursor % capacity_; |
| 1505 return At(cursor); | 1505 return At(cursor); |
| 1506 } | 1506 } |
| 1507 | 1507 |
| 1508 |
| 1508 class ProfilerDartStackWalker : public ValueObject { | 1509 class ProfilerDartStackWalker : public ValueObject { |
| 1509 public: | 1510 public: |
| 1510 explicit ProfilerDartStackWalker(Sample* sample) | 1511 explicit ProfilerDartStackWalker(Sample* sample) |
| 1511 : sample_(sample), | 1512 : sample_(sample), |
| 1512 frame_iterator_() { | 1513 frame_iterator_() { |
| 1513 ASSERT(sample_ != NULL); | 1514 ASSERT(sample_ != NULL); |
| 1514 } | 1515 } |
| 1515 | 1516 |
| 1516 ProfilerDartStackWalker(Sample* sample, uword pc, uword fp, uword sp) | 1517 ProfilerDartStackWalker(Sample* sample, uword pc, uword fp, uword sp) |
| 1517 : sample_(sample), | 1518 : sample_(sample), |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1537 frame = frame_iterator_.NextFrame(); | 1538 frame = frame_iterator_.NextFrame(); |
| 1538 } | 1539 } |
| 1539 return frame_index; | 1540 return frame_index; |
| 1540 } | 1541 } |
| 1541 | 1542 |
| 1542 private: | 1543 private: |
| 1543 Sample* sample_; | 1544 Sample* sample_; |
| 1544 DartFrameIterator frame_iterator_; | 1545 DartFrameIterator frame_iterator_; |
| 1545 }; | 1546 }; |
| 1546 | 1547 |
| 1548 |
| 1547 // Notes on stack frame walking: | 1549 // Notes on stack frame walking: |
| 1548 // | 1550 // |
| 1549 // The sampling profiler will collect up to Sample::kNumStackFrames stack frames | 1551 // The sampling profiler will collect up to Sample::kNumStackFrames stack frames |
| 1550 // The stack frame walking code uses the frame pointer to traverse the stack. | 1552 // The stack frame walking code uses the frame pointer to traverse the stack. |
| 1551 // If the VM is compiled without frame pointers (which is the default on | 1553 // If the VM is compiled without frame pointers (which is the default on |
| 1552 // recent GCC versions with optimizing enabled) the stack walking code may | 1554 // recent GCC versions with optimizing enabled) the stack walking code may |
| 1553 // fail (sometimes leading to a crash). | 1555 // fail (sometimes leading to a crash). |
| 1554 // | 1556 // |
| 1555 class ProfilerNativeStackWalker : public ValueObject { | 1557 class ProfilerNativeStackWalker : public ValueObject { |
| 1556 public: | 1558 public: |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1719 ProfilerDartStackWalker stackWalker(sample); | 1721 ProfilerDartStackWalker stackWalker(sample); |
| 1720 stackWalker.walk(); | 1722 stackWalker.walk(); |
| 1721 } else { | 1723 } else { |
| 1722 // TODO(johnmccutchan): Support collecting only Dart frames with | 1724 // TODO(johnmccutchan): Support collecting only Dart frames with |
| 1723 // ProfilerNativeStackWalker. | 1725 // ProfilerNativeStackWalker. |
| 1724 } | 1726 } |
| 1725 } | 1727 } |
| 1726 } | 1728 } |
| 1727 | 1729 |
| 1728 } // namespace dart | 1730 } // namespace dart |
| OLD | NEW |