OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1268 for (intptr_t i = 0; i < number_of_fillers; i++) { | 1268 for (intptr_t i = 0; i < number_of_fillers; i++) { |
1269 CHECK(HEAP->InNewSpace(*FACTORY->NewFixedArray(32, NOT_TENURED))); | 1269 CHECK(HEAP->InNewSpace(*FACTORY->NewFixedArray(32, NOT_TENURED))); |
1270 } | 1270 } |
1271 } | 1271 } |
1272 | 1272 |
1273 | 1273 |
1274 TEST(GrowAndShrinkNewSpace) { | 1274 TEST(GrowAndShrinkNewSpace) { |
1275 InitializeVM(); | 1275 InitializeVM(); |
1276 NewSpace* new_space = HEAP->new_space(); | 1276 NewSpace* new_space = HEAP->new_space(); |
1277 | 1277 |
1278 if (HEAP->ReservedSemiSpaceSize() == HEAP->InitialSemiSpaceSize()) { | |
Michael Starzinger
2012/04/26 14:41:45
Shouldn't the test say something like "InitialSemi
| |
1279 // We can't test new space growing and shrinking if the max size | |
1280 // is the same as the minimum (initial) size. | |
1281 return; | |
1282 } | |
1283 | |
1278 // Explicitly growing should double the space capacity. | 1284 // Explicitly growing should double the space capacity. |
1279 intptr_t old_capacity, new_capacity; | 1285 intptr_t old_capacity, new_capacity; |
1280 old_capacity = new_space->Capacity(); | 1286 old_capacity = new_space->Capacity(); |
1281 new_space->Grow(); | 1287 new_space->Grow(); |
1282 new_capacity = new_space->Capacity(); | 1288 new_capacity = new_space->Capacity(); |
1283 CHECK(2 * old_capacity == new_capacity); | 1289 CHECK(2 * old_capacity == new_capacity); |
1284 | 1290 |
1285 old_capacity = new_space->Capacity(); | 1291 old_capacity = new_space->Capacity(); |
1286 FillUpNewSpace(new_space); | 1292 FillUpNewSpace(new_space); |
1287 new_capacity = new_space->Capacity(); | 1293 new_capacity = new_space->Capacity(); |
(...skipping 20 matching lines...) Expand all Loading... | |
1308 new_space->Shrink(); | 1314 new_space->Shrink(); |
1309 new_space->Shrink(); | 1315 new_space->Shrink(); |
1310 new_space->Shrink(); | 1316 new_space->Shrink(); |
1311 new_capacity = new_space->Capacity(); | 1317 new_capacity = new_space->Capacity(); |
1312 CHECK(old_capacity == new_capacity); | 1318 CHECK(old_capacity == new_capacity); |
1313 } | 1319 } |
1314 | 1320 |
1315 | 1321 |
1316 TEST(CollectingAllAvailableGarbageShrinksNewSpace) { | 1322 TEST(CollectingAllAvailableGarbageShrinksNewSpace) { |
1317 InitializeVM(); | 1323 InitializeVM(); |
1324 | |
1325 if (HEAP->ReservedSemiSpaceSize() == HEAP->InitialSemiSpaceSize()) { | |
1326 // We can't test new space growing and shrinking if the max size | |
1327 // is the same as the minimum (initial) size. | |
1328 return; | |
1329 } | |
1330 | |
1318 v8::HandleScope scope; | 1331 v8::HandleScope scope; |
1319 NewSpace* new_space = HEAP->new_space(); | 1332 NewSpace* new_space = HEAP->new_space(); |
1320 intptr_t old_capacity, new_capacity; | 1333 intptr_t old_capacity, new_capacity; |
1321 old_capacity = new_space->Capacity(); | 1334 old_capacity = new_space->Capacity(); |
1322 new_space->Grow(); | 1335 new_space->Grow(); |
1323 new_capacity = new_space->Capacity(); | 1336 new_capacity = new_space->Capacity(); |
1324 CHECK(2 * old_capacity == new_capacity); | 1337 CHECK(2 * old_capacity == new_capacity); |
1325 FillUpNewSpace(new_space); | 1338 FillUpNewSpace(new_space); |
1326 HEAP->CollectAllAvailableGarbage(); | 1339 HEAP->CollectAllAvailableGarbage(); |
1327 new_capacity = new_space->Capacity(); | 1340 new_capacity = new_space->Capacity(); |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1702 "f(1); f(2); f(3);" | 1715 "f(1); f(2); f(3);" |
1703 "%OptimizeFunctionOnNextCall(f);" | 1716 "%OptimizeFunctionOnNextCall(f);" |
1704 "f(4);"); | 1717 "f(4);"); |
1705 CHECK_EQ(4, res->ToObject()->GetRealNamedProperty(v8_str("x"))->Int32Value()); | 1718 CHECK_EQ(4, res->ToObject()->GetRealNamedProperty(v8_str("x"))->Int32Value()); |
1706 | 1719 |
1707 Handle<JSObject> o = | 1720 Handle<JSObject> o = |
1708 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 1721 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
1709 | 1722 |
1710 CHECK(HEAP->InNewSpace(*o)); | 1723 CHECK(HEAP->InNewSpace(*o)); |
1711 } | 1724 } |
OLD | NEW |