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 2906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2917 #undef ALLOCATE_MAP | 2917 #undef ALLOCATE_MAP |
2918 } | 2918 } |
2919 | 2919 |
2920 { // Empty arrays | 2920 { // Empty arrays |
2921 { | 2921 { |
2922 ByteArray* byte_array; | 2922 ByteArray* byte_array; |
2923 if (!AllocateByteArray(0, TENURED).To(&byte_array)) return false; | 2923 if (!AllocateByteArray(0, TENURED).To(&byte_array)) return false; |
2924 set_empty_byte_array(byte_array); | 2924 set_empty_byte_array(byte_array); |
2925 | 2925 |
2926 BytecodeArray* bytecode_array; | 2926 BytecodeArray* bytecode_array; |
2927 AllocationResult allocation = | 2927 AllocationResult allocation = AllocateBytecodeArray(0, nullptr, 0, 0); |
2928 AllocateBytecodeArray(0, nullptr, kPointerSize); | |
2929 if (!allocation.To(&bytecode_array)) { | 2928 if (!allocation.To(&bytecode_array)) { |
2930 return false; | 2929 return false; |
2931 } | 2930 } |
2932 set_empty_bytecode_array(bytecode_array); | 2931 set_empty_bytecode_array(bytecode_array); |
2933 } | 2932 } |
2934 | 2933 |
2935 #define ALLOCATE_EMPTY_FIXED_TYPED_ARRAY(Type, type, TYPE, ctype, size) \ | 2934 #define ALLOCATE_EMPTY_FIXED_TYPED_ARRAY(Type, type, TYPE, ctype, size) \ |
2936 { \ | 2935 { \ |
2937 FixedTypedArrayBase* obj; \ | 2936 FixedTypedArrayBase* obj; \ |
2938 if (!AllocateEmptyFixedTypedArray(kExternal##Type##Array).To(&obj)) \ | 2937 if (!AllocateEmptyFixedTypedArray(kExternal##Type##Array).To(&obj)) \ |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3517 } | 3516 } |
3518 | 3517 |
3519 result->set_map_no_write_barrier(byte_array_map()); | 3518 result->set_map_no_write_barrier(byte_array_map()); |
3520 ByteArray::cast(result)->set_length(length); | 3519 ByteArray::cast(result)->set_length(length); |
3521 return result; | 3520 return result; |
3522 } | 3521 } |
3523 | 3522 |
3524 | 3523 |
3525 AllocationResult Heap::AllocateBytecodeArray(int length, | 3524 AllocationResult Heap::AllocateBytecodeArray(int length, |
3526 const byte* const raw_bytecodes, | 3525 const byte* const raw_bytecodes, |
3527 int frame_size) { | 3526 int frame_size, |
| 3527 int parameter_count) { |
3528 if (length < 0 || length > BytecodeArray::kMaxLength) { | 3528 if (length < 0 || length > BytecodeArray::kMaxLength) { |
3529 v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); | 3529 v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); |
3530 } | 3530 } |
3531 | 3531 |
3532 int size = BytecodeArray::SizeFor(length); | 3532 int size = BytecodeArray::SizeFor(length); |
3533 HeapObject* result; | 3533 HeapObject* result; |
3534 { | 3534 { |
3535 AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE); | 3535 AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE); |
3536 if (!allocation.To(&result)) return allocation; | 3536 if (!allocation.To(&result)) return allocation; |
3537 } | 3537 } |
3538 | 3538 |
3539 result->set_map_no_write_barrier(bytecode_array_map()); | 3539 result->set_map_no_write_barrier(bytecode_array_map()); |
3540 BytecodeArray* instance = BytecodeArray::cast(result); | 3540 BytecodeArray* instance = BytecodeArray::cast(result); |
3541 instance->set_length(length); | 3541 instance->set_length(length); |
3542 instance->set_frame_size(frame_size); | 3542 instance->set_frame_size(frame_size); |
| 3543 instance->set_parameter_count(parameter_count); |
3543 CopyBytes(instance->GetFirstBytecodeAddress(), raw_bytecodes, length); | 3544 CopyBytes(instance->GetFirstBytecodeAddress(), raw_bytecodes, length); |
3544 | 3545 |
3545 return result; | 3546 return result; |
3546 } | 3547 } |
3547 | 3548 |
3548 | 3549 |
3549 void Heap::CreateFillerObjectAt(Address addr, int size) { | 3550 void Heap::CreateFillerObjectAt(Address addr, int size) { |
3550 if (size == 0) return; | 3551 if (size == 0) return; |
3551 HeapObject* filler = HeapObject::FromAddress(addr); | 3552 HeapObject* filler = HeapObject::FromAddress(addr); |
3552 if (size == kPointerSize) { | 3553 if (size == kPointerSize) { |
(...skipping 3229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6782 *object_type = "CODE_TYPE"; \ | 6783 *object_type = "CODE_TYPE"; \ |
6783 *object_sub_type = "CODE_AGE/" #name; \ | 6784 *object_sub_type = "CODE_AGE/" #name; \ |
6784 return true; | 6785 return true; |
6785 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) | 6786 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) |
6786 #undef COMPARE_AND_RETURN_NAME | 6787 #undef COMPARE_AND_RETURN_NAME |
6787 } | 6788 } |
6788 return false; | 6789 return false; |
6789 } | 6790 } |
6790 } // namespace internal | 6791 } // namespace internal |
6791 } // namespace v8 | 6792 } // namespace v8 |
OLD | NEW |