Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: runtime/vm/profiler.cc

Issue 341083002: Use Dart stack walker when we have an exit frame. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 18 matching lines...) Expand all
29 #endif 29 #endif
30 DEFINE_FLAG(bool, trace_profiled_isolates, false, "Trace profiled isolates."); 30 DEFINE_FLAG(bool, trace_profiled_isolates, false, "Trace profiled isolates.");
31 DEFINE_FLAG(charp, profile_dir, NULL, 31 DEFINE_FLAG(charp, profile_dir, NULL,
32 "Enable writing profile data into specified directory."); 32 "Enable writing profile data into specified directory.");
33 DEFINE_FLAG(int, profile_period, 1000, 33 DEFINE_FLAG(int, profile_period, 1000,
34 "Time between profiler samples in microseconds. Minimum 50."); 34 "Time between profiler samples in microseconds. Minimum 50.");
35 DEFINE_FLAG(int, profile_depth, 8, 35 DEFINE_FLAG(int, profile_depth, 8,
36 "Maximum number stack frames walked. Minimum 1. Maximum 255."); 36 "Maximum number stack frames walked. Minimum 1. Maximum 255.");
37 DEFINE_FLAG(bool, profile_verify_stack_walk, false, 37 DEFINE_FLAG(bool, profile_verify_stack_walk, false,
38 "Verify instruction addresses while walking the stack."); 38 "Verify instruction addresses while walking the stack.");
39 DEFINE_FLAG(bool, profile_native_stack, true, 39 DEFINE_FLAG(bool, profile_native_stack, false,
40 "Use native stack in profiler."); 40 "Use native stack in profiler.");
41 41
42 bool Profiler::initialized_ = false; 42 bool Profiler::initialized_ = false;
43 SampleBuffer* Profiler::sample_buffer_ = NULL; 43 SampleBuffer* Profiler::sample_buffer_ = NULL;
44 44
45 void Profiler::InitOnce() { 45 void Profiler::InitOnce() {
46 // Place some sane restrictions on user controlled flags. 46 // Place some sane restrictions on user controlled flags.
47 SetSamplePeriod(FLAG_profile_period); 47 SetSamplePeriod(FLAG_profile_period);
48 SetSampleDepth(FLAG_profile_depth); 48 SetSampleDepth(FLAG_profile_depth);
49 if (!FLAG_profile) { 49 if (!FLAG_profile) {
(...skipping 1577 matching lines...) Expand 10 before | Expand all | Expand 10 after
1627 1627
1628 1628
1629 class ProfilerDartStackWalker : public ValueObject { 1629 class ProfilerDartStackWalker : public ValueObject {
1630 public: 1630 public:
1631 explicit ProfilerDartStackWalker(Sample* sample) 1631 explicit ProfilerDartStackWalker(Sample* sample)
1632 : sample_(sample), 1632 : sample_(sample),
1633 frame_iterator_() { 1633 frame_iterator_() {
1634 ASSERT(sample_ != NULL); 1634 ASSERT(sample_ != NULL);
1635 } 1635 }
1636 1636
1637 ProfilerDartStackWalker(Sample* sample, uword pc, uword fp, uword sp)
1638 : sample_(sample),
1639 frame_iterator_(fp, sp, pc) {
1640 ASSERT(sample_ != NULL);
1641 }
1642
1643 ProfilerDartStackWalker(Sample* sample, uword fp) 1637 ProfilerDartStackWalker(Sample* sample, uword fp)
1644 : sample_(sample), 1638 : sample_(sample),
1645 frame_iterator_(fp) { 1639 frame_iterator_(fp) {
1646 ASSERT(sample_ != NULL); 1640 ASSERT(sample_ != NULL);
1647 } 1641 }
1648 1642
1649 int walk() { 1643 int walk() {
1650 intptr_t frame_index = 0; 1644 intptr_t frame_index = 0;
1651 StackFrame* frame = frame_iterator_.NextFrame(); 1645 StackFrame* frame = frame_iterator_.NextFrame();
1652 while (frame != NULL) { 1646 while (frame != NULL) {
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1837 SampleBuffer* sample_buffer = profiler_data->sample_buffer(); 1831 SampleBuffer* sample_buffer = profiler_data->sample_buffer();
1838 if (sample_buffer == NULL) { 1832 if (sample_buffer == NULL) {
1839 return; 1833 return;
1840 } 1834 }
1841 Sample* sample = sample_buffer->ReserveSample(); 1835 Sample* sample = sample_buffer->ReserveSample();
1842 sample->Init(isolate, OS::GetCurrentTimeMicros(), state.tid); 1836 sample->Init(isolate, OS::GetCurrentTimeMicros(), state.tid);
1843 sample->set_vm_tag(isolate->vm_tag()); 1837 sample->set_vm_tag(isolate->vm_tag());
1844 sample->set_user_tag(isolate->user_tag()); 1838 sample->set_user_tag(isolate->user_tag());
1845 sample->set_sp(state.sp); 1839 sample->set_sp(state.sp);
1846 sample->set_fp(state.fp); 1840 sample->set_fp(state.fp);
1841
1842 uword stack_lower = 0;
1843 uword stack_upper = 0;
1844 isolate->GetStackBounds(&stack_lower, &stack_upper);
1845 if ((stack_lower == 0) || (stack_upper == 0)) {
1846 stack_lower = 0;
1847 stack_upper = 0;
1848 }
1847 if (FLAG_profile_native_stack) { 1849 if (FLAG_profile_native_stack) {
1848 // Collect native and Dart frames. 1850 // Collect native and Dart frames.
1849 uword stack_lower = 0;
1850 uword stack_upper = 0;
1851 isolate->GetStackBounds(&stack_lower, &stack_upper);
1852 if ((stack_lower == 0) || (stack_upper == 0)) {
1853 stack_lower = 0;
1854 stack_upper = 0;
1855 }
1856 ProfilerNativeStackWalker stackWalker(sample, stack_lower, stack_upper, 1851 ProfilerNativeStackWalker stackWalker(sample, stack_lower, stack_upper,
1857 state.pc, state.fp, state.sp); 1852 state.pc, state.fp, state.sp);
1858 stackWalker.walk(isolate->heap()); 1853 stackWalker.walk(isolate->heap());
1859 } else { 1854 } else if (isolate->stub_code() != NULL) {
1860 if ((isolate->top_exit_frame_info() != 0) && 1855 if (isolate->top_exit_frame_info() != 0) {
1861 (isolate->stub_code() != NULL)) {
1862 ProfilerDartStackWalker stackWalker(sample); 1856 ProfilerDartStackWalker stackWalker(sample);
1863 stackWalker.walk(); 1857 stackWalker.walk();
1864 } else { 1858 } else {
1865 // TODO(johnmccutchan): Support collecting only Dart frames with 1859 ProfilerNativeStackWalker stackWalker(sample, stack_lower, stack_upper,
1866 // ProfilerNativeStackWalker. 1860 state.pc, state.fp, state.sp);
1861 stackWalker.walk(isolate->heap());
1867 } 1862 }
1868 } 1863 }
siva 2014/06/19 20:22:17 Should there be an UNREACHEABLE() here, i.e you do
Cutch 2014/06/23 17:30:12 We want to collect samples during isolate start up
1869 } 1864 }
1870 1865
1871 } // namespace dart 1866 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698