| 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 3983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3994 | 3994 |
| 3995 template <class Traits> | 3995 template <class Traits> |
| 3996 Handle<Object> FixedTypedArray<Traits>::get( | 3996 Handle<Object> FixedTypedArray<Traits>::get( |
| 3997 Handle<FixedTypedArray<Traits> > array, | 3997 Handle<FixedTypedArray<Traits> > array, |
| 3998 int index) { | 3998 int index) { |
| 3999 return Traits::ToHandle(array->GetIsolate(), array->get_scalar(index)); | 3999 return Traits::ToHandle(array->GetIsolate(), array->get_scalar(index)); |
| 4000 } | 4000 } |
| 4001 | 4001 |
| 4002 | 4002 |
| 4003 template <class Traits> | 4003 template <class Traits> |
| 4004 void FixedTypedArray<Traits>::SetValue(Handle<JSObject> holder, | 4004 void FixedTypedArray<Traits>::SetValue(Handle<FixedTypedArray<Traits> > array, |
| 4005 Handle<FixedTypedArray<Traits> > array, | |
| 4006 uint32_t index, Handle<Object> value) { | 4005 uint32_t index, Handle<Object> value) { |
| 4007 ElementType cast_value = Traits::defaultValue(); | 4006 ElementType cast_value = Traits::defaultValue(); |
| 4008 Handle<JSArrayBufferView> view = Handle<JSArrayBufferView>::cast(holder); | 4007 if (value->IsSmi()) { |
| 4009 if (!view->WasNeutered()) { | 4008 int int_value = Handle<Smi>::cast(value)->value(); |
| 4010 if (index < static_cast<uint32_t>(array->length())) { | 4009 cast_value = from_int(int_value); |
| 4011 if (value->IsSmi()) { | 4010 } else if (value->IsHeapNumber()) { |
| 4012 int int_value = Handle<Smi>::cast(value)->value(); | 4011 double double_value = Handle<HeapNumber>::cast(value)->value(); |
| 4013 cast_value = from_int(int_value); | 4012 cast_value = from_double(double_value); |
| 4014 } else if (value->IsHeapNumber()) { | 4013 } else { |
| 4015 double double_value = Handle<HeapNumber>::cast(value)->value(); | 4014 // Clamp undefined to the default value. All other types have been |
| 4016 cast_value = from_double(double_value); | 4015 // converted to a number type further up in the call chain. |
| 4017 } else { | 4016 DCHECK(value->IsUndefined()); |
| 4018 // Clamp undefined to the default value. All other types have been | |
| 4019 // converted to a number type further up in the call chain. | |
| 4020 DCHECK(value->IsUndefined()); | |
| 4021 } | |
| 4022 array->set(index, cast_value); | |
| 4023 } | |
| 4024 } | 4017 } |
| 4018 array->set(index, cast_value); |
| 4025 } | 4019 } |
| 4026 | 4020 |
| 4027 | 4021 |
| 4028 Handle<Object> Uint8ArrayTraits::ToHandle(Isolate* isolate, uint8_t scalar) { | 4022 Handle<Object> Uint8ArrayTraits::ToHandle(Isolate* isolate, uint8_t scalar) { |
| 4029 return handle(Smi::FromInt(scalar), isolate); | 4023 return handle(Smi::FromInt(scalar), isolate); |
| 4030 } | 4024 } |
| 4031 | 4025 |
| 4032 | 4026 |
| 4033 Handle<Object> Uint8ClampedArrayTraits::ToHandle(Isolate* isolate, | 4027 Handle<Object> Uint8ClampedArrayTraits::ToHandle(Isolate* isolate, |
| 4034 uint8_t scalar) { | 4028 uint8_t scalar) { |
| (...skipping 3293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7328 #undef READ_SHORT_FIELD | 7322 #undef READ_SHORT_FIELD |
| 7329 #undef WRITE_SHORT_FIELD | 7323 #undef WRITE_SHORT_FIELD |
| 7330 #undef READ_BYTE_FIELD | 7324 #undef READ_BYTE_FIELD |
| 7331 #undef WRITE_BYTE_FIELD | 7325 #undef WRITE_BYTE_FIELD |
| 7332 #undef NOBARRIER_READ_BYTE_FIELD | 7326 #undef NOBARRIER_READ_BYTE_FIELD |
| 7333 #undef NOBARRIER_WRITE_BYTE_FIELD | 7327 #undef NOBARRIER_WRITE_BYTE_FIELD |
| 7334 | 7328 |
| 7335 } } // namespace v8::internal | 7329 } } // namespace v8::internal |
| 7336 | 7330 |
| 7337 #endif // V8_OBJECTS_INL_H_ | 7331 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |