| 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/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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 ~MaxProfileDepthScope() { Profiler::SetSampleDepth(FLAG_max_profile_depth_); } | 62 ~MaxProfileDepthScope() { Profiler::SetSampleDepth(FLAG_max_profile_depth_); } |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 const intptr_t FLAG_max_profile_depth_; | 65 const intptr_t FLAG_max_profile_depth_; |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 | 68 |
| 69 class ProfileSampleBufferTestHelper { | 69 class ProfileSampleBufferTestHelper { |
| 70 public: | 70 public: |
| 71 static intptr_t IterateCount(const Dart_Port port, | 71 static intptr_t IterateCount(const Isolate* isolate, |
| 72 const SampleBuffer& sample_buffer) { | 72 const SampleBuffer& sample_buffer) { |
| 73 intptr_t c = 0; | 73 intptr_t c = 0; |
| 74 for (intptr_t i = 0; i < sample_buffer.capacity(); i++) { | 74 for (intptr_t i = 0; i < sample_buffer.capacity(); i++) { |
| 75 Sample* sample = sample_buffer.At(i); | 75 Sample* sample = sample_buffer.At(i); |
| 76 if (sample->port() != port) { | 76 if (sample->isolate() != isolate) { |
| 77 continue; | 77 continue; |
| 78 } | 78 } |
| 79 c++; | 79 c++; |
| 80 } | 80 } |
| 81 return c; | 81 return c; |
| 82 } | 82 } |
| 83 | 83 |
| 84 | 84 |
| 85 static intptr_t IterateSumPC(const Dart_Port port, | 85 static intptr_t IterateSumPC(const Isolate* isolate, |
| 86 const SampleBuffer& sample_buffer) { | 86 const SampleBuffer& sample_buffer) { |
| 87 intptr_t c = 0; | 87 intptr_t c = 0; |
| 88 for (intptr_t i = 0; i < sample_buffer.capacity(); i++) { | 88 for (intptr_t i = 0; i < sample_buffer.capacity(); i++) { |
| 89 Sample* sample = sample_buffer.At(i); | 89 Sample* sample = sample_buffer.At(i); |
| 90 if (sample->port() != port) { | 90 if (sample->isolate() != isolate) { |
| 91 continue; | 91 continue; |
| 92 } | 92 } |
| 93 c += sample->At(0); | 93 c += sample->At(0); |
| 94 } | 94 } |
| 95 return c; | 95 return c; |
| 96 } | 96 } |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 | 99 |
| 100 TEST_CASE(Profiler_SampleBufferWrapTest) { | 100 TEST_CASE(Profiler_SampleBufferWrapTest) { |
| 101 SampleBuffer* sample_buffer = new SampleBuffer(3); | 101 SampleBuffer* sample_buffer = new SampleBuffer(3); |
| 102 Dart_Port i = 123; | 102 Isolate* i = reinterpret_cast<Isolate*>(0x1); |
| 103 EXPECT_EQ(0, ProfileSampleBufferTestHelper::IterateSumPC(i, *sample_buffer)); | 103 EXPECT_EQ(0, ProfileSampleBufferTestHelper::IterateSumPC(i, *sample_buffer)); |
| 104 Sample* s; | 104 Sample* s; |
| 105 s = sample_buffer->ReserveSample(); | 105 s = sample_buffer->ReserveSample(); |
| 106 s->Init(i, 0, 0); | 106 s->Init(i, 0, 0); |
| 107 s->SetAt(0, 2); | 107 s->SetAt(0, 2); |
| 108 EXPECT_EQ(2, ProfileSampleBufferTestHelper::IterateSumPC(i, *sample_buffer)); | 108 EXPECT_EQ(2, ProfileSampleBufferTestHelper::IterateSumPC(i, *sample_buffer)); |
| 109 s = sample_buffer->ReserveSample(); | 109 s = sample_buffer->ReserveSample(); |
| 110 s->Init(i, 0, 0); | 110 s->Init(i, 0, 0); |
| 111 s->SetAt(0, 4); | 111 s->SetAt(0, 4); |
| 112 EXPECT_EQ(6, ProfileSampleBufferTestHelper::IterateSumPC(i, *sample_buffer)); | 112 EXPECT_EQ(6, ProfileSampleBufferTestHelper::IterateSumPC(i, *sample_buffer)); |
| 113 s = sample_buffer->ReserveSample(); | 113 s = sample_buffer->ReserveSample(); |
| 114 s->Init(i, 0, 0); | 114 s->Init(i, 0, 0); |
| 115 s->SetAt(0, 6); | 115 s->SetAt(0, 6); |
| 116 EXPECT_EQ(12, ProfileSampleBufferTestHelper::IterateSumPC(i, *sample_buffer)); | 116 EXPECT_EQ(12, ProfileSampleBufferTestHelper::IterateSumPC(i, *sample_buffer)); |
| 117 s = sample_buffer->ReserveSample(); | 117 s = sample_buffer->ReserveSample(); |
| 118 s->Init(i, 0, 0); | 118 s->Init(i, 0, 0); |
| 119 s->SetAt(0, 8); | 119 s->SetAt(0, 8); |
| 120 EXPECT_EQ(18, ProfileSampleBufferTestHelper::IterateSumPC(i, *sample_buffer)); | 120 EXPECT_EQ(18, ProfileSampleBufferTestHelper::IterateSumPC(i, *sample_buffer)); |
| 121 delete sample_buffer; | 121 delete sample_buffer; |
| 122 } | 122 } |
| 123 | 123 |
| 124 | 124 |
| 125 TEST_CASE(Profiler_SampleBufferIterateTest) { | 125 TEST_CASE(Profiler_SampleBufferIterateTest) { |
| 126 SampleBuffer* sample_buffer = new SampleBuffer(3); | 126 SampleBuffer* sample_buffer = new SampleBuffer(3); |
| 127 Dart_Port i = 123; | 127 Isolate* i = reinterpret_cast<Isolate*>(0x1); |
| 128 EXPECT_EQ(0, ProfileSampleBufferTestHelper::IterateCount(i, *sample_buffer)); | 128 EXPECT_EQ(0, ProfileSampleBufferTestHelper::IterateCount(i, *sample_buffer)); |
| 129 Sample* s; | 129 Sample* s; |
| 130 s = sample_buffer->ReserveSample(); | 130 s = sample_buffer->ReserveSample(); |
| 131 s->Init(i, 0, 0); | 131 s->Init(i, 0, 0); |
| 132 EXPECT_EQ(1, ProfileSampleBufferTestHelper::IterateCount(i, *sample_buffer)); | 132 EXPECT_EQ(1, ProfileSampleBufferTestHelper::IterateCount(i, *sample_buffer)); |
| 133 s = sample_buffer->ReserveSample(); | 133 s = sample_buffer->ReserveSample(); |
| 134 s->Init(i, 0, 0); | 134 s->Init(i, 0, 0); |
| 135 EXPECT_EQ(2, ProfileSampleBufferTestHelper::IterateCount(i, *sample_buffer)); | 135 EXPECT_EQ(2, ProfileSampleBufferTestHelper::IterateCount(i, *sample_buffer)); |
| 136 s = sample_buffer->ReserveSample(); | 136 s = sample_buffer->ReserveSample(); |
| 137 s->Init(i, 0, 0); | 137 s->Init(i, 0, 0); |
| 138 EXPECT_EQ(3, ProfileSampleBufferTestHelper::IterateCount(i, *sample_buffer)); | 138 EXPECT_EQ(3, ProfileSampleBufferTestHelper::IterateCount(i, *sample_buffer)); |
| 139 s = sample_buffer->ReserveSample(); | 139 s = sample_buffer->ReserveSample(); |
| 140 s->Init(i, 0, 0); | 140 s->Init(i, 0, 0); |
| 141 EXPECT_EQ(3, ProfileSampleBufferTestHelper::IterateCount(i, *sample_buffer)); | 141 EXPECT_EQ(3, ProfileSampleBufferTestHelper::IterateCount(i, *sample_buffer)); |
| 142 delete sample_buffer; | 142 delete sample_buffer; |
| 143 } | 143 } |
| 144 | 144 |
| 145 | 145 |
| 146 TEST_CASE(Profiler_AllocationSampleTest) { | 146 TEST_CASE(Profiler_AllocationSampleTest) { |
| 147 Isolate* isolate = Isolate::Current(); | 147 Isolate* isolate = Isolate::Current(); |
| 148 SampleBuffer* sample_buffer = new SampleBuffer(3); | 148 SampleBuffer* sample_buffer = new SampleBuffer(3); |
| 149 Sample* sample = sample_buffer->ReserveSample(); | 149 Sample* sample = sample_buffer->ReserveSample(); |
| 150 sample->Init(isolate->main_port(), 0, 0); | 150 sample->Init(isolate, 0, 0); |
| 151 sample->set_metadata(99); | 151 sample->set_metadata(99); |
| 152 sample->set_is_allocation_sample(true); | 152 sample->set_is_allocation_sample(true); |
| 153 EXPECT_EQ(99, sample->allocation_cid()); | 153 EXPECT_EQ(99, sample->allocation_cid()); |
| 154 delete sample_buffer; | 154 delete sample_buffer; |
| 155 } | 155 } |
| 156 | 156 |
| 157 | 157 |
| 158 static RawClass* GetClass(const Library& lib, const char* name) { | 158 static RawClass* GetClass(const Library& lib, const char* name) { |
| 159 const Class& cls = Class::Handle(lib.LookupClassAllowPrivate( | 159 const Class& cls = Class::Handle(lib.LookupClassAllowPrivate( |
| 160 String::Handle(Symbols::New(Thread::Current(), name)))); | 160 String::Handle(Symbols::New(Thread::Current(), name)))); |
| 161 EXPECT(!cls.IsNull()); // No ambiguity error expected. | 161 EXPECT(!cls.IsNull()); // No ambiguity error expected. |
| 162 return cls.raw(); | 162 return cls.raw(); |
| 163 } | 163 } |
| 164 | 164 |
| 165 | 165 |
| 166 static RawFunction* GetFunction(const Library& lib, const char* name) { | 166 static RawFunction* GetFunction(const Library& lib, const char* name) { |
| 167 const Function& func = Function::Handle(lib.LookupFunctionAllowPrivate( | 167 const Function& func = Function::Handle(lib.LookupFunctionAllowPrivate( |
| 168 String::Handle(Symbols::New(Thread::Current(), name)))); | 168 String::Handle(Symbols::New(Thread::Current(), name)))); |
| 169 EXPECT(!func.IsNull()); // No ambiguity error expected. | 169 EXPECT(!func.IsNull()); // No ambiguity error expected. |
| 170 return func.raw(); | 170 return func.raw(); |
| 171 } | 171 } |
| 172 | 172 |
| 173 | 173 |
| 174 class AllocationFilter : public SampleFilter { | 174 class AllocationFilter : public SampleFilter { |
| 175 public: | 175 public: |
| 176 AllocationFilter(Dart_Port port, | 176 AllocationFilter(Isolate* isolate, |
| 177 intptr_t cid, | 177 intptr_t cid, |
| 178 int64_t time_origin_micros = -1, | 178 int64_t time_origin_micros = -1, |
| 179 int64_t time_extent_micros = -1) | 179 int64_t time_extent_micros = -1) |
| 180 : SampleFilter(port, | 180 : SampleFilter(isolate, |
| 181 Thread::kMutatorTask, | 181 Thread::kMutatorTask, |
| 182 time_origin_micros, | 182 time_origin_micros, |
| 183 time_extent_micros), | 183 time_extent_micros), |
| 184 cid_(cid), | 184 cid_(cid), |
| 185 enable_vm_ticks_(false) {} | 185 enable_vm_ticks_(false) {} |
| 186 | 186 |
| 187 bool FilterSample(Sample* sample) { | 187 bool FilterSample(Sample* sample) { |
| 188 if (!enable_vm_ticks_ && (sample->vm_tag() == VMTag::kVMTagId)) { | 188 if (!enable_vm_ticks_ && (sample->vm_tag() == VMTag::kVMTagId)) { |
| 189 // We don't want to see embedder ticks in the test. | 189 // We don't want to see embedder ticks in the test. |
| 190 return false; | 190 return false; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 const int64_t after_allocations_micros = Dart_TimelineGetMicros(); | 232 const int64_t after_allocations_micros = Dart_TimelineGetMicros(); |
| 233 const int64_t allocation_extent_micros = | 233 const int64_t allocation_extent_micros = |
| 234 after_allocations_micros - before_allocations_micros; | 234 after_allocations_micros - before_allocations_micros; |
| 235 { | 235 { |
| 236 Thread* thread = Thread::Current(); | 236 Thread* thread = Thread::Current(); |
| 237 Isolate* isolate = thread->isolate(); | 237 Isolate* isolate = thread->isolate(); |
| 238 StackZone zone(thread); | 238 StackZone zone(thread); |
| 239 HANDLESCOPE(thread); | 239 HANDLESCOPE(thread); |
| 240 Profile profile(isolate); | 240 Profile profile(isolate); |
| 241 // Filter for the class in the time range. | 241 // Filter for the class in the time range. |
| 242 AllocationFilter filter(isolate->main_port(), class_a.id(), | 242 AllocationFilter filter(isolate, class_a.id(), before_allocations_micros, |
| 243 before_allocations_micros, | |
| 244 allocation_extent_micros); | 243 allocation_extent_micros); |
| 245 profile.Build(thread, &filter, Profile::kNoTags); | 244 profile.Build(thread, &filter, Profile::kNoTags); |
| 246 // We should have 1 allocation sample. | 245 // We should have 1 allocation sample. |
| 247 EXPECT_EQ(1, profile.sample_count()); | 246 EXPECT_EQ(1, profile.sample_count()); |
| 248 ProfileTrieWalker walker(&profile); | 247 ProfileTrieWalker walker(&profile); |
| 249 | 248 |
| 250 // Exclusive code: B.boo -> main. | 249 // Exclusive code: B.boo -> main. |
| 251 walker.Reset(Profile::kExclusiveCode); | 250 walker.Reset(Profile::kExclusiveCode); |
| 252 // Move down from the root. | 251 // Move down from the root. |
| 253 EXPECT(walker.Down()); | 252 EXPECT(walker.Down()); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 EXPECT(!walker.Down()); | 299 EXPECT(!walker.Down()); |
| 301 } | 300 } |
| 302 | 301 |
| 303 // Query with a time filter where no allocations occurred. | 302 // Query with a time filter where no allocations occurred. |
| 304 { | 303 { |
| 305 Thread* thread = Thread::Current(); | 304 Thread* thread = Thread::Current(); |
| 306 Isolate* isolate = thread->isolate(); | 305 Isolate* isolate = thread->isolate(); |
| 307 StackZone zone(thread); | 306 StackZone zone(thread); |
| 308 HANDLESCOPE(thread); | 307 HANDLESCOPE(thread); |
| 309 Profile profile(isolate); | 308 Profile profile(isolate); |
| 310 AllocationFilter filter(isolate->main_port(), class_a.id(), | 309 AllocationFilter filter(isolate, class_a.id(), Dart_TimelineGetMicros(), |
| 311 Dart_TimelineGetMicros(), 16000); | 310 16000); |
| 312 profile.Build(thread, &filter, Profile::kNoTags); | 311 profile.Build(thread, &filter, Profile::kNoTags); |
| 313 // We should have no allocation samples because none occured within | 312 // We should have no allocation samples because none occured within |
| 314 // the specified time range. | 313 // the specified time range. |
| 315 EXPECT_EQ(0, profile.sample_count()); | 314 EXPECT_EQ(0, profile.sample_count()); |
| 316 } | 315 } |
| 317 } | 316 } |
| 318 | 317 |
| 319 | 318 |
| 320 TEST_CASE(Profiler_ToggleRecordAllocation) { | 319 TEST_CASE(Profiler_ToggleRecordAllocation) { |
| 321 DisableNativeProfileScope dnps; | 320 DisableNativeProfileScope dnps; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 344 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 343 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
| 345 EXPECT_VALID(result); | 344 EXPECT_VALID(result); |
| 346 | 345 |
| 347 | 346 |
| 348 { | 347 { |
| 349 Thread* thread = Thread::Current(); | 348 Thread* thread = Thread::Current(); |
| 350 Isolate* isolate = thread->isolate(); | 349 Isolate* isolate = thread->isolate(); |
| 351 StackZone zone(thread); | 350 StackZone zone(thread); |
| 352 HANDLESCOPE(thread); | 351 HANDLESCOPE(thread); |
| 353 Profile profile(isolate); | 352 Profile profile(isolate); |
| 354 AllocationFilter filter(isolate->main_port(), class_a.id()); | 353 AllocationFilter filter(isolate, class_a.id()); |
| 355 profile.Build(thread, &filter, Profile::kNoTags); | 354 profile.Build(thread, &filter, Profile::kNoTags); |
| 356 // We should have no allocation samples. | 355 // We should have no allocation samples. |
| 357 EXPECT_EQ(0, profile.sample_count()); | 356 EXPECT_EQ(0, profile.sample_count()); |
| 358 } | 357 } |
| 359 | 358 |
| 360 // Turn on allocation tracing for A. | 359 // Turn on allocation tracing for A. |
| 361 class_a.SetTraceAllocation(true); | 360 class_a.SetTraceAllocation(true); |
| 362 | 361 |
| 363 result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 362 result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
| 364 EXPECT_VALID(result); | 363 EXPECT_VALID(result); |
| 365 | 364 |
| 366 { | 365 { |
| 367 Thread* thread = Thread::Current(); | 366 Thread* thread = Thread::Current(); |
| 368 Isolate* isolate = thread->isolate(); | 367 Isolate* isolate = thread->isolate(); |
| 369 StackZone zone(thread); | 368 StackZone zone(thread); |
| 370 HANDLESCOPE(thread); | 369 HANDLESCOPE(thread); |
| 371 Profile profile(isolate); | 370 Profile profile(isolate); |
| 372 AllocationFilter filter(isolate->main_port(), class_a.id()); | 371 AllocationFilter filter(isolate, class_a.id()); |
| 373 profile.Build(thread, &filter, Profile::kNoTags); | 372 profile.Build(thread, &filter, Profile::kNoTags); |
| 374 // We should have one allocation sample. | 373 // We should have one allocation sample. |
| 375 EXPECT_EQ(1, profile.sample_count()); | 374 EXPECT_EQ(1, profile.sample_count()); |
| 376 ProfileTrieWalker walker(&profile); | 375 ProfileTrieWalker walker(&profile); |
| 377 | 376 |
| 378 // Exclusive code: B.boo -> main. | 377 // Exclusive code: B.boo -> main. |
| 379 walker.Reset(Profile::kExclusiveCode); | 378 walker.Reset(Profile::kExclusiveCode); |
| 380 // Move down from the root. | 379 // Move down from the root. |
| 381 EXPECT(walker.Down()); | 380 EXPECT(walker.Down()); |
| 382 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); | 381 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 | 432 |
| 434 result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 433 result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
| 435 EXPECT_VALID(result); | 434 EXPECT_VALID(result); |
| 436 | 435 |
| 437 { | 436 { |
| 438 Thread* thread = Thread::Current(); | 437 Thread* thread = Thread::Current(); |
| 439 Isolate* isolate = thread->isolate(); | 438 Isolate* isolate = thread->isolate(); |
| 440 StackZone zone(thread); | 439 StackZone zone(thread); |
| 441 HANDLESCOPE(thread); | 440 HANDLESCOPE(thread); |
| 442 Profile profile(isolate); | 441 Profile profile(isolate); |
| 443 AllocationFilter filter(isolate->main_port(), class_a.id()); | 442 AllocationFilter filter(isolate, class_a.id()); |
| 444 profile.Build(thread, &filter, Profile::kNoTags); | 443 profile.Build(thread, &filter, Profile::kNoTags); |
| 445 // We should still only have one allocation sample. | 444 // We should still only have one allocation sample. |
| 446 EXPECT_EQ(1, profile.sample_count()); | 445 EXPECT_EQ(1, profile.sample_count()); |
| 447 } | 446 } |
| 448 } | 447 } |
| 449 | 448 |
| 450 | 449 |
| 451 TEST_CASE(Profiler_CodeTicks) { | 450 TEST_CASE(Profiler_CodeTicks) { |
| 452 DisableNativeProfileScope dnps; | 451 DisableNativeProfileScope dnps; |
| 453 const char* kScript = | 452 const char* kScript = |
| (...skipping 20 matching lines...) Expand all Loading... |
| 474 | 473 |
| 475 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 474 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
| 476 EXPECT_VALID(result); | 475 EXPECT_VALID(result); |
| 477 | 476 |
| 478 { | 477 { |
| 479 Thread* thread = Thread::Current(); | 478 Thread* thread = Thread::Current(); |
| 480 Isolate* isolate = thread->isolate(); | 479 Isolate* isolate = thread->isolate(); |
| 481 StackZone zone(thread); | 480 StackZone zone(thread); |
| 482 HANDLESCOPE(thread); | 481 HANDLESCOPE(thread); |
| 483 Profile profile(isolate); | 482 Profile profile(isolate); |
| 484 AllocationFilter filter(isolate->main_port(), class_a.id()); | 483 AllocationFilter filter(isolate, class_a.id()); |
| 485 profile.Build(thread, &filter, Profile::kNoTags); | 484 profile.Build(thread, &filter, Profile::kNoTags); |
| 486 // We should have no allocation samples. | 485 // We should have no allocation samples. |
| 487 EXPECT_EQ(0, profile.sample_count()); | 486 EXPECT_EQ(0, profile.sample_count()); |
| 488 } | 487 } |
| 489 | 488 |
| 490 // Turn on allocation tracing for A. | 489 // Turn on allocation tracing for A. |
| 491 class_a.SetTraceAllocation(true); | 490 class_a.SetTraceAllocation(true); |
| 492 | 491 |
| 493 // Allocate three times. | 492 // Allocate three times. |
| 494 result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 493 result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
| 495 EXPECT_VALID(result); | 494 EXPECT_VALID(result); |
| 496 result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 495 result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
| 497 EXPECT_VALID(result); | 496 EXPECT_VALID(result); |
| 498 result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 497 result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
| 499 EXPECT_VALID(result); | 498 EXPECT_VALID(result); |
| 500 | 499 |
| 501 { | 500 { |
| 502 Thread* thread = Thread::Current(); | 501 Thread* thread = Thread::Current(); |
| 503 Isolate* isolate = thread->isolate(); | 502 Isolate* isolate = thread->isolate(); |
| 504 StackZone zone(thread); | 503 StackZone zone(thread); |
| 505 HANDLESCOPE(thread); | 504 HANDLESCOPE(thread); |
| 506 Profile profile(isolate); | 505 Profile profile(isolate); |
| 507 AllocationFilter filter(isolate->main_port(), class_a.id()); | 506 AllocationFilter filter(isolate, class_a.id()); |
| 508 profile.Build(thread, &filter, Profile::kNoTags); | 507 profile.Build(thread, &filter, Profile::kNoTags); |
| 509 // We should have three allocation samples. | 508 // We should have three allocation samples. |
| 510 EXPECT_EQ(3, profile.sample_count()); | 509 EXPECT_EQ(3, profile.sample_count()); |
| 511 ProfileTrieWalker walker(&profile); | 510 ProfileTrieWalker walker(&profile); |
| 512 | 511 |
| 513 // Exclusive code: B.boo -> main. | 512 // Exclusive code: B.boo -> main. |
| 514 walker.Reset(Profile::kExclusiveCode); | 513 walker.Reset(Profile::kExclusiveCode); |
| 515 // Move down from the root. | 514 // Move down from the root. |
| 516 EXPECT(walker.Down()); | 515 EXPECT(walker.Down()); |
| 517 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); | 516 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 | 576 |
| 578 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 577 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
| 579 EXPECT_VALID(result); | 578 EXPECT_VALID(result); |
| 580 | 579 |
| 581 { | 580 { |
| 582 Thread* thread = Thread::Current(); | 581 Thread* thread = Thread::Current(); |
| 583 Isolate* isolate = thread->isolate(); | 582 Isolate* isolate = thread->isolate(); |
| 584 StackZone zone(thread); | 583 StackZone zone(thread); |
| 585 HANDLESCOPE(thread); | 584 HANDLESCOPE(thread); |
| 586 Profile profile(isolate); | 585 Profile profile(isolate); |
| 587 AllocationFilter filter(isolate->main_port(), class_a.id()); | 586 AllocationFilter filter(isolate, class_a.id()); |
| 588 profile.Build(thread, &filter, Profile::kNoTags); | 587 profile.Build(thread, &filter, Profile::kNoTags); |
| 589 // We should have no allocation samples. | 588 // We should have no allocation samples. |
| 590 EXPECT_EQ(0, profile.sample_count()); | 589 EXPECT_EQ(0, profile.sample_count()); |
| 591 } | 590 } |
| 592 | 591 |
| 593 // Turn on allocation tracing for A. | 592 // Turn on allocation tracing for A. |
| 594 class_a.SetTraceAllocation(true); | 593 class_a.SetTraceAllocation(true); |
| 595 | 594 |
| 596 // Allocate three times. | 595 // Allocate three times. |
| 597 result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 596 result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
| 598 EXPECT_VALID(result); | 597 EXPECT_VALID(result); |
| 599 result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 598 result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
| 600 EXPECT_VALID(result); | 599 EXPECT_VALID(result); |
| 601 result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 600 result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
| 602 EXPECT_VALID(result); | 601 EXPECT_VALID(result); |
| 603 | 602 |
| 604 { | 603 { |
| 605 Thread* thread = Thread::Current(); | 604 Thread* thread = Thread::Current(); |
| 606 Isolate* isolate = thread->isolate(); | 605 Isolate* isolate = thread->isolate(); |
| 607 StackZone zone(thread); | 606 StackZone zone(thread); |
| 608 HANDLESCOPE(thread); | 607 HANDLESCOPE(thread); |
| 609 Profile profile(isolate); | 608 Profile profile(isolate); |
| 610 AllocationFilter filter(isolate->main_port(), class_a.id()); | 609 AllocationFilter filter(isolate, class_a.id()); |
| 611 profile.Build(thread, &filter, Profile::kNoTags); | 610 profile.Build(thread, &filter, Profile::kNoTags); |
| 612 // We should have three allocation samples. | 611 // We should have three allocation samples. |
| 613 EXPECT_EQ(3, profile.sample_count()); | 612 EXPECT_EQ(3, profile.sample_count()); |
| 614 ProfileTrieWalker walker(&profile); | 613 ProfileTrieWalker walker(&profile); |
| 615 | 614 |
| 616 // Exclusive function: B.boo -> main. | 615 // Exclusive function: B.boo -> main. |
| 617 walker.Reset(Profile::kExclusiveFunction); | 616 walker.Reset(Profile::kExclusiveFunction); |
| 618 // Move down from the root. | 617 // Move down from the root. |
| 619 EXPECT(walker.Down()); | 618 EXPECT(walker.Down()); |
| 620 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); | 619 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 Dart_NewDouble(1.0), Dart_NewDouble(2.0), | 670 Dart_NewDouble(1.0), Dart_NewDouble(2.0), |
| 672 }; | 671 }; |
| 673 | 672 |
| 674 Dart_Handle result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); | 673 Dart_Handle result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); |
| 675 EXPECT_VALID(result); | 674 EXPECT_VALID(result); |
| 676 | 675 |
| 677 { | 676 { |
| 678 StackZone zone(thread); | 677 StackZone zone(thread); |
| 679 HANDLESCOPE(thread); | 678 HANDLESCOPE(thread); |
| 680 Profile profile(isolate); | 679 Profile profile(isolate); |
| 681 AllocationFilter filter(isolate->main_port(), double_class.id()); | 680 AllocationFilter filter(isolate, double_class.id()); |
| 682 profile.Build(thread, &filter, Profile::kNoTags); | 681 profile.Build(thread, &filter, Profile::kNoTags); |
| 683 // We should have no allocation samples. | 682 // We should have no allocation samples. |
| 684 EXPECT_EQ(0, profile.sample_count()); | 683 EXPECT_EQ(0, profile.sample_count()); |
| 685 } | 684 } |
| 686 | 685 |
| 687 double_class.SetTraceAllocation(true); | 686 double_class.SetTraceAllocation(true); |
| 688 result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); | 687 result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); |
| 689 EXPECT_VALID(result); | 688 EXPECT_VALID(result); |
| 690 | 689 |
| 691 { | 690 { |
| 692 StackZone zone(thread); | 691 StackZone zone(thread); |
| 693 HANDLESCOPE(thread); | 692 HANDLESCOPE(thread); |
| 694 Profile profile(isolate); | 693 Profile profile(isolate); |
| 695 AllocationFilter filter(isolate->main_port(), double_class.id()); | 694 AllocationFilter filter(isolate, double_class.id()); |
| 696 profile.Build(thread, &filter, Profile::kNoTags); | 695 profile.Build(thread, &filter, Profile::kNoTags); |
| 697 // We should have one allocation sample. | 696 // We should have one allocation sample. |
| 698 EXPECT_EQ(1, profile.sample_count()); | 697 EXPECT_EQ(1, profile.sample_count()); |
| 699 ProfileTrieWalker walker(&profile); | 698 ProfileTrieWalker walker(&profile); |
| 700 | 699 |
| 701 walker.Reset(Profile::kExclusiveCode); | 700 walker.Reset(Profile::kExclusiveCode); |
| 702 EXPECT(walker.Down()); | 701 EXPECT(walker.Down()); |
| 703 EXPECT_STREQ("Double_add", walker.CurrentName()); | 702 EXPECT_STREQ("Double_add", walker.CurrentName()); |
| 704 EXPECT(walker.Down()); | 703 EXPECT(walker.Down()); |
| 705 EXPECT_STREQ("_Double._add", walker.CurrentName()); | 704 EXPECT_STREQ("_Double._add", walker.CurrentName()); |
| 706 EXPECT(walker.Down()); | 705 EXPECT(walker.Down()); |
| 707 EXPECT_STREQ("_Double.+", walker.CurrentName()); | 706 EXPECT_STREQ("_Double.+", walker.CurrentName()); |
| 708 EXPECT(walker.Down()); | 707 EXPECT(walker.Down()); |
| 709 EXPECT_STREQ("foo", walker.CurrentName()); | 708 EXPECT_STREQ("foo", walker.CurrentName()); |
| 710 EXPECT(!walker.Down()); | 709 EXPECT(!walker.Down()); |
| 711 } | 710 } |
| 712 | 711 |
| 713 double_class.SetTraceAllocation(false); | 712 double_class.SetTraceAllocation(false); |
| 714 result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); | 713 result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); |
| 715 EXPECT_VALID(result); | 714 EXPECT_VALID(result); |
| 716 | 715 |
| 717 { | 716 { |
| 718 StackZone zone(thread); | 717 StackZone zone(thread); |
| 719 HANDLESCOPE(thread); | 718 HANDLESCOPE(thread); |
| 720 Profile profile(isolate); | 719 Profile profile(isolate); |
| 721 AllocationFilter filter(isolate->main_port(), double_class.id()); | 720 AllocationFilter filter(isolate, double_class.id()); |
| 722 profile.Build(thread, &filter, Profile::kNoTags); | 721 profile.Build(thread, &filter, Profile::kNoTags); |
| 723 // We should still only have one allocation sample. | 722 // We should still only have one allocation sample. |
| 724 EXPECT_EQ(1, profile.sample_count()); | 723 EXPECT_EQ(1, profile.sample_count()); |
| 725 } | 724 } |
| 726 } | 725 } |
| 727 | 726 |
| 728 | 727 |
| 729 TEST_CASE(Profiler_ArrayAllocation) { | 728 TEST_CASE(Profiler_ArrayAllocation) { |
| 730 DisableNativeProfileScope dnps; | 729 DisableNativeProfileScope dnps; |
| 731 const char* kScript = | 730 const char* kScript = |
| 732 "List foo() => new List(4);\n" | 731 "List foo() => new List(4);\n" |
| 733 "List bar() => new List();\n"; | 732 "List bar() => new List();\n"; |
| 734 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 733 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
| 735 EXPECT_VALID(lib); | 734 EXPECT_VALID(lib); |
| 736 Library& root_library = Library::Handle(); | 735 Library& root_library = Library::Handle(); |
| 737 root_library ^= Api::UnwrapHandle(lib); | 736 root_library ^= Api::UnwrapHandle(lib); |
| 738 Isolate* isolate = thread->isolate(); | 737 Isolate* isolate = thread->isolate(); |
| 739 | 738 |
| 740 const Class& array_class = | 739 const Class& array_class = |
| 741 Class::Handle(isolate->object_store()->array_class()); | 740 Class::Handle(isolate->object_store()->array_class()); |
| 742 EXPECT(!array_class.IsNull()); | 741 EXPECT(!array_class.IsNull()); |
| 743 | 742 |
| 744 Dart_Handle result = Dart_Invoke(lib, NewString("foo"), 0, NULL); | 743 Dart_Handle result = Dart_Invoke(lib, NewString("foo"), 0, NULL); |
| 745 EXPECT_VALID(result); | 744 EXPECT_VALID(result); |
| 746 | 745 |
| 747 { | 746 { |
| 748 StackZone zone(thread); | 747 StackZone zone(thread); |
| 749 HANDLESCOPE(thread); | 748 HANDLESCOPE(thread); |
| 750 Profile profile(isolate); | 749 Profile profile(isolate); |
| 751 AllocationFilter filter(isolate->main_port(), array_class.id()); | 750 AllocationFilter filter(isolate, array_class.id()); |
| 752 profile.Build(thread, &filter, Profile::kNoTags); | 751 profile.Build(thread, &filter, Profile::kNoTags); |
| 753 // We should have no allocation samples. | 752 // We should have no allocation samples. |
| 754 EXPECT_EQ(0, profile.sample_count()); | 753 EXPECT_EQ(0, profile.sample_count()); |
| 755 } | 754 } |
| 756 | 755 |
| 757 array_class.SetTraceAllocation(true); | 756 array_class.SetTraceAllocation(true); |
| 758 result = Dart_Invoke(lib, NewString("foo"), 0, NULL); | 757 result = Dart_Invoke(lib, NewString("foo"), 0, NULL); |
| 759 EXPECT_VALID(result); | 758 EXPECT_VALID(result); |
| 760 | 759 |
| 761 { | 760 { |
| 762 StackZone zone(thread); | 761 StackZone zone(thread); |
| 763 HANDLESCOPE(thread); | 762 HANDLESCOPE(thread); |
| 764 Profile profile(isolate); | 763 Profile profile(isolate); |
| 765 AllocationFilter filter(isolate->main_port(), array_class.id()); | 764 AllocationFilter filter(isolate, array_class.id()); |
| 766 profile.Build(thread, &filter, Profile::kNoTags); | 765 profile.Build(thread, &filter, Profile::kNoTags); |
| 767 // We should have one allocation sample. | 766 // We should have one allocation sample. |
| 768 EXPECT_EQ(1, profile.sample_count()); | 767 EXPECT_EQ(1, profile.sample_count()); |
| 769 ProfileTrieWalker walker(&profile); | 768 ProfileTrieWalker walker(&profile); |
| 770 | 769 |
| 771 walker.Reset(Profile::kExclusiveCode); | 770 walker.Reset(Profile::kExclusiveCode); |
| 772 EXPECT(walker.Down()); | 771 EXPECT(walker.Down()); |
| 773 EXPECT_STREQ("DRT_AllocateArray", walker.CurrentName()); | 772 EXPECT_STREQ("DRT_AllocateArray", walker.CurrentName()); |
| 774 EXPECT(walker.Down()); | 773 EXPECT(walker.Down()); |
| 775 EXPECT_STREQ("[Stub] AllocateArray", walker.CurrentName()); | 774 EXPECT_STREQ("[Stub] AllocateArray", walker.CurrentName()); |
| 776 EXPECT(walker.Down()); | 775 EXPECT(walker.Down()); |
| 777 EXPECT_STREQ("_List._List", walker.CurrentName()); | 776 EXPECT_STREQ("_List._List", walker.CurrentName()); |
| 778 EXPECT(walker.Down()); | 777 EXPECT(walker.Down()); |
| 779 EXPECT_STREQ("List.List._internal", walker.CurrentName()); | 778 EXPECT_STREQ("List.List._internal", walker.CurrentName()); |
| 780 EXPECT(walker.Down()); | 779 EXPECT(walker.Down()); |
| 781 EXPECT_STREQ("foo", walker.CurrentName()); | 780 EXPECT_STREQ("foo", walker.CurrentName()); |
| 782 EXPECT(!walker.Down()); | 781 EXPECT(!walker.Down()); |
| 783 } | 782 } |
| 784 | 783 |
| 785 array_class.SetTraceAllocation(false); | 784 array_class.SetTraceAllocation(false); |
| 786 result = Dart_Invoke(lib, NewString("foo"), 0, NULL); | 785 result = Dart_Invoke(lib, NewString("foo"), 0, NULL); |
| 787 EXPECT_VALID(result); | 786 EXPECT_VALID(result); |
| 788 | 787 |
| 789 { | 788 { |
| 790 StackZone zone(thread); | 789 StackZone zone(thread); |
| 791 HANDLESCOPE(thread); | 790 HANDLESCOPE(thread); |
| 792 Profile profile(isolate); | 791 Profile profile(isolate); |
| 793 AllocationFilter filter(isolate->main_port(), array_class.id()); | 792 AllocationFilter filter(isolate, array_class.id()); |
| 794 profile.Build(thread, &filter, Profile::kNoTags); | 793 profile.Build(thread, &filter, Profile::kNoTags); |
| 795 // We should still only have one allocation sample. | 794 // We should still only have one allocation sample. |
| 796 EXPECT_EQ(1, profile.sample_count()); | 795 EXPECT_EQ(1, profile.sample_count()); |
| 797 } | 796 } |
| 798 | 797 |
| 799 // Clear the samples. | 798 // Clear the samples. |
| 800 ProfilerService::ClearSamples(); | 799 ProfilerService::ClearSamples(); |
| 801 | 800 |
| 802 // Compile bar (many List objects allocated). | 801 // Compile bar (many List objects allocated). |
| 803 result = Dart_Invoke(lib, NewString("bar"), 0, NULL); | 802 result = Dart_Invoke(lib, NewString("bar"), 0, NULL); |
| 804 EXPECT_VALID(result); | 803 EXPECT_VALID(result); |
| 805 | 804 |
| 806 // Enable again. | 805 // Enable again. |
| 807 array_class.SetTraceAllocation(true); | 806 array_class.SetTraceAllocation(true); |
| 808 | 807 |
| 809 // Run bar. | 808 // Run bar. |
| 810 result = Dart_Invoke(lib, NewString("bar"), 0, NULL); | 809 result = Dart_Invoke(lib, NewString("bar"), 0, NULL); |
| 811 EXPECT_VALID(result); | 810 EXPECT_VALID(result); |
| 812 | 811 |
| 813 { | 812 { |
| 814 StackZone zone(thread); | 813 StackZone zone(thread); |
| 815 HANDLESCOPE(thread); | 814 HANDLESCOPE(thread); |
| 816 Profile profile(isolate); | 815 Profile profile(isolate); |
| 817 AllocationFilter filter(isolate->main_port(), array_class.id()); | 816 AllocationFilter filter(isolate, array_class.id()); |
| 818 profile.Build(thread, &filter, Profile::kNoTags); | 817 profile.Build(thread, &filter, Profile::kNoTags); |
| 819 // We should still only have one allocation sample. | 818 // We should still only have one allocation sample. |
| 820 EXPECT_EQ(1, profile.sample_count()); | 819 EXPECT_EQ(1, profile.sample_count()); |
| 821 ProfileTrieWalker walker(&profile); | 820 ProfileTrieWalker walker(&profile); |
| 822 | 821 |
| 823 walker.Reset(Profile::kExclusiveCode); | 822 walker.Reset(Profile::kExclusiveCode); |
| 824 EXPECT(walker.Down()); | 823 EXPECT(walker.Down()); |
| 825 EXPECT_STREQ("DRT_AllocateArray", walker.CurrentName()); | 824 EXPECT_STREQ("DRT_AllocateArray", walker.CurrentName()); |
| 826 EXPECT(walker.Down()); | 825 EXPECT(walker.Down()); |
| 827 EXPECT_STREQ("[Stub] AllocateArray", walker.CurrentName()); | 826 EXPECT_STREQ("[Stub] AllocateArray", walker.CurrentName()); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 855 const Class& context_class = Class::Handle(Object::context_class()); | 854 const Class& context_class = Class::Handle(Object::context_class()); |
| 856 EXPECT(!context_class.IsNull()); | 855 EXPECT(!context_class.IsNull()); |
| 857 | 856 |
| 858 Dart_Handle result = Dart_Invoke(lib, NewString("foo"), 0, NULL); | 857 Dart_Handle result = Dart_Invoke(lib, NewString("foo"), 0, NULL); |
| 859 EXPECT_VALID(result); | 858 EXPECT_VALID(result); |
| 860 | 859 |
| 861 { | 860 { |
| 862 StackZone zone(thread); | 861 StackZone zone(thread); |
| 863 HANDLESCOPE(thread); | 862 HANDLESCOPE(thread); |
| 864 Profile profile(isolate); | 863 Profile profile(isolate); |
| 865 AllocationFilter filter(isolate->main_port(), context_class.id()); | 864 AllocationFilter filter(isolate, context_class.id()); |
| 866 profile.Build(thread, &filter, Profile::kNoTags); | 865 profile.Build(thread, &filter, Profile::kNoTags); |
| 867 // We should have no allocation samples. | 866 // We should have no allocation samples. |
| 868 EXPECT_EQ(0, profile.sample_count()); | 867 EXPECT_EQ(0, profile.sample_count()); |
| 869 } | 868 } |
| 870 | 869 |
| 871 context_class.SetTraceAllocation(true); | 870 context_class.SetTraceAllocation(true); |
| 872 result = Dart_Invoke(lib, NewString("foo"), 0, NULL); | 871 result = Dart_Invoke(lib, NewString("foo"), 0, NULL); |
| 873 EXPECT_VALID(result); | 872 EXPECT_VALID(result); |
| 874 | 873 |
| 875 { | 874 { |
| 876 StackZone zone(thread); | 875 StackZone zone(thread); |
| 877 HANDLESCOPE(thread); | 876 HANDLESCOPE(thread); |
| 878 Profile profile(isolate); | 877 Profile profile(isolate); |
| 879 AllocationFilter filter(isolate->main_port(), context_class.id()); | 878 AllocationFilter filter(isolate, context_class.id()); |
| 880 profile.Build(thread, &filter, Profile::kNoTags); | 879 profile.Build(thread, &filter, Profile::kNoTags); |
| 881 // We should have one allocation sample. | 880 // We should have one allocation sample. |
| 882 EXPECT_EQ(1, profile.sample_count()); | 881 EXPECT_EQ(1, profile.sample_count()); |
| 883 ProfileTrieWalker walker(&profile); | 882 ProfileTrieWalker walker(&profile); |
| 884 | 883 |
| 885 walker.Reset(Profile::kExclusiveCode); | 884 walker.Reset(Profile::kExclusiveCode); |
| 886 EXPECT(walker.Down()); | 885 EXPECT(walker.Down()); |
| 887 EXPECT_STREQ("DRT_AllocateContext", walker.CurrentName()); | 886 EXPECT_STREQ("DRT_AllocateContext", walker.CurrentName()); |
| 888 EXPECT(walker.Down()); | 887 EXPECT(walker.Down()); |
| 889 EXPECT_STREQ("[Stub] AllocateContext", walker.CurrentName()); | 888 EXPECT_STREQ("[Stub] AllocateContext", walker.CurrentName()); |
| 890 EXPECT(walker.Down()); | 889 EXPECT(walker.Down()); |
| 891 EXPECT_STREQ("foo", walker.CurrentName()); | 890 EXPECT_STREQ("foo", walker.CurrentName()); |
| 892 EXPECT(!walker.Down()); | 891 EXPECT(!walker.Down()); |
| 893 } | 892 } |
| 894 | 893 |
| 895 context_class.SetTraceAllocation(false); | 894 context_class.SetTraceAllocation(false); |
| 896 result = Dart_Invoke(lib, NewString("foo"), 0, NULL); | 895 result = Dart_Invoke(lib, NewString("foo"), 0, NULL); |
| 897 EXPECT_VALID(result); | 896 EXPECT_VALID(result); |
| 898 | 897 |
| 899 { | 898 { |
| 900 StackZone zone(thread); | 899 StackZone zone(thread); |
| 901 HANDLESCOPE(thread); | 900 HANDLESCOPE(thread); |
| 902 Profile profile(isolate); | 901 Profile profile(isolate); |
| 903 AllocationFilter filter(isolate->main_port(), context_class.id()); | 902 AllocationFilter filter(isolate, context_class.id()); |
| 904 profile.Build(thread, &filter, Profile::kNoTags); | 903 profile.Build(thread, &filter, Profile::kNoTags); |
| 905 // We should still only have one allocation sample. | 904 // We should still only have one allocation sample. |
| 906 EXPECT_EQ(1, profile.sample_count()); | 905 EXPECT_EQ(1, profile.sample_count()); |
| 907 } | 906 } |
| 908 } | 907 } |
| 909 | 908 |
| 910 | 909 |
| 911 TEST_CASE(Profiler_ClosureAllocation) { | 910 TEST_CASE(Profiler_ClosureAllocation) { |
| 912 DisableNativeProfileScope dnps; | 911 DisableNativeProfileScope dnps; |
| 913 const char* kScript = | 912 const char* kScript = |
| (...skipping 22 matching lines...) Expand all Loading... |
| 936 closure_class.SetTraceAllocation(true); | 935 closure_class.SetTraceAllocation(true); |
| 937 | 936 |
| 938 // Invoke "foo" which during compilation, triggers a closure allocation. | 937 // Invoke "foo" which during compilation, triggers a closure allocation. |
| 939 Dart_Handle result = Dart_Invoke(lib, NewString("foo"), 0, NULL); | 938 Dart_Handle result = Dart_Invoke(lib, NewString("foo"), 0, NULL); |
| 940 EXPECT_VALID(result); | 939 EXPECT_VALID(result); |
| 941 | 940 |
| 942 { | 941 { |
| 943 StackZone zone(thread); | 942 StackZone zone(thread); |
| 944 HANDLESCOPE(thread); | 943 HANDLESCOPE(thread); |
| 945 Profile profile(isolate); | 944 Profile profile(isolate); |
| 946 AllocationFilter filter(isolate->main_port(), closure_class.id()); | 945 AllocationFilter filter(isolate, closure_class.id()); |
| 947 filter.set_enable_vm_ticks(true); | 946 filter.set_enable_vm_ticks(true); |
| 948 profile.Build(thread, &filter, Profile::kNoTags); | 947 profile.Build(thread, &filter, Profile::kNoTags); |
| 949 // We should have one allocation sample. | 948 // We should have one allocation sample. |
| 950 EXPECT_EQ(1, profile.sample_count()); | 949 EXPECT_EQ(1, profile.sample_count()); |
| 951 ProfileTrieWalker walker(&profile); | 950 ProfileTrieWalker walker(&profile); |
| 952 | 951 |
| 953 walker.Reset(Profile::kExclusiveCode); | 952 walker.Reset(Profile::kExclusiveCode); |
| 954 EXPECT(walker.Down()); | 953 EXPECT(walker.Down()); |
| 955 EXPECT_SUBSTRING("DRT_AllocateObject", walker.CurrentName()); | 954 EXPECT_SUBSTRING("DRT_AllocateObject", walker.CurrentName()); |
| 956 EXPECT(walker.Down()); | 955 EXPECT(walker.Down()); |
| 957 EXPECT_STREQ("[Stub] Allocate _Closure", walker.CurrentName()); | 956 EXPECT_STREQ("[Stub] Allocate _Closure", walker.CurrentName()); |
| 958 EXPECT(walker.Down()); | 957 EXPECT(walker.Down()); |
| 959 EXPECT_SUBSTRING("foo", walker.CurrentName()); | 958 EXPECT_SUBSTRING("foo", walker.CurrentName()); |
| 960 EXPECT(!walker.Down()); | 959 EXPECT(!walker.Down()); |
| 961 } | 960 } |
| 962 | 961 |
| 963 // Disable allocation tracing for Closure. | 962 // Disable allocation tracing for Closure. |
| 964 closure_class.SetTraceAllocation(false); | 963 closure_class.SetTraceAllocation(false); |
| 965 | 964 |
| 966 // Invoke "bar" which during compilation, triggers a closure allocation. | 965 // Invoke "bar" which during compilation, triggers a closure allocation. |
| 967 result = Dart_Invoke(lib, NewString("bar"), 0, NULL); | 966 result = Dart_Invoke(lib, NewString("bar"), 0, NULL); |
| 968 EXPECT_VALID(result); | 967 EXPECT_VALID(result); |
| 969 | 968 |
| 970 { | 969 { |
| 971 StackZone zone(thread); | 970 StackZone zone(thread); |
| 972 HANDLESCOPE(thread); | 971 HANDLESCOPE(thread); |
| 973 Profile profile(isolate); | 972 Profile profile(isolate); |
| 974 AllocationFilter filter(isolate->main_port(), closure_class.id()); | 973 AllocationFilter filter(isolate, closure_class.id()); |
| 975 filter.set_enable_vm_ticks(true); | 974 filter.set_enable_vm_ticks(true); |
| 976 profile.Build(thread, &filter, Profile::kNoTags); | 975 profile.Build(thread, &filter, Profile::kNoTags); |
| 977 // We should still only have one allocation sample. | 976 // We should still only have one allocation sample. |
| 978 EXPECT_EQ(1, profile.sample_count()); | 977 EXPECT_EQ(1, profile.sample_count()); |
| 979 } | 978 } |
| 980 } | 979 } |
| 981 | 980 |
| 982 | 981 |
| 983 TEST_CASE(Profiler_TypedArrayAllocation) { | 982 TEST_CASE(Profiler_TypedArrayAllocation) { |
| 984 DisableNativeProfileScope dnps; | 983 DisableNativeProfileScope dnps; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 998 Class::Handle(GetClass(typed_data_library, "_Float32List")); | 997 Class::Handle(GetClass(typed_data_library, "_Float32List")); |
| 999 EXPECT(!float32_list_class.IsNull()); | 998 EXPECT(!float32_list_class.IsNull()); |
| 1000 | 999 |
| 1001 Dart_Handle result = Dart_Invoke(lib, NewString("foo"), 0, NULL); | 1000 Dart_Handle result = Dart_Invoke(lib, NewString("foo"), 0, NULL); |
| 1002 EXPECT_VALID(result); | 1001 EXPECT_VALID(result); |
| 1003 | 1002 |
| 1004 { | 1003 { |
| 1005 StackZone zone(thread); | 1004 StackZone zone(thread); |
| 1006 HANDLESCOPE(thread); | 1005 HANDLESCOPE(thread); |
| 1007 Profile profile(isolate); | 1006 Profile profile(isolate); |
| 1008 AllocationFilter filter(isolate->main_port(), float32_list_class.id()); | 1007 AllocationFilter filter(isolate, float32_list_class.id()); |
| 1009 profile.Build(thread, &filter, Profile::kNoTags); | 1008 profile.Build(thread, &filter, Profile::kNoTags); |
| 1010 // We should have no allocation samples. | 1009 // We should have no allocation samples. |
| 1011 EXPECT_EQ(0, profile.sample_count()); | 1010 EXPECT_EQ(0, profile.sample_count()); |
| 1012 } | 1011 } |
| 1013 | 1012 |
| 1014 float32_list_class.SetTraceAllocation(true); | 1013 float32_list_class.SetTraceAllocation(true); |
| 1015 result = Dart_Invoke(lib, NewString("foo"), 0, NULL); | 1014 result = Dart_Invoke(lib, NewString("foo"), 0, NULL); |
| 1016 EXPECT_VALID(result); | 1015 EXPECT_VALID(result); |
| 1017 | 1016 |
| 1018 { | 1017 { |
| 1019 StackZone zone(thread); | 1018 StackZone zone(thread); |
| 1020 HANDLESCOPE(thread); | 1019 HANDLESCOPE(thread); |
| 1021 Profile profile(isolate); | 1020 Profile profile(isolate); |
| 1022 AllocationFilter filter(isolate->main_port(), float32_list_class.id()); | 1021 AllocationFilter filter(isolate, float32_list_class.id()); |
| 1023 profile.Build(thread, &filter, Profile::kNoTags); | 1022 profile.Build(thread, &filter, Profile::kNoTags); |
| 1024 // We should have one allocation sample. | 1023 // We should have one allocation sample. |
| 1025 EXPECT_EQ(1, profile.sample_count()); | 1024 EXPECT_EQ(1, profile.sample_count()); |
| 1026 ProfileTrieWalker walker(&profile); | 1025 ProfileTrieWalker walker(&profile); |
| 1027 | 1026 |
| 1028 walker.Reset(Profile::kExclusiveCode); | 1027 walker.Reset(Profile::kExclusiveCode); |
| 1029 EXPECT(walker.Down()); | 1028 EXPECT(walker.Down()); |
| 1030 EXPECT_STREQ("TypedData_Float32Array_new", walker.CurrentName()); | 1029 EXPECT_STREQ("TypedData_Float32Array_new", walker.CurrentName()); |
| 1031 EXPECT(walker.Down()); | 1030 EXPECT(walker.Down()); |
| 1032 EXPECT_STREQ("Float32List.Float32List", walker.CurrentName()); | 1031 EXPECT_STREQ("Float32List.Float32List", walker.CurrentName()); |
| 1033 EXPECT(walker.Down()); | 1032 EXPECT(walker.Down()); |
| 1034 EXPECT_STREQ("foo", walker.CurrentName()); | 1033 EXPECT_STREQ("foo", walker.CurrentName()); |
| 1035 EXPECT(!walker.Down()); | 1034 EXPECT(!walker.Down()); |
| 1036 } | 1035 } |
| 1037 | 1036 |
| 1038 float32_list_class.SetTraceAllocation(false); | 1037 float32_list_class.SetTraceAllocation(false); |
| 1039 result = Dart_Invoke(lib, NewString("foo"), 0, NULL); | 1038 result = Dart_Invoke(lib, NewString("foo"), 0, NULL); |
| 1040 EXPECT_VALID(result); | 1039 EXPECT_VALID(result); |
| 1041 | 1040 |
| 1042 { | 1041 { |
| 1043 StackZone zone(thread); | 1042 StackZone zone(thread); |
| 1044 HANDLESCOPE(thread); | 1043 HANDLESCOPE(thread); |
| 1045 Profile profile(isolate); | 1044 Profile profile(isolate); |
| 1046 AllocationFilter filter(isolate->main_port(), float32_list_class.id()); | 1045 AllocationFilter filter(isolate, float32_list_class.id()); |
| 1047 profile.Build(thread, &filter, Profile::kNoTags); | 1046 profile.Build(thread, &filter, Profile::kNoTags); |
| 1048 // We should still only have one allocation sample. | 1047 // We should still only have one allocation sample. |
| 1049 EXPECT_EQ(1, profile.sample_count()); | 1048 EXPECT_EQ(1, profile.sample_count()); |
| 1050 } | 1049 } |
| 1051 | 1050 |
| 1052 float32_list_class.SetTraceAllocation(true); | 1051 float32_list_class.SetTraceAllocation(true); |
| 1053 result = Dart_Invoke(lib, NewString("foo"), 0, NULL); | 1052 result = Dart_Invoke(lib, NewString("foo"), 0, NULL); |
| 1054 EXPECT_VALID(result); | 1053 EXPECT_VALID(result); |
| 1055 | 1054 |
| 1056 { | 1055 { |
| 1057 StackZone zone(thread); | 1056 StackZone zone(thread); |
| 1058 HANDLESCOPE(thread); | 1057 HANDLESCOPE(thread); |
| 1059 Profile profile(isolate); | 1058 Profile profile(isolate); |
| 1060 AllocationFilter filter(isolate->main_port(), float32_list_class.id()); | 1059 AllocationFilter filter(isolate, float32_list_class.id()); |
| 1061 profile.Build(thread, &filter, Profile::kNoTags); | 1060 profile.Build(thread, &filter, Profile::kNoTags); |
| 1062 // We should now have two allocation samples. | 1061 // We should now have two allocation samples. |
| 1063 EXPECT_EQ(2, profile.sample_count()); | 1062 EXPECT_EQ(2, profile.sample_count()); |
| 1064 } | 1063 } |
| 1065 } | 1064 } |
| 1066 | 1065 |
| 1067 | 1066 |
| 1068 TEST_CASE(Profiler_StringAllocation) { | 1067 TEST_CASE(Profiler_StringAllocation) { |
| 1069 DisableNativeProfileScope dnps; | 1068 DisableNativeProfileScope dnps; |
| 1070 const char* kScript = "String foo(String a, String b) => a + b;"; | 1069 const char* kScript = "String foo(String a, String b) => a + b;"; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1082 NewString("a"), NewString("b"), | 1081 NewString("a"), NewString("b"), |
| 1083 }; | 1082 }; |
| 1084 | 1083 |
| 1085 Dart_Handle result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); | 1084 Dart_Handle result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); |
| 1086 EXPECT_VALID(result); | 1085 EXPECT_VALID(result); |
| 1087 | 1086 |
| 1088 { | 1087 { |
| 1089 StackZone zone(thread); | 1088 StackZone zone(thread); |
| 1090 HANDLESCOPE(thread); | 1089 HANDLESCOPE(thread); |
| 1091 Profile profile(isolate); | 1090 Profile profile(isolate); |
| 1092 AllocationFilter filter(isolate->main_port(), one_byte_string_class.id()); | 1091 AllocationFilter filter(isolate, one_byte_string_class.id()); |
| 1093 profile.Build(thread, &filter, Profile::kNoTags); | 1092 profile.Build(thread, &filter, Profile::kNoTags); |
| 1094 // We should have no allocation samples. | 1093 // We should have no allocation samples. |
| 1095 EXPECT_EQ(0, profile.sample_count()); | 1094 EXPECT_EQ(0, profile.sample_count()); |
| 1096 } | 1095 } |
| 1097 | 1096 |
| 1098 one_byte_string_class.SetTraceAllocation(true); | 1097 one_byte_string_class.SetTraceAllocation(true); |
| 1099 result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); | 1098 result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); |
| 1100 EXPECT_VALID(result); | 1099 EXPECT_VALID(result); |
| 1101 | 1100 |
| 1102 { | 1101 { |
| 1103 StackZone zone(thread); | 1102 StackZone zone(thread); |
| 1104 HANDLESCOPE(thread); | 1103 HANDLESCOPE(thread); |
| 1105 Profile profile(isolate); | 1104 Profile profile(isolate); |
| 1106 AllocationFilter filter(isolate->main_port(), one_byte_string_class.id()); | 1105 AllocationFilter filter(isolate, one_byte_string_class.id()); |
| 1107 profile.Build(thread, &filter, Profile::kNoTags); | 1106 profile.Build(thread, &filter, Profile::kNoTags); |
| 1108 // We should still only have one allocation sample. | 1107 // We should still only have one allocation sample. |
| 1109 EXPECT_EQ(1, profile.sample_count()); | 1108 EXPECT_EQ(1, profile.sample_count()); |
| 1110 ProfileTrieWalker walker(&profile); | 1109 ProfileTrieWalker walker(&profile); |
| 1111 | 1110 |
| 1112 walker.Reset(Profile::kExclusiveCode); | 1111 walker.Reset(Profile::kExclusiveCode); |
| 1113 EXPECT(walker.Down()); | 1112 EXPECT(walker.Down()); |
| 1114 EXPECT_STREQ("String_concat", walker.CurrentName()); | 1113 EXPECT_STREQ("String_concat", walker.CurrentName()); |
| 1115 EXPECT(walker.Down()); | 1114 EXPECT(walker.Down()); |
| 1116 #if 1 | 1115 #if 1 |
| 1117 EXPECT_STREQ("_StringBase.+", walker.CurrentName()); | 1116 EXPECT_STREQ("_StringBase.+", walker.CurrentName()); |
| 1118 EXPECT(walker.Down()); | 1117 EXPECT(walker.Down()); |
| 1119 #endif | 1118 #endif |
| 1120 EXPECT_STREQ("foo", walker.CurrentName()); | 1119 EXPECT_STREQ("foo", walker.CurrentName()); |
| 1121 EXPECT(!walker.Down()); | 1120 EXPECT(!walker.Down()); |
| 1122 } | 1121 } |
| 1123 | 1122 |
| 1124 one_byte_string_class.SetTraceAllocation(false); | 1123 one_byte_string_class.SetTraceAllocation(false); |
| 1125 result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); | 1124 result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); |
| 1126 EXPECT_VALID(result); | 1125 EXPECT_VALID(result); |
| 1127 | 1126 |
| 1128 { | 1127 { |
| 1129 StackZone zone(thread); | 1128 StackZone zone(thread); |
| 1130 HANDLESCOPE(thread); | 1129 HANDLESCOPE(thread); |
| 1131 Profile profile(isolate); | 1130 Profile profile(isolate); |
| 1132 AllocationFilter filter(isolate->main_port(), one_byte_string_class.id()); | 1131 AllocationFilter filter(isolate, one_byte_string_class.id()); |
| 1133 profile.Build(thread, &filter, Profile::kNoTags); | 1132 profile.Build(thread, &filter, Profile::kNoTags); |
| 1134 // We should still only have one allocation sample. | 1133 // We should still only have one allocation sample. |
| 1135 EXPECT_EQ(1, profile.sample_count()); | 1134 EXPECT_EQ(1, profile.sample_count()); |
| 1136 } | 1135 } |
| 1137 | 1136 |
| 1138 one_byte_string_class.SetTraceAllocation(true); | 1137 one_byte_string_class.SetTraceAllocation(true); |
| 1139 result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); | 1138 result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); |
| 1140 EXPECT_VALID(result); | 1139 EXPECT_VALID(result); |
| 1141 | 1140 |
| 1142 { | 1141 { |
| 1143 StackZone zone(thread); | 1142 StackZone zone(thread); |
| 1144 HANDLESCOPE(thread); | 1143 HANDLESCOPE(thread); |
| 1145 Profile profile(isolate); | 1144 Profile profile(isolate); |
| 1146 AllocationFilter filter(isolate->main_port(), one_byte_string_class.id()); | 1145 AllocationFilter filter(isolate, one_byte_string_class.id()); |
| 1147 profile.Build(thread, &filter, Profile::kNoTags); | 1146 profile.Build(thread, &filter, Profile::kNoTags); |
| 1148 // We should now have two allocation samples. | 1147 // We should now have two allocation samples. |
| 1149 EXPECT_EQ(2, profile.sample_count()); | 1148 EXPECT_EQ(2, profile.sample_count()); |
| 1150 } | 1149 } |
| 1151 } | 1150 } |
| 1152 | 1151 |
| 1153 | 1152 |
| 1154 TEST_CASE(Profiler_StringInterpolation) { | 1153 TEST_CASE(Profiler_StringInterpolation) { |
| 1155 DisableNativeProfileScope dnps; | 1154 DisableNativeProfileScope dnps; |
| 1156 DisableBackgroundCompilationScope dbcs; | 1155 DisableBackgroundCompilationScope dbcs; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1169 NewString("a"), NewString("b"), | 1168 NewString("a"), NewString("b"), |
| 1170 }; | 1169 }; |
| 1171 | 1170 |
| 1172 Dart_Handle result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); | 1171 Dart_Handle result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); |
| 1173 EXPECT_VALID(result); | 1172 EXPECT_VALID(result); |
| 1174 | 1173 |
| 1175 { | 1174 { |
| 1176 StackZone zone(thread); | 1175 StackZone zone(thread); |
| 1177 HANDLESCOPE(thread); | 1176 HANDLESCOPE(thread); |
| 1178 Profile profile(isolate); | 1177 Profile profile(isolate); |
| 1179 AllocationFilter filter(isolate->main_port(), one_byte_string_class.id()); | 1178 AllocationFilter filter(isolate, one_byte_string_class.id()); |
| 1180 profile.Build(thread, &filter, Profile::kNoTags); | 1179 profile.Build(thread, &filter, Profile::kNoTags); |
| 1181 // We should have no allocation samples. | 1180 // We should have no allocation samples. |
| 1182 EXPECT_EQ(0, profile.sample_count()); | 1181 EXPECT_EQ(0, profile.sample_count()); |
| 1183 } | 1182 } |
| 1184 | 1183 |
| 1185 one_byte_string_class.SetTraceAllocation(true); | 1184 one_byte_string_class.SetTraceAllocation(true); |
| 1186 result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); | 1185 result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); |
| 1187 EXPECT_VALID(result); | 1186 EXPECT_VALID(result); |
| 1188 | 1187 |
| 1189 { | 1188 { |
| 1190 StackZone zone(thread); | 1189 StackZone zone(thread); |
| 1191 HANDLESCOPE(thread); | 1190 HANDLESCOPE(thread); |
| 1192 Profile profile(isolate); | 1191 Profile profile(isolate); |
| 1193 AllocationFilter filter(isolate->main_port(), one_byte_string_class.id()); | 1192 AllocationFilter filter(isolate, one_byte_string_class.id()); |
| 1194 profile.Build(thread, &filter, Profile::kNoTags); | 1193 profile.Build(thread, &filter, Profile::kNoTags); |
| 1195 // We should still only have one allocation sample. | 1194 // We should still only have one allocation sample. |
| 1196 EXPECT_EQ(1, profile.sample_count()); | 1195 EXPECT_EQ(1, profile.sample_count()); |
| 1197 ProfileTrieWalker walker(&profile); | 1196 ProfileTrieWalker walker(&profile); |
| 1198 | 1197 |
| 1199 walker.Reset(Profile::kExclusiveCode); | 1198 walker.Reset(Profile::kExclusiveCode); |
| 1200 EXPECT(walker.Down()); | 1199 EXPECT(walker.Down()); |
| 1201 EXPECT_STREQ("OneByteString_allocate", walker.CurrentName()); | 1200 EXPECT_STREQ("OneByteString_allocate", walker.CurrentName()); |
| 1202 EXPECT(walker.Down()); | 1201 EXPECT(walker.Down()); |
| 1203 EXPECT_STREQ("_OneByteString._allocate", walker.CurrentName()); | 1202 EXPECT_STREQ("_OneByteString._allocate", walker.CurrentName()); |
| 1204 EXPECT(walker.Down()); | 1203 EXPECT(walker.Down()); |
| 1205 EXPECT_STREQ("_OneByteString._concatAll", walker.CurrentName()); | 1204 EXPECT_STREQ("_OneByteString._concatAll", walker.CurrentName()); |
| 1206 EXPECT(walker.Down()); | 1205 EXPECT(walker.Down()); |
| 1207 EXPECT_STREQ("_StringBase._interpolate", walker.CurrentName()); | 1206 EXPECT_STREQ("_StringBase._interpolate", walker.CurrentName()); |
| 1208 EXPECT(walker.Down()); | 1207 EXPECT(walker.Down()); |
| 1209 EXPECT_STREQ("foo", walker.CurrentName()); | 1208 EXPECT_STREQ("foo", walker.CurrentName()); |
| 1210 EXPECT(!walker.Down()); | 1209 EXPECT(!walker.Down()); |
| 1211 } | 1210 } |
| 1212 | 1211 |
| 1213 one_byte_string_class.SetTraceAllocation(false); | 1212 one_byte_string_class.SetTraceAllocation(false); |
| 1214 result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); | 1213 result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); |
| 1215 EXPECT_VALID(result); | 1214 EXPECT_VALID(result); |
| 1216 | 1215 |
| 1217 { | 1216 { |
| 1218 StackZone zone(thread); | 1217 StackZone zone(thread); |
| 1219 HANDLESCOPE(thread); | 1218 HANDLESCOPE(thread); |
| 1220 Profile profile(isolate); | 1219 Profile profile(isolate); |
| 1221 AllocationFilter filter(isolate->main_port(), one_byte_string_class.id()); | 1220 AllocationFilter filter(isolate, one_byte_string_class.id()); |
| 1222 profile.Build(thread, &filter, Profile::kNoTags); | 1221 profile.Build(thread, &filter, Profile::kNoTags); |
| 1223 // We should still only have one allocation sample. | 1222 // We should still only have one allocation sample. |
| 1224 EXPECT_EQ(1, profile.sample_count()); | 1223 EXPECT_EQ(1, profile.sample_count()); |
| 1225 } | 1224 } |
| 1226 | 1225 |
| 1227 one_byte_string_class.SetTraceAllocation(true); | 1226 one_byte_string_class.SetTraceAllocation(true); |
| 1228 result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); | 1227 result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); |
| 1229 EXPECT_VALID(result); | 1228 EXPECT_VALID(result); |
| 1230 | 1229 |
| 1231 { | 1230 { |
| 1232 StackZone zone(thread); | 1231 StackZone zone(thread); |
| 1233 HANDLESCOPE(thread); | 1232 HANDLESCOPE(thread); |
| 1234 Profile profile(isolate); | 1233 Profile profile(isolate); |
| 1235 AllocationFilter filter(isolate->main_port(), one_byte_string_class.id()); | 1234 AllocationFilter filter(isolate, one_byte_string_class.id()); |
| 1236 profile.Build(thread, &filter, Profile::kNoTags); | 1235 profile.Build(thread, &filter, Profile::kNoTags); |
| 1237 // We should now have two allocation samples. | 1236 // We should now have two allocation samples. |
| 1238 EXPECT_EQ(2, profile.sample_count()); | 1237 EXPECT_EQ(2, profile.sample_count()); |
| 1239 } | 1238 } |
| 1240 } | 1239 } |
| 1241 | 1240 |
| 1242 | 1241 |
| 1243 TEST_CASE(Profiler_FunctionInline) { | 1242 TEST_CASE(Profiler_FunctionInline) { |
| 1244 DisableNativeProfileScope dnps; | 1243 DisableNativeProfileScope dnps; |
| 1245 DisableBackgroundCompilationScope dbcs; | 1244 DisableBackgroundCompilationScope dbcs; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1285 result = Dart_Invoke(lib, NewString("mainA"), 0, NULL); | 1284 result = Dart_Invoke(lib, NewString("mainA"), 0, NULL); |
| 1286 EXPECT_VALID(result); | 1285 EXPECT_VALID(result); |
| 1287 // At this point B.boo should be optimized and inlined B.foo and B.choo. | 1286 // At this point B.boo should be optimized and inlined B.foo and B.choo. |
| 1288 | 1287 |
| 1289 { | 1288 { |
| 1290 Thread* thread = Thread::Current(); | 1289 Thread* thread = Thread::Current(); |
| 1291 Isolate* isolate = thread->isolate(); | 1290 Isolate* isolate = thread->isolate(); |
| 1292 StackZone zone(thread); | 1291 StackZone zone(thread); |
| 1293 HANDLESCOPE(thread); | 1292 HANDLESCOPE(thread); |
| 1294 Profile profile(isolate); | 1293 Profile profile(isolate); |
| 1295 AllocationFilter filter(isolate->main_port(), class_a.id()); | 1294 AllocationFilter filter(isolate, class_a.id()); |
| 1296 profile.Build(thread, &filter, Profile::kNoTags); | 1295 profile.Build(thread, &filter, Profile::kNoTags); |
| 1297 // We should have no allocation samples. | 1296 // We should have no allocation samples. |
| 1298 EXPECT_EQ(0, profile.sample_count()); | 1297 EXPECT_EQ(0, profile.sample_count()); |
| 1299 } | 1298 } |
| 1300 | 1299 |
| 1301 // Turn on allocation tracing for A. | 1300 // Turn on allocation tracing for A. |
| 1302 class_a.SetTraceAllocation(true); | 1301 class_a.SetTraceAllocation(true); |
| 1303 | 1302 |
| 1304 // Allocate 50,000 instances of A. | 1303 // Allocate 50,000 instances of A. |
| 1305 result = Dart_Invoke(lib, NewString("mainA"), 0, NULL); | 1304 result = Dart_Invoke(lib, NewString("mainA"), 0, NULL); |
| 1306 EXPECT_VALID(result); | 1305 EXPECT_VALID(result); |
| 1307 | 1306 |
| 1308 { | 1307 { |
| 1309 Thread* thread = Thread::Current(); | 1308 Thread* thread = Thread::Current(); |
| 1310 Isolate* isolate = thread->isolate(); | 1309 Isolate* isolate = thread->isolate(); |
| 1311 StackZone zone(thread); | 1310 StackZone zone(thread); |
| 1312 HANDLESCOPE(thread); | 1311 HANDLESCOPE(thread); |
| 1313 Profile profile(isolate); | 1312 Profile profile(isolate); |
| 1314 AllocationFilter filter(isolate->main_port(), class_a.id()); | 1313 AllocationFilter filter(isolate, class_a.id()); |
| 1315 profile.Build(thread, &filter, Profile::kNoTags); | 1314 profile.Build(thread, &filter, Profile::kNoTags); |
| 1316 // We should have 50,000 allocation samples. | 1315 // We should have 50,000 allocation samples. |
| 1317 EXPECT_EQ(50000, profile.sample_count()); | 1316 EXPECT_EQ(50000, profile.sample_count()); |
| 1318 ProfileTrieWalker walker(&profile); | 1317 ProfileTrieWalker walker(&profile); |
| 1319 // We have two code objects: mainA and B.boo. | 1318 // We have two code objects: mainA and B.boo. |
| 1320 walker.Reset(Profile::kExclusiveCode); | 1319 walker.Reset(Profile::kExclusiveCode); |
| 1321 EXPECT(walker.Down()); | 1320 EXPECT(walker.Down()); |
| 1322 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); | 1321 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); |
| 1323 EXPECT(walker.Down()); | 1322 EXPECT(walker.Down()); |
| 1324 EXPECT_STREQ("[Stub] Allocate A", walker.CurrentName()); | 1323 EXPECT_STREQ("[Stub] Allocate A", walker.CurrentName()); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1422 EXPECT(!walker.Down()); | 1421 EXPECT(!walker.Down()); |
| 1423 } | 1422 } |
| 1424 | 1423 |
| 1425 // Test code transition tags. | 1424 // Test code transition tags. |
| 1426 { | 1425 { |
| 1427 Thread* thread = Thread::Current(); | 1426 Thread* thread = Thread::Current(); |
| 1428 Isolate* isolate = thread->isolate(); | 1427 Isolate* isolate = thread->isolate(); |
| 1429 StackZone zone(thread); | 1428 StackZone zone(thread); |
| 1430 HANDLESCOPE(thread); | 1429 HANDLESCOPE(thread); |
| 1431 Profile profile(isolate); | 1430 Profile profile(isolate); |
| 1432 AllocationFilter filter(isolate->main_port(), class_a.id()); | 1431 AllocationFilter filter(isolate, class_a.id()); |
| 1433 profile.Build(thread, &filter, Profile::kNoTags, | 1432 profile.Build(thread, &filter, Profile::kNoTags, |
| 1434 ProfilerService::kCodeTransitionTagsBit); | 1433 ProfilerService::kCodeTransitionTagsBit); |
| 1435 // We should have 50,000 allocation samples. | 1434 // We should have 50,000 allocation samples. |
| 1436 EXPECT_EQ(50000, profile.sample_count()); | 1435 EXPECT_EQ(50000, profile.sample_count()); |
| 1437 ProfileTrieWalker walker(&profile); | 1436 ProfileTrieWalker walker(&profile); |
| 1438 // We have two code objects: mainA and B.boo. | 1437 // We have two code objects: mainA and B.boo. |
| 1439 walker.Reset(Profile::kExclusiveCode); | 1438 walker.Reset(Profile::kExclusiveCode); |
| 1440 EXPECT(walker.Down()); | 1439 EXPECT(walker.Down()); |
| 1441 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); | 1440 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); |
| 1442 EXPECT(walker.Down()); | 1441 EXPECT(walker.Down()); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1595 EXPECT(!func.is_inlinable()); | 1594 EXPECT(!func.is_inlinable()); |
| 1596 func = GetFunction(root_library, "maybeAlloc"); | 1595 func = GetFunction(root_library, "maybeAlloc"); |
| 1597 EXPECT(!func.is_inlinable()); | 1596 EXPECT(!func.is_inlinable()); |
| 1598 | 1597 |
| 1599 { | 1598 { |
| 1600 Thread* thread = Thread::Current(); | 1599 Thread* thread = Thread::Current(); |
| 1601 Isolate* isolate = thread->isolate(); | 1600 Isolate* isolate = thread->isolate(); |
| 1602 StackZone zone(thread); | 1601 StackZone zone(thread); |
| 1603 HANDLESCOPE(thread); | 1602 HANDLESCOPE(thread); |
| 1604 Profile profile(isolate); | 1603 Profile profile(isolate); |
| 1605 AllocationFilter filter(isolate->main_port(), class_a.id()); | 1604 AllocationFilter filter(isolate, class_a.id()); |
| 1606 profile.Build(thread, &filter, Profile::kNoTags); | 1605 profile.Build(thread, &filter, Profile::kNoTags); |
| 1607 // We should have no allocation samples. | 1606 // We should have no allocation samples. |
| 1608 EXPECT_EQ(0, profile.sample_count()); | 1607 EXPECT_EQ(0, profile.sample_count()); |
| 1609 } | 1608 } |
| 1610 | 1609 |
| 1611 // Turn on allocation tracing for A. | 1610 // Turn on allocation tracing for A. |
| 1612 class_a.SetTraceAllocation(true); | 1611 class_a.SetTraceAllocation(true); |
| 1613 | 1612 |
| 1614 result = Dart_Invoke(lib, NewString("mainAlloc"), 0, NULL); | 1613 result = Dart_Invoke(lib, NewString("mainAlloc"), 0, NULL); |
| 1615 EXPECT_VALID(result); | 1614 EXPECT_VALID(result); |
| 1616 | 1615 |
| 1617 { | 1616 { |
| 1618 Thread* thread = Thread::Current(); | 1617 Thread* thread = Thread::Current(); |
| 1619 Isolate* isolate = thread->isolate(); | 1618 Isolate* isolate = thread->isolate(); |
| 1620 StackZone zone(thread); | 1619 StackZone zone(thread); |
| 1621 HANDLESCOPE(thread); | 1620 HANDLESCOPE(thread); |
| 1622 Profile profile(isolate); | 1621 Profile profile(isolate); |
| 1623 AllocationFilter filter(isolate->main_port(), class_a.id()); | 1622 AllocationFilter filter(isolate, class_a.id()); |
| 1624 profile.Build(thread, &filter, Profile::kNoTags); | 1623 profile.Build(thread, &filter, Profile::kNoTags); |
| 1625 EXPECT_EQ(1, profile.sample_count()); | 1624 EXPECT_EQ(1, profile.sample_count()); |
| 1626 ProfileTrieWalker walker(&profile); | 1625 ProfileTrieWalker walker(&profile); |
| 1627 | 1626 |
| 1628 // Inline expansion should show us the complete call chain: | 1627 // Inline expansion should show us the complete call chain: |
| 1629 walker.Reset(Profile::kExclusiveFunction); | 1628 walker.Reset(Profile::kExclusiveFunction); |
| 1630 EXPECT(walker.Down()); | 1629 EXPECT(walker.Down()); |
| 1631 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); | 1630 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); |
| 1632 EXPECT(walker.Down()); | 1631 EXPECT(walker.Down()); |
| 1633 EXPECT_STREQ("[Stub] Allocate A", walker.CurrentName()); | 1632 EXPECT_STREQ("[Stub] Allocate A", walker.CurrentName()); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1712 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 1711 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
| 1713 EXPECT_VALID(result); | 1712 EXPECT_VALID(result); |
| 1714 | 1713 |
| 1715 | 1714 |
| 1716 { | 1715 { |
| 1717 Thread* thread = Thread::Current(); | 1716 Thread* thread = Thread::Current(); |
| 1718 Isolate* isolate = thread->isolate(); | 1717 Isolate* isolate = thread->isolate(); |
| 1719 StackZone zone(thread); | 1718 StackZone zone(thread); |
| 1720 HANDLESCOPE(thread); | 1719 HANDLESCOPE(thread); |
| 1721 Profile profile(isolate); | 1720 Profile profile(isolate); |
| 1722 AllocationFilter filter(isolate->main_port(), class_a.id()); | 1721 AllocationFilter filter(isolate, class_a.id()); |
| 1723 profile.Build(thread, &filter, Profile::kNoTags); | 1722 profile.Build(thread, &filter, Profile::kNoTags); |
| 1724 // We should have 1 allocation sample. | 1723 // We should have 1 allocation sample. |
| 1725 EXPECT_EQ(1, profile.sample_count()); | 1724 EXPECT_EQ(1, profile.sample_count()); |
| 1726 ProfileTrieWalker walker(&profile); | 1725 ProfileTrieWalker walker(&profile); |
| 1727 | 1726 |
| 1728 walker.Reset(Profile::kExclusiveCode); | 1727 walker.Reset(Profile::kExclusiveCode); |
| 1729 // Move down from the root. | 1728 // Move down from the root. |
| 1730 EXPECT(walker.Down()); | 1729 EXPECT(walker.Down()); |
| 1731 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); | 1730 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); |
| 1732 EXPECT(walker.Down()); | 1731 EXPECT(walker.Down()); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1814 // Allocate one time. | 1813 // Allocate one time. |
| 1815 result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 1814 result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
| 1816 EXPECT_VALID(result); | 1815 EXPECT_VALID(result); |
| 1817 | 1816 |
| 1818 { | 1817 { |
| 1819 Thread* thread = Thread::Current(); | 1818 Thread* thread = Thread::Current(); |
| 1820 Isolate* isolate = thread->isolate(); | 1819 Isolate* isolate = thread->isolate(); |
| 1821 StackZone zone(thread); | 1820 StackZone zone(thread); |
| 1822 HANDLESCOPE(thread); | 1821 HANDLESCOPE(thread); |
| 1823 Profile profile(isolate); | 1822 Profile profile(isolate); |
| 1824 AllocationFilter filter(isolate->main_port(), class_a.id()); | 1823 AllocationFilter filter(isolate, class_a.id()); |
| 1825 profile.Build(thread, &filter, Profile::kNoTags); | 1824 profile.Build(thread, &filter, Profile::kNoTags); |
| 1826 // We should have one allocation samples. | 1825 // We should have one allocation samples. |
| 1827 EXPECT_EQ(1, profile.sample_count()); | 1826 EXPECT_EQ(1, profile.sample_count()); |
| 1828 ProfileTrieWalker walker(&profile); | 1827 ProfileTrieWalker walker(&profile); |
| 1829 | 1828 |
| 1830 // Exclusive function: B.boo -> main. | 1829 // Exclusive function: B.boo -> main. |
| 1831 walker.Reset(Profile::kExclusiveFunction); | 1830 walker.Reset(Profile::kExclusiveFunction); |
| 1832 // Move down from the root. | 1831 // Move down from the root. |
| 1833 EXPECT(walker.Down()); | 1832 EXPECT(walker.Down()); |
| 1834 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); | 1833 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1908 // Still optimized. | 1907 // Still optimized. |
| 1909 const Code& code = Code::Handle(main.CurrentCode()); | 1908 const Code& code = Code::Handle(main.CurrentCode()); |
| 1910 EXPECT(code.is_optimized()); | 1909 EXPECT(code.is_optimized()); |
| 1911 | 1910 |
| 1912 { | 1911 { |
| 1913 Thread* thread = Thread::Current(); | 1912 Thread* thread = Thread::Current(); |
| 1914 Isolate* isolate = thread->isolate(); | 1913 Isolate* isolate = thread->isolate(); |
| 1915 StackZone zone(thread); | 1914 StackZone zone(thread); |
| 1916 HANDLESCOPE(thread); | 1915 HANDLESCOPE(thread); |
| 1917 Profile profile(isolate); | 1916 Profile profile(isolate); |
| 1918 AllocationFilter filter(isolate->main_port(), class_a.id()); | 1917 AllocationFilter filter(isolate, class_a.id()); |
| 1919 profile.Build(thread, &filter, Profile::kNoTags); | 1918 profile.Build(thread, &filter, Profile::kNoTags); |
| 1920 // We should have one allocation samples. | 1919 // We should have one allocation samples. |
| 1921 EXPECT_EQ(1, profile.sample_count()); | 1920 EXPECT_EQ(1, profile.sample_count()); |
| 1922 ProfileTrieWalker walker(&profile); | 1921 ProfileTrieWalker walker(&profile); |
| 1923 | 1922 |
| 1924 // Exclusive function: B.boo -> main. | 1923 // Exclusive function: B.boo -> main. |
| 1925 walker.Reset(Profile::kExclusiveFunction); | 1924 walker.Reset(Profile::kExclusiveFunction); |
| 1926 // Move down from the root. | 1925 // Move down from the root. |
| 1927 EXPECT(walker.Down()); | 1926 EXPECT(walker.Down()); |
| 1928 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); | 1927 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1995 // Allocate one time. | 1994 // Allocate one time. |
| 1996 result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 1995 result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
| 1997 EXPECT_VALID(result); | 1996 EXPECT_VALID(result); |
| 1998 | 1997 |
| 1999 { | 1998 { |
| 2000 Thread* thread = Thread::Current(); | 1999 Thread* thread = Thread::Current(); |
| 2001 Isolate* isolate = thread->isolate(); | 2000 Isolate* isolate = thread->isolate(); |
| 2002 StackZone zone(thread); | 2001 StackZone zone(thread); |
| 2003 HANDLESCOPE(thread); | 2002 HANDLESCOPE(thread); |
| 2004 Profile profile(isolate); | 2003 Profile profile(isolate); |
| 2005 AllocationFilter filter(isolate->main_port(), class_a.id()); | 2004 AllocationFilter filter(isolate, class_a.id()); |
| 2006 profile.Build(thread, &filter, Profile::kNoTags); | 2005 profile.Build(thread, &filter, Profile::kNoTags); |
| 2007 // We should have one allocation samples. | 2006 // We should have one allocation samples. |
| 2008 EXPECT_EQ(1, profile.sample_count()); | 2007 EXPECT_EQ(1, profile.sample_count()); |
| 2009 ProfileTrieWalker walker(&profile); | 2008 ProfileTrieWalker walker(&profile); |
| 2010 | 2009 |
| 2011 // Exclusive function: B.boo -> main. | 2010 // Exclusive function: B.boo -> main. |
| 2012 walker.Reset(Profile::kExclusiveFunction); | 2011 walker.Reset(Profile::kExclusiveFunction); |
| 2013 // Move down from the root. | 2012 // Move down from the root. |
| 2014 EXPECT(walker.Down()); | 2013 EXPECT(walker.Down()); |
| 2015 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); | 2014 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2120 // Still optimized. | 2119 // Still optimized. |
| 2121 const Code& code = Code::Handle(main.CurrentCode()); | 2120 const Code& code = Code::Handle(main.CurrentCode()); |
| 2122 EXPECT(code.is_optimized()); | 2121 EXPECT(code.is_optimized()); |
| 2123 | 2122 |
| 2124 { | 2123 { |
| 2125 Thread* thread = Thread::Current(); | 2124 Thread* thread = Thread::Current(); |
| 2126 Isolate* isolate = thread->isolate(); | 2125 Isolate* isolate = thread->isolate(); |
| 2127 StackZone zone(thread); | 2126 StackZone zone(thread); |
| 2128 HANDLESCOPE(thread); | 2127 HANDLESCOPE(thread); |
| 2129 Profile profile(isolate); | 2128 Profile profile(isolate); |
| 2130 AllocationFilter filter(isolate->main_port(), class_a.id()); | 2129 AllocationFilter filter(isolate, class_a.id()); |
| 2131 profile.Build(thread, &filter, Profile::kNoTags); | 2130 profile.Build(thread, &filter, Profile::kNoTags); |
| 2132 // We should have one allocation samples. | 2131 // We should have one allocation samples. |
| 2133 EXPECT_EQ(1, profile.sample_count()); | 2132 EXPECT_EQ(1, profile.sample_count()); |
| 2134 ProfileTrieWalker walker(&profile); | 2133 ProfileTrieWalker walker(&profile); |
| 2135 | 2134 |
| 2136 // Exclusive function: B.boo -> main. | 2135 // Exclusive function: B.boo -> main. |
| 2137 walker.Reset(Profile::kExclusiveFunction); | 2136 walker.Reset(Profile::kExclusiveFunction); |
| 2138 // Move down from the root. | 2137 // Move down from the root. |
| 2139 EXPECT(walker.Down()); | 2138 EXPECT(walker.Down()); |
| 2140 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); | 2139 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2228 // Allocate one time. | 2227 // Allocate one time. |
| 2229 result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 2228 result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
| 2230 EXPECT_VALID(result); | 2229 EXPECT_VALID(result); |
| 2231 | 2230 |
| 2232 { | 2231 { |
| 2233 Thread* thread = Thread::Current(); | 2232 Thread* thread = Thread::Current(); |
| 2234 Isolate* isolate = thread->isolate(); | 2233 Isolate* isolate = thread->isolate(); |
| 2235 StackZone zone(thread); | 2234 StackZone zone(thread); |
| 2236 HANDLESCOPE(thread); | 2235 HANDLESCOPE(thread); |
| 2237 Profile profile(isolate); | 2236 Profile profile(isolate); |
| 2238 AllocationFilter filter(isolate->main_port(), class_a.id()); | 2237 AllocationFilter filter(isolate, class_a.id()); |
| 2239 profile.Build(thread, &filter, Profile::kNoTags); | 2238 profile.Build(thread, &filter, Profile::kNoTags); |
| 2240 // We should have one allocation samples. | 2239 // We should have one allocation samples. |
| 2241 EXPECT_EQ(1, profile.sample_count()); | 2240 EXPECT_EQ(1, profile.sample_count()); |
| 2242 ProfileTrieWalker walker(&profile); | 2241 ProfileTrieWalker walker(&profile); |
| 2243 | 2242 |
| 2244 // Exclusive function: B.boo -> main. | 2243 // Exclusive function: B.boo -> main. |
| 2245 walker.Reset(Profile::kExclusiveFunction); | 2244 walker.Reset(Profile::kExclusiveFunction); |
| 2246 // Move down from the root. | 2245 // Move down from the root. |
| 2247 EXPECT(walker.Down()); | 2246 EXPECT(walker.Down()); |
| 2248 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); | 2247 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2362 // Still optimized. | 2361 // Still optimized. |
| 2363 const Code& code = Code::Handle(main.CurrentCode()); | 2362 const Code& code = Code::Handle(main.CurrentCode()); |
| 2364 EXPECT(code.is_optimized()); | 2363 EXPECT(code.is_optimized()); |
| 2365 | 2364 |
| 2366 { | 2365 { |
| 2367 Thread* thread = Thread::Current(); | 2366 Thread* thread = Thread::Current(); |
| 2368 Isolate* isolate = thread->isolate(); | 2367 Isolate* isolate = thread->isolate(); |
| 2369 StackZone zone(thread); | 2368 StackZone zone(thread); |
| 2370 HANDLESCOPE(thread); | 2369 HANDLESCOPE(thread); |
| 2371 Profile profile(isolate); | 2370 Profile profile(isolate); |
| 2372 AllocationFilter filter(isolate->main_port(), class_a.id()); | 2371 AllocationFilter filter(isolate, class_a.id()); |
| 2373 profile.Build(thread, &filter, Profile::kNoTags); | 2372 profile.Build(thread, &filter, Profile::kNoTags); |
| 2374 // We should have one allocation samples. | 2373 // We should have one allocation samples. |
| 2375 EXPECT_EQ(1, profile.sample_count()); | 2374 EXPECT_EQ(1, profile.sample_count()); |
| 2376 ProfileTrieWalker walker(&profile); | 2375 ProfileTrieWalker walker(&profile); |
| 2377 | 2376 |
| 2378 // Exclusive function: B.boo -> main. | 2377 // Exclusive function: B.boo -> main. |
| 2379 walker.Reset(Profile::kExclusiveFunction); | 2378 walker.Reset(Profile::kExclusiveFunction); |
| 2380 // Move down from the root. | 2379 // Move down from the root. |
| 2381 EXPECT(walker.Down()); | 2380 EXPECT(walker.Down()); |
| 2382 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); | 2381 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2421 EXPECT(!walker.Down()); | 2420 EXPECT(!walker.Down()); |
| 2422 } | 2421 } |
| 2423 } | 2422 } |
| 2424 | 2423 |
| 2425 | 2424 |
| 2426 static void InsertFakeSample(SampleBuffer* sample_buffer, uword* pc_offsets) { | 2425 static void InsertFakeSample(SampleBuffer* sample_buffer, uword* pc_offsets) { |
| 2427 ASSERT(sample_buffer != NULL); | 2426 ASSERT(sample_buffer != NULL); |
| 2428 Isolate* isolate = Isolate::Current(); | 2427 Isolate* isolate = Isolate::Current(); |
| 2429 Sample* sample = sample_buffer->ReserveSample(); | 2428 Sample* sample = sample_buffer->ReserveSample(); |
| 2430 ASSERT(sample != NULL); | 2429 ASSERT(sample != NULL); |
| 2431 sample->Init(isolate->main_port(), OS::GetCurrentMonotonicMicros(), | 2430 sample->Init(isolate, OS::GetCurrentMonotonicMicros(), |
| 2432 OSThread::Current()->trace_id()); | 2431 OSThread::Current()->trace_id()); |
| 2433 sample->set_thread_task(Thread::kMutatorTask); | 2432 sample->set_thread_task(Thread::kMutatorTask); |
| 2434 | 2433 |
| 2435 intptr_t i = 0; | 2434 intptr_t i = 0; |
| 2436 while (pc_offsets[i] != 0) { | 2435 while (pc_offsets[i] != 0) { |
| 2437 // When we collect a real stack trace, all PCs collected aside from the | 2436 // When we collect a real stack trace, all PCs collected aside from the |
| 2438 // executing one (i == 0) are actually return addresses. Return addresses | 2437 // executing one (i == 0) are actually return addresses. Return addresses |
| 2439 // are one byte beyond the call instruction that is executing. The profiler | 2438 // are one byte beyond the call instruction that is executing. The profiler |
| 2440 // accounts for this and subtracts one from these addresses when querying | 2439 // accounts for this and subtracts one from these addresses when querying |
| 2441 // inline and token position ranges. To be consistent with real stack | 2440 // inline and token position ranges. To be consistent with real stack |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2594 EXPECT_SUBSTRING("\"positions\":[\"TempMove\",39]", js.ToCString()); | 2593 EXPECT_SUBSTRING("\"positions\":[\"TempMove\",39]", js.ToCString()); |
| 2595 // Verify exclusive ticks in main. | 2594 // Verify exclusive ticks in main. |
| 2596 EXPECT_SUBSTRING("\"exclusiveTicks\":[1,0]", js.ToCString()); | 2595 EXPECT_SUBSTRING("\"exclusiveTicks\":[1,0]", js.ToCString()); |
| 2597 // Verify inclusive ticks in main. | 2596 // Verify inclusive ticks in main. |
| 2598 EXPECT_SUBSTRING("\"inclusiveTicks\":[1,2]", js.ToCString()); | 2597 EXPECT_SUBSTRING("\"inclusiveTicks\":[1,2]", js.ToCString()); |
| 2599 } | 2598 } |
| 2600 | 2599 |
| 2601 #endif // !PRODUCT | 2600 #endif // !PRODUCT |
| 2602 | 2601 |
| 2603 } // namespace dart | 2602 } // namespace dart |
| OLD | NEW |