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

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

Issue 1471953002: When deciding not to walk the native stack, don't overwrite the vm_tag set in SetupSample. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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.cc ('k') | 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/assert.h" 5 #include "platform/assert.h"
6 6
7 #include "vm/dart_api_impl.h" 7 #include "vm/dart_api_impl.h"
8 #include "vm/dart_api_state.h" 8 #include "vm/dart_api_state.h"
9 #include "vm/globals.h" 9 #include "vm/globals.h"
10 #include "vm/profiler.h" 10 #include "vm/profiler.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 EXPECT(!cls.IsNull()); // No ambiguity error expected. 145 EXPECT(!cls.IsNull()); // No ambiguity error expected.
146 return cls.raw(); 146 return cls.raw();
147 } 147 }
148 148
149 149
150 class AllocationFilter : public SampleFilter { 150 class AllocationFilter : public SampleFilter {
151 public: 151 public:
152 explicit AllocationFilter(Isolate* isolate, intptr_t cid) 152 explicit AllocationFilter(Isolate* isolate, intptr_t cid)
153 : SampleFilter(isolate), 153 : SampleFilter(isolate),
154 cid_(cid), 154 cid_(cid),
155 enable_embedder_ticks_(false) { 155 enable_vm_ticks_(false) {
156 } 156 }
157 157
158 bool FilterSample(Sample* sample) { 158 bool FilterSample(Sample* sample) {
159 if (!enable_embedder_ticks_ && 159 if (!enable_vm_ticks_ &&
160 (sample->vm_tag() == VMTag::kEmbedderTagId)) { 160 (sample->vm_tag() == VMTag::kVMTagId)) {
161 // We don't want to see embedder ticks in the test. 161 // We don't want to see embedder ticks in the test.
162 return false; 162 return false;
163 } 163 }
164 return sample->is_allocation_sample() && 164 return sample->is_allocation_sample() &&
165 (sample->allocation_cid() == cid_); 165 (sample->allocation_cid() == cid_);
166 } 166 }
167 167
168 void set_enable_embedder_ticks(bool enable) { 168 void set_enable_vm_ticks(bool enable) {
169 enable_embedder_ticks_ = enable; 169 enable_vm_ticks_ = enable;
170 } 170 }
171 171
172 private: 172 private:
173 intptr_t cid_; 173 intptr_t cid_;
174 bool enable_embedder_ticks_; 174 bool enable_vm_ticks_;
175 }; 175 };
176 176
177 177
178 TEST_CASE(Profiler_TrivialRecordAllocation) { 178 TEST_CASE(Profiler_TrivialRecordAllocation) {
179 DisableNativeProfileScope dnps; 179 DisableNativeProfileScope dnps;
180 const char* kScript = 180 const char* kScript =
181 "class A {\n" 181 "class A {\n"
182 " var a;\n" 182 " var a;\n"
183 " var b;\n" 183 " var b;\n"
184 "}\n" 184 "}\n"
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 828
829 // Invoke "foo" which during compilation, triggers a closure class allocation. 829 // Invoke "foo" which during compilation, triggers a closure class allocation.
830 Dart_Handle result = Dart_Invoke(lib, NewString("foo"), 0, NULL); 830 Dart_Handle result = Dart_Invoke(lib, NewString("foo"), 0, NULL);
831 EXPECT_VALID(result); 831 EXPECT_VALID(result);
832 832
833 { 833 {
834 StackZone zone(thread); 834 StackZone zone(thread);
835 HANDLESCOPE(thread); 835 HANDLESCOPE(thread);
836 Profile profile(isolate); 836 Profile profile(isolate);
837 AllocationFilter filter(isolate, class_class.id()); 837 AllocationFilter filter(isolate, class_class.id());
838 filter.set_enable_embedder_ticks(true); 838 filter.set_enable_vm_ticks(true);
839 profile.Build(thread, &filter, Profile::kNoTags); 839 profile.Build(thread, &filter, Profile::kNoTags);
840 // We should have one allocation sample. 840 // We should have one allocation sample.
841 EXPECT_EQ(1, profile.sample_count()); 841 EXPECT_EQ(1, profile.sample_count());
842 ProfileTrieWalker walker(&profile); 842 ProfileTrieWalker walker(&profile);
843 843
844 walker.Reset(Profile::kExclusiveCode); 844 walker.Reset(Profile::kExclusiveCode);
845 EXPECT(walker.Down()); 845 EXPECT(walker.Down());
846 #if defined(TARGET_OS_WINDOWS) 846 #if defined(TARGET_OS_WINDOWS)
847 // TODO(johnmccutchan): Hookup native symbol resolver on Windows. 847 // TODO(johnmccutchan): Hookup native symbol resolver on Windows.
848 EXPECT_SUBSTRING("[Native]", walker.CurrentName()); 848 EXPECT_SUBSTRING("[Native]", walker.CurrentName());
849 #else 849 #else
850 EXPECT_SUBSTRING("dart::Profiler::SampleAllocation", walker.CurrentName()); 850 EXPECT_SUBSTRING("dart::Profiler::SampleAllocation", walker.CurrentName());
851 #endif 851 #endif
852 EXPECT(!walker.Down()); 852 EXPECT(!walker.Down());
853 } 853 }
854 854
855 // Disable allocation tracing for Class. 855 // Disable allocation tracing for Class.
856 class_class.SetTraceAllocation(false); 856 class_class.SetTraceAllocation(false);
857 857
858 // Invoke "bar" which during compilation, triggers a closure class allocation. 858 // Invoke "bar" which during compilation, triggers a closure class allocation.
859 result = Dart_Invoke(lib, NewString("bar"), 0, NULL); 859 result = Dart_Invoke(lib, NewString("bar"), 0, NULL);
860 EXPECT_VALID(result); 860 EXPECT_VALID(result);
861 861
862 { 862 {
863 StackZone zone(thread); 863 StackZone zone(thread);
864 HANDLESCOPE(thread); 864 HANDLESCOPE(thread);
865 Profile profile(isolate); 865 Profile profile(isolate);
866 AllocationFilter filter(isolate, class_class.id()); 866 AllocationFilter filter(isolate, class_class.id());
867 filter.set_enable_embedder_ticks(true); 867 filter.set_enable_vm_ticks(true);
868 profile.Build(thread, &filter, Profile::kNoTags); 868 profile.Build(thread, &filter, Profile::kNoTags);
869 // We should still only have one allocation sample. 869 // We should still only have one allocation sample.
870 EXPECT_EQ(1, profile.sample_count()); 870 EXPECT_EQ(1, profile.sample_count());
871 } 871 }
872 } 872 }
873 873
874 874
875 TEST_CASE(Profiler_TypedArrayAllocation) { 875 TEST_CASE(Profiler_TypedArrayAllocation) {
876 DisableNativeProfileScope dnps; 876 DisableNativeProfileScope dnps;
877 const char* kScript = 877 const char* kScript =
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
1477 EXPECT(walker.Down()); 1477 EXPECT(walker.Down());
1478 EXPECT_STREQ("go", walker.CurrentName()); 1478 EXPECT_STREQ("go", walker.CurrentName());
1479 EXPECT(walker.Down()); 1479 EXPECT(walker.Down());
1480 EXPECT_STREQ("main", walker.CurrentName()); 1480 EXPECT_STREQ("main", walker.CurrentName());
1481 EXPECT(!walker.Down()); 1481 EXPECT(!walker.Down());
1482 } 1482 }
1483 } 1483 }
1484 1484
1485 } // namespace dart 1485 } // namespace dart
1486 1486
OLDNEW
« no previous file with comments | « runtime/vm/profiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698