OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 3657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3668 | 3668 |
3669 | 3669 |
3670 template <class Traits> | 3670 template <class Traits> |
3671 typename Traits::ElementType FixedTypedArray<Traits>::get_scalar(int index) { | 3671 typename Traits::ElementType FixedTypedArray<Traits>::get_scalar(int index) { |
3672 ASSERT((index >= 0) && (index < this->length())); | 3672 ASSERT((index >= 0) && (index < this->length())); |
3673 ElementType* ptr = reinterpret_cast<ElementType*>( | 3673 ElementType* ptr = reinterpret_cast<ElementType*>( |
3674 FIELD_ADDR(this, kDataOffset)); | 3674 FIELD_ADDR(this, kDataOffset)); |
3675 return ptr[index]; | 3675 return ptr[index]; |
3676 } | 3676 } |
3677 | 3677 |
3678 | |
3679 template<> inline | |
3680 FixedTypedArray<Float64ArrayTraits>::ElementType | |
3681 FixedTypedArray<Float64ArrayTraits>::get_scalar(int index) { | |
3682 ASSERT((index >= 0) && (index < this->length())); | |
3683 return READ_DOUBLE_FIELD( | |
3684 this, FixedTypedArray<Float64ArrayTraits>::SizeFor(index)); | |
Dmitry Lomov (no reviews)
2014/01/30 16:55:22
I am not too happy with using SizeFor here - it do
kilvadyb
2014/01/30 18:27:05
Done.
| |
3685 } | |
3686 | |
3687 | |
3678 template <class Traits> | 3688 template <class Traits> |
3679 void FixedTypedArray<Traits>::set(int index, ElementType value) { | 3689 void FixedTypedArray<Traits>::set(int index, ElementType value) { |
3680 ASSERT((index >= 0) && (index < this->length())); | 3690 ASSERT((index >= 0) && (index < this->length())); |
3681 ElementType* ptr = reinterpret_cast<ElementType*>( | 3691 ElementType* ptr = reinterpret_cast<ElementType*>( |
3682 FIELD_ADDR(this, kDataOffset)); | 3692 FIELD_ADDR(this, kDataOffset)); |
3683 ptr[index] = value; | 3693 ptr[index] = value; |
3684 } | 3694 } |
3685 | 3695 |
3686 | 3696 |
3697 template<> inline | |
3698 void FixedTypedArray<Float64ArrayTraits>::set( | |
3699 int index, Float64ArrayTraits::ElementType value) { | |
3700 ASSERT((index >= 0) && (index < this->length())); | |
3701 WRITE_DOUBLE_FIELD( | |
3702 this, FixedTypedArray<Float64ArrayTraits>::SizeFor(index), value); | |
Dmitry Lomov (no reviews)
2014/01/30 16:55:22
Ditto
kilvadyb
2014/01/30 18:27:05
Done.
| |
3703 } | |
3704 | |
3705 | |
3687 template <class Traits> | 3706 template <class Traits> |
3688 MaybeObject* FixedTypedArray<Traits>::get(int index) { | 3707 MaybeObject* FixedTypedArray<Traits>::get(int index) { |
3689 return Traits::ToObject(GetHeap(), get_scalar(index)); | 3708 return Traits::ToObject(GetHeap(), get_scalar(index)); |
3690 } | 3709 } |
3691 | 3710 |
3692 template <class Traits> | 3711 template <class Traits> |
3693 MaybeObject* FixedTypedArray<Traits>::SetValue(uint32_t index, Object* value) { | 3712 MaybeObject* FixedTypedArray<Traits>::SetValue(uint32_t index, Object* value) { |
3694 ElementType cast_value = Traits::defaultValue(); | 3713 ElementType cast_value = Traits::defaultValue(); |
3695 if (index < static_cast<uint32_t>(length())) { | 3714 if (index < static_cast<uint32_t>(length())) { |
3696 if (value->IsSmi()) { | 3715 if (value->IsSmi()) { |
(...skipping 3090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6787 #undef READ_UINT32_FIELD | 6806 #undef READ_UINT32_FIELD |
6788 #undef WRITE_UINT32_FIELD | 6807 #undef WRITE_UINT32_FIELD |
6789 #undef READ_SHORT_FIELD | 6808 #undef READ_SHORT_FIELD |
6790 #undef WRITE_SHORT_FIELD | 6809 #undef WRITE_SHORT_FIELD |
6791 #undef READ_BYTE_FIELD | 6810 #undef READ_BYTE_FIELD |
6792 #undef WRITE_BYTE_FIELD | 6811 #undef WRITE_BYTE_FIELD |
6793 | 6812 |
6794 } } // namespace v8::internal | 6813 } } // namespace v8::internal |
6795 | 6814 |
6796 #endif // V8_OBJECTS_INL_H_ | 6815 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |