| 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 4207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4218 double* ptr = static_cast<double*>(external_pointer()); | 4218 double* ptr = static_cast<double*>(external_pointer()); |
| 4219 ptr[index] = value; | 4219 ptr[index] = value; |
| 4220 } | 4220 } |
| 4221 | 4221 |
| 4222 | 4222 |
| 4223 void* FixedTypedArrayBase::DataPtr() { | 4223 void* FixedTypedArrayBase::DataPtr() { |
| 4224 return FIELD_ADDR(this, kDataOffset); | 4224 return FIELD_ADDR(this, kDataOffset); |
| 4225 } | 4225 } |
| 4226 | 4226 |
| 4227 | 4227 |
| 4228 int FixedTypedArrayBase::DataSize(InstanceType type) { | 4228 int FixedTypedArrayBase::ElementSize(InstanceType type) { |
| 4229 int element_size; | 4229 int element_size; |
| 4230 switch (type) { | 4230 switch (type) { |
| 4231 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ | 4231 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ |
| 4232 case FIXED_##TYPE##_ARRAY_TYPE: \ | 4232 case FIXED_##TYPE##_ARRAY_TYPE: \ |
| 4233 element_size = size; \ | 4233 element_size = size; \ |
| 4234 break; | 4234 break; |
| 4235 | 4235 |
| 4236 TYPED_ARRAYS(TYPED_ARRAY_CASE) | 4236 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
| 4237 #undef TYPED_ARRAY_CASE | 4237 #undef TYPED_ARRAY_CASE |
| 4238 default: | 4238 default: |
| 4239 UNREACHABLE(); | 4239 UNREACHABLE(); |
| 4240 return 0; | 4240 return 0; |
| 4241 } | 4241 } |
| 4242 return length() * element_size; | 4242 return element_size; |
| 4243 } | 4243 } |
| 4244 | 4244 |
| 4245 | 4245 |
| 4246 int FixedTypedArrayBase::DataSize(InstanceType type) { |
| 4247 return length() * ElementSize(type); |
| 4248 } |
| 4249 |
| 4250 |
| 4246 int FixedTypedArrayBase::DataSize() { | 4251 int FixedTypedArrayBase::DataSize() { |
| 4247 return DataSize(map()->instance_type()); | 4252 return DataSize(map()->instance_type()); |
| 4248 } | 4253 } |
| 4249 | 4254 |
| 4250 | 4255 |
| 4251 int FixedTypedArrayBase::size() { | 4256 int FixedTypedArrayBase::size() { |
| 4252 return OBJECT_POINTER_ALIGN(kDataOffset + DataSize()); | 4257 return OBJECT_POINTER_ALIGN(kDataOffset + DataSize()); |
| 4253 } | 4258 } |
| 4254 | 4259 |
| 4255 | 4260 |
| 4256 int FixedTypedArrayBase::TypedArraySize(InstanceType type) { | 4261 int FixedTypedArrayBase::TypedArraySize(InstanceType type) { |
| 4257 return OBJECT_POINTER_ALIGN(kDataOffset + DataSize(type)); | 4262 return OBJECT_POINTER_ALIGN(kDataOffset + DataSize(type)); |
| 4258 } | 4263 } |
| 4259 | 4264 |
| 4260 | 4265 |
| 4266 int FixedTypedArrayBase::TypedArraySize(InstanceType type, int length) { |
| 4267 return OBJECT_POINTER_ALIGN(kDataOffset + length * ElementSize(type)); |
| 4268 } |
| 4269 |
| 4270 |
| 4261 uint8_t Uint8ArrayTraits::defaultValue() { return 0; } | 4271 uint8_t Uint8ArrayTraits::defaultValue() { return 0; } |
| 4262 | 4272 |
| 4263 | 4273 |
| 4264 uint8_t Uint8ClampedArrayTraits::defaultValue() { return 0; } | 4274 uint8_t Uint8ClampedArrayTraits::defaultValue() { return 0; } |
| 4265 | 4275 |
| 4266 | 4276 |
| 4267 int8_t Int8ArrayTraits::defaultValue() { return 0; } | 4277 int8_t Int8ArrayTraits::defaultValue() { return 0; } |
| 4268 | 4278 |
| 4269 | 4279 |
| 4270 uint16_t Uint16ArrayTraits::defaultValue() { return 0; } | 4280 uint16_t Uint16ArrayTraits::defaultValue() { return 0; } |
| (...skipping 3247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7518 #undef READ_SHORT_FIELD | 7528 #undef READ_SHORT_FIELD |
| 7519 #undef WRITE_SHORT_FIELD | 7529 #undef WRITE_SHORT_FIELD |
| 7520 #undef READ_BYTE_FIELD | 7530 #undef READ_BYTE_FIELD |
| 7521 #undef WRITE_BYTE_FIELD | 7531 #undef WRITE_BYTE_FIELD |
| 7522 #undef NOBARRIER_READ_BYTE_FIELD | 7532 #undef NOBARRIER_READ_BYTE_FIELD |
| 7523 #undef NOBARRIER_WRITE_BYTE_FIELD | 7533 #undef NOBARRIER_WRITE_BYTE_FIELD |
| 7524 | 7534 |
| 7525 } } // namespace v8::internal | 7535 } } // namespace v8::internal |
| 7526 | 7536 |
| 7527 #endif // V8_OBJECTS_INL_H_ | 7537 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |