ecmascript_simd icon indicating copy to clipboard operation
ecmascript_simd copied to clipboard

Polyfill simdCheckLaneIndex requires Int32 values, spec applies ToNumber first

Open stoklund opened this issue 9 years ago • 3 comments

The API function arguments that represent lane indexes are checked with the simdCheckLaneIndex() in the polyfill. This function throws a TypeError if the argument is not an Int32 Number.

The spec uses the abstract function SIMDToLane which first applies ToNumber before checking that the argument is an integer in the right range. This function only throws a TypeError when ToNumber throws.

Some differences:

  • extractLane(x, "1"): Polyfill throws TypeError, spec returns extractLane(x,1)
  • extractLane(x, false): Polyfill throws TypeError, spec returns extractLane(x,0)
  • extractLane(x, 0x100000000): Polyfill throws TypeError, spec throws RangeError
  • extractLane(x, 1.5): Polyfill throws TypeError, spec throws RangeError

stoklund avatar Feb 28 '16 19:02 stoklund

Is this the same as #237?

stoklund avatar Mar 01 '16 20:03 stoklund

Revisited here too: 308 The polyfill should be fixed to follow the spec.

nmostafa avatar Mar 01 '16 22:03 nmostafa

I agree. The spec is fine, we should just fix the polyfill and tests.

stoklund avatar Mar 02 '16 01:03 stoklund