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 2983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2994 | 2994 |
2995 { // Create a separate external one byte string map for native sources. | 2995 { // Create a separate external one byte string map for native sources. |
2996 AllocationResult allocation = AllocateMap(EXTERNAL_ONE_BYTE_STRING_TYPE, | 2996 AllocationResult allocation = AllocateMap(EXTERNAL_ONE_BYTE_STRING_TYPE, |
2997 ExternalOneByteString::kSize); | 2997 ExternalOneByteString::kSize); |
2998 if (!allocation.To(&obj)) return false; | 2998 if (!allocation.To(&obj)) return false; |
2999 set_native_source_string_map(Map::cast(obj)); | 2999 set_native_source_string_map(Map::cast(obj)); |
3000 } | 3000 } |
3001 | 3001 |
3002 ALLOCATE_VARSIZE_MAP(FIXED_DOUBLE_ARRAY_TYPE, fixed_double_array) | 3002 ALLOCATE_VARSIZE_MAP(FIXED_DOUBLE_ARRAY_TYPE, fixed_double_array) |
3003 ALLOCATE_VARSIZE_MAP(BYTE_ARRAY_TYPE, byte_array) | 3003 ALLOCATE_VARSIZE_MAP(BYTE_ARRAY_TYPE, byte_array) |
| 3004 ALLOCATE_VARSIZE_MAP(BYTECODE_ARRAY_TYPE, bytecode_array) |
3004 ALLOCATE_VARSIZE_MAP(FREE_SPACE_TYPE, free_space) | 3005 ALLOCATE_VARSIZE_MAP(FREE_SPACE_TYPE, free_space) |
3005 | 3006 |
3006 #define ALLOCATE_EXTERNAL_ARRAY_MAP(Type, type, TYPE, ctype, size) \ | 3007 #define ALLOCATE_EXTERNAL_ARRAY_MAP(Type, type, TYPE, ctype, size) \ |
3007 ALLOCATE_MAP(EXTERNAL_##TYPE##_ARRAY_TYPE, ExternalArray::kSize, \ | 3008 ALLOCATE_MAP(EXTERNAL_##TYPE##_ARRAY_TYPE, ExternalArray::kSize, \ |
3008 external_##type##_array) | 3009 external_##type##_array) |
3009 | 3010 |
3010 TYPED_ARRAYS(ALLOCATE_EXTERNAL_ARRAY_MAP) | 3011 TYPED_ARRAYS(ALLOCATE_EXTERNAL_ARRAY_MAP) |
3011 #undef ALLOCATE_EXTERNAL_ARRAY_MAP | 3012 #undef ALLOCATE_EXTERNAL_ARRAY_MAP |
3012 | 3013 |
3013 #define ALLOCATE_FIXED_TYPED_ARRAY_MAP(Type, type, TYPE, ctype, size) \ | 3014 #define ALLOCATE_FIXED_TYPED_ARRAY_MAP(Type, type, TYPE, ctype, size) \ |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3058 external_map()->set_is_extensible(false); | 3059 external_map()->set_is_extensible(false); |
3059 #undef ALLOCATE_VARSIZE_MAP | 3060 #undef ALLOCATE_VARSIZE_MAP |
3060 #undef ALLOCATE_MAP | 3061 #undef ALLOCATE_MAP |
3061 } | 3062 } |
3062 | 3063 |
3063 { // Empty arrays | 3064 { // Empty arrays |
3064 { | 3065 { |
3065 ByteArray* byte_array; | 3066 ByteArray* byte_array; |
3066 if (!AllocateByteArray(0, TENURED).To(&byte_array)) return false; | 3067 if (!AllocateByteArray(0, TENURED).To(&byte_array)) return false; |
3067 set_empty_byte_array(byte_array); | 3068 set_empty_byte_array(byte_array); |
| 3069 |
| 3070 BytecodeArray* bytecode_array; |
| 3071 if (!AllocateBytecodeArray(0, nullptr).To(&bytecode_array)) { |
| 3072 return false; |
| 3073 } |
| 3074 set_empty_bytecode_array(bytecode_array); |
3068 } | 3075 } |
3069 | 3076 |
3070 #define ALLOCATE_EMPTY_EXTERNAL_ARRAY(Type, type, TYPE, ctype, size) \ | 3077 #define ALLOCATE_EMPTY_EXTERNAL_ARRAY(Type, type, TYPE, ctype, size) \ |
3071 { \ | 3078 { \ |
3072 ExternalArray* obj; \ | 3079 ExternalArray* obj; \ |
3073 if (!AllocateEmptyExternalArray(kExternal##Type##Array).To(&obj)) \ | 3080 if (!AllocateEmptyExternalArray(kExternal##Type##Array).To(&obj)) \ |
3074 return false; \ | 3081 return false; \ |
3075 set_empty_external_##type##_array(obj); \ | 3082 set_empty_external_##type##_array(obj); \ |
3076 } | 3083 } |
3077 | 3084 |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3806 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); | 3813 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); |
3807 if (!allocation.To(&result)) return allocation; | 3814 if (!allocation.To(&result)) return allocation; |
3808 } | 3815 } |
3809 | 3816 |
3810 result->set_map_no_write_barrier(byte_array_map()); | 3817 result->set_map_no_write_barrier(byte_array_map()); |
3811 ByteArray::cast(result)->set_length(length); | 3818 ByteArray::cast(result)->set_length(length); |
3812 return result; | 3819 return result; |
3813 } | 3820 } |
3814 | 3821 |
3815 | 3822 |
| 3823 AllocationResult Heap::AllocateBytecodeArray(int length, |
| 3824 const byte* const raw_bytecodes) { |
| 3825 if (length < 0 || length > BytecodeArray::kMaxLength) { |
| 3826 v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); |
| 3827 } |
| 3828 |
| 3829 int size = BytecodeArray::SizeFor(length); |
| 3830 HeapObject* result; |
| 3831 { |
| 3832 AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE); |
| 3833 if (!allocation.To(&result)) return allocation; |
| 3834 } |
| 3835 |
| 3836 result->set_map_no_write_barrier(bytecode_array_map()); |
| 3837 BytecodeArray* instance = BytecodeArray::cast(result); |
| 3838 instance->set_length(length); |
| 3839 CopyBytes(instance->GetFirstBytecodeAddress(), raw_bytecodes, length); |
| 3840 |
| 3841 return result; |
| 3842 } |
| 3843 |
| 3844 |
3816 void Heap::CreateFillerObjectAt(Address addr, int size) { | 3845 void Heap::CreateFillerObjectAt(Address addr, int size) { |
3817 if (size == 0) return; | 3846 if (size == 0) return; |
3818 HeapObject* filler = HeapObject::FromAddress(addr); | 3847 HeapObject* filler = HeapObject::FromAddress(addr); |
3819 if (size == kPointerSize) { | 3848 if (size == kPointerSize) { |
3820 filler->set_map_no_write_barrier(raw_unchecked_one_pointer_filler_map()); | 3849 filler->set_map_no_write_barrier(raw_unchecked_one_pointer_filler_map()); |
3821 } else if (size == 2 * kPointerSize) { | 3850 } else if (size == 2 * kPointerSize) { |
3822 filler->set_map_no_write_barrier(raw_unchecked_two_pointer_filler_map()); | 3851 filler->set_map_no_write_barrier(raw_unchecked_two_pointer_filler_map()); |
3823 } else { | 3852 } else { |
3824 filler->set_map_no_write_barrier(raw_unchecked_free_space_map()); | 3853 filler->set_map_no_write_barrier(raw_unchecked_free_space_map()); |
3825 FreeSpace::cast(filler)->nobarrier_set_size(size); | 3854 FreeSpace::cast(filler)->nobarrier_set_size(size); |
(...skipping 3095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6921 *object_type = "CODE_TYPE"; \ | 6950 *object_type = "CODE_TYPE"; \ |
6922 *object_sub_type = "CODE_AGE/" #name; \ | 6951 *object_sub_type = "CODE_AGE/" #name; \ |
6923 return true; | 6952 return true; |
6924 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) | 6953 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) |
6925 #undef COMPARE_AND_RETURN_NAME | 6954 #undef COMPARE_AND_RETURN_NAME |
6926 } | 6955 } |
6927 return false; | 6956 return false; |
6928 } | 6957 } |
6929 } // namespace internal | 6958 } // namespace internal |
6930 } // namespace v8 | 6959 } // namespace v8 |
OLD | NEW |