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 "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #include "accessors.h" | 7 #include "accessors.h" |
8 #include "api.h" | 8 #include "api.h" |
9 #include "bootstrapper.h" | 9 #include "bootstrapper.h" |
10 #include "codegen.h" | 10 #include "codegen.h" |
(...skipping 1768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1779 | 1779 |
1780 // Take another spin if there are now unswept objects in new space | 1780 // Take another spin if there are now unswept objects in new space |
1781 // (there are currently no more unswept promoted objects). | 1781 // (there are currently no more unswept promoted objects). |
1782 } while (new_space_front != new_space_.top()); | 1782 } while (new_space_front != new_space_.top()); |
1783 | 1783 |
1784 return new_space_front; | 1784 return new_space_front; |
1785 } | 1785 } |
1786 | 1786 |
1787 | 1787 |
1788 STATIC_ASSERT((FixedDoubleArray::kHeaderSize & kDoubleAlignmentMask) == 0); | 1788 STATIC_ASSERT((FixedDoubleArray::kHeaderSize & kDoubleAlignmentMask) == 0); |
1789 STATIC_ASSERT((ConstantPoolArray::kHeaderSize & kDoubleAlignmentMask) == 0); | 1789 STATIC_ASSERT( |
| 1790 (ConstantPoolArray::kFirstEntryOffset & kDoubleAlignmentMask) == 0); |
| 1791 STATIC_ASSERT( |
| 1792 (ConstantPoolArray::kExtendedFirstOffset & kDoubleAlignmentMask) == 0); |
1790 | 1793 |
1791 | 1794 |
1792 INLINE(static HeapObject* EnsureDoubleAligned(Heap* heap, | 1795 INLINE(static HeapObject* EnsureDoubleAligned(Heap* heap, |
1793 HeapObject* object, | 1796 HeapObject* object, |
1794 int size)); | 1797 int size)); |
1795 | 1798 |
1796 static HeapObject* EnsureDoubleAligned(Heap* heap, | 1799 static HeapObject* EnsureDoubleAligned(Heap* heap, |
1797 HeapObject* object, | 1800 HeapObject* object, |
1798 int size) { | 1801 int size) { |
1799 if ((OffsetFrom(object->address()) & kDoubleAlignmentMask) != 0) { | 1802 if ((OffsetFrom(object->address()) & kDoubleAlignmentMask) != 0) { |
(...skipping 2220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4020 CopyBlock( | 4023 CopyBlock( |
4021 obj->address() + FixedDoubleArray::kLengthOffset, | 4024 obj->address() + FixedDoubleArray::kLengthOffset, |
4022 src->address() + FixedDoubleArray::kLengthOffset, | 4025 src->address() + FixedDoubleArray::kLengthOffset, |
4023 FixedDoubleArray::SizeFor(len) - FixedDoubleArray::kLengthOffset); | 4026 FixedDoubleArray::SizeFor(len) - FixedDoubleArray::kLengthOffset); |
4024 return obj; | 4027 return obj; |
4025 } | 4028 } |
4026 | 4029 |
4027 | 4030 |
4028 AllocationResult Heap::CopyConstantPoolArrayWithMap(ConstantPoolArray* src, | 4031 AllocationResult Heap::CopyConstantPoolArrayWithMap(ConstantPoolArray* src, |
4029 Map* map) { | 4032 Map* map) { |
4030 int int64_entries = src->count_of_int64_entries(); | |
4031 int code_ptr_entries = src->count_of_code_ptr_entries(); | |
4032 int heap_ptr_entries = src->count_of_heap_ptr_entries(); | |
4033 int int32_entries = src->count_of_int32_entries(); | |
4034 HeapObject* obj; | 4033 HeapObject* obj; |
4035 { AllocationResult allocation = | 4034 if (src->is_extended_layout()) { |
4036 AllocateConstantPoolArray(int64_entries, code_ptr_entries, | 4035 AllocationResult allocation = |
4037 heap_ptr_entries, int32_entries); | 4036 AllocateExtendedConstantPoolArray( |
| 4037 src->number_of_entries(ConstantPoolArray::INT64, |
| 4038 ConstantPoolArray::SMALL_SECTION), |
| 4039 src->number_of_entries(ConstantPoolArray::CODE_PTR, |
| 4040 ConstantPoolArray::SMALL_SECTION), |
| 4041 src->number_of_entries(ConstantPoolArray::HEAP_PTR, |
| 4042 ConstantPoolArray::SMALL_SECTION), |
| 4043 src->number_of_entries(ConstantPoolArray::INT32, |
| 4044 ConstantPoolArray::SMALL_SECTION), |
| 4045 src->number_of_entries(ConstantPoolArray::INT64, |
| 4046 ConstantPoolArray::EXTENDED_SECTION), |
| 4047 src->number_of_entries(ConstantPoolArray::CODE_PTR, |
| 4048 ConstantPoolArray::EXTENDED_SECTION), |
| 4049 src->number_of_entries(ConstantPoolArray::HEAP_PTR, |
| 4050 ConstantPoolArray::EXTENDED_SECTION), |
| 4051 src->number_of_entries(ConstantPoolArray::INT64, |
| 4052 ConstantPoolArray::EXTENDED_SECTION)); |
| 4053 if (!allocation.To(&obj)) return allocation; |
| 4054 } else { |
| 4055 AllocationResult allocation = |
| 4056 AllocateConstantPoolArray( |
| 4057 src->number_of_entries(ConstantPoolArray::INT64, |
| 4058 ConstantPoolArray::SMALL_SECTION), |
| 4059 src->number_of_entries(ConstantPoolArray::CODE_PTR, |
| 4060 ConstantPoolArray::SMALL_SECTION), |
| 4061 src->number_of_entries(ConstantPoolArray::HEAP_PTR, |
| 4062 ConstantPoolArray::SMALL_SECTION), |
| 4063 src->number_of_entries(ConstantPoolArray::INT32, |
| 4064 ConstantPoolArray::SMALL_SECTION)); |
4038 if (!allocation.To(&obj)) return allocation; | 4065 if (!allocation.To(&obj)) return allocation; |
4039 } | 4066 } |
4040 obj->set_map_no_write_barrier(map); | 4067 obj->set_map_no_write_barrier(map); |
4041 int size = ConstantPoolArray::SizeFor( | |
4042 int64_entries, code_ptr_entries, heap_ptr_entries, int32_entries); | |
4043 CopyBlock( | 4068 CopyBlock( |
4044 obj->address() + ConstantPoolArray::kLengthOffset, | 4069 obj->address() + ConstantPoolArray::kFirstEntryOffset, |
4045 src->address() + ConstantPoolArray::kLengthOffset, | 4070 src->address() + ConstantPoolArray::kFirstEntryOffset, |
4046 size - ConstantPoolArray::kLengthOffset); | 4071 src->size() - ConstantPoolArray::kFirstEntryOffset); |
4047 return obj; | 4072 return obj; |
4048 } | 4073 } |
4049 | 4074 |
4050 | 4075 |
4051 AllocationResult Heap::AllocateRawFixedArray(int length, | 4076 AllocationResult Heap::AllocateRawFixedArray(int length, |
4052 PretenureFlag pretenure) { | 4077 PretenureFlag pretenure) { |
4053 if (length < 0 || length > FixedArray::kMaxLength) { | 4078 if (length < 0 || length > FixedArray::kMaxLength) { |
4054 v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); | 4079 v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); |
4055 } | 4080 } |
4056 int size = FixedArray::SizeFor(length); | 4081 int size = FixedArray::SizeFor(length); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4128 | 4153 |
4129 HeapObject* object; | 4154 HeapObject* object; |
4130 { AllocationResult allocation = AllocateRaw(size, space, OLD_DATA_SPACE); | 4155 { AllocationResult allocation = AllocateRaw(size, space, OLD_DATA_SPACE); |
4131 if (!allocation.To(&object)) return allocation; | 4156 if (!allocation.To(&object)) return allocation; |
4132 } | 4157 } |
4133 | 4158 |
4134 return EnsureDoubleAligned(this, object, size); | 4159 return EnsureDoubleAligned(this, object, size); |
4135 } | 4160 } |
4136 | 4161 |
4137 | 4162 |
4138 AllocationResult Heap::AllocateConstantPoolArray(int number_of_int64_entries, | 4163 AllocationResult Heap::AllocateConstantPoolArray(int int64_count, |
4139 int number_of_code_ptr_entries, | 4164 int code_ptr_count, |
4140 int number_of_heap_ptr_entries, | 4165 int heap_ptr_count, |
4141 int number_of_int32_entries) { | 4166 int int32_count) { |
4142 CHECK(number_of_int64_entries >= 0 && | 4167 CHECK(int64_count >= 0 && |
4143 number_of_int64_entries <= ConstantPoolArray::kMaxEntriesPerType && | 4168 int64_count <= ConstantPoolArray::kMaxSmallEntriesPerType && |
4144 number_of_code_ptr_entries >= 0 && | 4169 code_ptr_count >= 0 && |
4145 number_of_code_ptr_entries <= ConstantPoolArray::kMaxEntriesPerType && | 4170 code_ptr_count <= ConstantPoolArray::kMaxSmallEntriesPerType && |
4146 number_of_heap_ptr_entries >= 0 && | 4171 heap_ptr_count >= 0 && |
4147 number_of_heap_ptr_entries <= ConstantPoolArray::kMaxEntriesPerType && | 4172 heap_ptr_count <= ConstantPoolArray::kMaxSmallEntriesPerType && |
4148 number_of_int32_entries >= 0 && | 4173 int32_count >= 0 && |
4149 number_of_int32_entries <= ConstantPoolArray::kMaxEntriesPerType); | 4174 int32_count <= ConstantPoolArray::kMaxSmallEntriesPerType); |
4150 int size = ConstantPoolArray::SizeFor(number_of_int64_entries, | 4175 int size = ConstantPoolArray::SizeFor(int64_count, |
4151 number_of_code_ptr_entries, | 4176 code_ptr_count, |
4152 number_of_heap_ptr_entries, | 4177 heap_ptr_count, |
4153 number_of_int32_entries); | 4178 int32_count); |
4154 #ifndef V8_HOST_ARCH_64_BIT | 4179 #ifndef V8_HOST_ARCH_64_BIT |
4155 size += kPointerSize; | 4180 size += kPointerSize; |
4156 #endif | 4181 #endif |
4157 AllocationSpace space = SelectSpace(size, OLD_POINTER_SPACE, TENURED); | 4182 AllocationSpace space = SelectSpace(size, OLD_POINTER_SPACE, TENURED); |
4158 | 4183 |
4159 HeapObject* object; | 4184 HeapObject* object; |
4160 { AllocationResult allocation = AllocateRaw(size, space, OLD_POINTER_SPACE); | 4185 { AllocationResult allocation = AllocateRaw(size, space, OLD_POINTER_SPACE); |
4161 if (!allocation.To(&object)) return allocation; | 4186 if (!allocation.To(&object)) return allocation; |
4162 } | 4187 } |
4163 object = EnsureDoubleAligned(this, object, size); | 4188 object = EnsureDoubleAligned(this, object, size); |
4164 object->set_map_no_write_barrier(constant_pool_array_map()); | 4189 object->set_map_no_write_barrier(constant_pool_array_map()); |
4165 | 4190 |
4166 ConstantPoolArray* constant_pool = ConstantPoolArray::cast(object); | 4191 ConstantPoolArray* constant_pool = ConstantPoolArray::cast(object); |
4167 constant_pool->Init(number_of_int64_entries, | 4192 constant_pool->Init(int64_count, code_ptr_count, heap_ptr_count, int32_count); |
4168 number_of_code_ptr_entries, | 4193 constant_pool->ClearPtrEntries(isolate()); |
4169 number_of_heap_ptr_entries, | |
4170 number_of_int32_entries); | |
4171 if (number_of_code_ptr_entries > 0) { | |
4172 int offset = | |
4173 constant_pool->OffsetOfElementAt(constant_pool->first_code_ptr_index()); | |
4174 MemsetPointer( | |
4175 reinterpret_cast<Address*>(HeapObject::RawField(constant_pool, offset)), | |
4176 isolate()->builtins()->builtin(Builtins::kIllegal)->entry(), | |
4177 number_of_code_ptr_entries); | |
4178 } | |
4179 if (number_of_heap_ptr_entries > 0) { | |
4180 int offset = | |
4181 constant_pool->OffsetOfElementAt(constant_pool->first_heap_ptr_index()); | |
4182 MemsetPointer( | |
4183 HeapObject::RawField(constant_pool, offset), | |
4184 undefined_value(), | |
4185 number_of_heap_ptr_entries); | |
4186 } | |
4187 return constant_pool; | 4194 return constant_pool; |
4188 } | 4195 } |
4189 | 4196 |
| 4197 |
| 4198 AllocationResult Heap::AllocateExtendedConstantPoolArray( |
| 4199 int small_section_int64_entries, |
| 4200 int small_section_code_ptr_entries, |
| 4201 int small_section_heap_ptr_entries, |
| 4202 int small_section_int32_entries, |
| 4203 int extended_section_int64_entries, |
| 4204 int extended_section_code_ptr_entries, |
| 4205 int extended_section_heap_ptr_entries, |
| 4206 int extended_section_int32_entries) { |
| 4207 int max_small_entries = ConstantPoolArray::kMaxSmallEntriesPerType; |
| 4208 CHECK(small_section_int64_entries >= 0 && |
| 4209 small_section_int64_entries <= max_small_entries && |
| 4210 small_section_code_ptr_entries >= 0 && |
| 4211 small_section_code_ptr_entries <= max_small_entries && |
| 4212 small_section_heap_ptr_entries >= 0 && |
| 4213 small_section_heap_ptr_entries <= max_small_entries && |
| 4214 small_section_int32_entries >= 0 && |
| 4215 small_section_int32_entries <= max_small_entries); |
| 4216 CHECK(extended_section_int64_entries >= 0 && |
| 4217 extended_section_code_ptr_entries >= 0 && |
| 4218 extended_section_heap_ptr_entries >= 0 && |
| 4219 extended_section_int32_entries >= 0); |
| 4220 int size = ConstantPoolArray::SizeForExtended( |
| 4221 small_section_int64_entries, |
| 4222 small_section_code_ptr_entries, |
| 4223 small_section_heap_ptr_entries, |
| 4224 small_section_int32_entries, |
| 4225 extended_section_int64_entries, |
| 4226 extended_section_code_ptr_entries, |
| 4227 extended_section_heap_ptr_entries, |
| 4228 extended_section_int32_entries); |
| 4229 #ifndef V8_HOST_ARCH_64_BIT |
| 4230 size += kPointerSize; |
| 4231 #endif |
| 4232 AllocationSpace space = SelectSpace(size, OLD_POINTER_SPACE, TENURED); |
| 4233 |
| 4234 HeapObject* object; |
| 4235 { AllocationResult allocation = AllocateRaw(size, space, OLD_POINTER_SPACE); |
| 4236 if (!allocation.To(&object)) return allocation; |
| 4237 } |
| 4238 object = EnsureDoubleAligned(this, object, size); |
| 4239 object->set_map_no_write_barrier(constant_pool_array_map()); |
| 4240 |
| 4241 ConstantPoolArray* constant_pool = ConstantPoolArray::cast(object); |
| 4242 constant_pool->InitExtended(small_section_int64_entries, |
| 4243 small_section_code_ptr_entries, |
| 4244 small_section_heap_ptr_entries, |
| 4245 small_section_int32_entries, |
| 4246 extended_section_int64_entries, |
| 4247 extended_section_code_ptr_entries, |
| 4248 extended_section_heap_ptr_entries, |
| 4249 extended_section_int32_entries); |
| 4250 constant_pool->ClearPtrEntries(isolate()); |
| 4251 return constant_pool; |
| 4252 } |
| 4253 |
4190 | 4254 |
4191 AllocationResult Heap::AllocateEmptyConstantPoolArray() { | 4255 AllocationResult Heap::AllocateEmptyConstantPoolArray() { |
4192 int size = ConstantPoolArray::SizeFor(0, 0, 0, 0); | 4256 int size = ConstantPoolArray::SizeFor(0, 0, 0, 0); |
4193 HeapObject* result; | 4257 HeapObject* result; |
4194 { AllocationResult allocation = | 4258 { AllocationResult allocation = |
4195 AllocateRaw(size, OLD_DATA_SPACE, OLD_DATA_SPACE); | 4259 AllocateRaw(size, OLD_DATA_SPACE, OLD_DATA_SPACE); |
4196 if (!allocation.To(&result)) return allocation; | 4260 if (!allocation.To(&result)) return allocation; |
4197 } | 4261 } |
4198 result->set_map_no_write_barrier(constant_pool_array_map()); | 4262 result->set_map_no_write_barrier(constant_pool_array_map()); |
4199 ConstantPoolArray::cast(result)->Init(0, 0, 0, 0); | 4263 ConstantPoolArray::cast(result)->Init(0, 0, 0, 0); |
(...skipping 2221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6421 static_cast<int>(object_sizes_last_time_[index])); | 6485 static_cast<int>(object_sizes_last_time_[index])); |
6422 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6486 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
6423 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6487 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
6424 | 6488 |
6425 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6489 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
6426 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6490 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
6427 ClearObjectStats(); | 6491 ClearObjectStats(); |
6428 } | 6492 } |
6429 | 6493 |
6430 } } // namespace v8::internal | 6494 } } // namespace v8::internal |
OLD | NEW |