| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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/heap/spaces.h" | 5 #include "src/heap/spaces.h" |
| 6 | 6 |
| 7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
| 8 #include "src/base/platform/platform.h" | 8 #include "src/base/platform/platform.h" |
| 9 #include "src/full-codegen/full-codegen.h" | 9 #include "src/full-codegen/full-codegen.h" |
| 10 #include "src/heap/slot-set.h" | 10 #include "src/heap/slot-set.h" |
| (...skipping 1414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1425 } | 1425 } |
| 1426 } | 1426 } |
| 1427 DCHECK_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_); | 1427 DCHECK_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_); |
| 1428 } | 1428 } |
| 1429 | 1429 |
| 1430 | 1430 |
| 1431 void LocalAllocationBuffer::Close() { | 1431 void LocalAllocationBuffer::Close() { |
| 1432 if (IsValid()) { | 1432 if (IsValid()) { |
| 1433 heap_->CreateFillerObjectAt( | 1433 heap_->CreateFillerObjectAt( |
| 1434 allocation_info_.top(), | 1434 allocation_info_.top(), |
| 1435 static_cast<int>(allocation_info_.limit() - allocation_info_.top())); | 1435 static_cast<int>(allocation_info_.limit() - allocation_info_.top()), |
| 1436 ClearRecordedSlots::kNo); |
| 1436 } | 1437 } |
| 1437 } | 1438 } |
| 1438 | 1439 |
| 1439 | 1440 |
| 1440 LocalAllocationBuffer::LocalAllocationBuffer(Heap* heap, | 1441 LocalAllocationBuffer::LocalAllocationBuffer(Heap* heap, |
| 1441 AllocationInfo allocation_info) | 1442 AllocationInfo allocation_info) |
| 1442 : heap_(heap), allocation_info_(allocation_info) { | 1443 : heap_(heap), allocation_info_(allocation_info) { |
| 1443 if (IsValid()) { | 1444 if (IsValid()) { |
| 1444 heap_->CreateFillerObjectAt( | 1445 heap_->CreateFillerObjectAt( |
| 1445 allocation_info_.top(), | 1446 allocation_info_.top(), |
| 1446 static_cast<int>(allocation_info_.limit() - allocation_info_.top())); | 1447 static_cast<int>(allocation_info_.limit() - allocation_info_.top()), |
| 1448 ClearRecordedSlots::kNo); |
| 1447 } | 1449 } |
| 1448 } | 1450 } |
| 1449 | 1451 |
| 1450 | 1452 |
| 1451 LocalAllocationBuffer::LocalAllocationBuffer( | 1453 LocalAllocationBuffer::LocalAllocationBuffer( |
| 1452 const LocalAllocationBuffer& other) { | 1454 const LocalAllocationBuffer& other) { |
| 1453 *this = other; | 1455 *this = other; |
| 1454 } | 1456 } |
| 1455 | 1457 |
| 1456 | 1458 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1519 return false; | 1521 return false; |
| 1520 } | 1522 } |
| 1521 | 1523 |
| 1522 // Clear remainder of current page. | 1524 // Clear remainder of current page. |
| 1523 Address limit = NewSpacePage::FromLimit(top)->area_end(); | 1525 Address limit = NewSpacePage::FromLimit(top)->area_end(); |
| 1524 if (heap()->gc_state() == Heap::SCAVENGE) { | 1526 if (heap()->gc_state() == Heap::SCAVENGE) { |
| 1525 heap()->promotion_queue()->SetNewLimit(limit); | 1527 heap()->promotion_queue()->SetNewLimit(limit); |
| 1526 } | 1528 } |
| 1527 | 1529 |
| 1528 int remaining_in_page = static_cast<int>(limit - top); | 1530 int remaining_in_page = static_cast<int>(limit - top); |
| 1529 heap()->CreateFillerObjectAt(top, remaining_in_page); | 1531 heap()->CreateFillerObjectAt(top, remaining_in_page, ClearRecordedSlots::kNo); |
| 1530 pages_used_++; | 1532 pages_used_++; |
| 1531 UpdateAllocationInfo(); | 1533 UpdateAllocationInfo(); |
| 1532 | 1534 |
| 1533 return true; | 1535 return true; |
| 1534 } | 1536 } |
| 1535 | 1537 |
| 1536 | 1538 |
| 1537 bool NewSpace::AddFreshPageSynchronized() { | 1539 bool NewSpace::AddFreshPageSynchronized() { |
| 1538 base::LockGuard<base::Mutex> guard(&mutex_); | 1540 base::LockGuard<base::Mutex> guard(&mutex_); |
| 1539 return AddFreshPage(); | 1541 return AddFreshPage(); |
| (...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2355 for (int i = kFirstCategory; i < kNumberOfCategories; i++) { | 2357 for (int i = kFirstCategory; i < kNumberOfCategories; i++) { |
| 2356 category_[i].Reset(); | 2358 category_[i].Reset(); |
| 2357 } | 2359 } |
| 2358 ResetStats(); | 2360 ResetStats(); |
| 2359 } | 2361 } |
| 2360 | 2362 |
| 2361 | 2363 |
| 2362 int FreeList::Free(Address start, int size_in_bytes) { | 2364 int FreeList::Free(Address start, int size_in_bytes) { |
| 2363 if (size_in_bytes == 0) return 0; | 2365 if (size_in_bytes == 0) return 0; |
| 2364 | 2366 |
| 2365 owner()->heap()->CreateFillerObjectAt(start, size_in_bytes); | 2367 owner()->heap()->CreateFillerObjectAt(start, size_in_bytes, |
| 2368 ClearRecordedSlots::kNo); |
| 2366 | 2369 |
| 2367 Page* page = Page::FromAddress(start); | 2370 Page* page = Page::FromAddress(start); |
| 2368 | 2371 |
| 2369 // Early return to drop too-small blocks on the floor. | 2372 // Early return to drop too-small blocks on the floor. |
| 2370 if (size_in_bytes <= kSmallListMin) { | 2373 if (size_in_bytes <= kSmallListMin) { |
| 2371 page->add_wasted_memory(size_in_bytes); | 2374 page->add_wasted_memory(size_in_bytes); |
| 2372 wasted_bytes_ += size_in_bytes; | 2375 wasted_bytes_ += size_in_bytes; |
| 2373 return size_in_bytes; | 2376 return size_in_bytes; |
| 2374 } | 2377 } |
| 2375 | 2378 |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2653 void PagedSpace::RepairFreeListsAfterDeserialization() { | 2656 void PagedSpace::RepairFreeListsAfterDeserialization() { |
| 2654 free_list_.RepairLists(heap()); | 2657 free_list_.RepairLists(heap()); |
| 2655 // Each page may have a small free space that is not tracked by a free list. | 2658 // Each page may have a small free space that is not tracked by a free list. |
| 2656 // Update the maps for those free space objects. | 2659 // Update the maps for those free space objects. |
| 2657 PageIterator iterator(this); | 2660 PageIterator iterator(this); |
| 2658 while (iterator.has_next()) { | 2661 while (iterator.has_next()) { |
| 2659 Page* page = iterator.next(); | 2662 Page* page = iterator.next(); |
| 2660 int size = static_cast<int>(page->wasted_memory()); | 2663 int size = static_cast<int>(page->wasted_memory()); |
| 2661 if (size == 0) continue; | 2664 if (size == 0) continue; |
| 2662 Address address = page->OffsetToAddress(Page::kPageSize - size); | 2665 Address address = page->OffsetToAddress(Page::kPageSize - size); |
| 2663 heap()->CreateFillerObjectAt(address, size); | 2666 heap()->CreateFillerObjectAt(address, size, ClearRecordedSlots::kNo); |
| 2664 } | 2667 } |
| 2665 } | 2668 } |
| 2666 | 2669 |
| 2667 | 2670 |
| 2668 void PagedSpace::EvictEvacuationCandidatesFromLinearAllocationArea() { | 2671 void PagedSpace::EvictEvacuationCandidatesFromLinearAllocationArea() { |
| 2669 if (allocation_info_.top() >= allocation_info_.limit()) return; | 2672 if (allocation_info_.top() >= allocation_info_.limit()) return; |
| 2670 | 2673 |
| 2671 if (!Page::FromAllocationTop(allocation_info_.top())->CanAllocate()) { | 2674 if (!Page::FromAllocationTop(allocation_info_.top())->CanAllocate()) { |
| 2672 // Create filler object to keep page iterable if it was iterable. | 2675 // Create filler object to keep page iterable if it was iterable. |
| 2673 int remaining = | 2676 int remaining = |
| 2674 static_cast<int>(allocation_info_.limit() - allocation_info_.top()); | 2677 static_cast<int>(allocation_info_.limit() - allocation_info_.top()); |
| 2675 heap()->CreateFillerObjectAt(allocation_info_.top(), remaining); | 2678 heap()->CreateFillerObjectAt(allocation_info_.top(), remaining, |
| 2679 ClearRecordedSlots::kNo); |
| 2676 allocation_info_.Reset(nullptr, nullptr); | 2680 allocation_info_.Reset(nullptr, nullptr); |
| 2677 } | 2681 } |
| 2678 } | 2682 } |
| 2679 | 2683 |
| 2680 | 2684 |
| 2681 HeapObject* PagedSpace::SweepAndRetryAllocation(int size_in_bytes) { | 2685 HeapObject* PagedSpace::SweepAndRetryAllocation(int size_in_bytes) { |
| 2682 MarkCompactCollector* collector = heap()->mark_compact_collector(); | 2686 MarkCompactCollector* collector = heap()->mark_compact_collector(); |
| 2683 if (collector->sweeping_in_progress()) { | 2687 if (collector->sweeping_in_progress()) { |
| 2684 // Wait for the sweeper threads here and complete the sweeping phase. | 2688 // Wait for the sweeper threads here and complete the sweeping phase. |
| 2685 collector->EnsureSweepingCompleted(); | 2689 collector->EnsureSweepingCompleted(); |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3230 object->ShortPrint(); | 3234 object->ShortPrint(); |
| 3231 PrintF("\n"); | 3235 PrintF("\n"); |
| 3232 } | 3236 } |
| 3233 printf(" --------------------------------------\n"); | 3237 printf(" --------------------------------------\n"); |
| 3234 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3238 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
| 3235 } | 3239 } |
| 3236 | 3240 |
| 3237 #endif // DEBUG | 3241 #endif // DEBUG |
| 3238 } // namespace internal | 3242 } // namespace internal |
| 3239 } // namespace v8 | 3243 } // namespace v8 |
| OLD | NEW |