OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/base/atomicops.h" | 7 #include "src/base/atomicops.h" |
8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/compilation-cache.h" | 10 #include "src/compilation-cache.h" |
(...skipping 3336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3347 for (int i = 0; i < npages; i++) { | 3347 for (int i = 0; i < npages; i++) { |
3348 Page* p = evacuation_candidates_[i]; | 3348 Page* p = evacuation_candidates_[i]; |
3349 DCHECK(p->IsEvacuationCandidate() || | 3349 DCHECK(p->IsEvacuationCandidate() || |
3350 p->IsFlagSet(Page::RESCAN_ON_EVACUATION)); | 3350 p->IsFlagSet(Page::RESCAN_ON_EVACUATION)); |
3351 DCHECK(static_cast<int>(p->parallel_sweeping()) == | 3351 DCHECK(static_cast<int>(p->parallel_sweeping()) == |
3352 MemoryChunk::SWEEPING_DONE); | 3352 MemoryChunk::SWEEPING_DONE); |
3353 PagedSpace* space = static_cast<PagedSpace*>(p->owner()); | 3353 PagedSpace* space = static_cast<PagedSpace*>(p->owner()); |
3354 // Allocate emergency memory for the case when compaction fails due to out | 3354 // Allocate emergency memory for the case when compaction fails due to out |
3355 // of memory. | 3355 // of memory. |
3356 if (!space->HasEmergencyMemory()) { | 3356 if (!space->HasEmergencyMemory()) { |
3357 space->CreateEmergencyMemory(); | 3357 space->CreateEmergencyMemory(); // If the OS lets us. |
3358 } | 3358 } |
3359 if (p->IsEvacuationCandidate()) { | 3359 if (p->IsEvacuationCandidate()) { |
3360 // During compaction we might have to request a new page. Check that we | 3360 // During compaction we might have to request a new page in order to free |
3361 // have an emergency page and the space still has room for that. | 3361 // up a page. Check that we actually got an emergency page above so we |
3362 if (space->HasEmergencyMemory() || space->CanExpand()) { | 3362 // can guarantee that this succeeds. |
| 3363 if (space->HasEmergencyMemory()) { |
3363 EvacuateLiveObjectsFromPage(p); | 3364 EvacuateLiveObjectsFromPage(p); |
3364 // Unlink the page from the list of pages here. We must not iterate | 3365 // Unlink the page from the list of pages here. We must not iterate |
3365 // over that page later (e.g. when scan on scavenge pages are | 3366 // over that page later (e.g. when scan on scavenge pages are |
3366 // processed). The page itself will be freed later and is still | 3367 // processed). The page itself will be freed later and is still |
3367 // reachable from the evacuation candidates list. | 3368 // reachable from the evacuation candidates list. |
3368 p->Unlink(); | 3369 p->Unlink(); |
3369 } else { | 3370 } else { |
3370 // Without room for expansion evacuation is not guaranteed to succeed. | 3371 // Without room for expansion evacuation is not guaranteed to succeed. |
3371 // Pessimistically abandon unevacuated pages. | 3372 // Pessimistically abandon unevacuated pages. |
3372 for (int j = i; j < npages; j++) { | 3373 for (int j = i; j < npages; j++) { |
(...skipping 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4797 SlotsBuffer* buffer = *buffer_address; | 4798 SlotsBuffer* buffer = *buffer_address; |
4798 while (buffer != NULL) { | 4799 while (buffer != NULL) { |
4799 SlotsBuffer* next_buffer = buffer->next(); | 4800 SlotsBuffer* next_buffer = buffer->next(); |
4800 DeallocateBuffer(buffer); | 4801 DeallocateBuffer(buffer); |
4801 buffer = next_buffer; | 4802 buffer = next_buffer; |
4802 } | 4803 } |
4803 *buffer_address = NULL; | 4804 *buffer_address = NULL; |
4804 } | 4805 } |
4805 } | 4806 } |
4806 } // namespace v8::internal | 4807 } // namespace v8::internal |
OLD | NEW |