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 1958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1969 // Take another spin if there are now unswept objects in new space | 1969 // Take another spin if there are now unswept objects in new space |
1970 // (there are currently no more unswept promoted objects). | 1970 // (there are currently no more unswept promoted objects). |
1971 } while (new_space_front != new_space_.top()); | 1971 } while (new_space_front != new_space_.top()); |
1972 | 1972 |
1973 return new_space_front; | 1973 return new_space_front; |
1974 } | 1974 } |
1975 | 1975 |
1976 | 1976 |
1977 STATIC_ASSERT((FixedDoubleArray::kHeaderSize & kDoubleAlignmentMask) == | 1977 STATIC_ASSERT((FixedDoubleArray::kHeaderSize & kDoubleAlignmentMask) == |
1978 0); // NOLINT | 1978 0); // NOLINT |
| 1979 STATIC_ASSERT((ConstantPoolArray::kFirstEntryOffset & kDoubleAlignmentMask) == |
| 1980 0); // NOLINT |
| 1981 STATIC_ASSERT((ConstantPoolArray::kExtendedFirstOffset & |
| 1982 kDoubleAlignmentMask) == 0); // NOLINT |
1979 STATIC_ASSERT((FixedTypedArrayBase::kDataOffset & kDoubleAlignmentMask) == | 1983 STATIC_ASSERT((FixedTypedArrayBase::kDataOffset & kDoubleAlignmentMask) == |
1980 0); // NOLINT | 1984 0); // NOLINT |
1981 #ifdef V8_HOST_ARCH_32_BIT | 1985 #ifdef V8_HOST_ARCH_32_BIT |
1982 STATIC_ASSERT((HeapNumber::kValueOffset & kDoubleAlignmentMask) != | 1986 STATIC_ASSERT((HeapNumber::kValueOffset & kDoubleAlignmentMask) != |
1983 0); // NOLINT | 1987 0); // NOLINT |
1984 #endif | 1988 #endif |
1985 | 1989 |
1986 | 1990 |
1987 int Heap::GetMaximumFillToAlign(AllocationAlignment alignment) { | 1991 int Heap::GetMaximumFillToAlign(AllocationAlignment alignment) { |
1988 switch (alignment) { | 1992 switch (alignment) { |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2602 #define ALLOCATE_PARTIAL_MAP(instance_type, size, field_name) \ | 2606 #define ALLOCATE_PARTIAL_MAP(instance_type, size, field_name) \ |
2603 { \ | 2607 { \ |
2604 Map* map; \ | 2608 Map* map; \ |
2605 if (!AllocatePartialMap((instance_type), (size)).To(&map)) return false; \ | 2609 if (!AllocatePartialMap((instance_type), (size)).To(&map)) return false; \ |
2606 set_##field_name##_map(map); \ | 2610 set_##field_name##_map(map); \ |
2607 } | 2611 } |
2608 | 2612 |
2609 ALLOCATE_PARTIAL_MAP(FIXED_ARRAY_TYPE, kVariableSizeSentinel, fixed_array); | 2613 ALLOCATE_PARTIAL_MAP(FIXED_ARRAY_TYPE, kVariableSizeSentinel, fixed_array); |
2610 ALLOCATE_PARTIAL_MAP(ODDBALL_TYPE, Oddball::kSize, undefined); | 2614 ALLOCATE_PARTIAL_MAP(ODDBALL_TYPE, Oddball::kSize, undefined); |
2611 ALLOCATE_PARTIAL_MAP(ODDBALL_TYPE, Oddball::kSize, null); | 2615 ALLOCATE_PARTIAL_MAP(ODDBALL_TYPE, Oddball::kSize, null); |
| 2616 ALLOCATE_PARTIAL_MAP(CONSTANT_POOL_ARRAY_TYPE, kVariableSizeSentinel, |
| 2617 constant_pool_array); |
2612 | 2618 |
2613 #undef ALLOCATE_PARTIAL_MAP | 2619 #undef ALLOCATE_PARTIAL_MAP |
2614 } | 2620 } |
2615 | 2621 |
2616 // Allocate the empty array. | 2622 // Allocate the empty array. |
2617 { | 2623 { |
2618 AllocationResult allocation = AllocateEmptyFixedArray(); | 2624 AllocationResult allocation = AllocateEmptyFixedArray(); |
2619 if (!allocation.To(&obj)) return false; | 2625 if (!allocation.To(&obj)) return false; |
2620 } | 2626 } |
2621 set_empty_fixed_array(FixedArray::cast(obj)); | 2627 set_empty_fixed_array(FixedArray::cast(obj)); |
(...skipping 16 matching lines...) Expand all Loading... |
2638 // Set preliminary exception sentinel value before actually initializing it. | 2644 // Set preliminary exception sentinel value before actually initializing it. |
2639 set_exception(null_value()); | 2645 set_exception(null_value()); |
2640 | 2646 |
2641 // Allocate the empty descriptor array. | 2647 // Allocate the empty descriptor array. |
2642 { | 2648 { |
2643 AllocationResult allocation = AllocateEmptyFixedArray(); | 2649 AllocationResult allocation = AllocateEmptyFixedArray(); |
2644 if (!allocation.To(&obj)) return false; | 2650 if (!allocation.To(&obj)) return false; |
2645 } | 2651 } |
2646 set_empty_descriptor_array(DescriptorArray::cast(obj)); | 2652 set_empty_descriptor_array(DescriptorArray::cast(obj)); |
2647 | 2653 |
| 2654 // Allocate the constant pool array. |
| 2655 { |
| 2656 AllocationResult allocation = AllocateEmptyConstantPoolArray(); |
| 2657 if (!allocation.To(&obj)) return false; |
| 2658 } |
| 2659 set_empty_constant_pool_array(ConstantPoolArray::cast(obj)); |
| 2660 |
2648 // Fix the instance_descriptors for the existing maps. | 2661 // Fix the instance_descriptors for the existing maps. |
2649 meta_map()->set_code_cache(empty_fixed_array()); | 2662 meta_map()->set_code_cache(empty_fixed_array()); |
2650 meta_map()->set_dependent_code(DependentCode::cast(empty_fixed_array())); | 2663 meta_map()->set_dependent_code(DependentCode::cast(empty_fixed_array())); |
2651 meta_map()->set_raw_transitions(Smi::FromInt(0)); | 2664 meta_map()->set_raw_transitions(Smi::FromInt(0)); |
2652 meta_map()->set_instance_descriptors(empty_descriptor_array()); | 2665 meta_map()->set_instance_descriptors(empty_descriptor_array()); |
2653 if (FLAG_unbox_double_fields) { | 2666 if (FLAG_unbox_double_fields) { |
2654 meta_map()->set_layout_descriptor(LayoutDescriptor::FastPointerLayout()); | 2667 meta_map()->set_layout_descriptor(LayoutDescriptor::FastPointerLayout()); |
2655 } | 2668 } |
2656 | 2669 |
2657 fixed_array_map()->set_code_cache(empty_fixed_array()); | 2670 fixed_array_map()->set_code_cache(empty_fixed_array()); |
(...skipping 16 matching lines...) Expand all Loading... |
2674 } | 2687 } |
2675 | 2688 |
2676 null_map()->set_code_cache(empty_fixed_array()); | 2689 null_map()->set_code_cache(empty_fixed_array()); |
2677 null_map()->set_dependent_code(DependentCode::cast(empty_fixed_array())); | 2690 null_map()->set_dependent_code(DependentCode::cast(empty_fixed_array())); |
2678 null_map()->set_raw_transitions(Smi::FromInt(0)); | 2691 null_map()->set_raw_transitions(Smi::FromInt(0)); |
2679 null_map()->set_instance_descriptors(empty_descriptor_array()); | 2692 null_map()->set_instance_descriptors(empty_descriptor_array()); |
2680 if (FLAG_unbox_double_fields) { | 2693 if (FLAG_unbox_double_fields) { |
2681 null_map()->set_layout_descriptor(LayoutDescriptor::FastPointerLayout()); | 2694 null_map()->set_layout_descriptor(LayoutDescriptor::FastPointerLayout()); |
2682 } | 2695 } |
2683 | 2696 |
| 2697 constant_pool_array_map()->set_code_cache(empty_fixed_array()); |
| 2698 constant_pool_array_map()->set_dependent_code( |
| 2699 DependentCode::cast(empty_fixed_array())); |
| 2700 constant_pool_array_map()->set_raw_transitions(Smi::FromInt(0)); |
| 2701 constant_pool_array_map()->set_instance_descriptors(empty_descriptor_array()); |
| 2702 if (FLAG_unbox_double_fields) { |
| 2703 constant_pool_array_map()->set_layout_descriptor( |
| 2704 LayoutDescriptor::FastPointerLayout()); |
| 2705 } |
| 2706 |
2684 // Fix prototype object for existing maps. | 2707 // Fix prototype object for existing maps. |
2685 meta_map()->set_prototype(null_value()); | 2708 meta_map()->set_prototype(null_value()); |
2686 meta_map()->set_constructor_or_backpointer(null_value()); | 2709 meta_map()->set_constructor_or_backpointer(null_value()); |
2687 | 2710 |
2688 fixed_array_map()->set_prototype(null_value()); | 2711 fixed_array_map()->set_prototype(null_value()); |
2689 fixed_array_map()->set_constructor_or_backpointer(null_value()); | 2712 fixed_array_map()->set_constructor_or_backpointer(null_value()); |
2690 | 2713 |
2691 undefined_map()->set_prototype(null_value()); | 2714 undefined_map()->set_prototype(null_value()); |
2692 undefined_map()->set_constructor_or_backpointer(null_value()); | 2715 undefined_map()->set_constructor_or_backpointer(null_value()); |
2693 | 2716 |
2694 null_map()->set_prototype(null_value()); | 2717 null_map()->set_prototype(null_value()); |
2695 null_map()->set_constructor_or_backpointer(null_value()); | 2718 null_map()->set_constructor_or_backpointer(null_value()); |
2696 | 2719 |
| 2720 constant_pool_array_map()->set_prototype(null_value()); |
| 2721 constant_pool_array_map()->set_constructor_or_backpointer(null_value()); |
| 2722 |
2697 { // Map allocation | 2723 { // Map allocation |
2698 #define ALLOCATE_MAP(instance_type, size, field_name) \ | 2724 #define ALLOCATE_MAP(instance_type, size, field_name) \ |
2699 { \ | 2725 { \ |
2700 Map* map; \ | 2726 Map* map; \ |
2701 if (!AllocateMap((instance_type), size).To(&map)) return false; \ | 2727 if (!AllocateMap((instance_type), size).To(&map)) return false; \ |
2702 set_##field_name##_map(map); \ | 2728 set_##field_name##_map(map); \ |
2703 } | 2729 } |
2704 | 2730 |
2705 #define ALLOCATE_VARSIZE_MAP(instance_type, field_name) \ | 2731 #define ALLOCATE_VARSIZE_MAP(instance_type, field_name) \ |
2706 ALLOCATE_MAP(instance_type, kVariableSizeSentinel, field_name) | 2732 ALLOCATE_MAP(instance_type, kVariableSizeSentinel, field_name) |
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3757 DCHECK(isolate_->code_range() == NULL || !isolate_->code_range()->valid() || | 3783 DCHECK(isolate_->code_range() == NULL || !isolate_->code_range()->valid() || |
3758 isolate_->code_range()->contains(code->address())); | 3784 isolate_->code_range()->contains(code->address())); |
3759 code->set_gc_metadata(Smi::FromInt(0)); | 3785 code->set_gc_metadata(Smi::FromInt(0)); |
3760 code->set_ic_age(global_ic_age_); | 3786 code->set_ic_age(global_ic_age_); |
3761 return code; | 3787 return code; |
3762 } | 3788 } |
3763 | 3789 |
3764 | 3790 |
3765 AllocationResult Heap::CopyCode(Code* code) { | 3791 AllocationResult Heap::CopyCode(Code* code) { |
3766 AllocationResult allocation; | 3792 AllocationResult allocation; |
| 3793 HeapObject* new_constant_pool; |
| 3794 if (FLAG_enable_ool_constant_pool && |
| 3795 code->constant_pool() != empty_constant_pool_array()) { |
| 3796 // Copy the constant pool, since edits to the copied code may modify |
| 3797 // the constant pool. |
| 3798 allocation = CopyConstantPoolArray(code->constant_pool()); |
| 3799 if (!allocation.To(&new_constant_pool)) return allocation; |
| 3800 } else { |
| 3801 new_constant_pool = empty_constant_pool_array(); |
| 3802 } |
3767 | 3803 |
3768 HeapObject* result = NULL; | 3804 HeapObject* result = NULL; |
3769 // Allocate an object the same size as the code object. | 3805 // Allocate an object the same size as the code object. |
3770 int obj_size = code->Size(); | 3806 int obj_size = code->Size(); |
3771 allocation = AllocateRaw(obj_size, CODE_SPACE, CODE_SPACE); | 3807 allocation = AllocateRaw(obj_size, CODE_SPACE, CODE_SPACE); |
3772 if (!allocation.To(&result)) return allocation; | 3808 if (!allocation.To(&result)) return allocation; |
3773 | 3809 |
3774 // Copy code object. | 3810 // Copy code object. |
3775 Address old_addr = code->address(); | 3811 Address old_addr = code->address(); |
3776 Address new_addr = result->address(); | 3812 Address new_addr = result->address(); |
3777 CopyBlock(new_addr, old_addr, obj_size); | 3813 CopyBlock(new_addr, old_addr, obj_size); |
3778 Code* new_code = Code::cast(result); | 3814 Code* new_code = Code::cast(result); |
3779 | 3815 |
| 3816 // Update the constant pool. |
| 3817 new_code->set_constant_pool(new_constant_pool); |
| 3818 |
3780 // Relocate the copy. | 3819 // Relocate the copy. |
3781 DCHECK(IsAligned(bit_cast<intptr_t>(new_code->address()), kCodeAlignment)); | 3820 DCHECK(IsAligned(bit_cast<intptr_t>(new_code->address()), kCodeAlignment)); |
3782 DCHECK(isolate_->code_range() == NULL || !isolate_->code_range()->valid() || | 3821 DCHECK(isolate_->code_range() == NULL || !isolate_->code_range()->valid() || |
3783 isolate_->code_range()->contains(code->address())); | 3822 isolate_->code_range()->contains(code->address())); |
3784 new_code->Relocate(new_addr - old_addr); | 3823 new_code->Relocate(new_addr - old_addr); |
3785 return new_code; | 3824 return new_code; |
3786 } | 3825 } |
3787 | 3826 |
3788 | 3827 |
3789 AllocationResult Heap::CopyCode(Code* code, Vector<byte> reloc_info) { | 3828 AllocationResult Heap::CopyCode(Code* code, Vector<byte> reloc_info) { |
3790 // Allocate ByteArray before the Code object, so that we do not risk | 3829 // Allocate ByteArray and ConstantPoolArray before the Code object, so that we |
3791 // leaving uninitialized Code object (and breaking the heap). | 3830 // do not risk leaving uninitialized Code object (and breaking the heap). |
3792 ByteArray* reloc_info_array; | 3831 ByteArray* reloc_info_array; |
3793 { | 3832 { |
3794 AllocationResult allocation = | 3833 AllocationResult allocation = |
3795 AllocateByteArray(reloc_info.length(), TENURED); | 3834 AllocateByteArray(reloc_info.length(), TENURED); |
3796 if (!allocation.To(&reloc_info_array)) return allocation; | 3835 if (!allocation.To(&reloc_info_array)) return allocation; |
3797 } | 3836 } |
| 3837 HeapObject* new_constant_pool; |
| 3838 if (FLAG_enable_ool_constant_pool && |
| 3839 code->constant_pool() != empty_constant_pool_array()) { |
| 3840 // Copy the constant pool, since edits to the copied code may modify |
| 3841 // the constant pool. |
| 3842 AllocationResult allocation = CopyConstantPoolArray(code->constant_pool()); |
| 3843 if (!allocation.To(&new_constant_pool)) return allocation; |
| 3844 } else { |
| 3845 new_constant_pool = empty_constant_pool_array(); |
| 3846 } |
3798 | 3847 |
3799 int new_body_size = RoundUp(code->instruction_size(), kObjectAlignment); | 3848 int new_body_size = RoundUp(code->instruction_size(), kObjectAlignment); |
3800 | 3849 |
3801 int new_obj_size = Code::SizeFor(new_body_size); | 3850 int new_obj_size = Code::SizeFor(new_body_size); |
3802 | 3851 |
3803 Address old_addr = code->address(); | 3852 Address old_addr = code->address(); |
3804 | 3853 |
3805 size_t relocation_offset = | 3854 size_t relocation_offset = |
3806 static_cast<size_t>(code->instruction_end() - old_addr); | 3855 static_cast<size_t>(code->instruction_end() - old_addr); |
3807 | 3856 |
3808 HeapObject* result; | 3857 HeapObject* result; |
3809 AllocationResult allocation = | 3858 AllocationResult allocation = |
3810 AllocateRaw(new_obj_size, CODE_SPACE, CODE_SPACE); | 3859 AllocateRaw(new_obj_size, CODE_SPACE, CODE_SPACE); |
3811 if (!allocation.To(&result)) return allocation; | 3860 if (!allocation.To(&result)) return allocation; |
3812 | 3861 |
3813 // Copy code object. | 3862 // Copy code object. |
3814 Address new_addr = result->address(); | 3863 Address new_addr = result->address(); |
3815 | 3864 |
3816 // Copy header and instructions. | 3865 // Copy header and instructions. |
3817 CopyBytes(new_addr, old_addr, relocation_offset); | 3866 CopyBytes(new_addr, old_addr, relocation_offset); |
3818 | 3867 |
3819 Code* new_code = Code::cast(result); | 3868 Code* new_code = Code::cast(result); |
3820 new_code->set_relocation_info(reloc_info_array); | 3869 new_code->set_relocation_info(reloc_info_array); |
3821 | 3870 |
| 3871 // Update constant pool. |
| 3872 new_code->set_constant_pool(new_constant_pool); |
| 3873 |
3822 // Copy patched rinfo. | 3874 // Copy patched rinfo. |
3823 CopyBytes(new_code->relocation_start(), reloc_info.start(), | 3875 CopyBytes(new_code->relocation_start(), reloc_info.start(), |
3824 static_cast<size_t>(reloc_info.length())); | 3876 static_cast<size_t>(reloc_info.length())); |
3825 | 3877 |
3826 // Relocate the copy. | 3878 // Relocate the copy. |
3827 DCHECK(IsAligned(bit_cast<intptr_t>(new_code->address()), kCodeAlignment)); | 3879 DCHECK(IsAligned(bit_cast<intptr_t>(new_code->address()), kCodeAlignment)); |
3828 DCHECK(isolate_->code_range() == NULL || !isolate_->code_range()->valid() || | 3880 DCHECK(isolate_->code_range() == NULL || !isolate_->code_range()->valid() || |
3829 isolate_->code_range()->contains(code->address())); | 3881 isolate_->code_range()->contains(code->address())); |
3830 new_code->Relocate(new_addr - old_addr); | 3882 new_code->Relocate(new_addr - old_addr); |
3831 | 3883 |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4304 if (!allocation.To(&obj)) return allocation; | 4356 if (!allocation.To(&obj)) return allocation; |
4305 } | 4357 } |
4306 obj->set_map_no_write_barrier(map); | 4358 obj->set_map_no_write_barrier(map); |
4307 CopyBlock(obj->address() + FixedDoubleArray::kLengthOffset, | 4359 CopyBlock(obj->address() + FixedDoubleArray::kLengthOffset, |
4308 src->address() + FixedDoubleArray::kLengthOffset, | 4360 src->address() + FixedDoubleArray::kLengthOffset, |
4309 FixedDoubleArray::SizeFor(len) - FixedDoubleArray::kLengthOffset); | 4361 FixedDoubleArray::SizeFor(len) - FixedDoubleArray::kLengthOffset); |
4310 return obj; | 4362 return obj; |
4311 } | 4363 } |
4312 | 4364 |
4313 | 4365 |
| 4366 AllocationResult Heap::CopyConstantPoolArrayWithMap(ConstantPoolArray* src, |
| 4367 Map* map) { |
| 4368 HeapObject* obj; |
| 4369 if (src->is_extended_layout()) { |
| 4370 ConstantPoolArray::NumberOfEntries small(src, |
| 4371 ConstantPoolArray::SMALL_SECTION); |
| 4372 ConstantPoolArray::NumberOfEntries extended( |
| 4373 src, ConstantPoolArray::EXTENDED_SECTION); |
| 4374 AllocationResult allocation = |
| 4375 AllocateExtendedConstantPoolArray(small, extended); |
| 4376 if (!allocation.To(&obj)) return allocation; |
| 4377 } else { |
| 4378 ConstantPoolArray::NumberOfEntries small(src, |
| 4379 ConstantPoolArray::SMALL_SECTION); |
| 4380 AllocationResult allocation = AllocateConstantPoolArray(small); |
| 4381 if (!allocation.To(&obj)) return allocation; |
| 4382 } |
| 4383 obj->set_map_no_write_barrier(map); |
| 4384 CopyBlock(obj->address() + ConstantPoolArray::kFirstEntryOffset, |
| 4385 src->address() + ConstantPoolArray::kFirstEntryOffset, |
| 4386 src->size() - ConstantPoolArray::kFirstEntryOffset); |
| 4387 return obj; |
| 4388 } |
| 4389 |
| 4390 |
4314 AllocationResult Heap::AllocateRawFixedArray(int length, | 4391 AllocationResult Heap::AllocateRawFixedArray(int length, |
4315 PretenureFlag pretenure) { | 4392 PretenureFlag pretenure) { |
4316 if (length < 0 || length > FixedArray::kMaxLength) { | 4393 if (length < 0 || length > FixedArray::kMaxLength) { |
4317 v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); | 4394 v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); |
4318 } | 4395 } |
4319 int size = FixedArray::SizeFor(length); | 4396 int size = FixedArray::SizeFor(length); |
4320 AllocationSpace space = SelectSpace(size, pretenure); | 4397 AllocationSpace space = SelectSpace(size, pretenure); |
4321 | 4398 |
4322 return AllocateRaw(size, space, OLD_SPACE); | 4399 return AllocateRaw(size, space, OLD_SPACE); |
4323 } | 4400 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4392 { | 4469 { |
4393 AllocationResult allocation = | 4470 AllocationResult allocation = |
4394 AllocateRaw(size, space, OLD_SPACE, kDoubleAligned); | 4471 AllocateRaw(size, space, OLD_SPACE, kDoubleAligned); |
4395 if (!allocation.To(&object)) return allocation; | 4472 if (!allocation.To(&object)) return allocation; |
4396 } | 4473 } |
4397 | 4474 |
4398 return object; | 4475 return object; |
4399 } | 4476 } |
4400 | 4477 |
4401 | 4478 |
| 4479 AllocationResult Heap::AllocateConstantPoolArray( |
| 4480 const ConstantPoolArray::NumberOfEntries& small) { |
| 4481 CHECK(small.are_in_range(0, ConstantPoolArray::kMaxSmallEntriesPerType)); |
| 4482 int size = ConstantPoolArray::SizeFor(small); |
| 4483 AllocationSpace space = SelectSpace(size, TENURED); |
| 4484 |
| 4485 HeapObject* object = nullptr; |
| 4486 { |
| 4487 AllocationResult allocation = |
| 4488 AllocateRaw(size, space, OLD_SPACE, kDoubleAligned); |
| 4489 if (!allocation.To(&object)) return allocation; |
| 4490 } |
| 4491 object->set_map_no_write_barrier(constant_pool_array_map()); |
| 4492 |
| 4493 ConstantPoolArray* constant_pool = ConstantPoolArray::cast(object); |
| 4494 constant_pool->Init(small); |
| 4495 constant_pool->ClearPtrEntries(isolate()); |
| 4496 return constant_pool; |
| 4497 } |
| 4498 |
| 4499 |
| 4500 AllocationResult Heap::AllocateExtendedConstantPoolArray( |
| 4501 const ConstantPoolArray::NumberOfEntries& small, |
| 4502 const ConstantPoolArray::NumberOfEntries& extended) { |
| 4503 CHECK(small.are_in_range(0, ConstantPoolArray::kMaxSmallEntriesPerType)); |
| 4504 CHECK(extended.are_in_range(0, kMaxInt)); |
| 4505 int size = ConstantPoolArray::SizeForExtended(small, extended); |
| 4506 AllocationSpace space = SelectSpace(size, TENURED); |
| 4507 |
| 4508 HeapObject* object; |
| 4509 { |
| 4510 AllocationResult allocation = |
| 4511 AllocateRaw(size, space, OLD_SPACE, kDoubleAligned); |
| 4512 if (!allocation.To(&object)) return allocation; |
| 4513 } |
| 4514 object->set_map_no_write_barrier(constant_pool_array_map()); |
| 4515 |
| 4516 ConstantPoolArray* constant_pool = ConstantPoolArray::cast(object); |
| 4517 constant_pool->InitExtended(small, extended); |
| 4518 constant_pool->ClearPtrEntries(isolate()); |
| 4519 return constant_pool; |
| 4520 } |
| 4521 |
| 4522 |
| 4523 AllocationResult Heap::AllocateEmptyConstantPoolArray() { |
| 4524 ConstantPoolArray::NumberOfEntries small(0, 0, 0, 0); |
| 4525 int size = ConstantPoolArray::SizeFor(small); |
| 4526 HeapObject* result = NULL; |
| 4527 { |
| 4528 AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE); |
| 4529 if (!allocation.To(&result)) return allocation; |
| 4530 } |
| 4531 result->set_map_no_write_barrier(constant_pool_array_map()); |
| 4532 ConstantPoolArray::cast(result)->Init(small); |
| 4533 return result; |
| 4534 } |
| 4535 |
| 4536 |
4402 AllocationResult Heap::AllocateSymbol() { | 4537 AllocationResult Heap::AllocateSymbol() { |
4403 // Statically ensure that it is safe to allocate symbols in paged spaces. | 4538 // Statically ensure that it is safe to allocate symbols in paged spaces. |
4404 STATIC_ASSERT(Symbol::kSize <= Page::kMaxRegularHeapObjectSize); | 4539 STATIC_ASSERT(Symbol::kSize <= Page::kMaxRegularHeapObjectSize); |
4405 | 4540 |
4406 HeapObject* result = NULL; | 4541 HeapObject* result = NULL; |
4407 AllocationResult allocation = | 4542 AllocationResult allocation = |
4408 AllocateRaw(Symbol::kSize, OLD_SPACE, OLD_SPACE); | 4543 AllocateRaw(Symbol::kSize, OLD_SPACE, OLD_SPACE); |
4409 if (!allocation.To(&result)) return allocation; | 4544 if (!allocation.To(&result)) return allocation; |
4410 | 4545 |
4411 result->set_map_no_write_barrier(symbol_map()); | 4546 result->set_map_no_write_barrier(symbol_map()); |
(...skipping 2119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6531 *object_type = "CODE_TYPE"; \ | 6666 *object_type = "CODE_TYPE"; \ |
6532 *object_sub_type = "CODE_AGE/" #name; \ | 6667 *object_sub_type = "CODE_AGE/" #name; \ |
6533 return true; | 6668 return true; |
6534 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) | 6669 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) |
6535 #undef COMPARE_AND_RETURN_NAME | 6670 #undef COMPARE_AND_RETURN_NAME |
6536 } | 6671 } |
6537 return false; | 6672 return false; |
6538 } | 6673 } |
6539 } // namespace internal | 6674 } // namespace internal |
6540 } // namespace v8 | 6675 } // namespace v8 |
OLD | NEW |