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

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: Created 9 years, 2 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
« src/heap.cc ('K') | « 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 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 intptr_t delta = size_of_objects_2 - size_of_objects_1; 1215 intptr_t delta = size_of_objects_2 - size_of_objects_1;
1216 PrintF("Heap::SizeOfObjects: %" V8_PTR_PREFIX "d, " 1216 PrintF("Heap::SizeOfObjects: %" V8_PTR_PREFIX "d, "
1217 "Iterator: %" V8_PTR_PREFIX "d, " 1217 "Iterator: %" V8_PTR_PREFIX "d, "
1218 "delta: %" V8_PTR_PREFIX "d\n", 1218 "delta: %" V8_PTR_PREFIX "d\n",
1219 size_of_objects_1, size_of_objects_2, delta); 1219 size_of_objects_1, size_of_objects_2, delta);
1220 CHECK_GT(size_of_objects_2 / 20, delta); 1220 CHECK_GT(size_of_objects_2 / 20, delta);
1221 } 1221 }
1222 } 1222 }
1223 1223
1224 1224
1225 static void FillUpNewSpace(NewSpace* new_space) {
1226 // Fill up new space to the point that it is completely full. Make sure
1227 // that the scavenger does not undo the filling.
1228 v8::HandleScope scope;
1229 AlwaysAllocateScope always_allocate;
1230 intptr_t available = new_space->EffectiveCapacity() - new_space->Size();
1231 intptr_t number_of_fillers = (available / FixedArray::SizeFor(1000)) - 10;
1232 for (intptr_t i = 0; i < number_of_fillers; i++) {
1233 CHECK(HEAP->InNewSpace(*FACTORY->NewFixedArray(1000, NOT_TENURED)));
1234 }
1235 }
1236
1237
1225 TEST(GrowAndShrinkNewSpace) { 1238 TEST(GrowAndShrinkNewSpace) {
1226 InitializeVM(); 1239 InitializeVM();
1227 NewSpace* new_space = HEAP->new_space(); 1240 NewSpace* new_space = HEAP->new_space();
1228 1241
1229 // Explicitly growing should double the space capacity. 1242 // Explicitly growing should double the space capacity.
1230 intptr_t old_capacity, new_capacity; 1243 intptr_t old_capacity, new_capacity;
1231 old_capacity = new_space->Capacity(); 1244 old_capacity = new_space->Capacity();
1232 new_space->Grow(); 1245 new_space->Grow();
1233 new_capacity = new_space->Capacity(); 1246 new_capacity = new_space->Capacity();
1234 CHECK(2 * old_capacity == new_capacity); 1247 CHECK(2 * old_capacity == new_capacity);
1235 1248
1236 // Fill up new space to the point that it is completely full. Make sure
1237 // that the scavenger does not undo the filling.
1238 old_capacity = new_space->Capacity(); 1249 old_capacity = new_space->Capacity();
1239 { 1250 FillUpNewSpace(new_space);
1240 v8::HandleScope scope;
1241 AlwaysAllocateScope always_allocate;
1242 intptr_t available = new_space->EffectiveCapacity() - new_space->Size();
1243 intptr_t number_of_fillers = (available / FixedArray::SizeFor(1000)) - 10;
1244 for (intptr_t i = 0; i < number_of_fillers; i++) {
1245 CHECK(HEAP->InNewSpace(*FACTORY->NewFixedArray(1000, NOT_TENURED)));
1246 }
1247 }
1248 new_capacity = new_space->Capacity(); 1251 new_capacity = new_space->Capacity();
1249 CHECK(old_capacity == new_capacity); 1252 CHECK(old_capacity == new_capacity);
1250 1253
1251 // Explicitly shrinking should not affect space capacity. 1254 // Explicitly shrinking should not affect space capacity.
1252 old_capacity = new_space->Capacity(); 1255 old_capacity = new_space->Capacity();
1253 new_space->Shrink(); 1256 new_space->Shrink();
1254 new_capacity = new_space->Capacity(); 1257 new_capacity = new_space->Capacity();
1255 CHECK(old_capacity == new_capacity); 1258 CHECK(old_capacity == new_capacity);
1256 1259
1257 // Let the scavenger empty the new space. 1260 // Let the scavenger empty the new space.
1258 HEAP->CollectGarbage(NEW_SPACE); 1261 HEAP->CollectGarbage(NEW_SPACE);
1259 CHECK_LE(new_space->Size(), old_capacity); 1262 CHECK_LE(new_space->Size(), old_capacity);
1260 1263
1261 // Explicitly shrinking should halve the space capacity. 1264 // Explicitly shrinking should halve the space capacity.
1262 old_capacity = new_space->Capacity(); 1265 old_capacity = new_space->Capacity();
1263 new_space->Shrink(); 1266 new_space->Shrink();
1264 new_capacity = new_space->Capacity(); 1267 new_capacity = new_space->Capacity();
1265 CHECK(old_capacity == 2 * new_capacity); 1268 CHECK(old_capacity == 2 * new_capacity);
1266 1269
1267 // Consecutive shrinking should not affect space capacity. 1270 // Consecutive shrinking should not affect space capacity.
1268 old_capacity = new_space->Capacity(); 1271 old_capacity = new_space->Capacity();
1269 new_space->Shrink(); 1272 new_space->Shrink();
1270 new_space->Shrink(); 1273 new_space->Shrink();
1271 new_space->Shrink(); 1274 new_space->Shrink();
1272 new_capacity = new_space->Capacity(); 1275 new_capacity = new_space->Capacity();
1273 CHECK(old_capacity == new_capacity); 1276 CHECK(old_capacity == new_capacity);
1274 } 1277 }
1278
1279
1280 TEST(CollectingAllAvailableGarbageShrinksNewSpace) {
1281 InitializeVM();
1282 v8::HandleScope scope;
1283 NewSpace* new_space = HEAP->new_space();
1284 intptr_t old_capacity, new_capacity;
1285 old_capacity = new_space->Capacity();
1286 new_space->Grow();
1287 new_capacity = new_space->Capacity();
1288 CHECK(2 * old_capacity == new_capacity);
1289 FillUpNewSpace(new_space);
1290 HEAP->CollectAllAvailableGarbage();
1291 new_capacity = new_space->Capacity();
1292 CHECK(old_capacity == new_capacity);
1293 }
OLDNEW
« src/heap.cc ('K') | « src/incremental-marking.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698