OLD | NEW |
1 // Copyright 2006-2010 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2010 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 1541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1552 free_[rem].head_node_ = rem_node->address(); | 1552 free_[rem].head_node_ = rem_node->address(); |
1553 if (rem_node->next() == NULL) InsertSize(rem); | 1553 if (rem_node->next() == NULL) InsertSize(rem); |
1554 } | 1554 } |
1555 available_ -= size_in_bytes; | 1555 available_ -= size_in_bytes; |
1556 *wasted_bytes = 0; | 1556 *wasted_bytes = 0; |
1557 return cur_node; | 1557 return cur_node; |
1558 } | 1558 } |
1559 | 1559 |
1560 | 1560 |
1561 void OldSpaceFreeList::MarkNodes() { | 1561 void OldSpaceFreeList::MarkNodes() { |
| 1562 #if 0 |
1562 for (int i = 0; i < kFreeListsLength; i++) { | 1563 for (int i = 0; i < kFreeListsLength; i++) { |
1563 Address cur_addr = free_[i].head_node_; | 1564 Address cur_addr = free_[i].head_node_; |
1564 while (cur_addr != NULL) { | 1565 while (cur_addr != NULL) { |
1565 FreeListNode* cur_node = FreeListNode::FromAddress(cur_addr); | 1566 FreeListNode* cur_node = FreeListNode::FromAddress(cur_addr); |
1566 cur_addr = cur_node->next(); | 1567 cur_addr = cur_node->next(); |
1567 cur_node->SetMark(); | 1568 cur_node->SetMark(); |
1568 } | 1569 } |
1569 } | 1570 } |
| 1571 #endif |
| 1572 UNREACHABLE(); |
1570 } | 1573 } |
1571 | 1574 |
1572 | 1575 |
1573 #ifdef DEBUG | 1576 #ifdef DEBUG |
1574 bool OldSpaceFreeList::Contains(FreeListNode* node) { | 1577 bool OldSpaceFreeList::Contains(FreeListNode* node) { |
1575 for (int i = 0; i < kFreeListsLength; i++) { | 1578 for (int i = 0; i < kFreeListsLength; i++) { |
1576 Address cur_addr = free_[i].head_node_; | 1579 Address cur_addr = free_[i].head_node_; |
1577 while (cur_addr != NULL) { | 1580 while (cur_addr != NULL) { |
1578 FreeListNode* cur_node = FreeListNode::FromAddress(cur_addr); | 1581 FreeListNode* cur_node = FreeListNode::FromAddress(cur_addr); |
1579 if (cur_node == node) return true; | 1582 if (cur_node == node) return true; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1623 | 1626 |
1624 ASSERT(!FLAG_always_compact); // We only use the freelists with mark-sweep. | 1627 ASSERT(!FLAG_always_compact); // We only use the freelists with mark-sweep. |
1625 FreeListNode* node = FreeListNode::FromAddress(head_); | 1628 FreeListNode* node = FreeListNode::FromAddress(head_); |
1626 head_ = node->next(); | 1629 head_ = node->next(); |
1627 available_ -= object_size_; | 1630 available_ -= object_size_; |
1628 return node; | 1631 return node; |
1629 } | 1632 } |
1630 | 1633 |
1631 | 1634 |
1632 void FixedSizeFreeList::MarkNodes() { | 1635 void FixedSizeFreeList::MarkNodes() { |
| 1636 #if 0 |
1633 Address cur_addr = head_; | 1637 Address cur_addr = head_; |
1634 while (cur_addr != NULL && cur_addr != tail_) { | 1638 while (cur_addr != NULL && cur_addr != tail_) { |
1635 FreeListNode* cur_node = FreeListNode::FromAddress(cur_addr); | 1639 FreeListNode* cur_node = FreeListNode::FromAddress(cur_addr); |
1636 cur_addr = cur_node->next(); | 1640 cur_addr = cur_node->next(); |
1637 cur_node->SetMark(); | 1641 cur_node->SetMark(); |
1638 } | 1642 } |
| 1643 #endif |
| 1644 UNREACHABLE(); |
1639 } | 1645 } |
1640 | 1646 |
1641 | 1647 |
1642 // ----------------------------------------------------------------------------- | 1648 // ----------------------------------------------------------------------------- |
1643 // OldSpace implementation | 1649 // OldSpace implementation |
1644 | 1650 |
1645 void OldSpace::PrepareForMarkCompact(bool will_compact) { | 1651 void OldSpace::PrepareForMarkCompact(bool will_compact) { |
1646 ASSERT(!will_compact); | 1652 ASSERT(!will_compact); |
1647 // Call prepare of the super class. | 1653 // Call prepare of the super class. |
1648 PagedSpace::PrepareForMarkCompact(will_compact); | 1654 PagedSpace::PrepareForMarkCompact(will_compact); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1690 last_page_->set_next_page(first); | 1696 last_page_->set_next_page(first); |
1691 last_page_ = last; | 1697 last_page_ = last; |
1692 last->set_next_page(NULL); | 1698 last->set_next_page(NULL); |
1693 | 1699 |
1694 // Clean them up. | 1700 // Clean them up. |
1695 do { | 1701 do { |
1696 first->InvalidateWatermark(true); | 1702 first->InvalidateWatermark(true); |
1697 first->SetAllocationWatermark(first->ObjectAreaStart()); | 1703 first->SetAllocationWatermark(first->ObjectAreaStart()); |
1698 first->SetCachedAllocationWatermark(first->ObjectAreaStart()); | 1704 first->SetCachedAllocationWatermark(first->ObjectAreaStart()); |
1699 first->SetRegionMarks(Page::kAllRegionsCleanMarks); | 1705 first->SetRegionMarks(Page::kAllRegionsCleanMarks); |
| 1706 first->markbits()->Clear(); |
1700 first = first->next_page(); | 1707 first = first->next_page(); |
1701 } while (first != NULL); | 1708 } while (first != NULL); |
1702 } | 1709 } |
1703 | 1710 |
1704 | 1711 |
1705 void PagedSpace::PrepareForMarkCompact(bool will_compact) { | 1712 void PagedSpace::PrepareForMarkCompact(bool will_compact) { |
1706 ASSERT(!will_compact); | 1713 ASSERT(!will_compact); |
1707 } | 1714 } |
1708 | 1715 |
1709 | 1716 |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2321 } | 2328 } |
2322 } | 2329 } |
2323 } | 2330 } |
2324 | 2331 |
2325 | 2332 |
2326 void LargeObjectSpace::FreeUnmarkedObjects() { | 2333 void LargeObjectSpace::FreeUnmarkedObjects() { |
2327 LargePage* previous = NULL; | 2334 LargePage* previous = NULL; |
2328 LargePage* current = first_page_; | 2335 LargePage* current = first_page_; |
2329 while (current != NULL) { | 2336 while (current != NULL) { |
2330 HeapObject* object = current->GetObject(); | 2337 HeapObject* object = current->GetObject(); |
2331 if (object->IsMarked()) { | 2338 if (Marking::IsMarked(object)) { |
2332 object->ClearMark(); | 2339 Marking::ClearMark(object); |
2333 MarkCompactCollector::tracer()->decrement_marked_count(); | 2340 MarkCompactCollector::tracer()->decrement_marked_count(); |
2334 previous = current; | 2341 previous = current; |
2335 current = current->next_page(); | 2342 current = current->next_page(); |
2336 } else { | 2343 } else { |
2337 LargePage* page = current; | 2344 LargePage* page = current; |
2338 // Cut the chunk out from the chunk list. | 2345 // Cut the chunk out from the chunk list. |
2339 current = current->next_page(); | 2346 current = current->next_page(); |
2340 if (previous == NULL) { | 2347 if (previous == NULL) { |
2341 first_page_ = current; | 2348 first_page_ = current; |
2342 } else { | 2349 } else { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2460 for (HeapObject* obj = obj_it.next(); obj != NULL; obj = obj_it.next()) { | 2467 for (HeapObject* obj = obj_it.next(); obj != NULL; obj = obj_it.next()) { |
2461 if (obj->IsCode()) { | 2468 if (obj->IsCode()) { |
2462 Code* code = Code::cast(obj); | 2469 Code* code = Code::cast(obj); |
2463 code_kind_statistics[code->kind()] += code->Size(); | 2470 code_kind_statistics[code->kind()] += code->Size(); |
2464 } | 2471 } |
2465 } | 2472 } |
2466 } | 2473 } |
2467 #endif // DEBUG | 2474 #endif // DEBUG |
2468 | 2475 |
2469 } } // namespace v8::internal | 2476 } } // namespace v8::internal |
OLD | NEW |