| 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 1567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1578 file_write(buffer->buf(), buffer->length(), f); | 1578 file_write(buffer->buf(), buffer->length(), f); |
| 1579 file_close(f); | 1579 file_close(f); |
| 1580 } | 1580 } |
| 1581 | 1581 |
| 1582 | 1582 |
| 1583 IsolateProfilerData::IsolateProfilerData(SampleBuffer* sample_buffer, | 1583 IsolateProfilerData::IsolateProfilerData(SampleBuffer* sample_buffer, |
| 1584 bool own_sample_buffer) { | 1584 bool own_sample_buffer) { |
| 1585 ASSERT(sample_buffer != NULL); | 1585 ASSERT(sample_buffer != NULL); |
| 1586 sample_buffer_ = sample_buffer; | 1586 sample_buffer_ = sample_buffer; |
| 1587 own_sample_buffer_ = own_sample_buffer; | 1587 own_sample_buffer_ = own_sample_buffer; |
| 1588 block_count_ = 0; |
| 1588 } | 1589 } |
| 1589 | 1590 |
| 1590 | 1591 |
| 1591 IsolateProfilerData::~IsolateProfilerData() { | 1592 IsolateProfilerData::~IsolateProfilerData() { |
| 1592 if (own_sample_buffer_) { | 1593 if (own_sample_buffer_) { |
| 1593 delete sample_buffer_; | 1594 delete sample_buffer_; |
| 1594 sample_buffer_ = NULL; | 1595 sample_buffer_ = NULL; |
| 1595 own_sample_buffer_ = false; | 1596 own_sample_buffer_ = false; |
| 1596 } | 1597 } |
| 1597 } | 1598 } |
| 1598 | 1599 |
| 1599 | 1600 |
| 1601 void IsolateProfilerData::Block() { |
| 1602 block_count_++; |
| 1603 } |
| 1604 |
| 1605 |
| 1606 void IsolateProfilerData::Unblock() { |
| 1607 block_count_--; |
| 1608 if (block_count_ < 0) { |
| 1609 FATAL("Too many calls to Dart_IsolateUnblocked."); |
| 1610 } |
| 1611 if (!blocked()) { |
| 1612 // We just unblocked this isolate, wake up the thread interrupter. |
| 1613 ThreadInterrupter::WakeUp(); |
| 1614 } |
| 1615 } |
| 1616 |
| 1617 |
| 1600 Sample* SampleBuffer::ReserveSample() { | 1618 Sample* SampleBuffer::ReserveSample() { |
| 1601 ASSERT(samples_ != NULL); | 1619 ASSERT(samples_ != NULL); |
| 1602 uintptr_t cursor = AtomicOperations::FetchAndIncrement(&cursor_); | 1620 uintptr_t cursor = AtomicOperations::FetchAndIncrement(&cursor_); |
| 1603 // Map back into sample buffer range. | 1621 // Map back into sample buffer range. |
| 1604 cursor = cursor % capacity_; | 1622 cursor = cursor % capacity_; |
| 1605 return At(cursor); | 1623 return At(cursor); |
| 1606 } | 1624 } |
| 1607 | 1625 |
| 1608 | 1626 |
| 1609 class ProfilerDartStackWalker : public ValueObject { | 1627 class ProfilerDartStackWalker : public ValueObject { |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1831 ProfilerDartStackWalker stackWalker(sample); | 1849 ProfilerDartStackWalker stackWalker(sample); |
| 1832 stackWalker.walk(); | 1850 stackWalker.walk(); |
| 1833 } else { | 1851 } else { |
| 1834 // TODO(johnmccutchan): Support collecting only Dart frames with | 1852 // TODO(johnmccutchan): Support collecting only Dart frames with |
| 1835 // ProfilerNativeStackWalker. | 1853 // ProfilerNativeStackWalker. |
| 1836 } | 1854 } |
| 1837 } | 1855 } |
| 1838 } | 1856 } |
| 1839 | 1857 |
| 1840 } // namespace dart | 1858 } // namespace dart |
| OLD | NEW |