| 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 1956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1967 // Take another spin if there are now unswept objects in new space | 1967 // Take another spin if there are now unswept objects in new space |
| 1968 // (there are currently no more unswept promoted objects). | 1968 // (there are currently no more unswept promoted objects). |
| 1969 } while (new_space_front != new_space_.top()); | 1969 } while (new_space_front != new_space_.top()); |
| 1970 | 1970 |
| 1971 return new_space_front; | 1971 return new_space_front; |
| 1972 } | 1972 } |
| 1973 | 1973 |
| 1974 | 1974 |
| 1975 STATIC_ASSERT((FixedDoubleArray::kHeaderSize & kDoubleAlignmentMask) == | 1975 STATIC_ASSERT((FixedDoubleArray::kHeaderSize & kDoubleAlignmentMask) == |
| 1976 0); // NOLINT | 1976 0); // NOLINT |
| 1977 STATIC_ASSERT((ConstantPoolArray::kFirstEntryOffset & kDoubleAlignmentMask) == | |
| 1978 0); // NOLINT | |
| 1979 STATIC_ASSERT((ConstantPoolArray::kExtendedFirstOffset & | |
| 1980 kDoubleAlignmentMask) == 0); // NOLINT | |
| 1981 STATIC_ASSERT((FixedTypedArrayBase::kDataOffset & kDoubleAlignmentMask) == | 1977 STATIC_ASSERT((FixedTypedArrayBase::kDataOffset & kDoubleAlignmentMask) == |
| 1982 0); // NOLINT | 1978 0); // NOLINT |
| 1983 #ifdef V8_HOST_ARCH_32_BIT | 1979 #ifdef V8_HOST_ARCH_32_BIT |
| 1984 STATIC_ASSERT((HeapNumber::kValueOffset & kDoubleAlignmentMask) != | 1980 STATIC_ASSERT((HeapNumber::kValueOffset & kDoubleAlignmentMask) != |
| 1985 0); // NOLINT | 1981 0); // NOLINT |
| 1986 #endif | 1982 #endif |
| 1987 | 1983 |
| 1988 | 1984 |
| 1989 int Heap::GetMaximumFillToAlign(AllocationAlignment alignment) { | 1985 int Heap::GetMaximumFillToAlign(AllocationAlignment alignment) { |
| 1990 switch (alignment) { | 1986 switch (alignment) { |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2610 #define ALLOCATE_PARTIAL_MAP(instance_type, size, field_name) \ | 2606 #define ALLOCATE_PARTIAL_MAP(instance_type, size, field_name) \ |
| 2611 { \ | 2607 { \ |
| 2612 Map* map; \ | 2608 Map* map; \ |
| 2613 if (!AllocatePartialMap((instance_type), (size)).To(&map)) return false; \ | 2609 if (!AllocatePartialMap((instance_type), (size)).To(&map)) return false; \ |
| 2614 set_##field_name##_map(map); \ | 2610 set_##field_name##_map(map); \ |
| 2615 } | 2611 } |
| 2616 | 2612 |
| 2617 ALLOCATE_PARTIAL_MAP(FIXED_ARRAY_TYPE, kVariableSizeSentinel, fixed_array); | 2613 ALLOCATE_PARTIAL_MAP(FIXED_ARRAY_TYPE, kVariableSizeSentinel, fixed_array); |
| 2618 ALLOCATE_PARTIAL_MAP(ODDBALL_TYPE, Oddball::kSize, undefined); | 2614 ALLOCATE_PARTIAL_MAP(ODDBALL_TYPE, Oddball::kSize, undefined); |
| 2619 ALLOCATE_PARTIAL_MAP(ODDBALL_TYPE, Oddball::kSize, null); | 2615 ALLOCATE_PARTIAL_MAP(ODDBALL_TYPE, Oddball::kSize, null); |
| 2620 ALLOCATE_PARTIAL_MAP(CONSTANT_POOL_ARRAY_TYPE, kVariableSizeSentinel, | |
| 2621 constant_pool_array); | |
| 2622 | 2616 |
| 2623 #undef ALLOCATE_PARTIAL_MAP | 2617 #undef ALLOCATE_PARTIAL_MAP |
| 2624 } | 2618 } |
| 2625 | 2619 |
| 2626 // Allocate the empty array. | 2620 // Allocate the empty array. |
| 2627 { | 2621 { |
| 2628 AllocationResult allocation = AllocateEmptyFixedArray(); | 2622 AllocationResult allocation = AllocateEmptyFixedArray(); |
| 2629 if (!allocation.To(&obj)) return false; | 2623 if (!allocation.To(&obj)) return false; |
| 2630 } | 2624 } |
| 2631 set_empty_fixed_array(FixedArray::cast(obj)); | 2625 set_empty_fixed_array(FixedArray::cast(obj)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2648 // Set preliminary exception sentinel value before actually initializing it. | 2642 // Set preliminary exception sentinel value before actually initializing it. |
| 2649 set_exception(null_value()); | 2643 set_exception(null_value()); |
| 2650 | 2644 |
| 2651 // Allocate the empty descriptor array. | 2645 // Allocate the empty descriptor array. |
| 2652 { | 2646 { |
| 2653 AllocationResult allocation = AllocateEmptyFixedArray(); | 2647 AllocationResult allocation = AllocateEmptyFixedArray(); |
| 2654 if (!allocation.To(&obj)) return false; | 2648 if (!allocation.To(&obj)) return false; |
| 2655 } | 2649 } |
| 2656 set_empty_descriptor_array(DescriptorArray::cast(obj)); | 2650 set_empty_descriptor_array(DescriptorArray::cast(obj)); |
| 2657 | 2651 |
| 2658 // Allocate the constant pool array. | |
| 2659 { | |
| 2660 AllocationResult allocation = AllocateEmptyConstantPoolArray(); | |
| 2661 if (!allocation.To(&obj)) return false; | |
| 2662 } | |
| 2663 set_empty_constant_pool_array(ConstantPoolArray::cast(obj)); | |
| 2664 | |
| 2665 // Fix the instance_descriptors for the existing maps. | 2652 // Fix the instance_descriptors for the existing maps. |
| 2666 meta_map()->set_code_cache(empty_fixed_array()); | 2653 meta_map()->set_code_cache(empty_fixed_array()); |
| 2667 meta_map()->set_dependent_code(DependentCode::cast(empty_fixed_array())); | 2654 meta_map()->set_dependent_code(DependentCode::cast(empty_fixed_array())); |
| 2668 meta_map()->set_raw_transitions(Smi::FromInt(0)); | 2655 meta_map()->set_raw_transitions(Smi::FromInt(0)); |
| 2669 meta_map()->set_instance_descriptors(empty_descriptor_array()); | 2656 meta_map()->set_instance_descriptors(empty_descriptor_array()); |
| 2670 if (FLAG_unbox_double_fields) { | 2657 if (FLAG_unbox_double_fields) { |
| 2671 meta_map()->set_layout_descriptor(LayoutDescriptor::FastPointerLayout()); | 2658 meta_map()->set_layout_descriptor(LayoutDescriptor::FastPointerLayout()); |
| 2672 } | 2659 } |
| 2673 | 2660 |
| 2674 fixed_array_map()->set_code_cache(empty_fixed_array()); | 2661 fixed_array_map()->set_code_cache(empty_fixed_array()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2691 } | 2678 } |
| 2692 | 2679 |
| 2693 null_map()->set_code_cache(empty_fixed_array()); | 2680 null_map()->set_code_cache(empty_fixed_array()); |
| 2694 null_map()->set_dependent_code(DependentCode::cast(empty_fixed_array())); | 2681 null_map()->set_dependent_code(DependentCode::cast(empty_fixed_array())); |
| 2695 null_map()->set_raw_transitions(Smi::FromInt(0)); | 2682 null_map()->set_raw_transitions(Smi::FromInt(0)); |
| 2696 null_map()->set_instance_descriptors(empty_descriptor_array()); | 2683 null_map()->set_instance_descriptors(empty_descriptor_array()); |
| 2697 if (FLAG_unbox_double_fields) { | 2684 if (FLAG_unbox_double_fields) { |
| 2698 null_map()->set_layout_descriptor(LayoutDescriptor::FastPointerLayout()); | 2685 null_map()->set_layout_descriptor(LayoutDescriptor::FastPointerLayout()); |
| 2699 } | 2686 } |
| 2700 | 2687 |
| 2701 constant_pool_array_map()->set_code_cache(empty_fixed_array()); | |
| 2702 constant_pool_array_map()->set_dependent_code( | |
| 2703 DependentCode::cast(empty_fixed_array())); | |
| 2704 constant_pool_array_map()->set_raw_transitions(Smi::FromInt(0)); | |
| 2705 constant_pool_array_map()->set_instance_descriptors(empty_descriptor_array()); | |
| 2706 if (FLAG_unbox_double_fields) { | |
| 2707 constant_pool_array_map()->set_layout_descriptor( | |
| 2708 LayoutDescriptor::FastPointerLayout()); | |
| 2709 } | |
| 2710 | |
| 2711 // Fix prototype object for existing maps. | 2688 // Fix prototype object for existing maps. |
| 2712 meta_map()->set_prototype(null_value()); | 2689 meta_map()->set_prototype(null_value()); |
| 2713 meta_map()->set_constructor_or_backpointer(null_value()); | 2690 meta_map()->set_constructor_or_backpointer(null_value()); |
| 2714 | 2691 |
| 2715 fixed_array_map()->set_prototype(null_value()); | 2692 fixed_array_map()->set_prototype(null_value()); |
| 2716 fixed_array_map()->set_constructor_or_backpointer(null_value()); | 2693 fixed_array_map()->set_constructor_or_backpointer(null_value()); |
| 2717 | 2694 |
| 2718 undefined_map()->set_prototype(null_value()); | 2695 undefined_map()->set_prototype(null_value()); |
| 2719 undefined_map()->set_constructor_or_backpointer(null_value()); | 2696 undefined_map()->set_constructor_or_backpointer(null_value()); |
| 2720 | 2697 |
| 2721 null_map()->set_prototype(null_value()); | 2698 null_map()->set_prototype(null_value()); |
| 2722 null_map()->set_constructor_or_backpointer(null_value()); | 2699 null_map()->set_constructor_or_backpointer(null_value()); |
| 2723 | 2700 |
| 2724 constant_pool_array_map()->set_prototype(null_value()); | |
| 2725 constant_pool_array_map()->set_constructor_or_backpointer(null_value()); | |
| 2726 | |
| 2727 { // Map allocation | 2701 { // Map allocation |
| 2728 #define ALLOCATE_MAP(instance_type, size, field_name) \ | 2702 #define ALLOCATE_MAP(instance_type, size, field_name) \ |
| 2729 { \ | 2703 { \ |
| 2730 Map* map; \ | 2704 Map* map; \ |
| 2731 if (!AllocateMap((instance_type), size).To(&map)) return false; \ | 2705 if (!AllocateMap((instance_type), size).To(&map)) return false; \ |
| 2732 set_##field_name##_map(map); \ | 2706 set_##field_name##_map(map); \ |
| 2733 } | 2707 } |
| 2734 | 2708 |
| 2735 #define ALLOCATE_VARSIZE_MAP(instance_type, field_name) \ | 2709 #define ALLOCATE_VARSIZE_MAP(instance_type, field_name) \ |
| 2736 ALLOCATE_MAP(instance_type, kVariableSizeSentinel, field_name) | 2710 ALLOCATE_MAP(instance_type, kVariableSizeSentinel, field_name) |
| (...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3815 DCHECK(isolate_->code_range() == NULL || !isolate_->code_range()->valid() || | 3789 DCHECK(isolate_->code_range() == NULL || !isolate_->code_range()->valid() || |
| 3816 isolate_->code_range()->contains(code->address())); | 3790 isolate_->code_range()->contains(code->address())); |
| 3817 code->set_gc_metadata(Smi::FromInt(0)); | 3791 code->set_gc_metadata(Smi::FromInt(0)); |
| 3818 code->set_ic_age(global_ic_age_); | 3792 code->set_ic_age(global_ic_age_); |
| 3819 return code; | 3793 return code; |
| 3820 } | 3794 } |
| 3821 | 3795 |
| 3822 | 3796 |
| 3823 AllocationResult Heap::CopyCode(Code* code) { | 3797 AllocationResult Heap::CopyCode(Code* code) { |
| 3824 AllocationResult allocation; | 3798 AllocationResult allocation; |
| 3825 HeapObject* new_constant_pool; | |
| 3826 if (FLAG_enable_ool_constant_pool && | |
| 3827 code->constant_pool() != empty_constant_pool_array()) { | |
| 3828 // Copy the constant pool, since edits to the copied code may modify | |
| 3829 // the constant pool. | |
| 3830 allocation = CopyConstantPoolArray(code->constant_pool()); | |
| 3831 if (!allocation.To(&new_constant_pool)) return allocation; | |
| 3832 } else { | |
| 3833 new_constant_pool = empty_constant_pool_array(); | |
| 3834 } | |
| 3835 | 3799 |
| 3836 HeapObject* result = NULL; | 3800 HeapObject* result = NULL; |
| 3837 // Allocate an object the same size as the code object. | 3801 // Allocate an object the same size as the code object. |
| 3838 int obj_size = code->Size(); | 3802 int obj_size = code->Size(); |
| 3839 allocation = AllocateRaw(obj_size, CODE_SPACE, CODE_SPACE); | 3803 allocation = AllocateRaw(obj_size, CODE_SPACE, CODE_SPACE); |
| 3840 if (!allocation.To(&result)) return allocation; | 3804 if (!allocation.To(&result)) return allocation; |
| 3841 | 3805 |
| 3842 // Copy code object. | 3806 // Copy code object. |
| 3843 Address old_addr = code->address(); | 3807 Address old_addr = code->address(); |
| 3844 Address new_addr = result->address(); | 3808 Address new_addr = result->address(); |
| 3845 CopyBlock(new_addr, old_addr, obj_size); | 3809 CopyBlock(new_addr, old_addr, obj_size); |
| 3846 Code* new_code = Code::cast(result); | 3810 Code* new_code = Code::cast(result); |
| 3847 | 3811 |
| 3848 // Update the constant pool. | |
| 3849 new_code->set_constant_pool(new_constant_pool); | |
| 3850 | |
| 3851 // Relocate the copy. | 3812 // Relocate the copy. |
| 3852 DCHECK(IsAligned(bit_cast<intptr_t>(new_code->address()), kCodeAlignment)); | 3813 DCHECK(IsAligned(bit_cast<intptr_t>(new_code->address()), kCodeAlignment)); |
| 3853 DCHECK(isolate_->code_range() == NULL || !isolate_->code_range()->valid() || | 3814 DCHECK(isolate_->code_range() == NULL || !isolate_->code_range()->valid() || |
| 3854 isolate_->code_range()->contains(code->address())); | 3815 isolate_->code_range()->contains(code->address())); |
| 3855 new_code->Relocate(new_addr - old_addr); | 3816 new_code->Relocate(new_addr - old_addr); |
| 3856 return new_code; | 3817 return new_code; |
| 3857 } | 3818 } |
| 3858 | 3819 |
| 3859 | 3820 |
| 3860 AllocationResult Heap::CopyCode(Code* code, Vector<byte> reloc_info) { | 3821 AllocationResult Heap::CopyCode(Code* code, Vector<byte> reloc_info) { |
| 3861 // Allocate ByteArray and ConstantPoolArray before the Code object, so that we | 3822 // Allocate ByteArray before the Code object, so that we do not risk |
| 3862 // do not risk leaving uninitialized Code object (and breaking the heap). | 3823 // leaving uninitialized Code object (and breaking the heap). |
| 3863 ByteArray* reloc_info_array; | 3824 ByteArray* reloc_info_array; |
| 3864 { | 3825 { |
| 3865 AllocationResult allocation = | 3826 AllocationResult allocation = |
| 3866 AllocateByteArray(reloc_info.length(), TENURED); | 3827 AllocateByteArray(reloc_info.length(), TENURED); |
| 3867 if (!allocation.To(&reloc_info_array)) return allocation; | 3828 if (!allocation.To(&reloc_info_array)) return allocation; |
| 3868 } | 3829 } |
| 3869 HeapObject* new_constant_pool; | |
| 3870 if (FLAG_enable_ool_constant_pool && | |
| 3871 code->constant_pool() != empty_constant_pool_array()) { | |
| 3872 // Copy the constant pool, since edits to the copied code may modify | |
| 3873 // the constant pool. | |
| 3874 AllocationResult allocation = CopyConstantPoolArray(code->constant_pool()); | |
| 3875 if (!allocation.To(&new_constant_pool)) return allocation; | |
| 3876 } else { | |
| 3877 new_constant_pool = empty_constant_pool_array(); | |
| 3878 } | |
| 3879 | 3830 |
| 3880 int new_body_size = RoundUp(code->instruction_size(), kObjectAlignment); | 3831 int new_body_size = RoundUp(code->instruction_size(), kObjectAlignment); |
| 3881 | 3832 |
| 3882 int new_obj_size = Code::SizeFor(new_body_size); | 3833 int new_obj_size = Code::SizeFor(new_body_size); |
| 3883 | 3834 |
| 3884 Address old_addr = code->address(); | 3835 Address old_addr = code->address(); |
| 3885 | 3836 |
| 3886 size_t relocation_offset = | 3837 size_t relocation_offset = |
| 3887 static_cast<size_t>(code->instruction_end() - old_addr); | 3838 static_cast<size_t>(code->instruction_end() - old_addr); |
| 3888 | 3839 |
| 3889 HeapObject* result; | 3840 HeapObject* result; |
| 3890 AllocationResult allocation = | 3841 AllocationResult allocation = |
| 3891 AllocateRaw(new_obj_size, CODE_SPACE, CODE_SPACE); | 3842 AllocateRaw(new_obj_size, CODE_SPACE, CODE_SPACE); |
| 3892 if (!allocation.To(&result)) return allocation; | 3843 if (!allocation.To(&result)) return allocation; |
| 3893 | 3844 |
| 3894 // Copy code object. | 3845 // Copy code object. |
| 3895 Address new_addr = result->address(); | 3846 Address new_addr = result->address(); |
| 3896 | 3847 |
| 3897 // Copy header and instructions. | 3848 // Copy header and instructions. |
| 3898 CopyBytes(new_addr, old_addr, relocation_offset); | 3849 CopyBytes(new_addr, old_addr, relocation_offset); |
| 3899 | 3850 |
| 3900 Code* new_code = Code::cast(result); | 3851 Code* new_code = Code::cast(result); |
| 3901 new_code->set_relocation_info(reloc_info_array); | 3852 new_code->set_relocation_info(reloc_info_array); |
| 3902 | 3853 |
| 3903 // Update constant pool. | |
| 3904 new_code->set_constant_pool(new_constant_pool); | |
| 3905 | |
| 3906 // Copy patched rinfo. | 3854 // Copy patched rinfo. |
| 3907 CopyBytes(new_code->relocation_start(), reloc_info.start(), | 3855 CopyBytes(new_code->relocation_start(), reloc_info.start(), |
| 3908 static_cast<size_t>(reloc_info.length())); | 3856 static_cast<size_t>(reloc_info.length())); |
| 3909 | 3857 |
| 3910 // Relocate the copy. | 3858 // Relocate the copy. |
| 3911 DCHECK(IsAligned(bit_cast<intptr_t>(new_code->address()), kCodeAlignment)); | 3859 DCHECK(IsAligned(bit_cast<intptr_t>(new_code->address()), kCodeAlignment)); |
| 3912 DCHECK(isolate_->code_range() == NULL || !isolate_->code_range()->valid() || | 3860 DCHECK(isolate_->code_range() == NULL || !isolate_->code_range()->valid() || |
| 3913 isolate_->code_range()->contains(code->address())); | 3861 isolate_->code_range()->contains(code->address())); |
| 3914 new_code->Relocate(new_addr - old_addr); | 3862 new_code->Relocate(new_addr - old_addr); |
| 3915 | 3863 |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4388 if (!allocation.To(&obj)) return allocation; | 4336 if (!allocation.To(&obj)) return allocation; |
| 4389 } | 4337 } |
| 4390 obj->set_map_no_write_barrier(map); | 4338 obj->set_map_no_write_barrier(map); |
| 4391 CopyBlock(obj->address() + FixedDoubleArray::kLengthOffset, | 4339 CopyBlock(obj->address() + FixedDoubleArray::kLengthOffset, |
| 4392 src->address() + FixedDoubleArray::kLengthOffset, | 4340 src->address() + FixedDoubleArray::kLengthOffset, |
| 4393 FixedDoubleArray::SizeFor(len) - FixedDoubleArray::kLengthOffset); | 4341 FixedDoubleArray::SizeFor(len) - FixedDoubleArray::kLengthOffset); |
| 4394 return obj; | 4342 return obj; |
| 4395 } | 4343 } |
| 4396 | 4344 |
| 4397 | 4345 |
| 4398 AllocationResult Heap::CopyConstantPoolArrayWithMap(ConstantPoolArray* src, | |
| 4399 Map* map) { | |
| 4400 HeapObject* obj; | |
| 4401 if (src->is_extended_layout()) { | |
| 4402 ConstantPoolArray::NumberOfEntries small(src, | |
| 4403 ConstantPoolArray::SMALL_SECTION); | |
| 4404 ConstantPoolArray::NumberOfEntries extended( | |
| 4405 src, ConstantPoolArray::EXTENDED_SECTION); | |
| 4406 AllocationResult allocation = | |
| 4407 AllocateExtendedConstantPoolArray(small, extended); | |
| 4408 if (!allocation.To(&obj)) return allocation; | |
| 4409 } else { | |
| 4410 ConstantPoolArray::NumberOfEntries small(src, | |
| 4411 ConstantPoolArray::SMALL_SECTION); | |
| 4412 AllocationResult allocation = AllocateConstantPoolArray(small); | |
| 4413 if (!allocation.To(&obj)) return allocation; | |
| 4414 } | |
| 4415 obj->set_map_no_write_barrier(map); | |
| 4416 CopyBlock(obj->address() + ConstantPoolArray::kFirstEntryOffset, | |
| 4417 src->address() + ConstantPoolArray::kFirstEntryOffset, | |
| 4418 src->size() - ConstantPoolArray::kFirstEntryOffset); | |
| 4419 return obj; | |
| 4420 } | |
| 4421 | |
| 4422 | |
| 4423 AllocationResult Heap::AllocateRawFixedArray(int length, | 4346 AllocationResult Heap::AllocateRawFixedArray(int length, |
| 4424 PretenureFlag pretenure) { | 4347 PretenureFlag pretenure) { |
| 4425 if (length < 0 || length > FixedArray::kMaxLength) { | 4348 if (length < 0 || length > FixedArray::kMaxLength) { |
| 4426 v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); | 4349 v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); |
| 4427 } | 4350 } |
| 4428 int size = FixedArray::SizeFor(length); | 4351 int size = FixedArray::SizeFor(length); |
| 4429 AllocationSpace space = SelectSpace(size, pretenure); | 4352 AllocationSpace space = SelectSpace(size, pretenure); |
| 4430 | 4353 |
| 4431 return AllocateRaw(size, space, OLD_SPACE); | 4354 return AllocateRaw(size, space, OLD_SPACE); |
| 4432 } | 4355 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4501 { | 4424 { |
| 4502 AllocationResult allocation = | 4425 AllocationResult allocation = |
| 4503 AllocateRaw(size, space, OLD_SPACE, kDoubleAligned); | 4426 AllocateRaw(size, space, OLD_SPACE, kDoubleAligned); |
| 4504 if (!allocation.To(&object)) return allocation; | 4427 if (!allocation.To(&object)) return allocation; |
| 4505 } | 4428 } |
| 4506 | 4429 |
| 4507 return object; | 4430 return object; |
| 4508 } | 4431 } |
| 4509 | 4432 |
| 4510 | 4433 |
| 4511 AllocationResult Heap::AllocateConstantPoolArray( | |
| 4512 const ConstantPoolArray::NumberOfEntries& small) { | |
| 4513 CHECK(small.are_in_range(0, ConstantPoolArray::kMaxSmallEntriesPerType)); | |
| 4514 int size = ConstantPoolArray::SizeFor(small); | |
| 4515 AllocationSpace space = SelectSpace(size, TENURED); | |
| 4516 | |
| 4517 HeapObject* object = nullptr; | |
| 4518 { | |
| 4519 AllocationResult allocation = | |
| 4520 AllocateRaw(size, space, OLD_SPACE, kDoubleAligned); | |
| 4521 if (!allocation.To(&object)) return allocation; | |
| 4522 } | |
| 4523 object->set_map_no_write_barrier(constant_pool_array_map()); | |
| 4524 | |
| 4525 ConstantPoolArray* constant_pool = ConstantPoolArray::cast(object); | |
| 4526 constant_pool->Init(small); | |
| 4527 constant_pool->ClearPtrEntries(isolate()); | |
| 4528 return constant_pool; | |
| 4529 } | |
| 4530 | |
| 4531 | |
| 4532 AllocationResult Heap::AllocateExtendedConstantPoolArray( | |
| 4533 const ConstantPoolArray::NumberOfEntries& small, | |
| 4534 const ConstantPoolArray::NumberOfEntries& extended) { | |
| 4535 CHECK(small.are_in_range(0, ConstantPoolArray::kMaxSmallEntriesPerType)); | |
| 4536 CHECK(extended.are_in_range(0, kMaxInt)); | |
| 4537 int size = ConstantPoolArray::SizeForExtended(small, extended); | |
| 4538 AllocationSpace space = SelectSpace(size, TENURED); | |
| 4539 | |
| 4540 HeapObject* object = nullptr; | |
| 4541 { | |
| 4542 AllocationResult allocation = | |
| 4543 AllocateRaw(size, space, OLD_SPACE, kDoubleAligned); | |
| 4544 if (!allocation.To(&object)) return allocation; | |
| 4545 } | |
| 4546 object->set_map_no_write_barrier(constant_pool_array_map()); | |
| 4547 | |
| 4548 ConstantPoolArray* constant_pool = ConstantPoolArray::cast(object); | |
| 4549 constant_pool->InitExtended(small, extended); | |
| 4550 constant_pool->ClearPtrEntries(isolate()); | |
| 4551 return constant_pool; | |
| 4552 } | |
| 4553 | |
| 4554 | |
| 4555 AllocationResult Heap::AllocateEmptyConstantPoolArray() { | |
| 4556 ConstantPoolArray::NumberOfEntries small(0, 0, 0, 0); | |
| 4557 int size = ConstantPoolArray::SizeFor(small); | |
| 4558 HeapObject* result = NULL; | |
| 4559 { | |
| 4560 AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE); | |
| 4561 if (!allocation.To(&result)) return allocation; | |
| 4562 } | |
| 4563 result->set_map_no_write_barrier(constant_pool_array_map()); | |
| 4564 ConstantPoolArray::cast(result)->Init(small); | |
| 4565 return result; | |
| 4566 } | |
| 4567 | |
| 4568 | |
| 4569 AllocationResult Heap::AllocateSymbol() { | 4434 AllocationResult Heap::AllocateSymbol() { |
| 4570 // Statically ensure that it is safe to allocate symbols in paged spaces. | 4435 // Statically ensure that it is safe to allocate symbols in paged spaces. |
| 4571 STATIC_ASSERT(Symbol::kSize <= Page::kMaxRegularHeapObjectSize); | 4436 STATIC_ASSERT(Symbol::kSize <= Page::kMaxRegularHeapObjectSize); |
| 4572 | 4437 |
| 4573 HeapObject* result = NULL; | 4438 HeapObject* result = NULL; |
| 4574 AllocationResult allocation = | 4439 AllocationResult allocation = |
| 4575 AllocateRaw(Symbol::kSize, OLD_SPACE, OLD_SPACE); | 4440 AllocateRaw(Symbol::kSize, OLD_SPACE, OLD_SPACE); |
| 4576 if (!allocation.To(&result)) return allocation; | 4441 if (!allocation.To(&result)) return allocation; |
| 4577 | 4442 |
| 4578 result->set_map_no_write_barrier(symbol_map()); | 4443 result->set_map_no_write_barrier(symbol_map()); |
| (...skipping 2119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6698 *object_type = "CODE_TYPE"; \ | 6563 *object_type = "CODE_TYPE"; \ |
| 6699 *object_sub_type = "CODE_AGE/" #name; \ | 6564 *object_sub_type = "CODE_AGE/" #name; \ |
| 6700 return true; | 6565 return true; |
| 6701 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) | 6566 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) |
| 6702 #undef COMPARE_AND_RETURN_NAME | 6567 #undef COMPARE_AND_RETURN_NAME |
| 6703 } | 6568 } |
| 6704 return false; | 6569 return false; |
| 6705 } | 6570 } |
| 6706 } // namespace internal | 6571 } // namespace internal |
| 6707 } // namespace v8 | 6572 } // namespace v8 |
| OLD | NEW |