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 2619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2630 JSWeakCollection* weak_collection = | 2630 JSWeakCollection* weak_collection = |
2631 reinterpret_cast<JSWeakCollection*>(weak_collection_obj); | 2631 reinterpret_cast<JSWeakCollection*>(weak_collection_obj); |
2632 weak_collection_obj = weak_collection->next(); | 2632 weak_collection_obj = weak_collection->next(); |
2633 weak_collection->set_next(heap()->undefined_value()); | 2633 weak_collection->set_next(heap()->undefined_value()); |
2634 } | 2634 } |
2635 heap()->set_encountered_weak_collections(Smi::FromInt(0)); | 2635 heap()->set_encountered_weak_collections(Smi::FromInt(0)); |
2636 } | 2636 } |
2637 | 2637 |
2638 | 2638 |
2639 void MarkCompactCollector::ProcessAndClearWeakCells() { | 2639 void MarkCompactCollector::ProcessAndClearWeakCells() { |
2640 HeapObject* undefined = heap()->undefined_value(); | 2640 HeapObject* the_hole = heap()->the_hole_value(); |
2641 Object* weak_cell_obj = heap()->encountered_weak_cells(); | 2641 Object* weak_cell_obj = heap()->encountered_weak_cells(); |
2642 while (weak_cell_obj != Smi::FromInt(0)) { | 2642 while (weak_cell_obj != Smi::FromInt(0)) { |
2643 WeakCell* weak_cell = reinterpret_cast<WeakCell*>(weak_cell_obj); | 2643 WeakCell* weak_cell = reinterpret_cast<WeakCell*>(weak_cell_obj); |
2644 // We do not insert cleared weak cells into the list, so the value | 2644 // We do not insert cleared weak cells into the list, so the value |
2645 // cannot be a Smi here. | 2645 // cannot be a Smi here. |
2646 HeapObject* value = HeapObject::cast(weak_cell->value()); | 2646 HeapObject* value = HeapObject::cast(weak_cell->value()); |
2647 if (!MarkCompactCollector::IsMarked(value)) { | 2647 if (!MarkCompactCollector::IsMarked(value)) { |
2648 // Cells for new-space objects embedded in optimized code are wrapped in | 2648 // Cells for new-space objects embedded in optimized code are wrapped in |
2649 // WeakCell and put into Heap::weak_object_to_code_table. | 2649 // WeakCell and put into Heap::weak_object_to_code_table. |
2650 // Such cells do not have any strong references but we want to keep them | 2650 // Such cells do not have any strong references but we want to keep them |
(...skipping 14 matching lines...) Expand all Loading... |
2665 weak_cell->clear(); | 2665 weak_cell->clear(); |
2666 } | 2666 } |
2667 } else { | 2667 } else { |
2668 weak_cell->clear(); | 2668 weak_cell->clear(); |
2669 } | 2669 } |
2670 } else { | 2670 } else { |
2671 Object** slot = HeapObject::RawField(weak_cell, WeakCell::kValueOffset); | 2671 Object** slot = HeapObject::RawField(weak_cell, WeakCell::kValueOffset); |
2672 RecordSlot(slot, slot, *slot); | 2672 RecordSlot(slot, slot, *slot); |
2673 } | 2673 } |
2674 weak_cell_obj = weak_cell->next(); | 2674 weak_cell_obj = weak_cell->next(); |
2675 weak_cell->set_next(undefined, SKIP_WRITE_BARRIER); | 2675 weak_cell->set_next(the_hole, SKIP_WRITE_BARRIER); |
2676 } | 2676 } |
2677 heap()->set_encountered_weak_cells(Smi::FromInt(0)); | 2677 heap()->set_encountered_weak_cells(Smi::FromInt(0)); |
2678 } | 2678 } |
2679 | 2679 |
2680 | 2680 |
2681 void MarkCompactCollector::AbortWeakCells() { | 2681 void MarkCompactCollector::AbortWeakCells() { |
2682 Object* undefined = heap()->undefined_value(); | 2682 Object* the_hole = heap()->the_hole_value(); |
2683 Object* weak_cell_obj = heap()->encountered_weak_cells(); | 2683 Object* weak_cell_obj = heap()->encountered_weak_cells(); |
2684 while (weak_cell_obj != Smi::FromInt(0)) { | 2684 while (weak_cell_obj != Smi::FromInt(0)) { |
2685 WeakCell* weak_cell = reinterpret_cast<WeakCell*>(weak_cell_obj); | 2685 WeakCell* weak_cell = reinterpret_cast<WeakCell*>(weak_cell_obj); |
2686 weak_cell_obj = weak_cell->next(); | 2686 weak_cell_obj = weak_cell->next(); |
2687 weak_cell->set_next(undefined, SKIP_WRITE_BARRIER); | 2687 weak_cell->set_next(the_hole, SKIP_WRITE_BARRIER); |
2688 } | 2688 } |
2689 heap()->set_encountered_weak_cells(Smi::FromInt(0)); | 2689 heap()->set_encountered_weak_cells(Smi::FromInt(0)); |
2690 } | 2690 } |
2691 | 2691 |
2692 | 2692 |
2693 void MarkCompactCollector::RecordMigratedSlot(Object* value, Address slot) { | 2693 void MarkCompactCollector::RecordMigratedSlot(Object* value, Address slot) { |
2694 if (heap_->InNewSpace(value)) { | 2694 if (heap_->InNewSpace(value)) { |
2695 heap_->store_buffer()->Mark(slot); | 2695 heap_->store_buffer()->Mark(slot); |
2696 } else if (value->IsHeapObject() && IsOnEvacuationCandidate(value)) { | 2696 } else if (value->IsHeapObject() && IsOnEvacuationCandidate(value)) { |
2697 SlotsBuffer::AddTo(&slots_buffer_allocator_, &migration_slots_buffer_, | 2697 SlotsBuffer::AddTo(&slots_buffer_allocator_, &migration_slots_buffer_, |
(...skipping 2038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4736 SlotsBuffer* buffer = *buffer_address; | 4736 SlotsBuffer* buffer = *buffer_address; |
4737 while (buffer != NULL) { | 4737 while (buffer != NULL) { |
4738 SlotsBuffer* next_buffer = buffer->next(); | 4738 SlotsBuffer* next_buffer = buffer->next(); |
4739 DeallocateBuffer(buffer); | 4739 DeallocateBuffer(buffer); |
4740 buffer = next_buffer; | 4740 buffer = next_buffer; |
4741 } | 4741 } |
4742 *buffer_address = NULL; | 4742 *buffer_address = NULL; |
4743 } | 4743 } |
4744 } // namespace internal | 4744 } // namespace internal |
4745 } // namespace v8 | 4745 } // namespace v8 |
OLD | NEW |