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/heap/heap.h" | 5 #include "src/heap/heap.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/ast/context-slot-cache.h" | 9 #include "src/ast/context-slot-cache.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 3355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3366 | 3366 |
3367 // Relocate the copy. | 3367 // Relocate the copy. |
3368 DCHECK(IsAligned(bit_cast<intptr_t>(new_code->address()), kCodeAlignment)); | 3368 DCHECK(IsAligned(bit_cast<intptr_t>(new_code->address()), kCodeAlignment)); |
3369 DCHECK(!memory_allocator()->code_range()->valid() || | 3369 DCHECK(!memory_allocator()->code_range()->valid() || |
3370 memory_allocator()->code_range()->contains(code->address()) || | 3370 memory_allocator()->code_range()->contains(code->address()) || |
3371 obj_size <= code_space()->AreaSize()); | 3371 obj_size <= code_space()->AreaSize()); |
3372 new_code->Relocate(new_addr - old_addr); | 3372 new_code->Relocate(new_addr - old_addr); |
3373 // We have to iterate over the object and process its pointers when black | 3373 // We have to iterate over the object and process its pointers when black |
3374 // allocation is on. | 3374 // allocation is on. |
3375 incremental_marking()->IterateBlackObject(new_code); | 3375 incremental_marking()->IterateBlackObject(new_code); |
| 3376 // Record all references to embedded objects in the new code object. |
| 3377 RecordWritesIntoCode(new_code); |
3376 return new_code; | 3378 return new_code; |
3377 } | 3379 } |
3378 | 3380 |
3379 AllocationResult Heap::CopyBytecodeArray(BytecodeArray* bytecode_array) { | 3381 AllocationResult Heap::CopyBytecodeArray(BytecodeArray* bytecode_array) { |
3380 int size = BytecodeArray::SizeFor(bytecode_array->length()); | 3382 int size = BytecodeArray::SizeFor(bytecode_array->length()); |
3381 HeapObject* result = nullptr; | 3383 HeapObject* result = nullptr; |
3382 { | 3384 { |
3383 AllocationResult allocation = AllocateRaw(size, OLD_SPACE); | 3385 AllocationResult allocation = AllocateRaw(size, OLD_SPACE); |
3384 if (!allocation.To(&result)) return allocation; | 3386 if (!allocation.To(&result)) return allocation; |
3385 } | 3387 } |
(...skipping 2395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5781 slot_type = CODE_ENTRY_SLOT; | 5783 slot_type = CODE_ENTRY_SLOT; |
5782 } else { | 5784 } else { |
5783 DCHECK(RelocInfo::IsEmbeddedObject(rmode)); | 5785 DCHECK(RelocInfo::IsEmbeddedObject(rmode)); |
5784 slot_type = OBJECT_SLOT; | 5786 slot_type = OBJECT_SLOT; |
5785 } | 5787 } |
5786 } | 5788 } |
5787 RememberedSet<OLD_TO_NEW>::InsertTyped( | 5789 RememberedSet<OLD_TO_NEW>::InsertTyped( |
5788 source_page, reinterpret_cast<Address>(host), slot_type, addr); | 5790 source_page, reinterpret_cast<Address>(host), slot_type, addr); |
5789 } | 5791 } |
5790 | 5792 |
| 5793 void Heap::RecordWritesIntoCode(Code* code) { |
| 5794 for (RelocIterator it(code, RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT)); |
| 5795 !it.done(); it.next()) { |
| 5796 RecordWriteIntoCode(code, it.rinfo(), it.rinfo()->target_object()); |
| 5797 } |
| 5798 } |
| 5799 |
5791 Space* AllSpaces::next() { | 5800 Space* AllSpaces::next() { |
5792 switch (counter_++) { | 5801 switch (counter_++) { |
5793 case NEW_SPACE: | 5802 case NEW_SPACE: |
5794 return heap_->new_space(); | 5803 return heap_->new_space(); |
5795 case OLD_SPACE: | 5804 case OLD_SPACE: |
5796 return heap_->old_space(); | 5805 return heap_->old_space(); |
5797 case CODE_SPACE: | 5806 case CODE_SPACE: |
5798 return heap_->code_space(); | 5807 return heap_->code_space(); |
5799 case MAP_SPACE: | 5808 case MAP_SPACE: |
5800 return heap_->map_space(); | 5809 return heap_->map_space(); |
5801 case LO_SPACE: | 5810 case LO_SPACE: |
5802 return heap_->lo_space(); | 5811 return heap_->lo_space(); |
5803 default: | 5812 default: |
5804 return NULL; | 5813 return NULL; |
5805 } | 5814 } |
5806 } | 5815 } |
5807 | 5816 |
5808 | |
5809 PagedSpace* PagedSpaces::next() { | 5817 PagedSpace* PagedSpaces::next() { |
5810 switch (counter_++) { | 5818 switch (counter_++) { |
5811 case OLD_SPACE: | 5819 case OLD_SPACE: |
5812 return heap_->old_space(); | 5820 return heap_->old_space(); |
5813 case CODE_SPACE: | 5821 case CODE_SPACE: |
5814 return heap_->code_space(); | 5822 return heap_->code_space(); |
5815 case MAP_SPACE: | 5823 case MAP_SPACE: |
5816 return heap_->map_space(); | 5824 return heap_->map_space(); |
5817 default: | 5825 default: |
5818 return NULL; | 5826 return NULL; |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6452 } | 6460 } |
6453 | 6461 |
6454 | 6462 |
6455 // static | 6463 // static |
6456 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6464 int Heap::GetStaticVisitorIdForMap(Map* map) { |
6457 return StaticVisitorBase::GetVisitorId(map); | 6465 return StaticVisitorBase::GetVisitorId(map); |
6458 } | 6466 } |
6459 | 6467 |
6460 } // namespace internal | 6468 } // namespace internal |
6461 } // namespace v8 | 6469 } // namespace v8 |
OLD | NEW |