OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 CHECK(compaction_space != NULL); | 422 CHECK(compaction_space != NULL); |
423 CHECK(compaction_space->SetUp()); | 423 CHECK(compaction_space->SetUp()); |
424 | 424 |
425 OldSpace* old_space = new OldSpace(heap, OLD_SPACE, NOT_EXECUTABLE); | 425 OldSpace* old_space = new OldSpace(heap, OLD_SPACE, NOT_EXECUTABLE); |
426 CHECK(old_space != NULL); | 426 CHECK(old_space != NULL); |
427 CHECK(old_space->SetUp()); | 427 CHECK(old_space->SetUp()); |
428 | 428 |
429 // Cannot loop until "Available()" since we initially have 0 bytes available | 429 // Cannot loop until "Available()" since we initially have 0 bytes available |
430 // and would thus neither grow, nor be able to allocate an object. | 430 // and would thus neither grow, nor be able to allocate an object. |
431 const int kNumObjects = 100; | 431 const int kNumObjects = 100; |
432 const int kExpectedPages = (kNumObjects / (compaction_space->AreaSize() / | 432 const int kNumObjectsPerPage = |
433 Page::kMaxRegularHeapObjectSize)); | 433 compaction_space->AreaSize() / Page::kMaxRegularHeapObjectSize; |
| 434 const int kExpectedPages = |
| 435 (kNumObjects + kNumObjectsPerPage - 1) / kNumObjectsPerPage; |
434 for (int i = 0; i < kNumObjects; i++) { | 436 for (int i = 0; i < kNumObjects; i++) { |
435 compaction_space->AllocateRawUnaligned(Page::kMaxRegularHeapObjectSize) | 437 compaction_space->AllocateRawUnaligned(Page::kMaxRegularHeapObjectSize) |
436 .ToObjectChecked(); | 438 .ToObjectChecked(); |
437 } | 439 } |
438 int pages_in_old_space = old_space->CountTotalPages(); | 440 int pages_in_old_space = old_space->CountTotalPages(); |
439 int pages_in_compaction_space = compaction_space->CountTotalPages(); | 441 int pages_in_compaction_space = compaction_space->CountTotalPages(); |
440 CHECK_EQ(pages_in_compaction_space, kExpectedPages); | 442 CHECK_EQ(pages_in_compaction_space, kExpectedPages); |
441 CHECK_LE(pages_in_old_space, 1); | 443 CHECK_LE(pages_in_old_space, 1); |
442 | 444 |
443 old_space->MergeCompactionSpace(compaction_space); | 445 old_space->MergeCompactionSpace(compaction_space); |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 | 785 |
784 // Turn the allocation into a proper object so isolate teardown won't | 786 // Turn the allocation into a proper object so isolate teardown won't |
785 // crash. | 787 // crash. |
786 HeapObject* free_space = NULL; | 788 HeapObject* free_space = NULL; |
787 CHECK(allocation.To(&free_space)); | 789 CHECK(allocation.To(&free_space)); |
788 new_space->heap()->CreateFillerObjectAt(free_space->address(), 80); | 790 new_space->heap()->CreateFillerObjectAt(free_space->address(), 80); |
789 } | 791 } |
790 } | 792 } |
791 isolate->Dispose(); | 793 isolate->Dispose(); |
792 } | 794 } |
OLD | NEW |