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

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

Issue 487973002: Track per-class promotion stats. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/heap.cc ('k') | no next file » | 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"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 EXPECT_EQ(2, class_stats->pre_gc.new_count); 121 EXPECT_EQ(2, class_stats->pre_gc.new_count);
122 // Only one survived. 122 // Only one survived.
123 EXPECT_EQ(1, class_stats->post_gc.new_count); 123 EXPECT_EQ(1, class_stats->post_gc.new_count);
124 EXPECT_EQ(0, class_stats->recent.new_count); 124 EXPECT_EQ(0, class_stats->recent.new_count);
125 // Perform GC. The following is heavily dependent on the behaviour 125 // Perform GC. The following is heavily dependent on the behaviour
126 // of the GC: Retained instance of A will be promoted. 126 // of the GC: Retained instance of A will be promoted.
127 heap->CollectGarbage(Heap::kNew); 127 heap->CollectGarbage(Heap::kNew);
128 // Verify postconditions: 128 // Verify postconditions:
129 EXPECT_EQ(0, class_stats->pre_gc.old_count); 129 EXPECT_EQ(0, class_stats->pre_gc.old_count);
130 EXPECT_EQ(0, class_stats->post_gc.old_count); 130 EXPECT_EQ(0, class_stats->post_gc.old_count);
131 // One promoted instance.
132 EXPECT_EQ(1, class_stats->promoted_count);
131 // Promotion counted as an allocation from old space. 133 // Promotion counted as an allocation from old space.
132 EXPECT_EQ(1, class_stats->recent.old_count); 134 EXPECT_EQ(1, class_stats->recent.old_count);
133 // There was one instance allocated before GC. 135 // There was one instance allocated before GC.
134 EXPECT_EQ(1, class_stats->pre_gc.new_count); 136 EXPECT_EQ(1, class_stats->pre_gc.new_count);
135 // There are no instances allocated in new space after GC. 137 // There are no instances allocated in new space after GC.
136 EXPECT_EQ(0, class_stats->post_gc.new_count); 138 EXPECT_EQ(0, class_stats->post_gc.new_count);
137 // No new allocations. 139 // No new allocations.
138 EXPECT_EQ(0, class_stats->recent.new_count); 140 EXPECT_EQ(0, class_stats->recent.new_count);
139 // Perform a GC on new space. 141 // Perform a GC on new space.
140 heap->CollectGarbage(Heap::kNew); 142 heap->CollectGarbage(Heap::kNew);
141 // There were no instances allocated before GC. 143 // There were no instances allocated before GC.
142 EXPECT_EQ(0, class_stats->pre_gc.new_count); 144 EXPECT_EQ(0, class_stats->pre_gc.new_count);
143 // There are no instances allocated in new space after GC. 145 // There are no instances allocated in new space after GC.
144 EXPECT_EQ(0, class_stats->post_gc.new_count); 146 EXPECT_EQ(0, class_stats->post_gc.new_count);
145 // No new allocations. 147 // No new allocations.
146 EXPECT_EQ(0, class_stats->recent.new_count); 148 EXPECT_EQ(0, class_stats->recent.new_count);
149 // Nothing was promoted.
150 EXPECT_EQ(0, class_stats->promoted_count);
147 heap->CollectGarbage(Heap::kOld); 151 heap->CollectGarbage(Heap::kOld);
148 // Verify postconditions: 152 // Verify postconditions:
149 EXPECT_EQ(1, class_stats->pre_gc.old_count); 153 EXPECT_EQ(1, class_stats->pre_gc.old_count);
150 EXPECT_EQ(1, class_stats->post_gc.old_count); 154 EXPECT_EQ(1, class_stats->post_gc.old_count);
151 EXPECT_EQ(0, class_stats->recent.old_count); 155 EXPECT_EQ(0, class_stats->recent.old_count);
152 // Exit scope, freeing instance. 156 // Exit scope, freeing instance.
153 Dart_ExitScope(); 157 Dart_ExitScope();
154 // Perform GC. 158 // Perform GC.
155 heap->CollectGarbage(Heap::kOld); 159 heap->CollectGarbage(Heap::kOld);
156 // Verify postconditions: 160 // Verify postconditions:
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 } 206 }
203 } 207 }
204 { 208 {
205 NoGCScope no_gc; 209 NoGCScope no_gc;
206 FindNothing find_nothing; 210 FindNothing find_nothing;
207 EXPECT(Object::null() == heap->FindObject(&find_nothing)); 211 EXPECT(Object::null() == heap->FindObject(&find_nothing));
208 } 212 }
209 } 213 }
210 214
211 } // namespace dart. 215 } // namespace dart.
OLDNEW
« no previous file with comments | « runtime/vm/heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698