From: plind44@gmail.com Date: Thu, 30 Jan 2014 20:05:11 +0000 (+0000) Subject: MIPS: Specialize FixedTypedArray<> set and get functions to solve unaligned double... X-Git-Tag: upstream/4.7.83~10946 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=02d8dc57c15c0f52b79d068398bf262aa9390ea4;p=platform%2Fupstream%2Fv8.git MIPS: Specialize FixedTypedArray<> set and get functions to solve unaligned double access. BUG= TEST=test-api/FixedFloat64Array R=dslomov@chromium.org Review URL: https://codereview.chromium.org/136333011 Patch from Balazs Kilvady . git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18965 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/objects-inl.h b/src/objects-inl.h index 3f178c0..1ea9441 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -3675,6 +3675,15 @@ typename Traits::ElementType FixedTypedArray::get_scalar(int index) { return ptr[index]; } + +template<> inline +FixedTypedArray::ElementType + FixedTypedArray::get_scalar(int index) { + ASSERT((index >= 0) && (index < this->length())); + return READ_DOUBLE_FIELD(this, ElementOffset(index)); +} + + template void FixedTypedArray::set(int index, ElementType value) { ASSERT((index >= 0) && (index < this->length())); @@ -3684,6 +3693,14 @@ void FixedTypedArray::set(int index, ElementType value) { } +template<> inline +void FixedTypedArray::set( + int index, Float64ArrayTraits::ElementType value) { + ASSERT((index >= 0) && (index < this->length())); + WRITE_DOUBLE_FIELD(this, ElementOffset(index), value); +} + + template MaybeObject* FixedTypedArray::get(int index) { return Traits::ToObject(GetHeap(), get_scalar(index)); diff --git a/src/objects.h b/src/objects.h index c6f36bf..ff21a1f 100644 --- a/src/objects.h +++ b/src/objects.h @@ -4895,8 +4895,12 @@ class FixedTypedArray: public FixedTypedArrayBase { // Casting: static inline FixedTypedArray* cast(Object* obj); + static inline int ElementOffset(int index) { + return kDataOffset + index * sizeof(ElementType); + } + static inline int SizeFor(int length) { - return kDataOffset + length * sizeof(ElementType); + return ElementOffset(length); } inline ElementType get_scalar(int index);