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

Side by Side Diff: test/cctest/test-heap.cc

Issue 8065003: Shrink the new space and uncommit marking deque on low memory notification. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased Created 9 years, 1 month 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 | « src/incremental-marking.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 2
3 #include <stdlib.h> 3 #include <stdlib.h>
4 4
5 #include "v8.h" 5 #include "v8.h"
6 6
7 #include "execution.h" 7 #include "execution.h"
8 #include "factory.h" 8 #include "factory.h"
9 #include "macro-assembler.h" 9 #include "macro-assembler.h"
10 #include "global-handles.h" 10 #include "global-handles.h"
(...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 intptr_t delta = size_of_objects_2 - size_of_objects_1; 1213 intptr_t delta = size_of_objects_2 - size_of_objects_1;
1214 PrintF("Heap::SizeOfObjects: %" V8_PTR_PREFIX "d, " 1214 PrintF("Heap::SizeOfObjects: %" V8_PTR_PREFIX "d, "
1215 "Iterator: %" V8_PTR_PREFIX "d, " 1215 "Iterator: %" V8_PTR_PREFIX "d, "
1216 "delta: %" V8_PTR_PREFIX "d\n", 1216 "delta: %" V8_PTR_PREFIX "d\n",
1217 size_of_objects_1, size_of_objects_2, delta); 1217 size_of_objects_1, size_of_objects_2, delta);
1218 CHECK_GT(size_of_objects_2 / 20, delta); 1218 CHECK_GT(size_of_objects_2 / 20, delta);
1219 } 1219 }
1220 } 1220 }
1221 1221
1222 1222
1223 static void FillUpNewSpace(NewSpace* new_space) {
1224 // Fill up new space to the point that it is completely full. Make sure
1225 // that the scavenger does not undo the filling.
1226 v8::HandleScope scope;
1227 AlwaysAllocateScope always_allocate;
1228 intptr_t available = new_space->EffectiveCapacity() - new_space->Size();
1229 intptr_t number_of_fillers = (available / FixedArray::SizeFor(1000)) - 10;
1230 for (intptr_t i = 0; i < number_of_fillers; i++) {
1231 CHECK(HEAP->InNewSpace(*FACTORY->NewFixedArray(1000, NOT_TENURED)));
1232 }
1233 }
1234
1235
1223 TEST(GrowAndShrinkNewSpace) { 1236 TEST(GrowAndShrinkNewSpace) {
1224 InitializeVM(); 1237 InitializeVM();
1225 NewSpace* new_space = HEAP->new_space(); 1238 NewSpace* new_space = HEAP->new_space();
1226 1239
1227 // Explicitly growing should double the space capacity. 1240 // Explicitly growing should double the space capacity.
1228 intptr_t old_capacity, new_capacity; 1241 intptr_t old_capacity, new_capacity;
1229 old_capacity = new_space->Capacity(); 1242 old_capacity = new_space->Capacity();
1230 new_space->Grow(); 1243 new_space->Grow();
1231 new_capacity = new_space->Capacity(); 1244 new_capacity = new_space->Capacity();
1232 CHECK(2 * old_capacity == new_capacity); 1245 CHECK(2 * old_capacity == new_capacity);
1233 1246
1234 // Fill up new space to the point that it is completely full. Make sure
1235 // that the scavenger does not undo the filling.
1236 old_capacity = new_space->Capacity(); 1247 old_capacity = new_space->Capacity();
1237 { 1248 FillUpNewSpace(new_space);
1238 v8::HandleScope scope;
1239 AlwaysAllocateScope always_allocate;
1240 intptr_t available = new_space->EffectiveCapacity() - new_space->Size();
1241 intptr_t number_of_fillers = (available / FixedArray::SizeFor(1000)) - 10;
1242 for (intptr_t i = 0; i < number_of_fillers; i++) {
1243 CHECK(HEAP->InNewSpace(*FACTORY->NewFixedArray(1000, NOT_TENURED)));
1244 }
1245 }
1246 new_capacity = new_space->Capacity(); 1249 new_capacity = new_space->Capacity();
1247 CHECK(old_capacity == new_capacity); 1250 CHECK(old_capacity == new_capacity);
1248 1251
1249 // Explicitly shrinking should not affect space capacity. 1252 // Explicitly shrinking should not affect space capacity.
1250 old_capacity = new_space->Capacity(); 1253 old_capacity = new_space->Capacity();
1251 new_space->Shrink(); 1254 new_space->Shrink();
1252 new_capacity = new_space->Capacity(); 1255 new_capacity = new_space->Capacity();
1253 CHECK(old_capacity == new_capacity); 1256 CHECK(old_capacity == new_capacity);
1254 1257
1255 // Let the scavenger empty the new space. 1258 // Let the scavenger empty the new space.
1256 HEAP->CollectGarbage(NEW_SPACE); 1259 HEAP->CollectGarbage(NEW_SPACE);
1257 CHECK_LE(new_space->Size(), old_capacity); 1260 CHECK_LE(new_space->Size(), old_capacity);
1258 1261
1259 // Explicitly shrinking should halve the space capacity. 1262 // Explicitly shrinking should halve the space capacity.
1260 old_capacity = new_space->Capacity(); 1263 old_capacity = new_space->Capacity();
1261 new_space->Shrink(); 1264 new_space->Shrink();
1262 new_capacity = new_space->Capacity(); 1265 new_capacity = new_space->Capacity();
1263 CHECK(old_capacity == 2 * new_capacity); 1266 CHECK(old_capacity == 2 * new_capacity);
1264 1267
1265 // Consecutive shrinking should not affect space capacity. 1268 // Consecutive shrinking should not affect space capacity.
1266 old_capacity = new_space->Capacity(); 1269 old_capacity = new_space->Capacity();
1267 new_space->Shrink(); 1270 new_space->Shrink();
1268 new_space->Shrink(); 1271 new_space->Shrink();
1269 new_space->Shrink(); 1272 new_space->Shrink();
1270 new_capacity = new_space->Capacity(); 1273 new_capacity = new_space->Capacity();
1271 CHECK(old_capacity == new_capacity); 1274 CHECK(old_capacity == new_capacity);
1272 } 1275 }
1276
1277
1278 TEST(CollectingAllAvailableGarbageShrinksNewSpace) {
1279 InitializeVM();
1280 v8::HandleScope scope;
1281 NewSpace* new_space = HEAP->new_space();
1282 intptr_t old_capacity, new_capacity;
1283 old_capacity = new_space->Capacity();
1284 new_space->Grow();
1285 new_capacity = new_space->Capacity();
1286 CHECK(2 * old_capacity == new_capacity);
1287 FillUpNewSpace(new_space);
1288 HEAP->CollectAllAvailableGarbage();
1289 new_capacity = new_space->Capacity();
1290 CHECK(old_capacity == new_capacity);
1291 }
OLDNEW
« no previous file with comments | « src/incremental-marking.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698