| 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 3331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3342 for (int i = 0; i < npages; i++) { | 3342 for (int i = 0; i < npages; i++) { |
| 3343 Page* p = evacuation_candidates_[i]; | 3343 Page* p = evacuation_candidates_[i]; |
| 3344 DCHECK(p->IsEvacuationCandidate() || | 3344 DCHECK(p->IsEvacuationCandidate() || |
| 3345 p->IsFlagSet(Page::RESCAN_ON_EVACUATION)); | 3345 p->IsFlagSet(Page::RESCAN_ON_EVACUATION)); |
| 3346 DCHECK(static_cast<int>(p->parallel_sweeping()) == | 3346 DCHECK(static_cast<int>(p->parallel_sweeping()) == |
| 3347 MemoryChunk::SWEEPING_DONE); | 3347 MemoryChunk::SWEEPING_DONE); |
| 3348 PagedSpace* space = static_cast<PagedSpace*>(p->owner()); | 3348 PagedSpace* space = static_cast<PagedSpace*>(p->owner()); |
| 3349 // Allocate emergency memory for the case when compaction fails due to out | 3349 // Allocate emergency memory for the case when compaction fails due to out |
| 3350 // of memory. | 3350 // of memory. |
| 3351 if (!space->HasEmergencyMemory()) { | 3351 if (!space->HasEmergencyMemory()) { |
| 3352 space->CreateEmergencyMemory(); | 3352 space->CreateEmergencyMemory(); // If the OS lets us. |
| 3353 } | 3353 } |
| 3354 if (p->IsEvacuationCandidate()) { | 3354 if (p->IsEvacuationCandidate()) { |
| 3355 // During compaction we might have to request a new page. Check that we | 3355 // During compaction we might have to request a new page in order to free |
| 3356 // have an emergency page and the space still has room for that. | 3356 // up a page. Check that we actually got an emergency page above so we |
| 3357 if (space->HasEmergencyMemory() || space->CanExpand()) { | 3357 // can guarantee that this succeeds. |
| 3358 if (space->HasEmergencyMemory()) { |
| 3358 EvacuateLiveObjectsFromPage(p); | 3359 EvacuateLiveObjectsFromPage(p); |
| 3359 // Unlink the page from the list of pages here. We must not iterate | 3360 // Unlink the page from the list of pages here. We must not iterate |
| 3360 // over that page later (e.g. when scan on scavenge pages are | 3361 // over that page later (e.g. when scan on scavenge pages are |
| 3361 // processed). The page itself will be freed later and is still | 3362 // processed). The page itself will be freed later and is still |
| 3362 // reachable from the evacuation candidates list. | 3363 // reachable from the evacuation candidates list. |
| 3363 p->Unlink(); | 3364 p->Unlink(); |
| 3364 } else { | 3365 } else { |
| 3365 // Without room for expansion evacuation is not guaranteed to succeed. | 3366 // Without room for expansion evacuation is not guaranteed to succeed. |
| 3366 // Pessimistically abandon unevacuated pages. | 3367 // Pessimistically abandon unevacuated pages. |
| 3367 for (int j = i; j < npages; j++) { | 3368 for (int j = i; j < npages; j++) { |
| (...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4761 SlotsBuffer* buffer = *buffer_address; | 4762 SlotsBuffer* buffer = *buffer_address; |
| 4762 while (buffer != NULL) { | 4763 while (buffer != NULL) { |
| 4763 SlotsBuffer* next_buffer = buffer->next(); | 4764 SlotsBuffer* next_buffer = buffer->next(); |
| 4764 DeallocateBuffer(buffer); | 4765 DeallocateBuffer(buffer); |
| 4765 buffer = next_buffer; | 4766 buffer = next_buffer; |
| 4766 } | 4767 } |
| 4767 *buffer_address = NULL; | 4768 *buffer_address = NULL; |
| 4768 } | 4769 } |
| 4769 } | 4770 } |
| 4770 } // namespace v8::internal | 4771 } // namespace v8::internal |
| OLD | NEW |