| 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 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, Profile::kNoTags); |
| 1030 // We should have no allocation samples, since empty | 1030 // We should still only have one allocation sample. |
| 1031 // growable lists use a shared backing. | 1031 EXPECT_EQ(1, profile.sample_count()); |
| 1032 EXPECT_EQ(0, profile.sample_count()); | 1032 ProfileTrieWalker walker(&profile); |
| 1033 |
| 1034 walker.Reset(Profile::kExclusiveCode); |
| 1035 EXPECT(walker.Down()); |
| 1036 EXPECT_STREQ("DRT_AllocateArray", walker.CurrentName()); |
| 1037 EXPECT(walker.Down()); |
| 1038 EXPECT_STREQ("[Stub] AllocateArray", walker.CurrentName()); |
| 1039 EXPECT(walker.Down()); |
| 1040 EXPECT_STREQ("new _List", walker.CurrentName()); |
| 1041 EXPECT(walker.Down()); |
| 1042 EXPECT_STREQ("new _GrowableList", walker.CurrentName()); |
| 1043 EXPECT(walker.Down()); |
| 1044 EXPECT_STREQ("new List._internal", walker.CurrentName()); |
| 1045 EXPECT(walker.Down()); |
| 1046 EXPECT_STREQ("bar", walker.CurrentName()); |
| 1047 EXPECT(!walker.Down()); |
| 1033 } | 1048 } |
| 1034 } | 1049 } |
| 1035 | 1050 |
| 1036 | 1051 |
| 1037 TEST_CASE(Profiler_ContextAllocation) { | 1052 TEST_CASE(Profiler_ContextAllocation) { |
| 1038 DisableNativeProfileScope dnps; | 1053 DisableNativeProfileScope dnps; |
| 1039 const char* kScript = | 1054 const char* kScript = |
| 1040 "var msg1 = 'a';\n" | 1055 "var msg1 = 'a';\n" |
| 1041 "foo() {\n" | 1056 "foo() {\n" |
| 1042 " var msg = msg1 + msg1;\n" | 1057 " var msg = msg1 + msg1;\n" |
| (...skipping 1853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2896 EXPECT_EQ(table->FindCodeForPC(45), code1); // Merged right. | 2911 EXPECT_EQ(table->FindCodeForPC(45), code1); // Merged right. |
| 2897 EXPECT_EQ(table->FindCodeForPC(54), code1); // Merged right. | 2912 EXPECT_EQ(table->FindCodeForPC(54), code1); // Merged right. |
| 2898 EXPECT_EQ(table->FindCodeForPC(20), code2); // Merged left. | 2913 EXPECT_EQ(table->FindCodeForPC(20), code2); // Merged left. |
| 2899 EXPECT_EQ(table->FindCodeForPC(49), code1); // Truncated. | 2914 EXPECT_EQ(table->FindCodeForPC(49), code1); // Truncated. |
| 2900 EXPECT_EQ(table->FindCodeForPC(50), code1); | 2915 EXPECT_EQ(table->FindCodeForPC(50), code1); |
| 2901 } | 2916 } |
| 2902 | 2917 |
| 2903 #endif // !PRODUCT | 2918 #endif // !PRODUCT |
| 2904 | 2919 |
| 2905 } // namespace dart | 2920 } // namespace dart |
| OLD | NEW |