| 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 3026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3037 external_map()->set_is_extensible(false); | 3037 external_map()->set_is_extensible(false); |
| 3038 #undef ALLOCATE_VARSIZE_MAP | 3038 #undef ALLOCATE_VARSIZE_MAP |
| 3039 #undef ALLOCATE_MAP | 3039 #undef ALLOCATE_MAP |
| 3040 } | 3040 } |
| 3041 | 3041 |
| 3042 { // Empty arrays | 3042 { // Empty arrays |
| 3043 { | 3043 { |
| 3044 ByteArray* byte_array; | 3044 ByteArray* byte_array; |
| 3045 if (!AllocateByteArray(0, TENURED).To(&byte_array)) return false; | 3045 if (!AllocateByteArray(0, TENURED).To(&byte_array)) return false; |
| 3046 set_empty_byte_array(byte_array); | 3046 set_empty_byte_array(byte_array); |
| 3047 |
| 3048 BytecodeArray* bytecode_array; |
| 3049 if (!AllocateBytecodeArray(0, nullptr, TENURED).To(&bytecode_array)) { |
| 3050 return false; |
| 3051 } |
| 3052 set_empty_bytecode_array(bytecode_array); |
| 3047 } | 3053 } |
| 3048 | 3054 |
| 3049 #define ALLOCATE_EMPTY_EXTERNAL_ARRAY(Type, type, TYPE, ctype, size) \ | 3055 #define ALLOCATE_EMPTY_EXTERNAL_ARRAY(Type, type, TYPE, ctype, size) \ |
| 3050 { \ | 3056 { \ |
| 3051 ExternalArray* obj; \ | 3057 ExternalArray* obj; \ |
| 3052 if (!AllocateEmptyExternalArray(kExternal##Type##Array).To(&obj)) \ | 3058 if (!AllocateEmptyExternalArray(kExternal##Type##Array).To(&obj)) \ |
| 3053 return false; \ | 3059 return false; \ |
| 3054 set_empty_external_##type##_array(obj); \ | 3060 set_empty_external_##type##_array(obj); \ |
| 3055 } | 3061 } |
| 3056 | 3062 |
| (...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3779 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); | 3785 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); |
| 3780 if (!allocation.To(&result)) return allocation; | 3786 if (!allocation.To(&result)) return allocation; |
| 3781 } | 3787 } |
| 3782 | 3788 |
| 3783 result->set_map_no_write_barrier(byte_array_map()); | 3789 result->set_map_no_write_barrier(byte_array_map()); |
| 3784 ByteArray::cast(result)->set_length(length); | 3790 ByteArray::cast(result)->set_length(length); |
| 3785 return result; | 3791 return result; |
| 3786 } | 3792 } |
| 3787 | 3793 |
| 3788 | 3794 |
| 3795 AllocationResult Heap::AllocateBytecodeArray(int length, |
| 3796 const byte* const start, |
| 3797 PretenureFlag pretenure) { |
| 3798 if (length < 0 || length > BytecodeArray::kMaxLength) { |
| 3799 v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); |
| 3800 } |
| 3801 int size = BytecodeArray::SizeFor(length); |
| 3802 AllocationSpace space = SelectSpace(size, pretenure); |
| 3803 HeapObject* result; |
| 3804 { |
| 3805 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); |
| 3806 if (!allocation.To(&result)) return allocation; |
| 3807 } |
| 3808 |
| 3809 BytecodeArray* instance = BytecodeArray::cast(result); |
| 3810 instance->set_length(length); |
| 3811 CopyBytes(instance->GetDataStartAddress(), start, length); |
| 3812 result->set_map_no_write_barrier(byte_array_map()); |
| 3813 return result; |
| 3814 } |
| 3815 |
| 3816 |
| 3789 void Heap::CreateFillerObjectAt(Address addr, int size) { | 3817 void Heap::CreateFillerObjectAt(Address addr, int size) { |
| 3790 if (size == 0) return; | 3818 if (size == 0) return; |
| 3791 HeapObject* filler = HeapObject::FromAddress(addr); | 3819 HeapObject* filler = HeapObject::FromAddress(addr); |
| 3792 if (size == kPointerSize) { | 3820 if (size == kPointerSize) { |
| 3793 filler->set_map_no_write_barrier(raw_unchecked_one_pointer_filler_map()); | 3821 filler->set_map_no_write_barrier(raw_unchecked_one_pointer_filler_map()); |
| 3794 } else if (size == 2 * kPointerSize) { | 3822 } else if (size == 2 * kPointerSize) { |
| 3795 filler->set_map_no_write_barrier(raw_unchecked_two_pointer_filler_map()); | 3823 filler->set_map_no_write_barrier(raw_unchecked_two_pointer_filler_map()); |
| 3796 } else { | 3824 } else { |
| 3797 filler->set_map_no_write_barrier(raw_unchecked_free_space_map()); | 3825 filler->set_map_no_write_barrier(raw_unchecked_free_space_map()); |
| 3798 FreeSpace::cast(filler)->nobarrier_set_size(size); | 3826 FreeSpace::cast(filler)->nobarrier_set_size(size); |
| (...skipping 3093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6892 *object_type = "CODE_TYPE"; \ | 6920 *object_type = "CODE_TYPE"; \ |
| 6893 *object_sub_type = "CODE_AGE/" #name; \ | 6921 *object_sub_type = "CODE_AGE/" #name; \ |
| 6894 return true; | 6922 return true; |
| 6895 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) | 6923 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) |
| 6896 #undef COMPARE_AND_RETURN_NAME | 6924 #undef COMPARE_AND_RETURN_NAME |
| 6897 } | 6925 } |
| 6898 return false; | 6926 return false; |
| 6899 } | 6927 } |
| 6900 } // namespace internal | 6928 } // namespace internal |
| 6901 } // namespace v8 | 6929 } // namespace v8 |
| OLD | NEW |