Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Update spec to coerce TypedArray indexes with ToNumber(). #337

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions tc39/spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -718,9 +718,10 @@ <h1>SIMDLoadFromTypedArray( tarray, index, descriptor [, length] )</h1>
1. If _length_ is not provided, let _length_ be _descriptor_.[[VectorLength]]. Otherwise, assert _length_ &le; _descriptor_.[[VectorLength]].
1. If IsDetachedBuffer(_tarray_.[[ViewedArrayBuffer]]) is *true*, throw a TypeError exception.
1. Let _block_ be _tarray_.[[ViewedArrayBuffer]].[[ArrayBufferData]]
1. If _index_ &ne; ToLength(_index_), throw a TypeError exception.
1. Let _numberIndex_ be ToNumber(_index_).
1. If _numberIndex_ &ne; ToInteger(_numberIndex_), throw a RangeError exception.
1. Let _elementLength_ be _tarray_.[[ByteLength]] &divide; _tarray_.[[ArrayLength]].
1. Let _byteIndex_ be _index_ &times; _elementLength_.
1. Let _byteIndex_ be _numberIndex_ &times; _elementLength_.
1. If _byteIndex_ + _descriptor_.[[ElementSize]] &times; length > _tarray_.[[ByteLength]] or _byteIndex_ < 0, throw a RangeError exception.
1. Return SIMDLoad(_block_, _descriptor_, _byteIndex_, length).
</emu-alg>
Expand All @@ -745,9 +746,10 @@ <h1>SIMDStoreInTypedArray( tarray, index, descriptor, n [, length] )</h1>
1. If IsDetachedBuffer(_tarray_.[[ViewedArrayBuffer]]) is *true*, throw a TypeError exception.
1. If _tarray_ does not have a [[ViewedArrayBuffer]] field, throw a TypeError exception.
1. Let _block_ be _tarray_.[[ViewedArrayBuffer]].[[ArrayBufferData]]
1. If _index_ &ne; ToLength(_index_), throw a TypeError exception.
1. Let _elementLength_ be _tarray_.[[ByteLength]] &divide; _tarray.[[ArrayLength]].
1. Let _byteIndex_ be _index_ &times; _elementLength_.
1. Let _numberIndex_ be ToNumber(_index_).
1. If _numberIndex_ &ne; ToInteger(_numberIndex_), throw a RangeError exception.
1. Let _elementLength_ be _tarray_.[[ByteLength]] &divide; _tarray_.[[ArrayLength]].
1. Let _byteIndex_ be _numberIndex_ &times; _elementLength_.
1. If _byteIndex_ + _SIMD_Descriptor.[[ElementSize]] &times; _length_ > _tarray_.[[ByteLength]] or _byteIndex_ < 0, throw a RangeError exception.
1. SIMDStore(_block_, _SIMD_Descriptor, _byteIndex_, _simd_, _length_).
1. Return _n_.
Expand Down