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

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

Issue 298153002: Version 1.4.1 (Closed) Base URL: http://dart.googlecode.com/svn/branches/1.4/
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 | « dart/runtime/vm/parser.cc ('k') | dart/runtime/vm/thread_interrupter.cc » ('j') | 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"
11 #include "vm/json_stream.h" 11 #include "vm/json_stream.h"
12 #include "vm/native_symbol.h" 12 #include "vm/native_symbol.h"
13 #include "vm/object.h" 13 #include "vm/object.h"
14 #include "vm/os.h" 14 #include "vm/os.h"
15 #include "vm/profiler.h" 15 #include "vm/profiler.h"
16 #include "vm/reusable_handles.h" 16 #include "vm/reusable_handles.h"
17 #include "vm/signal_handler.h" 17 #include "vm/signal_handler.h"
18 #include "vm/simulator.h" 18 #include "vm/simulator.h"
19 #include "vm/stack_frame.h" 19 #include "vm/stack_frame.h"
20 20
21 namespace dart { 21 namespace dart {
22 22
23 23
24 #if defined(USING_SIMULATOR) || defined(TARGET_OS_WINDOWS) || \ 24 #if defined(USING_SIMULATOR) || defined(TARGET_OS_ANDROID)
25 defined(TARGET_OS_ANDROID)
26 DEFINE_FLAG(bool, profile, false, "Enable Sampling Profiler"); 25 DEFINE_FLAG(bool, profile, false, "Enable Sampling Profiler");
27 #else 26 #else
28 DEFINE_FLAG(bool, profile, true, "Enable Sampling Profiler"); 27 DEFINE_FLAG(bool, profile, true, "Enable Sampling Profiler");
29 #endif 28 #endif
30 DEFINE_FLAG(bool, trace_profiled_isolates, false, "Trace profiled isolates."); 29 DEFINE_FLAG(bool, trace_profiled_isolates, false, "Trace profiled isolates.");
31 DEFINE_FLAG(charp, profile_dir, NULL, 30 DEFINE_FLAG(charp, profile_dir, NULL,
32 "Enable writing profile data into specified directory."); 31 "Enable writing profile data into specified directory.");
33 DEFINE_FLAG(int, profile_period, 1000, 32 DEFINE_FLAG(int, profile_period, 1000,
34 "Time between profiler samples in microseconds. Minimum 50."); 33 "Time between profiler samples in microseconds. Minimum 50.");
35 DEFINE_FLAG(int, profile_depth, 8, 34 DEFINE_FLAG(int, profile_depth, 8,
(...skipping 1645 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 // Not walking the stack, only took exclusive sample. 1680 // Not walking the stack, only took exclusive sample.
1682 return 1; 1681 return 1;
1683 } 1682 }
1684 uword* pc = reinterpret_cast<uword*>(original_pc_); 1683 uword* pc = reinterpret_cast<uword*>(original_pc_);
1685 uword* fp = reinterpret_cast<uword*>(original_fp_); 1684 uword* fp = reinterpret_cast<uword*>(original_fp_);
1686 uword* previous_fp = fp; 1685 uword* previous_fp = fp;
1687 if (original_sp_ > original_fp_) { 1686 if (original_sp_ > original_fp_) {
1688 // Stack pointer should not be above frame pointer. 1687 // Stack pointer should not be above frame pointer.
1689 return 1; 1688 return 1;
1690 } 1689 }
1691 intptr_t gap = original_fp_ - original_sp_; 1690 const intptr_t gap = original_fp_ - original_sp_;
1692 if (gap >= kMaxStep) { 1691 if (gap >= kMaxStep) {
1693 // Gap between frame pointer and stack pointer is 1692 // Gap between frame pointer and stack pointer is
1694 // too large. 1693 // too large.
1695 return 1; 1694 return 1;
1696 } 1695 }
1697 if (original_sp_ < lower_bound_) { 1696 if (original_sp_ < lower_bound_) {
1698 // The stack pointer gives us a better lower bound than 1697 // The stack pointer gives us a better lower bound than
1699 // the isolates stack limit. 1698 // the isolates stack limit.
1700 lower_bound_ = original_sp_; 1699 lower_bound_ = original_sp_;
1701 } 1700 }
1702 // Store the PC marker for the top frame. 1701 #if defined(TARGET_OS_WINDOWS)
1703 sample_->set_pc_marker(GetCurrentFramePcMarker(fp)); 1702 // If the original_fp_ is at the beginning of a page, it may be unsafe
1703 // to access the pc marker, because we are reading it from a different
1704 // thread on Windows. The next page may be a guard page.
1705 const intptr_t kPageMask = kMaxStep - 1;
1706 bool safe_to_read_pc_marker = (original_fp_ & kPageMask) != 0;
1707 #else
1708 bool safe_to_read_pc_marker = true;
1709 #endif
1710 if (safe_to_read_pc_marker && (gap > 0)) {
1711 // Store the PC marker for the top frame.
1712 sample_->set_pc_marker(GetCurrentFramePcMarker(fp));
1713 }
1704 int i = 0; 1714 int i = 0;
1705 for (; i < FLAG_profile_depth; i++) { 1715 for (; i < FLAG_profile_depth; i++) {
1706 if (FLAG_profile_verify_stack_walk) { 1716 if (FLAG_profile_verify_stack_walk) {
1707 VerifyCodeAddress(heap, i, reinterpret_cast<uword>(pc)); 1717 VerifyCodeAddress(heap, i, reinterpret_cast<uword>(pc));
1708 } 1718 }
1709 sample_->SetAt(i, reinterpret_cast<uword>(pc)); 1719 sample_->SetAt(i, reinterpret_cast<uword>(pc));
1710 if (fp == NULL) { 1720 if (fp == NULL) {
1711 return i + 1; 1721 return i + 1;
1712 } 1722 }
1713 if (!ValidFramePointer(fp)) { 1723 if (!ValidFramePointer(fp)) {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1832 ProfilerDartStackWalker stackWalker(sample); 1842 ProfilerDartStackWalker stackWalker(sample);
1833 stackWalker.walk(); 1843 stackWalker.walk();
1834 } else { 1844 } else {
1835 // TODO(johnmccutchan): Support collecting only Dart frames with 1845 // TODO(johnmccutchan): Support collecting only Dart frames with
1836 // ProfilerNativeStackWalker. 1846 // ProfilerNativeStackWalker.
1837 } 1847 }
1838 } 1848 }
1839 } 1849 }
1840 1850
1841 } // namespace dart 1851 } // namespace dart
OLDNEW
« no previous file with comments | « dart/runtime/vm/parser.cc ('k') | dart/runtime/vm/thread_interrupter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698