| 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/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
| (...skipping 2900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2911 #undef ALLOCATE_MAP | 2911 #undef ALLOCATE_MAP |
| 2912 } | 2912 } |
| 2913 | 2913 |
| 2914 { // Empty arrays | 2914 { // Empty arrays |
| 2915 { | 2915 { |
| 2916 ByteArray* byte_array; | 2916 ByteArray* byte_array; |
| 2917 if (!AllocateByteArray(0, TENURED).To(&byte_array)) return false; | 2917 if (!AllocateByteArray(0, TENURED).To(&byte_array)) return false; |
| 2918 set_empty_byte_array(byte_array); | 2918 set_empty_byte_array(byte_array); |
| 2919 | 2919 |
| 2920 BytecodeArray* bytecode_array; | 2920 BytecodeArray* bytecode_array; |
| 2921 AllocationResult allocation = | 2921 AllocationResult allocation = AllocateBytecodeArray(0, nullptr, 0, 0); |
| 2922 AllocateBytecodeArray(0, nullptr, kPointerSize); | |
| 2923 if (!allocation.To(&bytecode_array)) { | 2922 if (!allocation.To(&bytecode_array)) { |
| 2924 return false; | 2923 return false; |
| 2925 } | 2924 } |
| 2926 set_empty_bytecode_array(bytecode_array); | 2925 set_empty_bytecode_array(bytecode_array); |
| 2927 } | 2926 } |
| 2928 | 2927 |
| 2929 #define ALLOCATE_EMPTY_FIXED_TYPED_ARRAY(Type, type, TYPE, ctype, size) \ | 2928 #define ALLOCATE_EMPTY_FIXED_TYPED_ARRAY(Type, type, TYPE, ctype, size) \ |
| 2930 { \ | 2929 { \ |
| 2931 FixedTypedArrayBase* obj; \ | 2930 FixedTypedArrayBase* obj; \ |
| 2932 if (!AllocateEmptyFixedTypedArray(kExternal##Type##Array).To(&obj)) \ | 2931 if (!AllocateEmptyFixedTypedArray(kExternal##Type##Array).To(&obj)) \ |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3511 } | 3510 } |
| 3512 | 3511 |
| 3513 result->set_map_no_write_barrier(byte_array_map()); | 3512 result->set_map_no_write_barrier(byte_array_map()); |
| 3514 ByteArray::cast(result)->set_length(length); | 3513 ByteArray::cast(result)->set_length(length); |
| 3515 return result; | 3514 return result; |
| 3516 } | 3515 } |
| 3517 | 3516 |
| 3518 | 3517 |
| 3519 AllocationResult Heap::AllocateBytecodeArray(int length, | 3518 AllocationResult Heap::AllocateBytecodeArray(int length, |
| 3520 const byte* const raw_bytecodes, | 3519 const byte* const raw_bytecodes, |
| 3521 int frame_size) { | 3520 int frame_size, |
| 3521 int parameter_count) { |
| 3522 if (length < 0 || length > BytecodeArray::kMaxLength) { | 3522 if (length < 0 || length > BytecodeArray::kMaxLength) { |
| 3523 v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); | 3523 v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); |
| 3524 } | 3524 } |
| 3525 | 3525 |
| 3526 int size = BytecodeArray::SizeFor(length); | 3526 int size = BytecodeArray::SizeFor(length); |
| 3527 HeapObject* result; | 3527 HeapObject* result; |
| 3528 { | 3528 { |
| 3529 AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE); | 3529 AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE); |
| 3530 if (!allocation.To(&result)) return allocation; | 3530 if (!allocation.To(&result)) return allocation; |
| 3531 } | 3531 } |
| 3532 | 3532 |
| 3533 result->set_map_no_write_barrier(bytecode_array_map()); | 3533 result->set_map_no_write_barrier(bytecode_array_map()); |
| 3534 BytecodeArray* instance = BytecodeArray::cast(result); | 3534 BytecodeArray* instance = BytecodeArray::cast(result); |
| 3535 instance->set_length(length); | 3535 instance->set_length(length); |
| 3536 instance->set_frame_size(frame_size); | 3536 instance->set_frame_size(frame_size); |
| 3537 instance->set_parameter_count(parameter_count); |
| 3537 CopyBytes(instance->GetFirstBytecodeAddress(), raw_bytecodes, length); | 3538 CopyBytes(instance->GetFirstBytecodeAddress(), raw_bytecodes, length); |
| 3538 | 3539 |
| 3539 return result; | 3540 return result; |
| 3540 } | 3541 } |
| 3541 | 3542 |
| 3542 | 3543 |
| 3543 void Heap::CreateFillerObjectAt(Address addr, int size) { | 3544 void Heap::CreateFillerObjectAt(Address addr, int size) { |
| 3544 if (size == 0) return; | 3545 if (size == 0) return; |
| 3545 HeapObject* filler = HeapObject::FromAddress(addr); | 3546 HeapObject* filler = HeapObject::FromAddress(addr); |
| 3546 if (size == kPointerSize) { | 3547 if (size == kPointerSize) { |
| (...skipping 3223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6770 *object_type = "CODE_TYPE"; \ | 6771 *object_type = "CODE_TYPE"; \ |
| 6771 *object_sub_type = "CODE_AGE/" #name; \ | 6772 *object_sub_type = "CODE_AGE/" #name; \ |
| 6772 return true; | 6773 return true; |
| 6773 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) | 6774 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) |
| 6774 #undef COMPARE_AND_RETURN_NAME | 6775 #undef COMPARE_AND_RETURN_NAME |
| 6775 } | 6776 } |
| 6776 return false; | 6777 return false; |
| 6777 } | 6778 } |
| 6778 } // namespace internal | 6779 } // namespace internal |
| 6779 } // namespace v8 | 6780 } // namespace v8 |
| OLD | NEW |