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" |
11 #include "vm/profiler_service.h" | 11 #include "vm/profiler_service.h" |
12 #include "vm/unit_test.h" | 12 #include "vm/unit_test.h" |
13 | 13 |
14 namespace dart { | 14 namespace dart { |
15 | 15 |
| 16 DECLARE_FLAG(bool, background_compilation); |
16 DECLARE_FLAG(bool, profile_vm); | 17 DECLARE_FLAG(bool, profile_vm); |
17 DECLARE_FLAG(int, max_profile_depth); | 18 DECLARE_FLAG(int, max_profile_depth); |
18 | 19 |
19 // Some tests are written assuming native stack trace profiling is disabled. | 20 // Some tests are written assuming native stack trace profiling is disabled. |
20 class DisableNativeProfileScope : public ValueObject { | 21 class DisableNativeProfileScope : public ValueObject { |
21 public: | 22 public: |
22 DisableNativeProfileScope() | 23 DisableNativeProfileScope() |
23 : FLAG_profile_vm_(FLAG_profile_vm) { | 24 : FLAG_profile_vm_(FLAG_profile_vm) { |
24 FLAG_profile_vm = false; | 25 FLAG_profile_vm = false; |
25 } | 26 } |
(...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1143 " }\n" | 1144 " }\n" |
1144 " }\n" | 1145 " }\n" |
1145 "}\n" | 1146 "}\n" |
1146 "main() {\n" | 1147 "main() {\n" |
1147 " B.boo(false);\n" | 1148 " B.boo(false);\n" |
1148 "}\n" | 1149 "}\n" |
1149 "mainA() {\n" | 1150 "mainA() {\n" |
1150 " B.boo(true);\n" | 1151 " B.boo(true);\n" |
1151 "}\n"; | 1152 "}\n"; |
1152 | 1153 |
| 1154 const bool old_flag = FLAG_background_compilation; |
| 1155 FLAG_background_compilation = false; |
1153 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 1156 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
1154 EXPECT_VALID(lib); | 1157 EXPECT_VALID(lib); |
1155 Library& root_library = Library::Handle(); | 1158 Library& root_library = Library::Handle(); |
1156 root_library ^= Api::UnwrapHandle(lib); | 1159 root_library ^= Api::UnwrapHandle(lib); |
1157 | 1160 |
1158 const Class& class_a = Class::Handle(GetClass(root_library, "A")); | 1161 const Class& class_a = Class::Handle(GetClass(root_library, "A")); |
1159 EXPECT(!class_a.IsNull()); | 1162 EXPECT(!class_a.IsNull()); |
1160 | 1163 |
1161 // Compile "main". | 1164 // Compile "main". |
1162 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 1165 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1359 EXPECT(walker.Down()); | 1362 EXPECT(walker.Down()); |
1360 EXPECT_STREQ("[Inline Start]", walker.CurrentName()); | 1363 EXPECT_STREQ("[Inline Start]", walker.CurrentName()); |
1361 EXPECT(walker.Down()); | 1364 EXPECT(walker.Down()); |
1362 EXPECT_STREQ("B.foo", walker.CurrentName()); | 1365 EXPECT_STREQ("B.foo", walker.CurrentName()); |
1363 EXPECT(walker.Down()); | 1366 EXPECT(walker.Down()); |
1364 EXPECT_STREQ("B.choo", walker.CurrentName()); | 1367 EXPECT_STREQ("B.choo", walker.CurrentName()); |
1365 EXPECT(walker.Down()); | 1368 EXPECT(walker.Down()); |
1366 EXPECT_STREQ("[Inline End]", walker.CurrentName()); | 1369 EXPECT_STREQ("[Inline End]", walker.CurrentName()); |
1367 EXPECT(!walker.Down()); | 1370 EXPECT(!walker.Down()); |
1368 } | 1371 } |
| 1372 FLAG_background_compilation = old_flag; |
1369 } | 1373 } |
1370 | 1374 |
1371 | 1375 |
1372 TEST_CASE(Profiler_ChainedSamples) { | 1376 TEST_CASE(Profiler_ChainedSamples) { |
1373 MaxProfileDepthScope mpds(32); | 1377 MaxProfileDepthScope mpds(32); |
1374 DisableNativeProfileScope dnps; | 1378 DisableNativeProfileScope dnps; |
1375 | 1379 |
1376 // Each sample holds 8 stack frames. | 1380 // Each sample holds 8 stack frames. |
1377 // This chain is 20 stack frames deep. | 1381 // This chain is 20 stack frames deep. |
1378 const char* kScript = | 1382 const char* kScript = |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1473 EXPECT(walker.Down()); | 1477 EXPECT(walker.Down()); |
1474 EXPECT_STREQ("go", walker.CurrentName()); | 1478 EXPECT_STREQ("go", walker.CurrentName()); |
1475 EXPECT(walker.Down()); | 1479 EXPECT(walker.Down()); |
1476 EXPECT_STREQ("main", walker.CurrentName()); | 1480 EXPECT_STREQ("main", walker.CurrentName()); |
1477 EXPECT(!walker.Down()); | 1481 EXPECT(!walker.Down()); |
1478 } | 1482 } |
1479 } | 1483 } |
1480 | 1484 |
1481 } // namespace dart | 1485 } // namespace dart |
1482 | 1486 |
OLD | NEW |