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

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

Issue 1210283003: Extend allocation profile testing (Closed) Base URL: git@github.com:dart-lang/sdk.git@profile_model_public
Patch Set: Created 5 years, 5 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
« no previous file with comments | « runtime/vm/profiler_service.h ('k') | runtime/vm/profiler_test.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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 "vm/profiler_service.h" 5 #include "vm/profiler_service.h"
6 6
7 #include "vm/growable_array.h" 7 #include "vm/growable_array.h"
8 #include "vm/native_symbol.h" 8 #include "vm/native_symbol.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/os.h" 10 #include "vm/os.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 table_index_(table_index), 97 table_index_(table_index),
98 profile_codes_(0), 98 profile_codes_(0),
99 exclusive_ticks_(0), 99 exclusive_ticks_(0),
100 inclusive_ticks_(0) { 100 inclusive_ticks_(0) {
101 ASSERT((kind_ != kDartFunction) || !function_.IsNull()); 101 ASSERT((kind_ != kDartFunction) || !function_.IsNull());
102 ASSERT((kind_ != kDartFunction) || (table_index_ >= 0)); 102 ASSERT((kind_ != kDartFunction) || (table_index_ >= 0));
103 ASSERT(profile_codes_.length() == 0); 103 ASSERT(profile_codes_.length() == 0);
104 } 104 }
105 105
106 106
107 const char* ProfileFunction::Name() const {
108 if (name_ != NULL) {
109 return name_;
110 }
111 ASSERT(!function_.IsNull());
112 const String& func_name =
113 String::Handle(function_.QualifiedUserVisibleName());
114 return func_name.ToCString();
115 }
116
107 void ProfileFunction::Tick(bool exclusive, intptr_t inclusive_serial) { 117 void ProfileFunction::Tick(bool exclusive, intptr_t inclusive_serial) {
108 if (exclusive) { 118 if (exclusive) {
109 exclusive_ticks_++; 119 exclusive_ticks_++;
110 } else { 120 } else {
111 if (inclusive_serial_ == inclusive_serial) { 121 if (inclusive_serial_ == inclusive_serial) {
112 // Already ticket. 122 // Already ticket.
113 return; 123 return;
114 } 124 }
115 inclusive_serial_ = inclusive_serial; 125 inclusive_serial_ = inclusive_serial;
116 inclusive_ticks_++; 126 inclusive_ticks_++;
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 782
773 void ProfileTrieNode::SortChildren() { 783 void ProfileTrieNode::SortChildren() {
774 children_.Sort(ProfileTrieNodeCompare); 784 children_.Sort(ProfileTrieNodeCompare);
775 // Recurse. 785 // Recurse.
776 for (intptr_t i = 0; i < children_.length(); i++) { 786 for (intptr_t i = 0; i < children_.length(); i++) {
777 children_[i]->SortChildren(); 787 children_[i]->SortChildren();
778 } 788 }
779 } 789 }
780 790
781 791
792 intptr_t ProfileTrieNode::IndexOf(ProfileTrieNode* node) {
793 for (intptr_t i = 0; i < children_.length(); i++) {
794 if (children_[i] == node) {
795 return i;
796 }
797 }
798 return -1;
799 }
800
801
782 class ProfileCodeTrieNode : public ProfileTrieNode { 802 class ProfileCodeTrieNode : public ProfileTrieNode {
783 public: 803 public:
784 explicit ProfileCodeTrieNode(intptr_t table_index) 804 explicit ProfileCodeTrieNode(intptr_t table_index)
785 : ProfileTrieNode(table_index) { 805 : ProfileTrieNode(table_index) {
786 } 806 }
787 807
788 void PrintToJSONArray(JSONArray* array) const { 808 void PrintToJSONArray(JSONArray* array) const {
789 ASSERT(array != NULL); 809 ASSERT(array != NULL);
790 // Write CodeRegion index. 810 // Write CodeRegion index.
791 array->AddValue(table_index()); 811 array->AddValue(table_index());
(...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after
1887 } 1907 }
1888 { 1908 {
1889 JSONArray function_trie(&obj, "inclusiveFunctionTrie"); 1909 JSONArray function_trie(&obj, "inclusiveFunctionTrie");
1890 ProfileTrieNode* root = roots_[static_cast<intptr_t>(kInclusiveFunction)]; 1910 ProfileTrieNode* root = roots_[static_cast<intptr_t>(kInclusiveFunction)];
1891 ASSERT(root != NULL); 1911 ASSERT(root != NULL);
1892 root->PrintToJSONArray(&function_trie); 1912 root->PrintToJSONArray(&function_trie);
1893 } 1913 }
1894 } 1914 }
1895 1915
1896 1916
1917 void ProfileTrieWalker::Reset(Profile::TrieKind trie_kind) {
1918 code_trie_ = Profile::IsCodeTrie(trie_kind);
1919 parent_ = NULL;
1920 current_ = profile_->GetTrieRoot(trie_kind);
1921 ASSERT(current_ != NULL);
1922 }
1923
1924
1925 const char* ProfileTrieWalker::CurrentName() {
1926 if (current_ == NULL) {
1927 return NULL;
1928 }
1929 if (code_trie_) {
1930 ProfileCode* code = profile_->GetCode(current_->table_index());
1931 return code->name();
1932 } else {
1933 ProfileFunction* func = profile_->GetFunction(current_->table_index());
1934 return func->Name();
1935 }
1936 UNREACHABLE();
1937 }
1938
1939
1940 bool ProfileTrieWalker::Down() {
1941 if ((current_ == NULL) || (current_->NumChildren() == 0)) {
1942 return false;
1943 }
1944 parent_ = current_;
1945 current_ = current_->At(0);
1946 return true;
1947 }
1948
1949
1950 bool ProfileTrieWalker::NextSibling() {
1951 if (parent_ == NULL) {
1952 return false;
1953 }
1954 intptr_t current_index = parent_->IndexOf(current_);
1955 if (current_index < 0) {
1956 return false;
1957 }
1958 current_index++;
1959 if (current_index >= parent_->NumChildren()) {
1960 return false;
1961 }
1962 current_ = parent_->At(current_index);
1963 return true;
1964 }
1965
1966
1897 class NoAllocationSampleFilter : public SampleFilter { 1967 class NoAllocationSampleFilter : public SampleFilter {
1898 public: 1968 public:
1899 explicit NoAllocationSampleFilter(Isolate* isolate) 1969 explicit NoAllocationSampleFilter(Isolate* isolate)
1900 : SampleFilter(isolate) { 1970 : SampleFilter(isolate) {
1901 } 1971 }
1902 1972
1903 bool FilterSample(Sample* sample) { 1973 bool FilterSample(Sample* sample) {
1904 return !sample->is_allocation_sample(); 1974 return !sample->is_allocation_sample();
1905 } 1975 }
1906 }; 1976 };
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1950 ASSERT(sample_buffer != NULL); 2020 ASSERT(sample_buffer != NULL);
1951 2021
1952 ClearProfileVisitor clear_profile(isolate); 2022 ClearProfileVisitor clear_profile(isolate);
1953 sample_buffer->VisitSamples(&clear_profile); 2023 sample_buffer->VisitSamples(&clear_profile);
1954 2024
1955 // Enable profile interrupts. 2025 // Enable profile interrupts.
1956 Profiler::BeginExecution(isolate); 2026 Profiler::BeginExecution(isolate);
1957 } 2027 }
1958 2028
1959 } // namespace dart 2029 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/profiler_service.h ('k') | runtime/vm/profiler_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698