OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 #include "vm/globals.h" | 6 #include "vm/globals.h" |
7 #include "vm/heap.h" | 7 #include "vm/heap.h" |
8 #include "vm/unit_test.h" | 8 #include "vm/unit_test.h" |
9 | 9 |
10 namespace dart { | 10 namespace dart { |
11 | 11 |
12 // Only ia32 and x64 can run execution tests. | 12 // Only ia32 and x64 can run execution tests. |
13 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) | 13 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) |
14 TEST_CASE(OldGC) { | 14 TEST_CASE(OldGC) { |
15 const char* kScriptChars = | 15 const char* kScriptChars = |
16 "main() {\n" | 16 "main() {\n" |
17 " return [1, 2, 3];\n" | 17 " return [1, 2, 3];\n" |
18 "}\n"; | 18 "}\n"; |
19 FLAG_verbose_gc = true; | 19 FLAG_verbose_gc = true; |
20 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 20 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
21 Dart_Handle result = Dart_Invoke(lib, | 21 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
22 Dart_NewString("main"), | |
23 0, NULL); | |
24 | 22 |
25 EXPECT_VALID(result); | 23 EXPECT_VALID(result); |
26 EXPECT(!Dart_IsNull(result)); | 24 EXPECT(!Dart_IsNull(result)); |
27 EXPECT(Dart_IsList(result)); | 25 EXPECT(Dart_IsList(result)); |
28 Isolate* isolate = Isolate::Current(); | 26 Isolate* isolate = Isolate::Current(); |
29 Heap* heap = isolate->heap(); | 27 Heap* heap = isolate->heap(); |
30 heap->CollectGarbage(Heap::kOld); | 28 heap->CollectGarbage(Heap::kOld); |
31 } | 29 } |
32 | 30 |
33 | 31 |
34 TEST_CASE(LargeSweep) { | 32 TEST_CASE(LargeSweep) { |
35 const char* kScriptChars = | 33 const char* kScriptChars = |
36 "main() {\n" | 34 "main() {\n" |
37 " return new List(8 * 1024 * 1024);\n" | 35 " return new List(8 * 1024 * 1024);\n" |
38 "}\n"; | 36 "}\n"; |
39 FLAG_verbose_gc = true; | 37 FLAG_verbose_gc = true; |
40 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 38 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
41 Dart_EnterScope(); | 39 Dart_EnterScope(); |
42 Dart_Handle result = Dart_Invoke(lib, | 40 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
43 Dart_NewString("main"), | |
44 0, NULL); | |
45 | 41 |
46 EXPECT_VALID(result); | 42 EXPECT_VALID(result); |
47 EXPECT(!Dart_IsNull(result)); | 43 EXPECT(!Dart_IsNull(result)); |
48 EXPECT(Dart_IsList(result)); | 44 EXPECT(Dart_IsList(result)); |
49 Isolate* isolate = Isolate::Current(); | 45 Isolate* isolate = Isolate::Current(); |
50 Heap* heap = isolate->heap(); | 46 Heap* heap = isolate->heap(); |
51 heap->CollectGarbage(Heap::kOld); | 47 heap->CollectGarbage(Heap::kOld); |
52 Dart_ExitScope(); | 48 Dart_ExitScope(); |
53 heap->CollectGarbage(Heap::kOld); | 49 heap->CollectGarbage(Heap::kOld); |
54 } | 50 } |
55 | 51 |
56 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 52 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
57 } | 53 } |
OLD | NEW |