| 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 2661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2672 } | 2672 } |
| 2673 heap()->set_encountered_weak_collections(Smi::FromInt(0)); | 2673 heap()->set_encountered_weak_collections(Smi::FromInt(0)); |
| 2674 } | 2674 } |
| 2675 | 2675 |
| 2676 | 2676 |
| 2677 void MarkCompactCollector::ProcessAndClearWeakCells() { | 2677 void MarkCompactCollector::ProcessAndClearWeakCells() { |
| 2678 HeapObject* undefined = heap()->undefined_value(); | 2678 HeapObject* undefined = heap()->undefined_value(); |
| 2679 Object* weak_cell_obj = heap()->encountered_weak_cells(); | 2679 Object* weak_cell_obj = heap()->encountered_weak_cells(); |
| 2680 while (weak_cell_obj != Smi::FromInt(0)) { | 2680 while (weak_cell_obj != Smi::FromInt(0)) { |
| 2681 WeakCell* weak_cell = reinterpret_cast<WeakCell*>(weak_cell_obj); | 2681 WeakCell* weak_cell = reinterpret_cast<WeakCell*>(weak_cell_obj); |
| 2682 // We do not insert cleared weak cells into the list, so the value | 2682 // Raw read avoids read barrier. |
| 2683 // cannot be a Smi here. | 2683 Object* value = weak_cell->ValueNoReadBarrier(); |
| 2684 HeapObject* value = HeapObject::cast(weak_cell->value()); | 2684 if (value != Smi::FromInt(0)) { |
| 2685 if (!MarkCompactCollector::IsMarked(value)) { | 2685 HeapObject* heap_value = HeapObject::cast(value); |
| 2686 weak_cell->clear(); | 2686 // TODO(erikcorry): Also check whether the cell has been used. |
| 2687 } else { | 2687 if (!MarkCompactCollector::IsMarked(heap_value)) { |
| 2688 Object** slot = HeapObject::RawField(weak_cell, WeakCell::kValueOffset); | 2688 weak_cell->clear(); |
| 2689 heap()->mark_compact_collector()->RecordSlot(slot, slot, value); | 2689 } else { |
| 2690 Object** slot = HeapObject::RawField( |
| 2691 weak_cell, WeakCell::kValueOffsetDontForgetTheReadBarrier); |
| 2692 heap()->mark_compact_collector()->RecordSlot(slot, slot, value); |
| 2693 } |
| 2694 // Tag for the next round of GC. |
| 2695 *HeapObject::RawField(weak_cell, HeapObject::kMapOffset) = |
| 2696 heap()->unused_weak_cell_map(); |
| 2690 } | 2697 } |
| 2691 weak_cell_obj = weak_cell->next(); | 2698 weak_cell_obj = weak_cell->next(); |
| 2692 weak_cell->set_next(undefined, SKIP_WRITE_BARRIER); | 2699 weak_cell->set_next(undefined, SKIP_WRITE_BARRIER); |
| 2693 } | 2700 } |
| 2694 heap()->set_encountered_weak_cells(Smi::FromInt(0)); | 2701 heap()->set_encountered_weak_cells(Smi::FromInt(0)); |
| 2695 } | 2702 } |
| 2696 | 2703 |
| 2697 | 2704 |
| 2698 void MarkCompactCollector::AbortWeakCells() { | 2705 void MarkCompactCollector::AbortWeakCells() { |
| 2699 Object* undefined = heap()->undefined_value(); | 2706 Object* undefined = heap()->undefined_value(); |
| (...skipping 1707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4407 SlotsBuffer* buffer = *buffer_address; | 4414 SlotsBuffer* buffer = *buffer_address; |
| 4408 while (buffer != NULL) { | 4415 while (buffer != NULL) { |
| 4409 SlotsBuffer* next_buffer = buffer->next(); | 4416 SlotsBuffer* next_buffer = buffer->next(); |
| 4410 DeallocateBuffer(buffer); | 4417 DeallocateBuffer(buffer); |
| 4411 buffer = next_buffer; | 4418 buffer = next_buffer; |
| 4412 } | 4419 } |
| 4413 *buffer_address = NULL; | 4420 *buffer_address = NULL; |
| 4414 } | 4421 } |
| 4415 } | 4422 } |
| 4416 } // namespace v8::internal | 4423 } // namespace v8::internal |
| OLD | NEW |