Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: runtime/vm/heap_test.cc

Issue 1541073002: Implement safepointing of threads (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fix-typo Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/heap.cc ('k') | runtime/vm/intermediate_language_arm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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); 15 DECLARE_FLAG(int, marker_tasks);
16 16
17 TEST_CASE(OldGC) { 17 TEST_CASE(OldGC) {
18 const char* kScriptChars = 18 const char* kScriptChars =
19 "main() {\n" 19 "main() {\n"
20 " return [1, 2, 3];\n" 20 " return [1, 2, 3];\n"
21 "}\n"; 21 "}\n";
22 FLAG_verbose_gc = true; 22 FLAG_verbose_gc = true;
23 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 23 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
24 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); 24 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL);
25 25
26 EXPECT_VALID(result); 26 EXPECT_VALID(result);
27 EXPECT(!Dart_IsNull(result)); 27 EXPECT(!Dart_IsNull(result));
28 EXPECT(Dart_IsList(result)); 28 EXPECT(Dart_IsList(result));
29 TransitionNativeToVM transition(thread);
29 Isolate* isolate = Isolate::Current(); 30 Isolate* isolate = Isolate::Current();
30 Heap* heap = isolate->heap(); 31 Heap* heap = isolate->heap();
31 heap->CollectGarbage(Heap::kOld); 32 heap->CollectGarbage(Heap::kOld);
32 } 33 }
33 34
34 35
35 TEST_CASE(OldGC_Unsync) { 36 TEST_CASE(OldGC_Unsync) {
36 FLAG_marker_tasks = 0; 37 FLAG_marker_tasks = 0;
37 const char* kScriptChars = 38 const char* kScriptChars =
38 "main() {\n" 39 "main() {\n"
39 " return [1, 2, 3];\n" 40 " return [1, 2, 3];\n"
40 "}\n"; 41 "}\n";
41 FLAG_verbose_gc = true; 42 FLAG_verbose_gc = true;
42 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 43 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
43 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); 44 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL);
44 45
45 EXPECT_VALID(result); 46 EXPECT_VALID(result);
46 EXPECT(!Dart_IsNull(result)); 47 EXPECT(!Dart_IsNull(result));
47 EXPECT(Dart_IsList(result)); 48 EXPECT(Dart_IsList(result));
49 TransitionNativeToVM transition(thread);
48 Isolate* isolate = Isolate::Current(); 50 Isolate* isolate = Isolate::Current();
49 Heap* heap = isolate->heap(); 51 Heap* heap = isolate->heap();
50 heap->CollectGarbage(Heap::kOld); 52 heap->CollectGarbage(Heap::kOld);
51 } 53 }
52 54
53 55
54 TEST_CASE(LargeSweep) { 56 TEST_CASE(LargeSweep) {
55 const char* kScriptChars = 57 const char* kScriptChars =
56 "main() {\n" 58 "main() {\n"
57 " return new List(8 * 1024 * 1024);\n" 59 " return new List(8 * 1024 * 1024);\n"
58 "}\n"; 60 "}\n";
59 FLAG_verbose_gc = true; 61 FLAG_verbose_gc = true;
60 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 62 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
61 Dart_EnterScope(); 63 Dart_EnterScope();
62 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); 64 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL);
63 65
64 EXPECT_VALID(result); 66 EXPECT_VALID(result);
65 EXPECT(!Dart_IsNull(result)); 67 EXPECT(!Dart_IsNull(result));
66 EXPECT(Dart_IsList(result)); 68 EXPECT(Dart_IsList(result));
69 TransitionNativeToVM transition(thread);
67 Isolate* isolate = Isolate::Current(); 70 Isolate* isolate = Isolate::Current();
68 Heap* heap = isolate->heap(); 71 Heap* heap = isolate->heap();
69 heap->CollectGarbage(Heap::kOld); 72 heap->CollectGarbage(Heap::kOld);
70 Dart_ExitScope(); 73 Dart_ExitScope();
71 heap->CollectGarbage(Heap::kOld); 74 heap->CollectGarbage(Heap::kOld);
72 } 75 }
73 76
74 77
75 class ClassHeapStatsTestHelper { 78 class ClassHeapStatsTestHelper {
76 public: 79 public:
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 " return new A();\n" 111 " return new A();\n"
109 "}\n"; 112 "}\n";
110 Dart_Handle h_lib = TestCase::LoadTestScript(kScriptChars, NULL); 113 Dart_Handle h_lib = TestCase::LoadTestScript(kScriptChars, NULL);
111 Isolate* isolate = Isolate::Current(); 114 Isolate* isolate = Isolate::Current();
112 ClassTable* class_table = isolate->class_table(); 115 ClassTable* class_table = isolate->class_table();
113 Heap* heap = isolate->heap(); 116 Heap* heap = isolate->heap();
114 Dart_EnterScope(); 117 Dart_EnterScope();
115 Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL); 118 Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL);
116 EXPECT_VALID(result); 119 EXPECT_VALID(result);
117 EXPECT(!Dart_IsNull(result)); 120 EXPECT(!Dart_IsNull(result));
121 TransitionNativeToVM transition(thread);
118 Library& lib = Library::Handle(); 122 Library& lib = Library::Handle();
119 lib ^= Api::UnwrapHandle(h_lib); 123 lib ^= Api::UnwrapHandle(h_lib);
120 EXPECT(!lib.IsNull()); 124 EXPECT(!lib.IsNull());
121 const Class& cls = Class::Handle(GetClass(lib, "A")); 125 const Class& cls = Class::Handle(GetClass(lib, "A"));
122 ASSERT(!cls.IsNull()); 126 ASSERT(!cls.IsNull());
123 intptr_t cid = cls.id(); 127 intptr_t cid = cls.id();
124 ClassHeapStats* class_stats = 128 ClassHeapStats* class_stats =
125 ClassHeapStatsTestHelper::GetHeapStatsForCid(class_table, 129 ClassHeapStatsTestHelper::GetHeapStatsForCid(class_table,
126 cid); 130 cid);
127 // Verify preconditions: 131 // Verify preconditions:
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 const String& obj = String::Handle(String::New("x", Heap::kOld)); 284 const String& obj = String::Handle(String::New("x", Heap::kOld));
281 Heap* heap = Thread::Current()->isolate()->heap(); 285 Heap* heap = Thread::Current()->isolate()->heap();
282 EXPECT(heap->Contains(RawObject::ToAddr(obj.raw()))); 286 EXPECT(heap->Contains(RawObject::ToAddr(obj.raw())));
283 heap->WriteProtect(true, true /* include_code_pages */); 287 heap->WriteProtect(true, true /* include_code_pages */);
284 EXPECT(heap->Contains(RawObject::ToAddr(obj.raw()))); 288 EXPECT(heap->Contains(RawObject::ToAddr(obj.raw())));
285 heap->WriteProtect(false, true /* include_code_pages */); 289 heap->WriteProtect(false, true /* include_code_pages */);
286 EXPECT(heap->Contains(RawObject::ToAddr(obj.raw()))); 290 EXPECT(heap->Contains(RawObject::ToAddr(obj.raw())));
287 } 291 }
288 292
289 } // namespace dart. 293 } // namespace dart.
OLDNEW
« no previous file with comments | « runtime/vm/heap.cc ('k') | runtime/vm/intermediate_language_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698