| 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/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/api.h" | 8 #include "src/api.h" |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
| (...skipping 3829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3840 allocation = lo_space_->AllocateRaw(object_size, EXECUTABLE); | 3840 allocation = lo_space_->AllocateRaw(object_size, EXECUTABLE); |
| 3841 if (!allocation.To(&result)) return allocation; | 3841 if (!allocation.To(&result)) return allocation; |
| 3842 OnAllocationEvent(result, object_size); | 3842 OnAllocationEvent(result, object_size); |
| 3843 } | 3843 } |
| 3844 } | 3844 } |
| 3845 | 3845 |
| 3846 result->set_map_no_write_barrier(code_map()); | 3846 result->set_map_no_write_barrier(code_map()); |
| 3847 Code* code = Code::cast(result); | 3847 Code* code = Code::cast(result); |
| 3848 DCHECK(IsAligned(bit_cast<intptr_t>(code->address()), kCodeAlignment)); | 3848 DCHECK(IsAligned(bit_cast<intptr_t>(code->address()), kCodeAlignment)); |
| 3849 DCHECK(isolate_->code_range() == NULL || !isolate_->code_range()->valid() || | 3849 DCHECK(isolate_->code_range() == NULL || !isolate_->code_range()->valid() || |
| 3850 isolate_->code_range()->contains(code->address())); | 3850 isolate_->code_range()->contains(code->address()) || |
| 3851 object_size <= code_space()->AreaSize()); |
| 3851 code->set_gc_metadata(Smi::FromInt(0)); | 3852 code->set_gc_metadata(Smi::FromInt(0)); |
| 3852 code->set_ic_age(global_ic_age_); | 3853 code->set_ic_age(global_ic_age_); |
| 3853 return code; | 3854 return code; |
| 3854 } | 3855 } |
| 3855 | 3856 |
| 3856 | 3857 |
| 3857 AllocationResult Heap::CopyCode(Code* code) { | 3858 AllocationResult Heap::CopyCode(Code* code) { |
| 3858 AllocationResult allocation; | 3859 AllocationResult allocation; |
| 3859 | 3860 |
| 3860 HeapObject* result = NULL; | 3861 HeapObject* result = NULL; |
| 3861 // Allocate an object the same size as the code object. | 3862 // Allocate an object the same size as the code object. |
| 3862 int obj_size = code->Size(); | 3863 int obj_size = code->Size(); |
| 3863 allocation = AllocateRaw(obj_size, CODE_SPACE, CODE_SPACE); | 3864 allocation = AllocateRaw(obj_size, CODE_SPACE, CODE_SPACE); |
| 3864 if (!allocation.To(&result)) return allocation; | 3865 if (!allocation.To(&result)) return allocation; |
| 3865 | 3866 |
| 3866 // Copy code object. | 3867 // Copy code object. |
| 3867 Address old_addr = code->address(); | 3868 Address old_addr = code->address(); |
| 3868 Address new_addr = result->address(); | 3869 Address new_addr = result->address(); |
| 3869 CopyBlock(new_addr, old_addr, obj_size); | 3870 CopyBlock(new_addr, old_addr, obj_size); |
| 3870 Code* new_code = Code::cast(result); | 3871 Code* new_code = Code::cast(result); |
| 3871 | 3872 |
| 3872 // Relocate the copy. | 3873 // Relocate the copy. |
| 3873 DCHECK(IsAligned(bit_cast<intptr_t>(new_code->address()), kCodeAlignment)); | 3874 DCHECK(IsAligned(bit_cast<intptr_t>(new_code->address()), kCodeAlignment)); |
| 3874 DCHECK(isolate_->code_range() == NULL || !isolate_->code_range()->valid() || | 3875 DCHECK(isolate_->code_range() == NULL || !isolate_->code_range()->valid() || |
| 3875 isolate_->code_range()->contains(code->address())); | 3876 isolate_->code_range()->contains(code->address()) || |
| 3877 obj_size <= code_space()->AreaSize()); |
| 3876 new_code->Relocate(new_addr - old_addr); | 3878 new_code->Relocate(new_addr - old_addr); |
| 3877 return new_code; | 3879 return new_code; |
| 3878 } | 3880 } |
| 3879 | 3881 |
| 3880 | 3882 |
| 3881 AllocationResult Heap::CopyCode(Code* code, Vector<byte> reloc_info) { | 3883 AllocationResult Heap::CopyCode(Code* code, Vector<byte> reloc_info) { |
| 3882 // Allocate ByteArray before the Code object, so that we do not risk | 3884 // Allocate ByteArray before the Code object, so that we do not risk |
| 3883 // leaving uninitialized Code object (and breaking the heap). | 3885 // leaving uninitialized Code object (and breaking the heap). |
| 3884 ByteArray* reloc_info_array; | 3886 ByteArray* reloc_info_array; |
| 3885 { | 3887 { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 3911 Code* new_code = Code::cast(result); | 3913 Code* new_code = Code::cast(result); |
| 3912 new_code->set_relocation_info(reloc_info_array); | 3914 new_code->set_relocation_info(reloc_info_array); |
| 3913 | 3915 |
| 3914 // Copy patched rinfo. | 3916 // Copy patched rinfo. |
| 3915 CopyBytes(new_code->relocation_start(), reloc_info.start(), | 3917 CopyBytes(new_code->relocation_start(), reloc_info.start(), |
| 3916 static_cast<size_t>(reloc_info.length())); | 3918 static_cast<size_t>(reloc_info.length())); |
| 3917 | 3919 |
| 3918 // Relocate the copy. | 3920 // Relocate the copy. |
| 3919 DCHECK(IsAligned(bit_cast<intptr_t>(new_code->address()), kCodeAlignment)); | 3921 DCHECK(IsAligned(bit_cast<intptr_t>(new_code->address()), kCodeAlignment)); |
| 3920 DCHECK(isolate_->code_range() == NULL || !isolate_->code_range()->valid() || | 3922 DCHECK(isolate_->code_range() == NULL || !isolate_->code_range()->valid() || |
| 3921 isolate_->code_range()->contains(code->address())); | 3923 isolate_->code_range()->contains(code->address()) || |
| 3924 new_obj_size <= code_space()->AreaSize()); |
| 3925 |
| 3922 new_code->Relocate(new_addr - old_addr); | 3926 new_code->Relocate(new_addr - old_addr); |
| 3923 | 3927 |
| 3924 #ifdef VERIFY_HEAP | 3928 #ifdef VERIFY_HEAP |
| 3925 if (FLAG_verify_heap) code->ObjectVerify(); | 3929 if (FLAG_verify_heap) code->ObjectVerify(); |
| 3926 #endif | 3930 #endif |
| 3927 return new_code; | 3931 return new_code; |
| 3928 } | 3932 } |
| 3929 | 3933 |
| 3930 | 3934 |
| 3931 void Heap::InitializeAllocationMemento(AllocationMemento* memento, | 3935 void Heap::InitializeAllocationMemento(AllocationMemento* memento, |
| (...skipping 2698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6630 *object_type = "CODE_TYPE"; \ | 6634 *object_type = "CODE_TYPE"; \ |
| 6631 *object_sub_type = "CODE_AGE/" #name; \ | 6635 *object_sub_type = "CODE_AGE/" #name; \ |
| 6632 return true; | 6636 return true; |
| 6633 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) | 6637 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) |
| 6634 #undef COMPARE_AND_RETURN_NAME | 6638 #undef COMPARE_AND_RETURN_NAME |
| 6635 } | 6639 } |
| 6636 return false; | 6640 return false; |
| 6637 } | 6641 } |
| 6638 } // namespace internal | 6642 } // namespace internal |
| 6639 } // namespace v8 | 6643 } // namespace v8 |
| OLD | NEW |