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 // Review notes: | 5 // Review notes: |
6 // | 6 // |
7 // - The use of macros in these inline functions may seem superfluous | 7 // - The use of macros in these inline functions may seem superfluous |
8 // but it is absolutely needed to make sure gcc generates optimal | 8 // but it is absolutely needed to make sure gcc generates optimal |
9 // code. gcc is not happy when attempting to inline too deep. | 9 // code. gcc is not happy when attempting to inline too deep. |
10 // | 10 // |
(...skipping 4313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4324 int HeapObject::SizeFromMap(Map* map) { | 4324 int HeapObject::SizeFromMap(Map* map) { |
4325 int instance_size = map->instance_size(); | 4325 int instance_size = map->instance_size(); |
4326 if (instance_size != kVariableSizeSentinel) return instance_size; | 4326 if (instance_size != kVariableSizeSentinel) return instance_size; |
4327 // Only inline the most frequent cases. | 4327 // Only inline the most frequent cases. |
4328 InstanceType instance_type = map->instance_type(); | 4328 InstanceType instance_type = map->instance_type(); |
4329 if (instance_type == FIXED_ARRAY_TYPE) { | 4329 if (instance_type == FIXED_ARRAY_TYPE) { |
4330 return FixedArray::BodyDescriptor::SizeOf(map, this); | 4330 return FixedArray::BodyDescriptor::SizeOf(map, this); |
4331 } | 4331 } |
4332 if (instance_type == ONE_BYTE_STRING_TYPE || | 4332 if (instance_type == ONE_BYTE_STRING_TYPE || |
4333 instance_type == ONE_BYTE_INTERNALIZED_STRING_TYPE) { | 4333 instance_type == ONE_BYTE_INTERNALIZED_STRING_TYPE) { |
| 4334 // Strings may get concurrently truncated, hence we have to access its |
| 4335 // length synchronized. |
4334 return SeqOneByteString::SizeFor( | 4336 return SeqOneByteString::SizeFor( |
4335 reinterpret_cast<SeqOneByteString*>(this)->length()); | 4337 reinterpret_cast<SeqOneByteString*>(this)->synchronized_length()); |
4336 } | 4338 } |
4337 if (instance_type == BYTE_ARRAY_TYPE) { | 4339 if (instance_type == BYTE_ARRAY_TYPE) { |
4338 return reinterpret_cast<ByteArray*>(this)->ByteArraySize(); | 4340 return reinterpret_cast<ByteArray*>(this)->ByteArraySize(); |
4339 } | 4341 } |
4340 if (instance_type == FREE_SPACE_TYPE) { | 4342 if (instance_type == FREE_SPACE_TYPE) { |
4341 return reinterpret_cast<FreeSpace*>(this)->nobarrier_size(); | 4343 return reinterpret_cast<FreeSpace*>(this)->nobarrier_size(); |
4342 } | 4344 } |
4343 if (instance_type == STRING_TYPE || | 4345 if (instance_type == STRING_TYPE || |
4344 instance_type == INTERNALIZED_STRING_TYPE) { | 4346 instance_type == INTERNALIZED_STRING_TYPE) { |
| 4347 // Strings may get concurrently truncated, hence we have to access its |
| 4348 // length synchronized. |
4345 return SeqTwoByteString::SizeFor( | 4349 return SeqTwoByteString::SizeFor( |
4346 reinterpret_cast<SeqTwoByteString*>(this)->length()); | 4350 reinterpret_cast<SeqTwoByteString*>(this)->synchronized_length()); |
4347 } | 4351 } |
4348 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) { | 4352 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) { |
4349 return FixedDoubleArray::SizeFor( | 4353 return FixedDoubleArray::SizeFor( |
4350 reinterpret_cast<FixedDoubleArray*>(this)->length()); | 4354 reinterpret_cast<FixedDoubleArray*>(this)->length()); |
4351 } | 4355 } |
4352 if (instance_type == CONSTANT_POOL_ARRAY_TYPE) { | 4356 if (instance_type == CONSTANT_POOL_ARRAY_TYPE) { |
4353 return reinterpret_cast<ConstantPoolArray*>(this)->size(); | 4357 return reinterpret_cast<ConstantPoolArray*>(this)->size(); |
4354 } | 4358 } |
4355 if (instance_type >= FIRST_FIXED_TYPED_ARRAY_TYPE && | 4359 if (instance_type >= FIRST_FIXED_TYPED_ARRAY_TYPE && |
4356 instance_type <= LAST_FIXED_TYPED_ARRAY_TYPE) { | 4360 instance_type <= LAST_FIXED_TYPED_ARRAY_TYPE) { |
(...skipping 2959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7316 #undef READ_SHORT_FIELD | 7320 #undef READ_SHORT_FIELD |
7317 #undef WRITE_SHORT_FIELD | 7321 #undef WRITE_SHORT_FIELD |
7318 #undef READ_BYTE_FIELD | 7322 #undef READ_BYTE_FIELD |
7319 #undef WRITE_BYTE_FIELD | 7323 #undef WRITE_BYTE_FIELD |
7320 #undef NOBARRIER_READ_BYTE_FIELD | 7324 #undef NOBARRIER_READ_BYTE_FIELD |
7321 #undef NOBARRIER_WRITE_BYTE_FIELD | 7325 #undef NOBARRIER_WRITE_BYTE_FIELD |
7322 | 7326 |
7323 } } // namespace v8::internal | 7327 } } // namespace v8::internal |
7324 | 7328 |
7325 #endif // V8_OBJECTS_INL_H_ | 7329 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |