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/globals.h" | 5 #include "platform/globals.h" |
6 | 6 |
7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "vm/dart_api_impl.h" | 8 #include "vm/dart_api_impl.h" |
9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
10 #include "vm/heap.h" | 10 #include "vm/heap.h" |
11 #include "vm/unit_test.h" | 11 #include "vm/unit_test.h" |
12 | 12 |
13 namespace dart { | 13 namespace dart { |
14 | 14 |
15 DECLARE_FLAG(int, marker_tasks); | |
16 | |
17 TEST_CASE(OldGC) { | 15 TEST_CASE(OldGC) { |
18 const char* kScriptChars = | 16 const char* kScriptChars = |
19 "main() {\n" | 17 "main() {\n" |
20 " return [1, 2, 3];\n" | 18 " return [1, 2, 3];\n" |
21 "}\n"; | 19 "}\n"; |
22 FLAG_verbose_gc = true; | 20 FLAG_verbose_gc = true; |
23 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 21 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
24 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 22 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
25 | 23 |
26 EXPECT_VALID(result); | 24 EXPECT_VALID(result); |
27 EXPECT(!Dart_IsNull(result)); | 25 EXPECT(!Dart_IsNull(result)); |
28 EXPECT(Dart_IsList(result)); | 26 EXPECT(Dart_IsList(result)); |
29 TransitionNativeToVM transition(thread); | 27 TransitionNativeToVM transition(thread); |
30 Isolate* isolate = Isolate::Current(); | 28 Isolate* isolate = Isolate::Current(); |
31 Heap* heap = isolate->heap(); | 29 Heap* heap = isolate->heap(); |
32 heap->CollectGarbage(Heap::kOld); | 30 heap->CollectGarbage(Heap::kOld); |
33 } | 31 } |
34 | 32 |
35 | 33 #if !defined(PRODUCT) |
36 TEST_CASE(OldGC_Unsync) { | 34 TEST_CASE(OldGC_Unsync) { |
37 FLAG_marker_tasks = 0; | 35 FLAG_marker_tasks = 0; |
38 const char* kScriptChars = | 36 const char* kScriptChars = |
39 "main() {\n" | 37 "main() {\n" |
40 " return [1, 2, 3];\n" | 38 " return [1, 2, 3];\n" |
41 "}\n"; | 39 "}\n"; |
42 FLAG_verbose_gc = true; | 40 FLAG_verbose_gc = true; |
43 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 41 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
44 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 42 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
45 | 43 |
46 EXPECT_VALID(result); | 44 EXPECT_VALID(result); |
47 EXPECT(!Dart_IsNull(result)); | 45 EXPECT(!Dart_IsNull(result)); |
48 EXPECT(Dart_IsList(result)); | 46 EXPECT(Dart_IsList(result)); |
49 TransitionNativeToVM transition(thread); | 47 TransitionNativeToVM transition(thread); |
50 Isolate* isolate = Isolate::Current(); | 48 Isolate* isolate = Isolate::Current(); |
51 Heap* heap = isolate->heap(); | 49 Heap* heap = isolate->heap(); |
52 heap->CollectGarbage(Heap::kOld); | 50 heap->CollectGarbage(Heap::kOld); |
53 } | 51 } |
54 | 52 #endif |
55 | 53 |
56 TEST_CASE(LargeSweep) { | 54 TEST_CASE(LargeSweep) { |
57 const char* kScriptChars = | 55 const char* kScriptChars = |
58 "main() {\n" | 56 "main() {\n" |
59 " return new List(8 * 1024 * 1024);\n" | 57 " return new List(8 * 1024 * 1024);\n" |
60 "}\n"; | 58 "}\n"; |
61 FLAG_verbose_gc = true; | 59 FLAG_verbose_gc = true; |
62 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 60 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
63 Dart_EnterScope(); | 61 Dart_EnterScope(); |
64 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 62 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 const String& obj = String::Handle(String::New("x", Heap::kOld)); | 281 const String& obj = String::Handle(String::New("x", Heap::kOld)); |
284 Heap* heap = Thread::Current()->isolate()->heap(); | 282 Heap* heap = Thread::Current()->isolate()->heap(); |
285 EXPECT(heap->Contains(RawObject::ToAddr(obj.raw()))); | 283 EXPECT(heap->Contains(RawObject::ToAddr(obj.raw()))); |
286 heap->WriteProtect(true); | 284 heap->WriteProtect(true); |
287 EXPECT(heap->Contains(RawObject::ToAddr(obj.raw()))); | 285 EXPECT(heap->Contains(RawObject::ToAddr(obj.raw()))); |
288 heap->WriteProtect(false); | 286 heap->WriteProtect(false); |
289 EXPECT(heap->Contains(RawObject::ToAddr(obj.raw()))); | 287 EXPECT(heap->Contains(RawObject::ToAddr(obj.raw()))); |
290 } | 288 } |
291 | 289 |
292 } // namespace dart. | 290 } // namespace dart. |
OLD | NEW |