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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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->main_port(), class_a.id(), |
243 before_allocations_micros, | 243 before_allocations_micros, |
244 allocation_extent_micros); | 244 allocation_extent_micros); |
245 profile.Build(thread, &filter, Profile::kNoTags); | 245 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
246 // We should have 1 allocation sample. | 246 // We should have 1 allocation sample. |
247 EXPECT_EQ(1, profile.sample_count()); | 247 EXPECT_EQ(1, profile.sample_count()); |
248 ProfileTrieWalker walker(&profile); | 248 ProfileTrieWalker walker(&profile); |
249 | 249 |
250 // Exclusive code: B.boo -> main. | 250 // Exclusive code: B.boo -> main. |
251 walker.Reset(Profile::kExclusiveCode); | 251 walker.Reset(Profile::kExclusiveCode); |
252 // Move down from the root. | 252 // Move down from the root. |
253 EXPECT(walker.Down()); | 253 EXPECT(walker.Down()); |
254 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); | 254 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); |
255 EXPECT(walker.Down()); | 255 EXPECT(walker.Down()); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 | 302 |
303 // Query with a time filter where no allocations occurred. | 303 // Query with a time filter where no allocations occurred. |
304 { | 304 { |
305 Thread* thread = Thread::Current(); | 305 Thread* thread = Thread::Current(); |
306 Isolate* isolate = thread->isolate(); | 306 Isolate* isolate = thread->isolate(); |
307 StackZone zone(thread); | 307 StackZone zone(thread); |
308 HANDLESCOPE(thread); | 308 HANDLESCOPE(thread); |
309 Profile profile(isolate); | 309 Profile profile(isolate); |
310 AllocationFilter filter(isolate->main_port(), class_a.id(), | 310 AllocationFilter filter(isolate->main_port(), class_a.id(), |
311 Dart_TimelineGetMicros(), 16000); | 311 Dart_TimelineGetMicros(), 16000); |
312 profile.Build(thread, &filter, Profile::kNoTags); | 312 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
313 // We should have no allocation samples because none occured within | 313 // We should have no allocation samples because none occured within |
314 // the specified time range. | 314 // the specified time range. |
315 EXPECT_EQ(0, profile.sample_count()); | 315 EXPECT_EQ(0, profile.sample_count()); |
316 } | 316 } |
317 } | 317 } |
318 | 318 |
319 #if defined(DART_USE_TCMALLOC) && defined(HOST_OS_LINUX) && defined(DEBUG) && \ | 319 #if defined(DART_USE_TCMALLOC) && defined(HOST_OS_LINUX) && defined(DEBUG) && \ |
320 defined(HOST_ARCH_x64) | 320 defined(HOST_ARCH_x64) |
321 | 321 |
322 DART_NOINLINE static void NativeAllocationSampleHelper(char** result) { | 322 DART_NOINLINE static void NativeAllocationSampleHelper(char** result) { |
(...skipping 28 matching lines...) Expand all Loading... |
351 { | 351 { |
352 Thread* thread = Thread::Current(); | 352 Thread* thread = Thread::Current(); |
353 Isolate* isolate = thread->isolate(); | 353 Isolate* isolate = thread->isolate(); |
354 StackZone zone(thread); | 354 StackZone zone(thread); |
355 HANDLESCOPE(thread); | 355 HANDLESCOPE(thread); |
356 Profile profile(isolate); | 356 Profile profile(isolate); |
357 | 357 |
358 // Filter for the class in the time range. | 358 // Filter for the class in the time range. |
359 NativeAllocationSampleFilter filter(before_allocations_micros, | 359 NativeAllocationSampleFilter filter(before_allocations_micros, |
360 allocation_extent_micros); | 360 allocation_extent_micros); |
361 profile.Build(thread, &filter, Profile::kNoTags); | 361 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
362 // We should have 1 allocation sample. | 362 // We should have 1 allocation sample. |
363 EXPECT_EQ(1, profile.sample_count()); | 363 EXPECT_EQ(1, profile.sample_count()); |
364 ProfileTrieWalker walker(&profile); | 364 ProfileTrieWalker walker(&profile); |
365 | 365 |
366 // Exclusive code: NativeAllocationSampleHelper -> main. | 366 // Exclusive code: NativeAllocationSampleHelper -> main. |
367 walker.Reset(Profile::kExclusiveCode); | 367 walker.Reset(Profile::kExclusiveCode); |
368 // Move down from the root. | 368 // Move down from the root. |
369 EXPECT(walker.Down()); | 369 EXPECT(walker.Down()); |
370 EXPECT_SUBSTRING("[Native]", walker.CurrentName()); | 370 EXPECT_SUBSTRING("[Native]", walker.CurrentName()); |
371 EXPECT_EQ(walker.CurrentInclusiveAllocations(), 1024); | 371 EXPECT_EQ(walker.CurrentInclusiveAllocations(), 1024); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 { | 493 { |
494 Thread* thread = Thread::Current(); | 494 Thread* thread = Thread::Current(); |
495 Isolate* isolate = thread->isolate(); | 495 Isolate* isolate = thread->isolate(); |
496 StackZone zone(thread); | 496 StackZone zone(thread); |
497 HANDLESCOPE(thread); | 497 HANDLESCOPE(thread); |
498 Profile profile(isolate); | 498 Profile profile(isolate); |
499 | 499 |
500 // Filter for the class in the time range. | 500 // Filter for the class in the time range. |
501 NativeAllocationSampleFilter filter(before_allocations_micros, | 501 NativeAllocationSampleFilter filter(before_allocations_micros, |
502 allocation_extent_micros); | 502 allocation_extent_micros); |
503 profile.Build(thread, &filter, Profile::kNoTags); | 503 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
504 // We should have 0 allocation samples since we freed the memory. | 504 // We should have 0 allocation samples since we freed the memory. |
505 EXPECT_EQ(0, profile.sample_count()); | 505 EXPECT_EQ(0, profile.sample_count()); |
506 } | 506 } |
507 | 507 |
508 // Query with a time filter where no allocations occurred. | 508 // Query with a time filter where no allocations occurred. |
509 { | 509 { |
510 Thread* thread = Thread::Current(); | 510 Thread* thread = Thread::Current(); |
511 Isolate* isolate = thread->isolate(); | 511 Isolate* isolate = thread->isolate(); |
512 StackZone zone(thread); | 512 StackZone zone(thread); |
513 HANDLESCOPE(thread); | 513 HANDLESCOPE(thread); |
514 Profile profile(isolate); | 514 Profile profile(isolate); |
515 NativeAllocationSampleFilter filter(Dart_TimelineGetMicros(), 16000); | 515 NativeAllocationSampleFilter filter(Dart_TimelineGetMicros(), 16000); |
516 profile.Build(thread, &filter, Profile::kNoTags); | 516 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
517 // We should have no allocation samples because none occured within | 517 // We should have no allocation samples because none occured within |
518 // the specified time range. | 518 // the specified time range. |
519 EXPECT_EQ(0, profile.sample_count()); | 519 EXPECT_EQ(0, profile.sample_count()); |
520 } | 520 } |
521 | 521 |
522 MallocHooks::set_stack_trace_collection_enabled( | 522 MallocHooks::set_stack_trace_collection_enabled( |
523 stack_trace_collection_enabled); | 523 stack_trace_collection_enabled); |
524 MallocHooks::TearDown(); | 524 MallocHooks::TearDown(); |
525 FLAG_profiler_native_memory = enable_malloc_hooks_saved; | 525 FLAG_profiler_native_memory = enable_malloc_hooks_saved; |
526 } | 526 } |
(...skipping 29 matching lines...) Expand all Loading... |
556 EXPECT_VALID(result); | 556 EXPECT_VALID(result); |
557 | 557 |
558 | 558 |
559 { | 559 { |
560 Thread* thread = Thread::Current(); | 560 Thread* thread = Thread::Current(); |
561 Isolate* isolate = thread->isolate(); | 561 Isolate* isolate = thread->isolate(); |
562 StackZone zone(thread); | 562 StackZone zone(thread); |
563 HANDLESCOPE(thread); | 563 HANDLESCOPE(thread); |
564 Profile profile(isolate); | 564 Profile profile(isolate); |
565 AllocationFilter filter(isolate->main_port(), class_a.id()); | 565 AllocationFilter filter(isolate->main_port(), class_a.id()); |
566 profile.Build(thread, &filter, Profile::kNoTags); | 566 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
567 // We should have no allocation samples. | 567 // We should have no allocation samples. |
568 EXPECT_EQ(0, profile.sample_count()); | 568 EXPECT_EQ(0, profile.sample_count()); |
569 } | 569 } |
570 | 570 |
571 // Turn on allocation tracing for A. | 571 // Turn on allocation tracing for A. |
572 class_a.SetTraceAllocation(true); | 572 class_a.SetTraceAllocation(true); |
573 | 573 |
574 result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 574 result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
575 EXPECT_VALID(result); | 575 EXPECT_VALID(result); |
576 | 576 |
577 { | 577 { |
578 Thread* thread = Thread::Current(); | 578 Thread* thread = Thread::Current(); |
579 Isolate* isolate = thread->isolate(); | 579 Isolate* isolate = thread->isolate(); |
580 StackZone zone(thread); | 580 StackZone zone(thread); |
581 HANDLESCOPE(thread); | 581 HANDLESCOPE(thread); |
582 Profile profile(isolate); | 582 Profile profile(isolate); |
583 AllocationFilter filter(isolate->main_port(), class_a.id()); | 583 AllocationFilter filter(isolate->main_port(), class_a.id()); |
584 profile.Build(thread, &filter, Profile::kNoTags); | 584 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
585 // We should have one allocation sample. | 585 // We should have one allocation sample. |
586 EXPECT_EQ(1, profile.sample_count()); | 586 EXPECT_EQ(1, profile.sample_count()); |
587 ProfileTrieWalker walker(&profile); | 587 ProfileTrieWalker walker(&profile); |
588 | 588 |
589 // Exclusive code: B.boo -> main. | 589 // Exclusive code: B.boo -> main. |
590 walker.Reset(Profile::kExclusiveCode); | 590 walker.Reset(Profile::kExclusiveCode); |
591 // Move down from the root. | 591 // Move down from the root. |
592 EXPECT(walker.Down()); | 592 EXPECT(walker.Down()); |
593 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); | 593 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); |
594 EXPECT(walker.Down()); | 594 EXPECT(walker.Down()); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 645 result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
646 EXPECT_VALID(result); | 646 EXPECT_VALID(result); |
647 | 647 |
648 { | 648 { |
649 Thread* thread = Thread::Current(); | 649 Thread* thread = Thread::Current(); |
650 Isolate* isolate = thread->isolate(); | 650 Isolate* isolate = thread->isolate(); |
651 StackZone zone(thread); | 651 StackZone zone(thread); |
652 HANDLESCOPE(thread); | 652 HANDLESCOPE(thread); |
653 Profile profile(isolate); | 653 Profile profile(isolate); |
654 AllocationFilter filter(isolate->main_port(), class_a.id()); | 654 AllocationFilter filter(isolate->main_port(), class_a.id()); |
655 profile.Build(thread, &filter, Profile::kNoTags); | 655 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
656 // We should still only have one allocation sample. | 656 // We should still only have one allocation sample. |
657 EXPECT_EQ(1, profile.sample_count()); | 657 EXPECT_EQ(1, profile.sample_count()); |
658 } | 658 } |
659 } | 659 } |
660 | 660 |
661 | 661 |
662 TEST_CASE(Profiler_CodeTicks) { | 662 TEST_CASE(Profiler_CodeTicks) { |
663 DisableNativeProfileScope dnps; | 663 DisableNativeProfileScope dnps; |
664 const char* kScript = | 664 const char* kScript = |
665 "class A {\n" | 665 "class A {\n" |
(...skipping 20 matching lines...) Expand all Loading... |
686 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 686 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
687 EXPECT_VALID(result); | 687 EXPECT_VALID(result); |
688 | 688 |
689 { | 689 { |
690 Thread* thread = Thread::Current(); | 690 Thread* thread = Thread::Current(); |
691 Isolate* isolate = thread->isolate(); | 691 Isolate* isolate = thread->isolate(); |
692 StackZone zone(thread); | 692 StackZone zone(thread); |
693 HANDLESCOPE(thread); | 693 HANDLESCOPE(thread); |
694 Profile profile(isolate); | 694 Profile profile(isolate); |
695 AllocationFilter filter(isolate->main_port(), class_a.id()); | 695 AllocationFilter filter(isolate->main_port(), class_a.id()); |
696 profile.Build(thread, &filter, Profile::kNoTags); | 696 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
697 // We should have no allocation samples. | 697 // We should have no allocation samples. |
698 EXPECT_EQ(0, profile.sample_count()); | 698 EXPECT_EQ(0, profile.sample_count()); |
699 } | 699 } |
700 | 700 |
701 // Turn on allocation tracing for A. | 701 // Turn on allocation tracing for A. |
702 class_a.SetTraceAllocation(true); | 702 class_a.SetTraceAllocation(true); |
703 | 703 |
704 // Allocate three times. | 704 // Allocate three times. |
705 result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 705 result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
706 EXPECT_VALID(result); | 706 EXPECT_VALID(result); |
707 result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 707 result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
708 EXPECT_VALID(result); | 708 EXPECT_VALID(result); |
709 result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 709 result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
710 EXPECT_VALID(result); | 710 EXPECT_VALID(result); |
711 | 711 |
712 { | 712 { |
713 Thread* thread = Thread::Current(); | 713 Thread* thread = Thread::Current(); |
714 Isolate* isolate = thread->isolate(); | 714 Isolate* isolate = thread->isolate(); |
715 StackZone zone(thread); | 715 StackZone zone(thread); |
716 HANDLESCOPE(thread); | 716 HANDLESCOPE(thread); |
717 Profile profile(isolate); | 717 Profile profile(isolate); |
718 AllocationFilter filter(isolate->main_port(), class_a.id()); | 718 AllocationFilter filter(isolate->main_port(), class_a.id()); |
719 profile.Build(thread, &filter, Profile::kNoTags); | 719 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
720 // We should have three allocation samples. | 720 // We should have three allocation samples. |
721 EXPECT_EQ(3, profile.sample_count()); | 721 EXPECT_EQ(3, profile.sample_count()); |
722 ProfileTrieWalker walker(&profile); | 722 ProfileTrieWalker walker(&profile); |
723 | 723 |
724 // Exclusive code: B.boo -> main. | 724 // Exclusive code: B.boo -> main. |
725 walker.Reset(Profile::kExclusiveCode); | 725 walker.Reset(Profile::kExclusiveCode); |
726 // Move down from the root. | 726 // Move down from the root. |
727 EXPECT(walker.Down()); | 727 EXPECT(walker.Down()); |
728 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); | 728 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); |
729 EXPECT(walker.Down()); | 729 EXPECT(walker.Down()); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 789 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
790 EXPECT_VALID(result); | 790 EXPECT_VALID(result); |
791 | 791 |
792 { | 792 { |
793 Thread* thread = Thread::Current(); | 793 Thread* thread = Thread::Current(); |
794 Isolate* isolate = thread->isolate(); | 794 Isolate* isolate = thread->isolate(); |
795 StackZone zone(thread); | 795 StackZone zone(thread); |
796 HANDLESCOPE(thread); | 796 HANDLESCOPE(thread); |
797 Profile profile(isolate); | 797 Profile profile(isolate); |
798 AllocationFilter filter(isolate->main_port(), class_a.id()); | 798 AllocationFilter filter(isolate->main_port(), class_a.id()); |
799 profile.Build(thread, &filter, Profile::kNoTags); | 799 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
800 // We should have no allocation samples. | 800 // We should have no allocation samples. |
801 EXPECT_EQ(0, profile.sample_count()); | 801 EXPECT_EQ(0, profile.sample_count()); |
802 } | 802 } |
803 | 803 |
804 // Turn on allocation tracing for A. | 804 // Turn on allocation tracing for A. |
805 class_a.SetTraceAllocation(true); | 805 class_a.SetTraceAllocation(true); |
806 | 806 |
807 // Allocate three times. | 807 // Allocate three times. |
808 result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 808 result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
809 EXPECT_VALID(result); | 809 EXPECT_VALID(result); |
810 result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 810 result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
811 EXPECT_VALID(result); | 811 EXPECT_VALID(result); |
812 result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 812 result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
813 EXPECT_VALID(result); | 813 EXPECT_VALID(result); |
814 | 814 |
815 { | 815 { |
816 Thread* thread = Thread::Current(); | 816 Thread* thread = Thread::Current(); |
817 Isolate* isolate = thread->isolate(); | 817 Isolate* isolate = thread->isolate(); |
818 StackZone zone(thread); | 818 StackZone zone(thread); |
819 HANDLESCOPE(thread); | 819 HANDLESCOPE(thread); |
820 Profile profile(isolate); | 820 Profile profile(isolate); |
821 AllocationFilter filter(isolate->main_port(), class_a.id()); | 821 AllocationFilter filter(isolate->main_port(), class_a.id()); |
822 profile.Build(thread, &filter, Profile::kNoTags); | 822 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
823 // We should have three allocation samples. | 823 // We should have three allocation samples. |
824 EXPECT_EQ(3, profile.sample_count()); | 824 EXPECT_EQ(3, profile.sample_count()); |
825 ProfileTrieWalker walker(&profile); | 825 ProfileTrieWalker walker(&profile); |
826 | 826 |
827 // Exclusive function: B.boo -> main. | 827 // Exclusive function: B.boo -> main. |
828 walker.Reset(Profile::kExclusiveFunction); | 828 walker.Reset(Profile::kExclusiveFunction); |
829 // Move down from the root. | 829 // Move down from the root. |
830 EXPECT(walker.Down()); | 830 EXPECT(walker.Down()); |
831 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); | 831 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); |
832 EXPECT(walker.Down()); | 832 EXPECT(walker.Down()); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
883 }; | 883 }; |
884 | 884 |
885 Dart_Handle result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); | 885 Dart_Handle result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); |
886 EXPECT_VALID(result); | 886 EXPECT_VALID(result); |
887 | 887 |
888 { | 888 { |
889 StackZone zone(thread); | 889 StackZone zone(thread); |
890 HANDLESCOPE(thread); | 890 HANDLESCOPE(thread); |
891 Profile profile(isolate); | 891 Profile profile(isolate); |
892 AllocationFilter filter(isolate->main_port(), double_class.id()); | 892 AllocationFilter filter(isolate->main_port(), double_class.id()); |
893 profile.Build(thread, &filter, Profile::kNoTags); | 893 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
894 // We should have no allocation samples. | 894 // We should have no allocation samples. |
895 EXPECT_EQ(0, profile.sample_count()); | 895 EXPECT_EQ(0, profile.sample_count()); |
896 } | 896 } |
897 | 897 |
898 double_class.SetTraceAllocation(true); | 898 double_class.SetTraceAllocation(true); |
899 result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); | 899 result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); |
900 EXPECT_VALID(result); | 900 EXPECT_VALID(result); |
901 | 901 |
902 { | 902 { |
903 StackZone zone(thread); | 903 StackZone zone(thread); |
904 HANDLESCOPE(thread); | 904 HANDLESCOPE(thread); |
905 Profile profile(isolate); | 905 Profile profile(isolate); |
906 AllocationFilter filter(isolate->main_port(), double_class.id()); | 906 AllocationFilter filter(isolate->main_port(), double_class.id()); |
907 profile.Build(thread, &filter, Profile::kNoTags); | 907 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
908 // We should have one allocation sample. | 908 // We should have one allocation sample. |
909 EXPECT_EQ(1, profile.sample_count()); | 909 EXPECT_EQ(1, profile.sample_count()); |
910 ProfileTrieWalker walker(&profile); | 910 ProfileTrieWalker walker(&profile); |
911 | 911 |
912 walker.Reset(Profile::kExclusiveCode); | 912 walker.Reset(Profile::kExclusiveCode); |
913 EXPECT(walker.Down()); | 913 EXPECT(walker.Down()); |
914 EXPECT_STREQ("Double_add", walker.CurrentName()); | 914 EXPECT_STREQ("Double_add", walker.CurrentName()); |
915 EXPECT(walker.Down()); | 915 EXPECT(walker.Down()); |
916 EXPECT_STREQ("_Double._add", walker.CurrentName()); | 916 EXPECT_STREQ("_Double._add", walker.CurrentName()); |
917 EXPECT(walker.Down()); | 917 EXPECT(walker.Down()); |
918 EXPECT_STREQ("_Double.+", walker.CurrentName()); | 918 EXPECT_STREQ("_Double.+", walker.CurrentName()); |
919 EXPECT(walker.Down()); | 919 EXPECT(walker.Down()); |
920 EXPECT_STREQ("foo", walker.CurrentName()); | 920 EXPECT_STREQ("foo", walker.CurrentName()); |
921 EXPECT(!walker.Down()); | 921 EXPECT(!walker.Down()); |
922 } | 922 } |
923 | 923 |
924 double_class.SetTraceAllocation(false); | 924 double_class.SetTraceAllocation(false); |
925 result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); | 925 result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); |
926 EXPECT_VALID(result); | 926 EXPECT_VALID(result); |
927 | 927 |
928 { | 928 { |
929 StackZone zone(thread); | 929 StackZone zone(thread); |
930 HANDLESCOPE(thread); | 930 HANDLESCOPE(thread); |
931 Profile profile(isolate); | 931 Profile profile(isolate); |
932 AllocationFilter filter(isolate->main_port(), double_class.id()); | 932 AllocationFilter filter(isolate->main_port(), double_class.id()); |
933 profile.Build(thread, &filter, Profile::kNoTags); | 933 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
934 // We should still only have one allocation sample. | 934 // We should still only have one allocation sample. |
935 EXPECT_EQ(1, profile.sample_count()); | 935 EXPECT_EQ(1, profile.sample_count()); |
936 } | 936 } |
937 } | 937 } |
938 | 938 |
939 | 939 |
940 TEST_CASE(Profiler_ArrayAllocation) { | 940 TEST_CASE(Profiler_ArrayAllocation) { |
941 DisableNativeProfileScope dnps; | 941 DisableNativeProfileScope dnps; |
942 const char* kScript = | 942 const char* kScript = |
943 "List foo() => new List(4);\n" | 943 "List foo() => new List(4);\n" |
944 "List bar() => new List();\n"; | 944 "List bar() => new List();\n"; |
945 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 945 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
946 EXPECT_VALID(lib); | 946 EXPECT_VALID(lib); |
947 Library& root_library = Library::Handle(); | 947 Library& root_library = Library::Handle(); |
948 root_library ^= Api::UnwrapHandle(lib); | 948 root_library ^= Api::UnwrapHandle(lib); |
949 Isolate* isolate = thread->isolate(); | 949 Isolate* isolate = thread->isolate(); |
950 | 950 |
951 const Class& array_class = | 951 const Class& array_class = |
952 Class::Handle(isolate->object_store()->array_class()); | 952 Class::Handle(isolate->object_store()->array_class()); |
953 EXPECT(!array_class.IsNull()); | 953 EXPECT(!array_class.IsNull()); |
954 | 954 |
955 Dart_Handle result = Dart_Invoke(lib, NewString("foo"), 0, NULL); | 955 Dart_Handle result = Dart_Invoke(lib, NewString("foo"), 0, NULL); |
956 EXPECT_VALID(result); | 956 EXPECT_VALID(result); |
957 | 957 |
958 { | 958 { |
959 StackZone zone(thread); | 959 StackZone zone(thread); |
960 HANDLESCOPE(thread); | 960 HANDLESCOPE(thread); |
961 Profile profile(isolate); | 961 Profile profile(isolate); |
962 AllocationFilter filter(isolate->main_port(), array_class.id()); | 962 AllocationFilter filter(isolate->main_port(), array_class.id()); |
963 profile.Build(thread, &filter, Profile::kNoTags); | 963 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
964 // We should have no allocation samples. | 964 // We should have no allocation samples. |
965 EXPECT_EQ(0, profile.sample_count()); | 965 EXPECT_EQ(0, profile.sample_count()); |
966 } | 966 } |
967 | 967 |
968 array_class.SetTraceAllocation(true); | 968 array_class.SetTraceAllocation(true); |
969 result = Dart_Invoke(lib, NewString("foo"), 0, NULL); | 969 result = Dart_Invoke(lib, NewString("foo"), 0, NULL); |
970 EXPECT_VALID(result); | 970 EXPECT_VALID(result); |
971 | 971 |
972 { | 972 { |
973 StackZone zone(thread); | 973 StackZone zone(thread); |
974 HANDLESCOPE(thread); | 974 HANDLESCOPE(thread); |
975 Profile profile(isolate); | 975 Profile profile(isolate); |
976 AllocationFilter filter(isolate->main_port(), array_class.id()); | 976 AllocationFilter filter(isolate->main_port(), array_class.id()); |
977 profile.Build(thread, &filter, Profile::kNoTags); | 977 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
978 // We should have one allocation sample. | 978 // We should have one allocation sample. |
979 EXPECT_EQ(1, profile.sample_count()); | 979 EXPECT_EQ(1, profile.sample_count()); |
980 ProfileTrieWalker walker(&profile); | 980 ProfileTrieWalker walker(&profile); |
981 | 981 |
982 walker.Reset(Profile::kExclusiveCode); | 982 walker.Reset(Profile::kExclusiveCode); |
983 EXPECT(walker.Down()); | 983 EXPECT(walker.Down()); |
984 EXPECT_STREQ("DRT_AllocateArray", walker.CurrentName()); | 984 EXPECT_STREQ("DRT_AllocateArray", walker.CurrentName()); |
985 EXPECT(walker.Down()); | 985 EXPECT(walker.Down()); |
986 EXPECT_STREQ("[Stub] AllocateArray", walker.CurrentName()); | 986 EXPECT_STREQ("[Stub] AllocateArray", walker.CurrentName()); |
987 EXPECT(walker.Down()); | 987 EXPECT(walker.Down()); |
988 EXPECT_STREQ("new _List", walker.CurrentName()); | 988 EXPECT_STREQ("new _List", walker.CurrentName()); |
989 EXPECT(walker.Down()); | 989 EXPECT(walker.Down()); |
990 EXPECT_STREQ("new List._internal", walker.CurrentName()); | 990 EXPECT_STREQ("new List._internal", walker.CurrentName()); |
991 EXPECT(walker.Down()); | 991 EXPECT(walker.Down()); |
992 EXPECT_STREQ("foo", walker.CurrentName()); | 992 EXPECT_STREQ("foo", walker.CurrentName()); |
993 EXPECT(!walker.Down()); | 993 EXPECT(!walker.Down()); |
994 } | 994 } |
995 | 995 |
996 array_class.SetTraceAllocation(false); | 996 array_class.SetTraceAllocation(false); |
997 result = Dart_Invoke(lib, NewString("foo"), 0, NULL); | 997 result = Dart_Invoke(lib, NewString("foo"), 0, NULL); |
998 EXPECT_VALID(result); | 998 EXPECT_VALID(result); |
999 | 999 |
1000 { | 1000 { |
1001 StackZone zone(thread); | 1001 StackZone zone(thread); |
1002 HANDLESCOPE(thread); | 1002 HANDLESCOPE(thread); |
1003 Profile profile(isolate); | 1003 Profile profile(isolate); |
1004 AllocationFilter filter(isolate->main_port(), array_class.id()); | 1004 AllocationFilter filter(isolate->main_port(), array_class.id()); |
1005 profile.Build(thread, &filter, Profile::kNoTags); | 1005 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
1006 // We should still only have one allocation sample. | 1006 // We should still only have one allocation sample. |
1007 EXPECT_EQ(1, profile.sample_count()); | 1007 EXPECT_EQ(1, profile.sample_count()); |
1008 } | 1008 } |
1009 | 1009 |
1010 // Clear the samples. | 1010 // Clear the samples. |
1011 ProfilerService::ClearSamples(); | 1011 ProfilerService::ClearSamples(); |
1012 | 1012 |
1013 // Compile bar (many List objects allocated). | 1013 // Compile bar (many List objects allocated). |
1014 result = Dart_Invoke(lib, NewString("bar"), 0, NULL); | 1014 result = Dart_Invoke(lib, NewString("bar"), 0, NULL); |
1015 EXPECT_VALID(result); | 1015 EXPECT_VALID(result); |
1016 | 1016 |
1017 // Enable again. | 1017 // Enable again. |
1018 array_class.SetTraceAllocation(true); | 1018 array_class.SetTraceAllocation(true); |
1019 | 1019 |
1020 // Run bar. | 1020 // Run bar. |
1021 result = Dart_Invoke(lib, NewString("bar"), 0, NULL); | 1021 result = Dart_Invoke(lib, NewString("bar"), 0, NULL); |
1022 EXPECT_VALID(result); | 1022 EXPECT_VALID(result); |
1023 | 1023 |
1024 { | 1024 { |
1025 StackZone zone(thread); | 1025 StackZone zone(thread); |
1026 HANDLESCOPE(thread); | 1026 HANDLESCOPE(thread); |
1027 Profile profile(isolate); | 1027 Profile profile(isolate); |
1028 AllocationFilter filter(isolate->main_port(), array_class.id()); | 1028 AllocationFilter filter(isolate->main_port(), array_class.id()); |
1029 profile.Build(thread, &filter, Profile::kNoTags); | 1029 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
1030 // We should have no allocation samples, since empty | 1030 // We should have no allocation samples, since empty |
1031 // growable lists use a shared backing. | 1031 // growable lists use a shared backing. |
1032 EXPECT_EQ(0, profile.sample_count()); | 1032 EXPECT_EQ(0, profile.sample_count()); |
1033 } | 1033 } |
1034 } | 1034 } |
1035 | 1035 |
1036 | 1036 |
1037 TEST_CASE(Profiler_ContextAllocation) { | 1037 TEST_CASE(Profiler_ContextAllocation) { |
1038 DisableNativeProfileScope dnps; | 1038 DisableNativeProfileScope dnps; |
1039 const char* kScript = | 1039 const char* kScript = |
(...skipping 12 matching lines...) Expand all Loading... |
1052 EXPECT(!context_class.IsNull()); | 1052 EXPECT(!context_class.IsNull()); |
1053 | 1053 |
1054 Dart_Handle result = Dart_Invoke(lib, NewString("foo"), 0, NULL); | 1054 Dart_Handle result = Dart_Invoke(lib, NewString("foo"), 0, NULL); |
1055 EXPECT_VALID(result); | 1055 EXPECT_VALID(result); |
1056 | 1056 |
1057 { | 1057 { |
1058 StackZone zone(thread); | 1058 StackZone zone(thread); |
1059 HANDLESCOPE(thread); | 1059 HANDLESCOPE(thread); |
1060 Profile profile(isolate); | 1060 Profile profile(isolate); |
1061 AllocationFilter filter(isolate->main_port(), context_class.id()); | 1061 AllocationFilter filter(isolate->main_port(), context_class.id()); |
1062 profile.Build(thread, &filter, Profile::kNoTags); | 1062 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
1063 // We should have no allocation samples. | 1063 // We should have no allocation samples. |
1064 EXPECT_EQ(0, profile.sample_count()); | 1064 EXPECT_EQ(0, profile.sample_count()); |
1065 } | 1065 } |
1066 | 1066 |
1067 context_class.SetTraceAllocation(true); | 1067 context_class.SetTraceAllocation(true); |
1068 result = Dart_Invoke(lib, NewString("foo"), 0, NULL); | 1068 result = Dart_Invoke(lib, NewString("foo"), 0, NULL); |
1069 EXPECT_VALID(result); | 1069 EXPECT_VALID(result); |
1070 | 1070 |
1071 { | 1071 { |
1072 StackZone zone(thread); | 1072 StackZone zone(thread); |
1073 HANDLESCOPE(thread); | 1073 HANDLESCOPE(thread); |
1074 Profile profile(isolate); | 1074 Profile profile(isolate); |
1075 AllocationFilter filter(isolate->main_port(), context_class.id()); | 1075 AllocationFilter filter(isolate->main_port(), context_class.id()); |
1076 profile.Build(thread, &filter, Profile::kNoTags); | 1076 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
1077 // We should have one allocation sample. | 1077 // We should have one allocation sample. |
1078 EXPECT_EQ(1, profile.sample_count()); | 1078 EXPECT_EQ(1, profile.sample_count()); |
1079 ProfileTrieWalker walker(&profile); | 1079 ProfileTrieWalker walker(&profile); |
1080 | 1080 |
1081 walker.Reset(Profile::kExclusiveCode); | 1081 walker.Reset(Profile::kExclusiveCode); |
1082 EXPECT(walker.Down()); | 1082 EXPECT(walker.Down()); |
1083 EXPECT_STREQ("DRT_AllocateContext", walker.CurrentName()); | 1083 EXPECT_STREQ("DRT_AllocateContext", walker.CurrentName()); |
1084 EXPECT(walker.Down()); | 1084 EXPECT(walker.Down()); |
1085 EXPECT_STREQ("[Stub] AllocateContext", walker.CurrentName()); | 1085 EXPECT_STREQ("[Stub] AllocateContext", walker.CurrentName()); |
1086 EXPECT(walker.Down()); | 1086 EXPECT(walker.Down()); |
1087 EXPECT_STREQ("foo", walker.CurrentName()); | 1087 EXPECT_STREQ("foo", walker.CurrentName()); |
1088 EXPECT(!walker.Down()); | 1088 EXPECT(!walker.Down()); |
1089 } | 1089 } |
1090 | 1090 |
1091 context_class.SetTraceAllocation(false); | 1091 context_class.SetTraceAllocation(false); |
1092 result = Dart_Invoke(lib, NewString("foo"), 0, NULL); | 1092 result = Dart_Invoke(lib, NewString("foo"), 0, NULL); |
1093 EXPECT_VALID(result); | 1093 EXPECT_VALID(result); |
1094 | 1094 |
1095 { | 1095 { |
1096 StackZone zone(thread); | 1096 StackZone zone(thread); |
1097 HANDLESCOPE(thread); | 1097 HANDLESCOPE(thread); |
1098 Profile profile(isolate); | 1098 Profile profile(isolate); |
1099 AllocationFilter filter(isolate->main_port(), context_class.id()); | 1099 AllocationFilter filter(isolate->main_port(), context_class.id()); |
1100 profile.Build(thread, &filter, Profile::kNoTags); | 1100 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
1101 // We should still only have one allocation sample. | 1101 // We should still only have one allocation sample. |
1102 EXPECT_EQ(1, profile.sample_count()); | 1102 EXPECT_EQ(1, profile.sample_count()); |
1103 } | 1103 } |
1104 } | 1104 } |
1105 | 1105 |
1106 | 1106 |
1107 TEST_CASE(Profiler_ClosureAllocation) { | 1107 TEST_CASE(Profiler_ClosureAllocation) { |
1108 DisableNativeProfileScope dnps; | 1108 DisableNativeProfileScope dnps; |
1109 const char* kScript = | 1109 const char* kScript = |
1110 "var msg1 = 'a';\n" | 1110 "var msg1 = 'a';\n" |
(...skipping 23 matching lines...) Expand all Loading... |
1134 // Invoke "foo" which during compilation, triggers a closure allocation. | 1134 // Invoke "foo" which during compilation, triggers a closure allocation. |
1135 Dart_Handle result = Dart_Invoke(lib, NewString("foo"), 0, NULL); | 1135 Dart_Handle result = Dart_Invoke(lib, NewString("foo"), 0, NULL); |
1136 EXPECT_VALID(result); | 1136 EXPECT_VALID(result); |
1137 | 1137 |
1138 { | 1138 { |
1139 StackZone zone(thread); | 1139 StackZone zone(thread); |
1140 HANDLESCOPE(thread); | 1140 HANDLESCOPE(thread); |
1141 Profile profile(isolate); | 1141 Profile profile(isolate); |
1142 AllocationFilter filter(isolate->main_port(), closure_class.id()); | 1142 AllocationFilter filter(isolate->main_port(), closure_class.id()); |
1143 filter.set_enable_vm_ticks(true); | 1143 filter.set_enable_vm_ticks(true); |
1144 profile.Build(thread, &filter, Profile::kNoTags); | 1144 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
1145 // We should have one allocation sample. | 1145 // We should have one allocation sample. |
1146 EXPECT_EQ(1, profile.sample_count()); | 1146 EXPECT_EQ(1, profile.sample_count()); |
1147 ProfileTrieWalker walker(&profile); | 1147 ProfileTrieWalker walker(&profile); |
1148 | 1148 |
1149 walker.Reset(Profile::kExclusiveCode); | 1149 walker.Reset(Profile::kExclusiveCode); |
1150 EXPECT(walker.Down()); | 1150 EXPECT(walker.Down()); |
1151 EXPECT_SUBSTRING("DRT_AllocateObject", walker.CurrentName()); | 1151 EXPECT_SUBSTRING("DRT_AllocateObject", walker.CurrentName()); |
1152 EXPECT(walker.Down()); | 1152 EXPECT(walker.Down()); |
1153 EXPECT_STREQ("[Stub] Allocate _Closure", walker.CurrentName()); | 1153 EXPECT_STREQ("[Stub] Allocate _Closure", walker.CurrentName()); |
1154 EXPECT(walker.Down()); | 1154 EXPECT(walker.Down()); |
1155 EXPECT_SUBSTRING("foo", walker.CurrentName()); | 1155 EXPECT_SUBSTRING("foo", walker.CurrentName()); |
1156 EXPECT(!walker.Down()); | 1156 EXPECT(!walker.Down()); |
1157 } | 1157 } |
1158 | 1158 |
1159 // Disable allocation tracing for Closure. | 1159 // Disable allocation tracing for Closure. |
1160 closure_class.SetTraceAllocation(false); | 1160 closure_class.SetTraceAllocation(false); |
1161 | 1161 |
1162 // Invoke "bar" which during compilation, triggers a closure allocation. | 1162 // Invoke "bar" which during compilation, triggers a closure allocation. |
1163 result = Dart_Invoke(lib, NewString("bar"), 0, NULL); | 1163 result = Dart_Invoke(lib, NewString("bar"), 0, NULL); |
1164 EXPECT_VALID(result); | 1164 EXPECT_VALID(result); |
1165 | 1165 |
1166 { | 1166 { |
1167 StackZone zone(thread); | 1167 StackZone zone(thread); |
1168 HANDLESCOPE(thread); | 1168 HANDLESCOPE(thread); |
1169 Profile profile(isolate); | 1169 Profile profile(isolate); |
1170 AllocationFilter filter(isolate->main_port(), closure_class.id()); | 1170 AllocationFilter filter(isolate->main_port(), closure_class.id()); |
1171 filter.set_enable_vm_ticks(true); | 1171 filter.set_enable_vm_ticks(true); |
1172 profile.Build(thread, &filter, Profile::kNoTags); | 1172 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
1173 // We should still only have one allocation sample. | 1173 // We should still only have one allocation sample. |
1174 EXPECT_EQ(1, profile.sample_count()); | 1174 EXPECT_EQ(1, profile.sample_count()); |
1175 } | 1175 } |
1176 } | 1176 } |
1177 | 1177 |
1178 | 1178 |
1179 TEST_CASE(Profiler_TypedArrayAllocation) { | 1179 TEST_CASE(Profiler_TypedArrayAllocation) { |
1180 DisableNativeProfileScope dnps; | 1180 DisableNativeProfileScope dnps; |
1181 const char* kScript = | 1181 const char* kScript = |
1182 "import 'dart:typed_data';\n" | 1182 "import 'dart:typed_data';\n" |
(...skipping 12 matching lines...) Expand all Loading... |
1195 EXPECT(!float32_list_class.IsNull()); | 1195 EXPECT(!float32_list_class.IsNull()); |
1196 | 1196 |
1197 Dart_Handle result = Dart_Invoke(lib, NewString("foo"), 0, NULL); | 1197 Dart_Handle result = Dart_Invoke(lib, NewString("foo"), 0, NULL); |
1198 EXPECT_VALID(result); | 1198 EXPECT_VALID(result); |
1199 | 1199 |
1200 { | 1200 { |
1201 StackZone zone(thread); | 1201 StackZone zone(thread); |
1202 HANDLESCOPE(thread); | 1202 HANDLESCOPE(thread); |
1203 Profile profile(isolate); | 1203 Profile profile(isolate); |
1204 AllocationFilter filter(isolate->main_port(), float32_list_class.id()); | 1204 AllocationFilter filter(isolate->main_port(), float32_list_class.id()); |
1205 profile.Build(thread, &filter, Profile::kNoTags); | 1205 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
1206 // We should have no allocation samples. | 1206 // We should have no allocation samples. |
1207 EXPECT_EQ(0, profile.sample_count()); | 1207 EXPECT_EQ(0, profile.sample_count()); |
1208 } | 1208 } |
1209 | 1209 |
1210 float32_list_class.SetTraceAllocation(true); | 1210 float32_list_class.SetTraceAllocation(true); |
1211 result = Dart_Invoke(lib, NewString("foo"), 0, NULL); | 1211 result = Dart_Invoke(lib, NewString("foo"), 0, NULL); |
1212 EXPECT_VALID(result); | 1212 EXPECT_VALID(result); |
1213 | 1213 |
1214 { | 1214 { |
1215 StackZone zone(thread); | 1215 StackZone zone(thread); |
1216 HANDLESCOPE(thread); | 1216 HANDLESCOPE(thread); |
1217 Profile profile(isolate); | 1217 Profile profile(isolate); |
1218 AllocationFilter filter(isolate->main_port(), float32_list_class.id()); | 1218 AllocationFilter filter(isolate->main_port(), float32_list_class.id()); |
1219 profile.Build(thread, &filter, Profile::kNoTags); | 1219 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
1220 // We should have one allocation sample. | 1220 // We should have one allocation sample. |
1221 EXPECT_EQ(1, profile.sample_count()); | 1221 EXPECT_EQ(1, profile.sample_count()); |
1222 ProfileTrieWalker walker(&profile); | 1222 ProfileTrieWalker walker(&profile); |
1223 | 1223 |
1224 walker.Reset(Profile::kExclusiveCode); | 1224 walker.Reset(Profile::kExclusiveCode); |
1225 EXPECT(walker.Down()); | 1225 EXPECT(walker.Down()); |
1226 EXPECT_STREQ("TypedData_Float32Array_new", walker.CurrentName()); | 1226 EXPECT_STREQ("TypedData_Float32Array_new", walker.CurrentName()); |
1227 EXPECT(walker.Down()); | 1227 EXPECT(walker.Down()); |
1228 EXPECT_STREQ("new Float32List", walker.CurrentName()); | 1228 EXPECT_STREQ("new Float32List", walker.CurrentName()); |
1229 EXPECT(walker.Down()); | 1229 EXPECT(walker.Down()); |
1230 EXPECT_STREQ("foo", walker.CurrentName()); | 1230 EXPECT_STREQ("foo", walker.CurrentName()); |
1231 EXPECT(!walker.Down()); | 1231 EXPECT(!walker.Down()); |
1232 } | 1232 } |
1233 | 1233 |
1234 float32_list_class.SetTraceAllocation(false); | 1234 float32_list_class.SetTraceAllocation(false); |
1235 result = Dart_Invoke(lib, NewString("foo"), 0, NULL); | 1235 result = Dart_Invoke(lib, NewString("foo"), 0, NULL); |
1236 EXPECT_VALID(result); | 1236 EXPECT_VALID(result); |
1237 | 1237 |
1238 { | 1238 { |
1239 StackZone zone(thread); | 1239 StackZone zone(thread); |
1240 HANDLESCOPE(thread); | 1240 HANDLESCOPE(thread); |
1241 Profile profile(isolate); | 1241 Profile profile(isolate); |
1242 AllocationFilter filter(isolate->main_port(), float32_list_class.id()); | 1242 AllocationFilter filter(isolate->main_port(), float32_list_class.id()); |
1243 profile.Build(thread, &filter, Profile::kNoTags); | 1243 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
1244 // We should still only have one allocation sample. | 1244 // We should still only have one allocation sample. |
1245 EXPECT_EQ(1, profile.sample_count()); | 1245 EXPECT_EQ(1, profile.sample_count()); |
1246 } | 1246 } |
1247 | 1247 |
1248 float32_list_class.SetTraceAllocation(true); | 1248 float32_list_class.SetTraceAllocation(true); |
1249 result = Dart_Invoke(lib, NewString("foo"), 0, NULL); | 1249 result = Dart_Invoke(lib, NewString("foo"), 0, NULL); |
1250 EXPECT_VALID(result); | 1250 EXPECT_VALID(result); |
1251 | 1251 |
1252 { | 1252 { |
1253 StackZone zone(thread); | 1253 StackZone zone(thread); |
1254 HANDLESCOPE(thread); | 1254 HANDLESCOPE(thread); |
1255 Profile profile(isolate); | 1255 Profile profile(isolate); |
1256 AllocationFilter filter(isolate->main_port(), float32_list_class.id()); | 1256 AllocationFilter filter(isolate->main_port(), float32_list_class.id()); |
1257 profile.Build(thread, &filter, Profile::kNoTags); | 1257 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
1258 // We should now have two allocation samples. | 1258 // We should now have two allocation samples. |
1259 EXPECT_EQ(2, profile.sample_count()); | 1259 EXPECT_EQ(2, profile.sample_count()); |
1260 } | 1260 } |
1261 } | 1261 } |
1262 | 1262 |
1263 | 1263 |
1264 TEST_CASE(Profiler_StringAllocation) { | 1264 TEST_CASE(Profiler_StringAllocation) { |
1265 DisableNativeProfileScope dnps; | 1265 DisableNativeProfileScope dnps; |
1266 const char* kScript = "String foo(String a, String b) => a + b;"; | 1266 const char* kScript = "String foo(String a, String b) => a + b;"; |
1267 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 1267 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
(...skipping 11 matching lines...) Expand all Loading... |
1279 }; | 1279 }; |
1280 | 1280 |
1281 Dart_Handle result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); | 1281 Dart_Handle result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); |
1282 EXPECT_VALID(result); | 1282 EXPECT_VALID(result); |
1283 | 1283 |
1284 { | 1284 { |
1285 StackZone zone(thread); | 1285 StackZone zone(thread); |
1286 HANDLESCOPE(thread); | 1286 HANDLESCOPE(thread); |
1287 Profile profile(isolate); | 1287 Profile profile(isolate); |
1288 AllocationFilter filter(isolate->main_port(), one_byte_string_class.id()); | 1288 AllocationFilter filter(isolate->main_port(), one_byte_string_class.id()); |
1289 profile.Build(thread, &filter, Profile::kNoTags); | 1289 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
1290 // We should have no allocation samples. | 1290 // We should have no allocation samples. |
1291 EXPECT_EQ(0, profile.sample_count()); | 1291 EXPECT_EQ(0, profile.sample_count()); |
1292 } | 1292 } |
1293 | 1293 |
1294 one_byte_string_class.SetTraceAllocation(true); | 1294 one_byte_string_class.SetTraceAllocation(true); |
1295 result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); | 1295 result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); |
1296 EXPECT_VALID(result); | 1296 EXPECT_VALID(result); |
1297 | 1297 |
1298 { | 1298 { |
1299 StackZone zone(thread); | 1299 StackZone zone(thread); |
1300 HANDLESCOPE(thread); | 1300 HANDLESCOPE(thread); |
1301 Profile profile(isolate); | 1301 Profile profile(isolate); |
1302 AllocationFilter filter(isolate->main_port(), one_byte_string_class.id()); | 1302 AllocationFilter filter(isolate->main_port(), one_byte_string_class.id()); |
1303 profile.Build(thread, &filter, Profile::kNoTags); | 1303 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
1304 // We should still only have one allocation sample. | 1304 // We should still only have one allocation sample. |
1305 EXPECT_EQ(1, profile.sample_count()); | 1305 EXPECT_EQ(1, profile.sample_count()); |
1306 ProfileTrieWalker walker(&profile); | 1306 ProfileTrieWalker walker(&profile); |
1307 | 1307 |
1308 walker.Reset(Profile::kExclusiveCode); | 1308 walker.Reset(Profile::kExclusiveCode); |
1309 EXPECT(walker.Down()); | 1309 EXPECT(walker.Down()); |
1310 EXPECT_STREQ("String_concat", walker.CurrentName()); | 1310 EXPECT_STREQ("String_concat", walker.CurrentName()); |
1311 EXPECT(walker.Down()); | 1311 EXPECT(walker.Down()); |
1312 #if 1 | 1312 #if 1 |
1313 EXPECT_STREQ("_StringBase.+", walker.CurrentName()); | 1313 EXPECT_STREQ("_StringBase.+", walker.CurrentName()); |
1314 EXPECT(walker.Down()); | 1314 EXPECT(walker.Down()); |
1315 #endif | 1315 #endif |
1316 EXPECT_STREQ("foo", walker.CurrentName()); | 1316 EXPECT_STREQ("foo", walker.CurrentName()); |
1317 EXPECT(!walker.Down()); | 1317 EXPECT(!walker.Down()); |
1318 } | 1318 } |
1319 | 1319 |
1320 one_byte_string_class.SetTraceAllocation(false); | 1320 one_byte_string_class.SetTraceAllocation(false); |
1321 result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); | 1321 result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); |
1322 EXPECT_VALID(result); | 1322 EXPECT_VALID(result); |
1323 | 1323 |
1324 { | 1324 { |
1325 StackZone zone(thread); | 1325 StackZone zone(thread); |
1326 HANDLESCOPE(thread); | 1326 HANDLESCOPE(thread); |
1327 Profile profile(isolate); | 1327 Profile profile(isolate); |
1328 AllocationFilter filter(isolate->main_port(), one_byte_string_class.id()); | 1328 AllocationFilter filter(isolate->main_port(), one_byte_string_class.id()); |
1329 profile.Build(thread, &filter, Profile::kNoTags); | 1329 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
1330 // We should still only have one allocation sample. | 1330 // We should still only have one allocation sample. |
1331 EXPECT_EQ(1, profile.sample_count()); | 1331 EXPECT_EQ(1, profile.sample_count()); |
1332 } | 1332 } |
1333 | 1333 |
1334 one_byte_string_class.SetTraceAllocation(true); | 1334 one_byte_string_class.SetTraceAllocation(true); |
1335 result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); | 1335 result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); |
1336 EXPECT_VALID(result); | 1336 EXPECT_VALID(result); |
1337 | 1337 |
1338 { | 1338 { |
1339 StackZone zone(thread); | 1339 StackZone zone(thread); |
1340 HANDLESCOPE(thread); | 1340 HANDLESCOPE(thread); |
1341 Profile profile(isolate); | 1341 Profile profile(isolate); |
1342 AllocationFilter filter(isolate->main_port(), one_byte_string_class.id()); | 1342 AllocationFilter filter(isolate->main_port(), one_byte_string_class.id()); |
1343 profile.Build(thread, &filter, Profile::kNoTags); | 1343 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
1344 // We should now have two allocation samples. | 1344 // We should now have two allocation samples. |
1345 EXPECT_EQ(2, profile.sample_count()); | 1345 EXPECT_EQ(2, profile.sample_count()); |
1346 } | 1346 } |
1347 } | 1347 } |
1348 | 1348 |
1349 | 1349 |
1350 TEST_CASE(Profiler_StringInterpolation) { | 1350 TEST_CASE(Profiler_StringInterpolation) { |
1351 DisableNativeProfileScope dnps; | 1351 DisableNativeProfileScope dnps; |
1352 DisableBackgroundCompilationScope dbcs; | 1352 DisableBackgroundCompilationScope dbcs; |
1353 const char* kScript = "String foo(String a, String b) => '$a | $b';"; | 1353 const char* kScript = "String foo(String a, String b) => '$a | $b';"; |
(...skipping 12 matching lines...) Expand all Loading... |
1366 }; | 1366 }; |
1367 | 1367 |
1368 Dart_Handle result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); | 1368 Dart_Handle result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); |
1369 EXPECT_VALID(result); | 1369 EXPECT_VALID(result); |
1370 | 1370 |
1371 { | 1371 { |
1372 StackZone zone(thread); | 1372 StackZone zone(thread); |
1373 HANDLESCOPE(thread); | 1373 HANDLESCOPE(thread); |
1374 Profile profile(isolate); | 1374 Profile profile(isolate); |
1375 AllocationFilter filter(isolate->main_port(), one_byte_string_class.id()); | 1375 AllocationFilter filter(isolate->main_port(), one_byte_string_class.id()); |
1376 profile.Build(thread, &filter, Profile::kNoTags); | 1376 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
1377 // We should have no allocation samples. | 1377 // We should have no allocation samples. |
1378 EXPECT_EQ(0, profile.sample_count()); | 1378 EXPECT_EQ(0, profile.sample_count()); |
1379 } | 1379 } |
1380 | 1380 |
1381 one_byte_string_class.SetTraceAllocation(true); | 1381 one_byte_string_class.SetTraceAllocation(true); |
1382 result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); | 1382 result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); |
1383 EXPECT_VALID(result); | 1383 EXPECT_VALID(result); |
1384 | 1384 |
1385 { | 1385 { |
1386 StackZone zone(thread); | 1386 StackZone zone(thread); |
1387 HANDLESCOPE(thread); | 1387 HANDLESCOPE(thread); |
1388 Profile profile(isolate); | 1388 Profile profile(isolate); |
1389 AllocationFilter filter(isolate->main_port(), one_byte_string_class.id()); | 1389 AllocationFilter filter(isolate->main_port(), one_byte_string_class.id()); |
1390 profile.Build(thread, &filter, Profile::kNoTags); | 1390 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
1391 // We should still only have one allocation sample. | 1391 // We should still only have one allocation sample. |
1392 EXPECT_EQ(1, profile.sample_count()); | 1392 EXPECT_EQ(1, profile.sample_count()); |
1393 ProfileTrieWalker walker(&profile); | 1393 ProfileTrieWalker walker(&profile); |
1394 | 1394 |
1395 walker.Reset(Profile::kExclusiveCode); | 1395 walker.Reset(Profile::kExclusiveCode); |
1396 EXPECT(walker.Down()); | 1396 EXPECT(walker.Down()); |
1397 EXPECT_STREQ("OneByteString_allocate", walker.CurrentName()); | 1397 EXPECT_STREQ("OneByteString_allocate", walker.CurrentName()); |
1398 EXPECT(walker.Down()); | 1398 EXPECT(walker.Down()); |
1399 EXPECT_STREQ("_OneByteString._allocate", walker.CurrentName()); | 1399 EXPECT_STREQ("_OneByteString._allocate", walker.CurrentName()); |
1400 EXPECT(walker.Down()); | 1400 EXPECT(walker.Down()); |
1401 EXPECT_STREQ("_OneByteString._concatAll", walker.CurrentName()); | 1401 EXPECT_STREQ("_OneByteString._concatAll", walker.CurrentName()); |
1402 EXPECT(walker.Down()); | 1402 EXPECT(walker.Down()); |
1403 EXPECT_STREQ("_StringBase._interpolate", walker.CurrentName()); | 1403 EXPECT_STREQ("_StringBase._interpolate", walker.CurrentName()); |
1404 EXPECT(walker.Down()); | 1404 EXPECT(walker.Down()); |
1405 EXPECT_STREQ("foo", walker.CurrentName()); | 1405 EXPECT_STREQ("foo", walker.CurrentName()); |
1406 EXPECT(!walker.Down()); | 1406 EXPECT(!walker.Down()); |
1407 } | 1407 } |
1408 | 1408 |
1409 one_byte_string_class.SetTraceAllocation(false); | 1409 one_byte_string_class.SetTraceAllocation(false); |
1410 result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); | 1410 result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); |
1411 EXPECT_VALID(result); | 1411 EXPECT_VALID(result); |
1412 | 1412 |
1413 { | 1413 { |
1414 StackZone zone(thread); | 1414 StackZone zone(thread); |
1415 HANDLESCOPE(thread); | 1415 HANDLESCOPE(thread); |
1416 Profile profile(isolate); | 1416 Profile profile(isolate); |
1417 AllocationFilter filter(isolate->main_port(), one_byte_string_class.id()); | 1417 AllocationFilter filter(isolate->main_port(), one_byte_string_class.id()); |
1418 profile.Build(thread, &filter, Profile::kNoTags); | 1418 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
1419 // We should still only have one allocation sample. | 1419 // We should still only have one allocation sample. |
1420 EXPECT_EQ(1, profile.sample_count()); | 1420 EXPECT_EQ(1, profile.sample_count()); |
1421 } | 1421 } |
1422 | 1422 |
1423 one_byte_string_class.SetTraceAllocation(true); | 1423 one_byte_string_class.SetTraceAllocation(true); |
1424 result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); | 1424 result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]); |
1425 EXPECT_VALID(result); | 1425 EXPECT_VALID(result); |
1426 | 1426 |
1427 { | 1427 { |
1428 StackZone zone(thread); | 1428 StackZone zone(thread); |
1429 HANDLESCOPE(thread); | 1429 HANDLESCOPE(thread); |
1430 Profile profile(isolate); | 1430 Profile profile(isolate); |
1431 AllocationFilter filter(isolate->main_port(), one_byte_string_class.id()); | 1431 AllocationFilter filter(isolate->main_port(), one_byte_string_class.id()); |
1432 profile.Build(thread, &filter, Profile::kNoTags); | 1432 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
1433 // We should now have two allocation samples. | 1433 // We should now have two allocation samples. |
1434 EXPECT_EQ(2, profile.sample_count()); | 1434 EXPECT_EQ(2, profile.sample_count()); |
1435 } | 1435 } |
1436 } | 1436 } |
1437 | 1437 |
1438 | 1438 |
1439 TEST_CASE(Profiler_FunctionInline) { | 1439 TEST_CASE(Profiler_FunctionInline) { |
1440 DisableNativeProfileScope dnps; | 1440 DisableNativeProfileScope dnps; |
1441 DisableBackgroundCompilationScope dbcs; | 1441 DisableBackgroundCompilationScope dbcs; |
1442 | 1442 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1482 EXPECT_VALID(result); | 1482 EXPECT_VALID(result); |
1483 // At this point B.boo should be optimized and inlined B.foo and B.choo. | 1483 // At this point B.boo should be optimized and inlined B.foo and B.choo. |
1484 | 1484 |
1485 { | 1485 { |
1486 Thread* thread = Thread::Current(); | 1486 Thread* thread = Thread::Current(); |
1487 Isolate* isolate = thread->isolate(); | 1487 Isolate* isolate = thread->isolate(); |
1488 StackZone zone(thread); | 1488 StackZone zone(thread); |
1489 HANDLESCOPE(thread); | 1489 HANDLESCOPE(thread); |
1490 Profile profile(isolate); | 1490 Profile profile(isolate); |
1491 AllocationFilter filter(isolate->main_port(), class_a.id()); | 1491 AllocationFilter filter(isolate->main_port(), class_a.id()); |
1492 profile.Build(thread, &filter, Profile::kNoTags); | 1492 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
1493 // We should have no allocation samples. | 1493 // We should have no allocation samples. |
1494 EXPECT_EQ(0, profile.sample_count()); | 1494 EXPECT_EQ(0, profile.sample_count()); |
1495 } | 1495 } |
1496 | 1496 |
1497 // Turn on allocation tracing for A. | 1497 // Turn on allocation tracing for A. |
1498 class_a.SetTraceAllocation(true); | 1498 class_a.SetTraceAllocation(true); |
1499 | 1499 |
1500 // Allocate 50,000 instances of A. | 1500 // Allocate 50,000 instances of A. |
1501 result = Dart_Invoke(lib, NewString("mainA"), 0, NULL); | 1501 result = Dart_Invoke(lib, NewString("mainA"), 0, NULL); |
1502 EXPECT_VALID(result); | 1502 EXPECT_VALID(result); |
1503 | 1503 |
1504 { | 1504 { |
1505 Thread* thread = Thread::Current(); | 1505 Thread* thread = Thread::Current(); |
1506 Isolate* isolate = thread->isolate(); | 1506 Isolate* isolate = thread->isolate(); |
1507 StackZone zone(thread); | 1507 StackZone zone(thread); |
1508 HANDLESCOPE(thread); | 1508 HANDLESCOPE(thread); |
1509 Profile profile(isolate); | 1509 Profile profile(isolate); |
1510 AllocationFilter filter(isolate->main_port(), class_a.id()); | 1510 AllocationFilter filter(isolate->main_port(), class_a.id()); |
1511 profile.Build(thread, &filter, Profile::kNoTags); | 1511 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
1512 // We should have 50,000 allocation samples. | 1512 // We should have 50,000 allocation samples. |
1513 EXPECT_EQ(50000, profile.sample_count()); | 1513 EXPECT_EQ(50000, profile.sample_count()); |
1514 ProfileTrieWalker walker(&profile); | 1514 ProfileTrieWalker walker(&profile); |
1515 // We have two code objects: mainA and B.boo. | 1515 // We have two code objects: mainA and B.boo. |
1516 walker.Reset(Profile::kExclusiveCode); | 1516 walker.Reset(Profile::kExclusiveCode); |
1517 EXPECT(walker.Down()); | 1517 EXPECT(walker.Down()); |
1518 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); | 1518 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); |
1519 EXPECT(walker.Down()); | 1519 EXPECT(walker.Down()); |
1520 EXPECT_STREQ("[Stub] Allocate A", walker.CurrentName()); | 1520 EXPECT_STREQ("[Stub] Allocate A", walker.CurrentName()); |
1521 EXPECT_EQ(50000, walker.CurrentExclusiveTicks()); | 1521 EXPECT_EQ(50000, walker.CurrentExclusiveTicks()); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1619 } | 1619 } |
1620 | 1620 |
1621 // Test code transition tags. | 1621 // Test code transition tags. |
1622 { | 1622 { |
1623 Thread* thread = Thread::Current(); | 1623 Thread* thread = Thread::Current(); |
1624 Isolate* isolate = thread->isolate(); | 1624 Isolate* isolate = thread->isolate(); |
1625 StackZone zone(thread); | 1625 StackZone zone(thread); |
1626 HANDLESCOPE(thread); | 1626 HANDLESCOPE(thread); |
1627 Profile profile(isolate); | 1627 Profile profile(isolate); |
1628 AllocationFilter filter(isolate->main_port(), class_a.id()); | 1628 AllocationFilter filter(isolate->main_port(), class_a.id()); |
1629 profile.Build(thread, &filter, Profile::kNoTags, | 1629 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags, |
1630 ProfilerService::kCodeTransitionTagsBit); | 1630 ProfilerService::kCodeTransitionTagsBit); |
1631 // We should have 50,000 allocation samples. | 1631 // We should have 50,000 allocation samples. |
1632 EXPECT_EQ(50000, profile.sample_count()); | 1632 EXPECT_EQ(50000, profile.sample_count()); |
1633 ProfileTrieWalker walker(&profile); | 1633 ProfileTrieWalker walker(&profile); |
1634 // We have two code objects: mainA and B.boo. | 1634 // We have two code objects: mainA and B.boo. |
1635 walker.Reset(Profile::kExclusiveCode); | 1635 walker.Reset(Profile::kExclusiveCode); |
1636 EXPECT(walker.Down()); | 1636 EXPECT(walker.Down()); |
1637 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); | 1637 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); |
1638 EXPECT(walker.Down()); | 1638 EXPECT(walker.Down()); |
1639 EXPECT_STREQ("[Stub] Allocate A", walker.CurrentName()); | 1639 EXPECT_STREQ("[Stub] Allocate A", walker.CurrentName()); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1792 func = GetFunction(root_library, "maybeAlloc"); | 1792 func = GetFunction(root_library, "maybeAlloc"); |
1793 EXPECT(!func.is_inlinable()); | 1793 EXPECT(!func.is_inlinable()); |
1794 | 1794 |
1795 { | 1795 { |
1796 Thread* thread = Thread::Current(); | 1796 Thread* thread = Thread::Current(); |
1797 Isolate* isolate = thread->isolate(); | 1797 Isolate* isolate = thread->isolate(); |
1798 StackZone zone(thread); | 1798 StackZone zone(thread); |
1799 HANDLESCOPE(thread); | 1799 HANDLESCOPE(thread); |
1800 Profile profile(isolate); | 1800 Profile profile(isolate); |
1801 AllocationFilter filter(isolate->main_port(), class_a.id()); | 1801 AllocationFilter filter(isolate->main_port(), class_a.id()); |
1802 profile.Build(thread, &filter, Profile::kNoTags); | 1802 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
1803 // We should have no allocation samples. | 1803 // We should have no allocation samples. |
1804 EXPECT_EQ(0, profile.sample_count()); | 1804 EXPECT_EQ(0, profile.sample_count()); |
1805 } | 1805 } |
1806 | 1806 |
1807 // Turn on allocation tracing for A. | 1807 // Turn on allocation tracing for A. |
1808 class_a.SetTraceAllocation(true); | 1808 class_a.SetTraceAllocation(true); |
1809 | 1809 |
1810 result = Dart_Invoke(lib, NewString("mainAlloc"), 0, NULL); | 1810 result = Dart_Invoke(lib, NewString("mainAlloc"), 0, NULL); |
1811 EXPECT_VALID(result); | 1811 EXPECT_VALID(result); |
1812 | 1812 |
1813 { | 1813 { |
1814 Thread* thread = Thread::Current(); | 1814 Thread* thread = Thread::Current(); |
1815 Isolate* isolate = thread->isolate(); | 1815 Isolate* isolate = thread->isolate(); |
1816 StackZone zone(thread); | 1816 StackZone zone(thread); |
1817 HANDLESCOPE(thread); | 1817 HANDLESCOPE(thread); |
1818 Profile profile(isolate); | 1818 Profile profile(isolate); |
1819 AllocationFilter filter(isolate->main_port(), class_a.id()); | 1819 AllocationFilter filter(isolate->main_port(), class_a.id()); |
1820 profile.Build(thread, &filter, Profile::kNoTags); | 1820 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
1821 EXPECT_EQ(1, profile.sample_count()); | 1821 EXPECT_EQ(1, profile.sample_count()); |
1822 ProfileTrieWalker walker(&profile); | 1822 ProfileTrieWalker walker(&profile); |
1823 | 1823 |
1824 // Inline expansion should show us the complete call chain: | 1824 // Inline expansion should show us the complete call chain: |
1825 walker.Reset(Profile::kExclusiveFunction); | 1825 walker.Reset(Profile::kExclusiveFunction); |
1826 EXPECT(walker.Down()); | 1826 EXPECT(walker.Down()); |
1827 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); | 1827 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); |
1828 EXPECT(walker.Down()); | 1828 EXPECT(walker.Down()); |
1829 EXPECT_STREQ("[Stub] Allocate A", walker.CurrentName()); | 1829 EXPECT_STREQ("[Stub] Allocate A", walker.CurrentName()); |
1830 EXPECT(walker.Down()); | 1830 EXPECT(walker.Down()); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1909 EXPECT_VALID(result); | 1909 EXPECT_VALID(result); |
1910 | 1910 |
1911 | 1911 |
1912 { | 1912 { |
1913 Thread* thread = Thread::Current(); | 1913 Thread* thread = Thread::Current(); |
1914 Isolate* isolate = thread->isolate(); | 1914 Isolate* isolate = thread->isolate(); |
1915 StackZone zone(thread); | 1915 StackZone zone(thread); |
1916 HANDLESCOPE(thread); | 1916 HANDLESCOPE(thread); |
1917 Profile profile(isolate); | 1917 Profile profile(isolate); |
1918 AllocationFilter filter(isolate->main_port(), class_a.id()); | 1918 AllocationFilter filter(isolate->main_port(), class_a.id()); |
1919 profile.Build(thread, &filter, Profile::kNoTags); | 1919 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
1920 // We should have 1 allocation sample. | 1920 // We should have 1 allocation sample. |
1921 EXPECT_EQ(1, profile.sample_count()); | 1921 EXPECT_EQ(1, profile.sample_count()); |
1922 ProfileTrieWalker walker(&profile); | 1922 ProfileTrieWalker walker(&profile); |
1923 | 1923 |
1924 walker.Reset(Profile::kExclusiveCode); | 1924 walker.Reset(Profile::kExclusiveCode); |
1925 // Move down from the root. | 1925 // Move down from the root. |
1926 EXPECT(walker.Down()); | 1926 EXPECT(walker.Down()); |
1927 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); | 1927 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); |
1928 EXPECT(walker.Down()); | 1928 EXPECT(walker.Down()); |
1929 EXPECT_STREQ("[Stub] Allocate A", walker.CurrentName()); | 1929 EXPECT_STREQ("[Stub] Allocate A", walker.CurrentName()); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2011 result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 2011 result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
2012 EXPECT_VALID(result); | 2012 EXPECT_VALID(result); |
2013 | 2013 |
2014 { | 2014 { |
2015 Thread* thread = Thread::Current(); | 2015 Thread* thread = Thread::Current(); |
2016 Isolate* isolate = thread->isolate(); | 2016 Isolate* isolate = thread->isolate(); |
2017 StackZone zone(thread); | 2017 StackZone zone(thread); |
2018 HANDLESCOPE(thread); | 2018 HANDLESCOPE(thread); |
2019 Profile profile(isolate); | 2019 Profile profile(isolate); |
2020 AllocationFilter filter(isolate->main_port(), class_a.id()); | 2020 AllocationFilter filter(isolate->main_port(), class_a.id()); |
2021 profile.Build(thread, &filter, Profile::kNoTags); | 2021 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
2022 // We should have one allocation samples. | 2022 // We should have one allocation samples. |
2023 EXPECT_EQ(1, profile.sample_count()); | 2023 EXPECT_EQ(1, profile.sample_count()); |
2024 ProfileTrieWalker walker(&profile); | 2024 ProfileTrieWalker walker(&profile); |
2025 | 2025 |
2026 // Exclusive function: B.boo -> main. | 2026 // Exclusive function: B.boo -> main. |
2027 walker.Reset(Profile::kExclusiveFunction); | 2027 walker.Reset(Profile::kExclusiveFunction); |
2028 // Move down from the root. | 2028 // Move down from the root. |
2029 EXPECT(walker.Down()); | 2029 EXPECT(walker.Down()); |
2030 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); | 2030 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); |
2031 EXPECT(walker.Down()); | 2031 EXPECT(walker.Down()); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2105 const Code& code = Code::Handle(main.CurrentCode()); | 2105 const Code& code = Code::Handle(main.CurrentCode()); |
2106 EXPECT(code.is_optimized()); | 2106 EXPECT(code.is_optimized()); |
2107 | 2107 |
2108 { | 2108 { |
2109 Thread* thread = Thread::Current(); | 2109 Thread* thread = Thread::Current(); |
2110 Isolate* isolate = thread->isolate(); | 2110 Isolate* isolate = thread->isolate(); |
2111 StackZone zone(thread); | 2111 StackZone zone(thread); |
2112 HANDLESCOPE(thread); | 2112 HANDLESCOPE(thread); |
2113 Profile profile(isolate); | 2113 Profile profile(isolate); |
2114 AllocationFilter filter(isolate->main_port(), class_a.id()); | 2114 AllocationFilter filter(isolate->main_port(), class_a.id()); |
2115 profile.Build(thread, &filter, Profile::kNoTags); | 2115 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
2116 // We should have one allocation samples. | 2116 // We should have one allocation samples. |
2117 EXPECT_EQ(1, profile.sample_count()); | 2117 EXPECT_EQ(1, profile.sample_count()); |
2118 ProfileTrieWalker walker(&profile); | 2118 ProfileTrieWalker walker(&profile); |
2119 | 2119 |
2120 // Exclusive function: B.boo -> main. | 2120 // Exclusive function: B.boo -> main. |
2121 walker.Reset(Profile::kExclusiveFunction); | 2121 walker.Reset(Profile::kExclusiveFunction); |
2122 // Move down from the root. | 2122 // Move down from the root. |
2123 EXPECT(walker.Down()); | 2123 EXPECT(walker.Down()); |
2124 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); | 2124 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); |
2125 EXPECT(walker.Down()); | 2125 EXPECT(walker.Down()); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2192 result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 2192 result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
2193 EXPECT_VALID(result); | 2193 EXPECT_VALID(result); |
2194 | 2194 |
2195 { | 2195 { |
2196 Thread* thread = Thread::Current(); | 2196 Thread* thread = Thread::Current(); |
2197 Isolate* isolate = thread->isolate(); | 2197 Isolate* isolate = thread->isolate(); |
2198 StackZone zone(thread); | 2198 StackZone zone(thread); |
2199 HANDLESCOPE(thread); | 2199 HANDLESCOPE(thread); |
2200 Profile profile(isolate); | 2200 Profile profile(isolate); |
2201 AllocationFilter filter(isolate->main_port(), class_a.id()); | 2201 AllocationFilter filter(isolate->main_port(), class_a.id()); |
2202 profile.Build(thread, &filter, Profile::kNoTags); | 2202 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
2203 // We should have one allocation samples. | 2203 // We should have one allocation samples. |
2204 EXPECT_EQ(1, profile.sample_count()); | 2204 EXPECT_EQ(1, profile.sample_count()); |
2205 ProfileTrieWalker walker(&profile); | 2205 ProfileTrieWalker walker(&profile); |
2206 | 2206 |
2207 // Exclusive function: B.boo -> main. | 2207 // Exclusive function: B.boo -> main. |
2208 walker.Reset(Profile::kExclusiveFunction); | 2208 walker.Reset(Profile::kExclusiveFunction); |
2209 // Move down from the root. | 2209 // Move down from the root. |
2210 EXPECT(walker.Down()); | 2210 EXPECT(walker.Down()); |
2211 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); | 2211 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); |
2212 EXPECT(walker.Down()); | 2212 EXPECT(walker.Down()); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2317 const Code& code = Code::Handle(main.CurrentCode()); | 2317 const Code& code = Code::Handle(main.CurrentCode()); |
2318 EXPECT(code.is_optimized()); | 2318 EXPECT(code.is_optimized()); |
2319 | 2319 |
2320 { | 2320 { |
2321 Thread* thread = Thread::Current(); | 2321 Thread* thread = Thread::Current(); |
2322 Isolate* isolate = thread->isolate(); | 2322 Isolate* isolate = thread->isolate(); |
2323 StackZone zone(thread); | 2323 StackZone zone(thread); |
2324 HANDLESCOPE(thread); | 2324 HANDLESCOPE(thread); |
2325 Profile profile(isolate); | 2325 Profile profile(isolate); |
2326 AllocationFilter filter(isolate->main_port(), class_a.id()); | 2326 AllocationFilter filter(isolate->main_port(), class_a.id()); |
2327 profile.Build(thread, &filter, Profile::kNoTags); | 2327 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
2328 // We should have one allocation samples. | 2328 // We should have one allocation samples. |
2329 EXPECT_EQ(1, profile.sample_count()); | 2329 EXPECT_EQ(1, profile.sample_count()); |
2330 ProfileTrieWalker walker(&profile); | 2330 ProfileTrieWalker walker(&profile); |
2331 | 2331 |
2332 // Exclusive function: B.boo -> main. | 2332 // Exclusive function: B.boo -> main. |
2333 walker.Reset(Profile::kExclusiveFunction); | 2333 walker.Reset(Profile::kExclusiveFunction); |
2334 // Move down from the root. | 2334 // Move down from the root. |
2335 EXPECT(walker.Down()); | 2335 EXPECT(walker.Down()); |
2336 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); | 2336 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); |
2337 EXPECT(walker.Down()); | 2337 EXPECT(walker.Down()); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2425 result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 2425 result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
2426 EXPECT_VALID(result); | 2426 EXPECT_VALID(result); |
2427 | 2427 |
2428 { | 2428 { |
2429 Thread* thread = Thread::Current(); | 2429 Thread* thread = Thread::Current(); |
2430 Isolate* isolate = thread->isolate(); | 2430 Isolate* isolate = thread->isolate(); |
2431 StackZone zone(thread); | 2431 StackZone zone(thread); |
2432 HANDLESCOPE(thread); | 2432 HANDLESCOPE(thread); |
2433 Profile profile(isolate); | 2433 Profile profile(isolate); |
2434 AllocationFilter filter(isolate->main_port(), class_a.id()); | 2434 AllocationFilter filter(isolate->main_port(), class_a.id()); |
2435 profile.Build(thread, &filter, Profile::kNoTags); | 2435 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
2436 // We should have one allocation samples. | 2436 // We should have one allocation samples. |
2437 EXPECT_EQ(1, profile.sample_count()); | 2437 EXPECT_EQ(1, profile.sample_count()); |
2438 ProfileTrieWalker walker(&profile); | 2438 ProfileTrieWalker walker(&profile); |
2439 | 2439 |
2440 // Exclusive function: B.boo -> main. | 2440 // Exclusive function: B.boo -> main. |
2441 walker.Reset(Profile::kExclusiveFunction); | 2441 walker.Reset(Profile::kExclusiveFunction); |
2442 // Move down from the root. | 2442 // Move down from the root. |
2443 EXPECT(walker.Down()); | 2443 EXPECT(walker.Down()); |
2444 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); | 2444 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); |
2445 EXPECT(walker.Down()); | 2445 EXPECT(walker.Down()); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2559 const Code& code = Code::Handle(main.CurrentCode()); | 2559 const Code& code = Code::Handle(main.CurrentCode()); |
2560 EXPECT(code.is_optimized()); | 2560 EXPECT(code.is_optimized()); |
2561 | 2561 |
2562 { | 2562 { |
2563 Thread* thread = Thread::Current(); | 2563 Thread* thread = Thread::Current(); |
2564 Isolate* isolate = thread->isolate(); | 2564 Isolate* isolate = thread->isolate(); |
2565 StackZone zone(thread); | 2565 StackZone zone(thread); |
2566 HANDLESCOPE(thread); | 2566 HANDLESCOPE(thread); |
2567 Profile profile(isolate); | 2567 Profile profile(isolate); |
2568 AllocationFilter filter(isolate->main_port(), class_a.id()); | 2568 AllocationFilter filter(isolate->main_port(), class_a.id()); |
2569 profile.Build(thread, &filter, Profile::kNoTags); | 2569 profile.Build(thread, &filter, Profiler::sample_buffer(), Profile::kNoTags); |
2570 // We should have one allocation samples. | 2570 // We should have one allocation samples. |
2571 EXPECT_EQ(1, profile.sample_count()); | 2571 EXPECT_EQ(1, profile.sample_count()); |
2572 ProfileTrieWalker walker(&profile); | 2572 ProfileTrieWalker walker(&profile); |
2573 | 2573 |
2574 // Exclusive function: B.boo -> main. | 2574 // Exclusive function: B.boo -> main. |
2575 walker.Reset(Profile::kExclusiveFunction); | 2575 walker.Reset(Profile::kExclusiveFunction); |
2576 // Move down from the root. | 2576 // Move down from the root. |
2577 EXPECT(walker.Down()); | 2577 EXPECT(walker.Down()); |
2578 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); | 2578 EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName()); |
2579 EXPECT(walker.Down()); | 2579 EXPECT(walker.Down()); |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2896 EXPECT_EQ(table->FindCodeForPC(45), code1); // Merged right. | 2896 EXPECT_EQ(table->FindCodeForPC(45), code1); // Merged right. |
2897 EXPECT_EQ(table->FindCodeForPC(54), code1); // Merged right. | 2897 EXPECT_EQ(table->FindCodeForPC(54), code1); // Merged right. |
2898 EXPECT_EQ(table->FindCodeForPC(20), code2); // Merged left. | 2898 EXPECT_EQ(table->FindCodeForPC(20), code2); // Merged left. |
2899 EXPECT_EQ(table->FindCodeForPC(49), code1); // Truncated. | 2899 EXPECT_EQ(table->FindCodeForPC(49), code1); // Truncated. |
2900 EXPECT_EQ(table->FindCodeForPC(50), code1); | 2900 EXPECT_EQ(table->FindCodeForPC(50), code1); |
2901 } | 2901 } |
2902 | 2902 |
2903 #endif // !PRODUCT | 2903 #endif // !PRODUCT |
2904 | 2904 |
2905 } // namespace dart | 2905 } // namespace dart |
OLD | NEW |