OLD | NEW |
---|---|
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 Loading... | |
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 = String::Handle(function_.UserVisibleName()); | |
rmacnak
2015/06/26 17:55:57
QualifiedUserVisibleName
Cutch
2015/06/26 18:02:49
Done.
| |
113 return func_name.ToCString(); | |
114 } | |
115 | |
107 void ProfileFunction::Tick(bool exclusive, intptr_t inclusive_serial) { | 116 void ProfileFunction::Tick(bool exclusive, intptr_t inclusive_serial) { |
108 if (exclusive) { | 117 if (exclusive) { |
109 exclusive_ticks_++; | 118 exclusive_ticks_++; |
110 } else { | 119 } else { |
111 if (inclusive_serial_ == inclusive_serial) { | 120 if (inclusive_serial_ == inclusive_serial) { |
112 // Already ticket. | 121 // Already ticket. |
113 return; | 122 return; |
114 } | 123 } |
115 inclusive_serial_ = inclusive_serial; | 124 inclusive_serial_ = inclusive_serial; |
116 inclusive_ticks_++; | 125 inclusive_ticks_++; |
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
772 | 781 |
773 void ProfileTrieNode::SortChildren() { | 782 void ProfileTrieNode::SortChildren() { |
774 children_.Sort(ProfileTrieNodeCompare); | 783 children_.Sort(ProfileTrieNodeCompare); |
775 // Recurse. | 784 // Recurse. |
776 for (intptr_t i = 0; i < children_.length(); i++) { | 785 for (intptr_t i = 0; i < children_.length(); i++) { |
777 children_[i]->SortChildren(); | 786 children_[i]->SortChildren(); |
778 } | 787 } |
779 } | 788 } |
780 | 789 |
781 | 790 |
791 intptr_t ProfileTrieNode::IndexOf(ProfileTrieNode* node) { | |
792 for (intptr_t i = 0; i < children_.length(); i++) { | |
793 if (children_[i] == node) { | |
794 return i; | |
795 } | |
796 } | |
797 return -1; | |
798 } | |
799 | |
800 | |
782 class ProfileCodeTrieNode : public ProfileTrieNode { | 801 class ProfileCodeTrieNode : public ProfileTrieNode { |
783 public: | 802 public: |
784 explicit ProfileCodeTrieNode(intptr_t table_index) | 803 explicit ProfileCodeTrieNode(intptr_t table_index) |
785 : ProfileTrieNode(table_index) { | 804 : ProfileTrieNode(table_index) { |
786 } | 805 } |
787 | 806 |
788 void PrintToJSONArray(JSONArray* array) const { | 807 void PrintToJSONArray(JSONArray* array) const { |
789 ASSERT(array != NULL); | 808 ASSERT(array != NULL); |
790 // Write CodeRegion index. | 809 // Write CodeRegion index. |
791 array->AddValue(table_index()); | 810 array->AddValue(table_index()); |
(...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1893 } | 1912 } |
1894 { | 1913 { |
1895 JSONArray function_trie(&obj, "inclusiveFunctionTrie"); | 1914 JSONArray function_trie(&obj, "inclusiveFunctionTrie"); |
1896 ProfileTrieNode* root = roots_[static_cast<intptr_t>(kInclusiveFunction)]; | 1915 ProfileTrieNode* root = roots_[static_cast<intptr_t>(kInclusiveFunction)]; |
1897 ASSERT(root != NULL); | 1916 ASSERT(root != NULL); |
1898 root->PrintToJSONArray(&function_trie); | 1917 root->PrintToJSONArray(&function_trie); |
1899 } | 1918 } |
1900 } | 1919 } |
1901 | 1920 |
1902 | 1921 |
1922 void ProfileTrieWalker::Reset(Profile::TrieKind trie_kind) { | |
1923 code_trie_ = Profile::IsCodeTrie(trie_kind); | |
1924 parent_ = NULL; | |
1925 current_ = profile_->GetTrieRoot(trie_kind); | |
1926 ASSERT(current_ != NULL); | |
1927 } | |
1928 | |
1929 | |
1930 const char* ProfileTrieWalker::CurrentName() { | |
1931 if (current_ == NULL) { | |
1932 return NULL; | |
1933 } | |
1934 if (code_trie_) { | |
1935 ProfileCode* code = profile_->GetCode(current_->table_index()); | |
1936 return code->name(); | |
1937 } else { | |
1938 ProfileFunction* func = profile_->GetFunction(current_->table_index()); | |
1939 return func->Name(); | |
1940 } | |
1941 UNREACHABLE(); | |
1942 } | |
1943 | |
1944 | |
1945 bool ProfileTrieWalker::Down() { | |
1946 if ((current_ == NULL) || (current_->NumChildren() == 0)) { | |
1947 return false; | |
1948 } | |
1949 parent_ = current_; | |
1950 current_ = current_->At(0); | |
1951 return true; | |
1952 } | |
1953 | |
1954 | |
1955 bool ProfileTrieWalker::NextSibling() { | |
1956 if (parent_ == NULL) { | |
1957 return false; | |
1958 } | |
1959 intptr_t current_index = parent_->IndexOf(current_); | |
1960 if (current_index < 0) { | |
1961 return false; | |
1962 } | |
1963 current_index++; | |
1964 if (current_index >= parent_->NumChildren()) { | |
1965 return false; | |
1966 } | |
1967 current_ = parent_->At(current_index); | |
1968 return true; | |
1969 } | |
1970 | |
1971 | |
1903 class NoAllocationSampleFilter : public SampleFilter { | 1972 class NoAllocationSampleFilter : public SampleFilter { |
1904 public: | 1973 public: |
1905 explicit NoAllocationSampleFilter(Isolate* isolate) | 1974 explicit NoAllocationSampleFilter(Isolate* isolate) |
1906 : SampleFilter(isolate) { | 1975 : SampleFilter(isolate) { |
1907 } | 1976 } |
1908 | 1977 |
1909 bool FilterSample(Sample* sample) { | 1978 bool FilterSample(Sample* sample) { |
1910 return !sample->is_allocation_sample(); | 1979 return !sample->is_allocation_sample(); |
1911 } | 1980 } |
1912 }; | 1981 }; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1956 ASSERT(sample_buffer != NULL); | 2025 ASSERT(sample_buffer != NULL); |
1957 | 2026 |
1958 ClearProfileVisitor clear_profile(isolate); | 2027 ClearProfileVisitor clear_profile(isolate); |
1959 sample_buffer->VisitSamples(&clear_profile); | 2028 sample_buffer->VisitSamples(&clear_profile); |
1960 | 2029 |
1961 // Enable profile interrupts. | 2030 // Enable profile interrupts. |
1962 Profiler::BeginExecution(isolate); | 2031 Profiler::BeginExecution(isolate); |
1963 } | 2032 } |
1964 | 2033 |
1965 } // namespace dart | 2034 } // namespace dart |
OLD | NEW |