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 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1035 } | 1035 } |
1036 // Make sure VM tag is created. | 1036 // Make sure VM tag is created. |
1037 if (VMTag::IsNativeEntryTag(sample->vm_tag())) { | 1037 if (VMTag::IsNativeEntryTag(sample->vm_tag())) { |
1038 CreateTag(VMTag::kNativeTagId); | 1038 CreateTag(VMTag::kNativeTagId); |
1039 } else if (VMTag::IsRuntimeEntryTag(sample->vm_tag())) { | 1039 } else if (VMTag::IsRuntimeEntryTag(sample->vm_tag())) { |
1040 CreateTag(VMTag::kRuntimeTagId); | 1040 CreateTag(VMTag::kRuntimeTagId); |
1041 } | 1041 } |
1042 CreateTag(sample->vm_tag()); | 1042 CreateTag(sample->vm_tag()); |
1043 // Make sure user tag is created. | 1043 // Make sure user tag is created. |
1044 CreateUserTag(sample->user_tag()); | 1044 CreateUserTag(sample->user_tag()); |
1045 // Exclusive tick for bottom frame. | 1045 // Exclusive tick for bottom frame if we aren't sampled from an exit frame. |
1046 Tick(sample->At(0), true, timestamp); | 1046 if (!sample->exit_frame_sample()) { |
| 1047 Tick(sample->At(0), true, timestamp); |
| 1048 } |
1047 // Inclusive tick for all frames. | 1049 // Inclusive tick for all frames. |
1048 for (intptr_t i = 0; i < FLAG_profile_depth; i++) { | 1050 for (intptr_t i = 0; i < FLAG_profile_depth; i++) { |
1049 if (sample->At(i) == 0) { | 1051 if (sample->At(i) == 0) { |
1050 break; | 1052 break; |
1051 } | 1053 } |
1052 frames_++; | 1054 frames_++; |
1053 Tick(sample->At(i), false, timestamp); | 1055 Tick(sample->At(i), false, timestamp); |
1054 } | 1056 } |
1055 } | 1057 } |
1056 | 1058 |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1684 } | 1686 } |
1685 | 1687 |
1686 | 1688 |
1687 // Given an exit frame, walk the Dart stack. | 1689 // Given an exit frame, walk the Dart stack. |
1688 class ProfilerDartExitStackWalker : public ValueObject { | 1690 class ProfilerDartExitStackWalker : public ValueObject { |
1689 public: | 1691 public: |
1690 ProfilerDartExitStackWalker(Isolate* isolate, Sample* sample) | 1692 ProfilerDartExitStackWalker(Isolate* isolate, Sample* sample) |
1691 : sample_(sample), | 1693 : sample_(sample), |
1692 frame_iterator_(isolate) { | 1694 frame_iterator_(isolate) { |
1693 ASSERT(sample_ != NULL); | 1695 ASSERT(sample_ != NULL); |
| 1696 // Mark that this sample was collected from an exit frame. |
| 1697 sample_->set_exit_frame_sample(true); |
1694 } | 1698 } |
1695 | 1699 |
1696 void walk() { | 1700 void walk() { |
1697 intptr_t frame_index = 0; | 1701 intptr_t frame_index = 0; |
1698 StackFrame* frame = frame_iterator_.NextFrame(); | 1702 StackFrame* frame = frame_iterator_.NextFrame(); |
1699 while (frame != NULL) { | 1703 while (frame != NULL) { |
1700 sample_->SetAt(frame_index, frame->pc()); | 1704 sample_->SetAt(frame_index, frame->pc()); |
1701 frame_index++; | 1705 frame_index++; |
1702 if (frame_index >= FLAG_profile_depth) { | 1706 if (frame_index >= FLAG_profile_depth) { |
1703 break; | 1707 break; |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2048 stack_upper, | 2052 stack_upper, |
2049 state.pc, | 2053 state.pc, |
2050 state.fp, | 2054 state.fp, |
2051 state.sp); | 2055 state.sp); |
2052 stackWalker.walk(); | 2056 stackWalker.walk(); |
2053 } else { | 2057 } else { |
2054 // Attempt to walk only the Dart call stack, falling back to walking | 2058 // Attempt to walk only the Dart call stack, falling back to walking |
2055 // the native stack. | 2059 // the native stack. |
2056 if ((isolate->stub_code() != NULL) && | 2060 if ((isolate->stub_code() != NULL) && |
2057 (isolate->top_exit_frame_info() != 0) && | 2061 (isolate->top_exit_frame_info() != 0) && |
2058 (isolate->vm_tag() != VMTag::kScriptTagId)) { | 2062 (isolate->vm_tag() != VMTag::kDartTagId)) { |
2059 // We have a valid exit frame info, use the Dart stack walker. | 2063 // We have a valid exit frame info, use the Dart stack walker. |
2060 ProfilerDartExitStackWalker stackWalker(isolate, sample); | 2064 ProfilerDartExitStackWalker stackWalker(isolate, sample); |
2061 stackWalker.walk(); | 2065 stackWalker.walk(); |
2062 } else if ((isolate->stub_code() != NULL) && | 2066 } else if ((isolate->stub_code() != NULL) && |
2063 (isolate->top_exit_frame_info() == 0) && | 2067 (isolate->top_exit_frame_info() == 0) && |
2064 (isolate->vm_tag() == VMTag::kScriptTagId)) { | 2068 (isolate->vm_tag() == VMTag::kDartTagId)) { |
2065 // We are executing Dart code. We have frame pointers. | 2069 // We are executing Dart code. We have frame pointers. |
2066 ProfilerDartStackWalker stackWalker(isolate, | 2070 ProfilerDartStackWalker stackWalker(isolate, |
2067 sample, | 2071 sample, |
2068 stack_lower, | 2072 stack_lower, |
2069 stack_upper, | 2073 stack_upper, |
2070 state.pc, | 2074 state.pc, |
2071 state.fp, | 2075 state.fp, |
2072 state.sp); | 2076 state.sp); |
2073 stackWalker.walk(); | 2077 stackWalker.walk(); |
2074 } else { | 2078 } else { |
2075 // Fall back to an extremely conservative stack walker. | 2079 // Fall back to an extremely conservative stack walker. |
2076 ProfilerNativeStackWalker stackWalker(sample, | 2080 ProfilerNativeStackWalker stackWalker(sample, |
2077 stack_lower, | 2081 stack_lower, |
2078 stack_upper, | 2082 stack_upper, |
2079 state.pc, | 2083 state.pc, |
2080 state.fp, | 2084 state.fp, |
2081 state.sp); | 2085 state.sp); |
2082 stackWalker.walk(); | 2086 stackWalker.walk(); |
2083 } | 2087 } |
2084 } | 2088 } |
2085 } | 2089 } |
2086 | 2090 |
2087 } // namespace dart | 2091 } // namespace dart |
OLD | NEW |