| 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 4540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4551 buffer = allocator->AllocateBuffer(buffer); | 4551 buffer = allocator->AllocateBuffer(buffer); |
| 4552 *buffer_address = buffer; | 4552 *buffer_address = buffer; |
| 4553 } | 4553 } |
| 4554 DCHECK(buffer->HasSpaceForTypedSlot()); | 4554 DCHECK(buffer->HasSpaceForTypedSlot()); |
| 4555 buffer->Add(reinterpret_cast<ObjectSlot>(type)); | 4555 buffer->Add(reinterpret_cast<ObjectSlot>(type)); |
| 4556 buffer->Add(reinterpret_cast<ObjectSlot>(addr)); | 4556 buffer->Add(reinterpret_cast<ObjectSlot>(addr)); |
| 4557 return true; | 4557 return true; |
| 4558 } | 4558 } |
| 4559 | 4559 |
| 4560 | 4560 |
| 4561 static Object* g_smi_slot = NULL; | |
| 4562 | |
| 4563 | |
| 4564 void SlotsBuffer::RemoveInvalidSlots(Heap* heap, SlotsBuffer* buffer) { | 4561 void SlotsBuffer::RemoveInvalidSlots(Heap* heap, SlotsBuffer* buffer) { |
| 4565 DCHECK_EQ(Smi::FromInt(0), g_smi_slot); | 4562 // Remove entries by replacing them with an old-space slot containing a smi |
| 4566 | 4563 // that is located in an unmovable page. |
| 4567 // Remove entries by replacing them with a dummy slot containing a smi. | 4564 const ObjectSlot kRemovedEntry = |
| 4568 const ObjectSlot kRemovedEntry = &g_smi_slot; | 4565 HeapObject::RawField(heap->empty_fixed_array(), |
| 4566 FixedArrayBase::kLengthOffset); |
| 4567 DCHECK(Page::FromAddress( |
| 4568 reinterpret_cast<Address>(kRemovedEntry))->NeverEvacuate()); |
| 4569 | 4569 |
| 4570 while (buffer != NULL) { | 4570 while (buffer != NULL) { |
| 4571 SlotsBuffer::ObjectSlot* slots = buffer->slots_; | 4571 SlotsBuffer::ObjectSlot* slots = buffer->slots_; |
| 4572 intptr_t slots_count = buffer->idx_; | 4572 intptr_t slots_count = buffer->idx_; |
| 4573 | 4573 |
| 4574 for (int slot_idx = 0; slot_idx < slots_count; ++slot_idx) { | 4574 for (int slot_idx = 0; slot_idx < slots_count; ++slot_idx) { |
| 4575 ObjectSlot slot = slots[slot_idx]; | 4575 ObjectSlot slot = slots[slot_idx]; |
| 4576 if (!IsTypedSlot(slot)) { | 4576 if (!IsTypedSlot(slot)) { |
| 4577 Object* object = *slot; | 4577 Object* object = *slot; |
| 4578 if (object->IsHeapObject()) { | 4578 if (object->IsHeapObject()) { |
| 4579 if (heap->InNewSpace(object) || | 4579 if (heap->InNewSpace(object) || |
| 4580 !heap->mark_compact_collector()->IsSlotInLiveObject( | 4580 !heap->mark_compact_collector()->IsSlotInLiveObject( |
| 4581 reinterpret_cast<Address>(slot))) { | 4581 reinterpret_cast<Address>(slot))) { |
| 4582 slots[slot_idx] = kRemovedEntry; | 4582 slots[slot_idx] = kRemovedEntry; |
| 4583 } | 4583 } |
| 4584 } | 4584 } |
| 4585 } else { | 4585 } else { |
| 4586 ++slot_idx; | 4586 ++slot_idx; |
| 4587 DCHECK(slot_idx < slots_count); | 4587 DCHECK(slot_idx < slots_count); |
| 4588 } | 4588 } |
| 4589 } | 4589 } |
| 4590 buffer = buffer->next(); | 4590 buffer = buffer->next(); |
| 4591 } | 4591 } |
| 4592 } | 4592 } |
| 4593 | 4593 |
| 4594 | 4594 |
| 4595 void SlotsBuffer::VerifySlots(Heap* heap, SlotsBuffer* buffer) { | 4595 void SlotsBuffer::VerifySlots(Heap* heap, SlotsBuffer* buffer) { |
| 4596 DCHECK_EQ(Smi::FromInt(0), g_smi_slot); | |
| 4597 | |
| 4598 while (buffer != NULL) { | 4596 while (buffer != NULL) { |
| 4599 SlotsBuffer::ObjectSlot* slots = buffer->slots_; | 4597 SlotsBuffer::ObjectSlot* slots = buffer->slots_; |
| 4600 intptr_t slots_count = buffer->idx_; | 4598 intptr_t slots_count = buffer->idx_; |
| 4601 | 4599 |
| 4602 for (int slot_idx = 0; slot_idx < slots_count; ++slot_idx) { | 4600 for (int slot_idx = 0; slot_idx < slots_count; ++slot_idx) { |
| 4603 ObjectSlot slot = slots[slot_idx]; | 4601 ObjectSlot slot = slots[slot_idx]; |
| 4604 if (!IsTypedSlot(slot)) { | 4602 if (!IsTypedSlot(slot)) { |
| 4605 Object* object = *slot; | 4603 Object* object = *slot; |
| 4606 if (object->IsHeapObject()) { | 4604 if (object->IsHeapObject()) { |
| 4607 CHECK(!heap->InNewSpace(object)); | 4605 CHECK(!heap->InNewSpace(object)); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4752 SlotsBuffer* buffer = *buffer_address; | 4750 SlotsBuffer* buffer = *buffer_address; |
| 4753 while (buffer != NULL) { | 4751 while (buffer != NULL) { |
| 4754 SlotsBuffer* next_buffer = buffer->next(); | 4752 SlotsBuffer* next_buffer = buffer->next(); |
| 4755 DeallocateBuffer(buffer); | 4753 DeallocateBuffer(buffer); |
| 4756 buffer = next_buffer; | 4754 buffer = next_buffer; |
| 4757 } | 4755 } |
| 4758 *buffer_address = NULL; | 4756 *buffer_address = NULL; |
| 4759 } | 4757 } |
| 4760 } | 4758 } |
| 4761 } // namespace v8::internal | 4759 } // namespace v8::internal |
| OLD | NEW |