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

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

Issue 2984883002: Remove fields from Isolate in Product mode (Closed)
Patch Set: Address comments Created 3 years, 5 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/isolate.h » ('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/become.h" 8 #include "vm/become.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/globals.h" 10 #include "vm/globals.h"
11 #include "vm/heap.h" 11 #include "vm/heap.h"
12 #include "vm/unit_test.h" 12 #include "vm/unit_test.h"
13 13
14 namespace dart { 14 namespace dart {
15 15
16 TEST_CASE(OldGC) { 16 TEST_CASE(OldGC) {
17 const char* kScriptChars = 17 const char* kScriptChars =
18 "main() {\n" 18 "main() {\n"
19 " return [1, 2, 3];\n" 19 " return [1, 2, 3];\n"
20 "}\n"; 20 "}\n";
21 FLAG_verbose_gc = true; 21 NOT_IN_PRODUCT(FLAG_verbose_gc = true);
22 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 22 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
23 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); 23 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL);
24 24
25 EXPECT_VALID(result); 25 EXPECT_VALID(result);
26 EXPECT(!Dart_IsNull(result)); 26 EXPECT(!Dart_IsNull(result));
27 EXPECT(Dart_IsList(result)); 27 EXPECT(Dart_IsList(result));
28 TransitionNativeToVM transition(thread); 28 TransitionNativeToVM transition(thread);
29 Isolate* isolate = Isolate::Current(); 29 Isolate* isolate = Isolate::Current();
30 Heap* heap = isolate->heap(); 30 Heap* heap = isolate->heap();
31 heap->CollectGarbage(Heap::kOld); 31 heap->CollectGarbage(Heap::kOld);
(...skipping 11 matching lines...) Expand all
43 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); 43 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL);
44 44
45 EXPECT_VALID(result); 45 EXPECT_VALID(result);
46 EXPECT(!Dart_IsNull(result)); 46 EXPECT(!Dart_IsNull(result));
47 EXPECT(Dart_IsList(result)); 47 EXPECT(Dart_IsList(result));
48 TransitionNativeToVM transition(thread); 48 TransitionNativeToVM transition(thread);
49 Isolate* isolate = Isolate::Current(); 49 Isolate* isolate = Isolate::Current();
50 Heap* heap = isolate->heap(); 50 Heap* heap = isolate->heap();
51 heap->CollectGarbage(Heap::kOld); 51 heap->CollectGarbage(Heap::kOld);
52 } 52 }
53 #endif 53 #endif // !defined(PRODUCT)
54 54
55 TEST_CASE(LargeSweep) { 55 TEST_CASE(LargeSweep) {
56 const char* kScriptChars = 56 const char* kScriptChars =
57 "main() {\n" 57 "main() {\n"
58 " return new List(8 * 1024 * 1024);\n" 58 " return new List(8 * 1024 * 1024);\n"
59 "}\n"; 59 "}\n";
60 FLAG_verbose_gc = true; 60 NOT_IN_PRODUCT(FLAG_verbose_gc = true);
61 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 61 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
62 Dart_EnterScope(); 62 Dart_EnterScope();
63 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); 63 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL);
64 64
65 EXPECT_VALID(result); 65 EXPECT_VALID(result);
66 EXPECT(!Dart_IsNull(result)); 66 EXPECT(!Dart_IsNull(result));
67 EXPECT(Dart_IsList(result)); 67 EXPECT(Dart_IsList(result));
68 TransitionNativeToVM transition(thread); 68 TransitionNativeToVM transition(thread);
69 Isolate* isolate = Isolate::Current(); 69 Isolate* isolate = Isolate::Current();
70 Heap* heap = isolate->heap(); 70 Heap* heap = isolate->heap();
(...skipping 29 matching lines...) Expand all
100 const char* kScriptChars = 100 const char* kScriptChars =
101 "class A {\n" 101 "class A {\n"
102 " var a;\n" 102 " var a;\n"
103 " var b;\n" 103 " var b;\n"
104 "}\n" 104 "}\n"
105 "" 105 ""
106 "main() {\n" 106 "main() {\n"
107 " var x = new A();\n" 107 " var x = new A();\n"
108 " return new A();\n" 108 " return new A();\n"
109 "}\n"; 109 "}\n";
110 bool saved_concurrent_sweep_mode = FLAG_concurrent_sweep;
111 FLAG_concurrent_sweep = false;
110 Dart_Handle h_lib = TestCase::LoadTestScript(kScriptChars, NULL); 112 Dart_Handle h_lib = TestCase::LoadTestScript(kScriptChars, NULL);
111 Isolate* isolate = Isolate::Current(); 113 Isolate* isolate = Isolate::Current();
112 ClassTable* class_table = isolate->class_table(); 114 ClassTable* class_table = isolate->class_table();
113 Heap* heap = isolate->heap(); 115 Heap* heap = isolate->heap();
114 Dart_EnterScope(); 116 Dart_EnterScope();
115 Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL); 117 Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL);
116 EXPECT_VALID(result); 118 EXPECT_VALID(result);
117 EXPECT(!Dart_IsNull(result)); 119 EXPECT(!Dart_IsNull(result));
118 TransitionNativeToVM transition(thread); 120 TransitionNativeToVM transition(thread);
119 Library& lib = Library::Handle(); 121 Library& lib = Library::Handle();
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 heap->CollectGarbage(Heap::kOld); 182 heap->CollectGarbage(Heap::kOld);
181 // Verify postconditions: 183 // Verify postconditions:
182 EXPECT_EQ(1, class_stats->pre_gc.old_count); 184 EXPECT_EQ(1, class_stats->pre_gc.old_count);
183 EXPECT_EQ(0, class_stats->post_gc.old_count); 185 EXPECT_EQ(0, class_stats->post_gc.old_count);
184 EXPECT_EQ(0, class_stats->recent.old_count); 186 EXPECT_EQ(0, class_stats->recent.old_count);
185 // Perform GC. 187 // Perform GC.
186 heap->CollectGarbage(Heap::kOld); 188 heap->CollectGarbage(Heap::kOld);
187 EXPECT_EQ(0, class_stats->pre_gc.old_count); 189 EXPECT_EQ(0, class_stats->pre_gc.old_count);
188 EXPECT_EQ(0, class_stats->post_gc.old_count); 190 EXPECT_EQ(0, class_stats->post_gc.old_count);
189 EXPECT_EQ(0, class_stats->recent.old_count); 191 EXPECT_EQ(0, class_stats->recent.old_count);
192 FLAG_concurrent_sweep = saved_concurrent_sweep_mode;
190 } 193 }
191 194
192 TEST_CASE(ArrayHeapStats) { 195 TEST_CASE(ArrayHeapStats) {
193 const char* kScriptChars = 196 const char* kScriptChars =
194 "List f(int len) {\n" 197 "List f(int len) {\n"
195 " return new List(len);\n" 198 " return new List(len);\n"
196 "}\n" 199 "}\n"
197 "" 200 ""
198 "main() {\n" 201 "main() {\n"
199 " return f(1234);\n" 202 " return f(1234);\n"
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 545
543 heap->CollectAllGarbage(); 546 heap->CollectAllGarbage();
544 547
545 intptr_t size_after = 548 intptr_t size_after =
546 heap->new_space()->UsedInWords() + heap->old_space()->UsedInWords(); 549 heap->new_space()->UsedInWords() + heap->old_space()->UsedInWords();
547 550
548 EXPECT(size_before < size_after); 551 EXPECT(size_before < size_after);
549 } 552 }
550 553
551 } // namespace dart 554 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/heap.cc ('k') | runtime/vm/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698