Skip to content

Commit

Permalink
Editorial: cleanups from tc39#1515 (tc39#1704)
Browse files Browse the repository at this point in the history
 - Let -> Set
 - Eliminate otherwise-assertions (per tc39#1559)
 - Change '?' to '!', because ::subtract can't return an abrupt completion.
 - Fix bug: '_v_' should be '_value_'

 - Fix bug: `_arrayTypeName_` not defined
... in Atomics.{store,wait,notify}.

(In Atomics.store, it does get defined in step 5, but needs to be defined
before the reference in step 3.)

(In Atomics.wait, the undefined reference is in step 11,
but by defining it earlier, it can also be used in the current step 3.)

(In Atomics.notify, the undefined reference is in step 7.)
  • Loading branch information
jmdyck authored and ljharb committed Sep 28, 2019
1 parent dc00d4d commit 55c611d
Showing 1 changed file with 33 additions and 27 deletions.
60 changes: 33 additions & 27 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -1953,21 +1953,21 @@ <h1>BigIntBitwiseOp ( _op_, _x_, _y_ )</h1>
1. Repeat, until (_x_ = 0 or _x_ = -1) and (_y_ = 0 or _y_ = -1),
1. Let _xDigit_ be _x_ modulo 2.
1. Let _yDigit_ be _y_ modulo 2.
1. If _op_ is `"&amp;"`, let _result_ be _result_ + 2<sup>_shift_</sup> &times; BinaryAnd(_xDigit_, _yDigit_).
1. Else if _op_ is `"|"`, let _result_ be _result_ + 2<sup>_shift_</sup> &times; BinaryOr(_xDigit_, _yDigit_).
1. If _op_ is `"&amp;"`, set _result_ to _result_ + 2<sup>_shift_</sup> &times; BinaryAnd(_xDigit_, _yDigit_).
1. Else if _op_ is `"|"`, set _result_ to _result_ + 2<sup>_shift_</sup> &times; BinaryOr(_xDigit_, _yDigit_).
1. Else,
1. Assert: _op_ is `"^"`.
1. Let _result_ be _result_ + 2<sup>_shift_</sup> &times; BinaryXor(_xDigit_, _yDigit_).
1. Let _shift_ be _shift_ + 1.
1. Let _x_ be (_x_ - _xDigit_) / 2.
1. Let _y_ be (_y_ - _yDigit_) / 2.
1. Set _result_ to _result_ + 2<sup>_shift_</sup> &times; BinaryXor(_xDigit_, _yDigit_).
1. Set _shift_ to _shift_ + 1.
1. Set _x_ to (_x_ - _xDigit_) / 2.
1. Set _y_ to (_y_ - _yDigit_) / 2.
1. If _op_ is `"&amp;"`, let _tmp_ be BinaryAnd(_x_ modulo 2, _y_ modulo 2).
1. Else if _op_ is `"|"`, let _tmp_ be BinaryOr(_x_ modulo 2, _y_ modulo 2).
1. Else,
1. Assert: _op_ is `"^"`.
1. Let _tmp_ be BinaryXor(_x_ modulo 2, _y_ modulo 2).
1. If _tmp_ &ne; 0, then
1. Let _result_ be _result_ - 2<sup>_shift_</sup>. NOTE: This extends the sign.
1. Set _result_ to _result_ - 2<sup>_shift_</sup>. NOTE: This extends the sign.
1. Return _result_.
</emu-alg>
</emu-clause>
Expand Down Expand Up @@ -14019,7 +14019,7 @@ <h1>Runtime Semantics: Evaluation</h1>
<emu-alg>
1. Let _expr_ be the result of evaluating |UnaryExpression|.
1. Let _oldValue_ be ? ToNumeric(? GetValue(_expr_)).
1. Let _newValue_ be ? Type(_oldvalue_)::subtract(_oldValue_, Type(_oldValue_)::unit).
1. Let _newValue_ be ! Type(_oldvalue_)::subtract(_oldValue_, Type(_oldValue_)::unit).
1. Perform ? PutValue(_expr_, _newValue_).
1. Return _newValue_.
</emu-alg>
Expand Down Expand Up @@ -14412,7 +14412,9 @@ <h1>Runtime Semantics: Evaluation</h1>
1. Let _T_ be Type(_lnum_).
1. If |MultiplicativeOperator| is `*`, return _T_::multiply(_lnum_, _rnum_).
1. If |MultiplicativeOperator| is `/`, return _T_::divide(_lnum_, _rnum_).
1. Otherwise, |MultiplicativeOperator| is `%`; return _T_::remainder(_lnum_, _rnum_).
1. Else,
1. Assert: |MultiplicativeOperator| is `%`.
1. Return _T_::remainder(_lnum_, _rnum_).
</emu-alg>
</emu-clause>
</emu-clause>
Expand Down Expand Up @@ -14936,7 +14938,9 @@ <h1>Runtime Semantics: Evaluation</h1>
1. Let _T_ be Type(_lnum_).
1. If @ is `&amp;`, return _T_::bitwiseAND(_lnum_, _rnum_).
1. If @ is `|`, return _T_::bitwiseOR(_lnum_, _rnum_).
1. Otherwise, @ is `^`; return _T_::bitwiseXOR(_lnum_, _rnum_).
1. Else,
1. Assert: @ is `^`.
1. Return _T_::bitwiseXOR(_lnum_, _rnum_).
</emu-alg>
</emu-clause>
</emu-clause>
Expand Down Expand Up @@ -26960,8 +26964,8 @@ <h1>Properties of the BigInt Constructor</h1>
<h1>BigInt.asIntN ( _bits_, _bigint_ )</h1>
<p>When the `BigInt.asIntN` is called with two arguments _bits_ and _bigint_, the following steps are taken:</p>
<emu-alg>
1. Let _bits_ be ? ToIndex(_bits_).
1. Let _bigint_ be ? ToBigInt(_bigint_).
1. Set _bits_ to ? ToIndex(_bits_).
1. Set _bigint_ to ? ToBigInt(_bigint_).
1. Let _mod_ be the BigInt value that represents _bigint_ modulo 2<sup>_bits_</sup>.
1. If _mod_ &ge; 2<sup>_bits_ - 1</sup>, return _mod_ - 2<sup>_bits_</sup>; otherwise, return _mod_.
</emu-alg>
Expand All @@ -26971,8 +26975,8 @@ <h1>BigInt.asIntN ( _bits_, _bigint_ )</h1>
<h1>BigInt.asUintN ( _bits_, _bigint_ )</h1>
<p>When the `BigInt.asUintN` function is called with two arguments _bits_ and _bigint_, the following steps are taken:</p>
<emu-alg>
1. Let _bits_ be ? ToIndex(_bits_).
1. Let _bigint_ be ? ToBigInt(_bigint_).
1. Set _bits_ to ? ToIndex(_bits_).
1. Set _bigint_ to ? ToBigInt(_bigint_).
1. Return the BigInt value that represents _bigint_ modulo 2<sup>_bits_</sup>.
</emu-alg>
</emu-clause>
Expand Down Expand Up @@ -27723,8 +27727,8 @@ <h1>Math.min ( _value1_, _value2_, ..._values_ )</h1>
<emu-clause id="sec-math.pow">
<h1>Math.pow ( _base_, _exponent_ )</h1>
<emu-alg>
1. Let _base_ be ? ToNumber(_base_).
1. Let _exponent_ be ? ToNumber(_exponent_).
1. Set _base_ to ? ToNumber(_base_).
1. Set _exponent_ to ? ToNumber(_exponent_).
1. Return ! Number::exponentiate(_base_, _exponent_).
</emu-alg>
</emu-clause>
Expand Down Expand Up @@ -34652,8 +34656,8 @@ <h1>%TypedArray%.prototype.fill ( _value_ [ , _start_ [ , _end_ ] ] )</h1>
1. Let _O_ be the *this* value.
1. Perform ? ValidateTypedArray(_O_).
1. Let _len_ be _O_.[[ArrayLength]].
1. If _O_.[[ContentType]] is `"BigInt"`, let _value_ be ? ToBigInt(_value_).
1. Otherwise, let _value_ be ? ToNumber(_value_).
1. If _O_.[[ContentType]] is `"BigInt"`, set _value_ to ? ToBigInt(_value_).
1. Otherwise, set _value_ to ? ToNumber(_value_).
1. Let _relativeStart_ be ? ToInteger(_start_).
1. If _relativeStart_ &lt; 0, let _k_ be max((_len_ + _relativeStart_), 0); else let _k_ be min(_relativeStart_, _len_).
1. If _end_ is *undefined*, let _relativeEnd_ be _len_; else let _relativeEnd_ be ? ToInteger(_end_).
Expand Down Expand Up @@ -34837,8 +34841,8 @@ <h1>%TypedArray%.prototype.set ( _array_ [ , _offset_ ] )</h1>
1. Repeat, while _targetByteIndex_ &lt; _limit_
1. Let _Pk_ be ! ToString(_k_).
1. Let _value_ be ? Get(_src_, _Pk_).
1. If _target_.[[ContentType]] is `"BigInt"`, let _value_ be ? ToBigInt(_value_).
1. Otherwise, let _value_ be ? ToNumber(_value_).
1. If _target_.[[ContentType]] is `"BigInt"`, set _value_ to ? ToBigInt(_value_).
1. Otherwise, set _value_ to ? ToNumber(_value_).
1. If IsDetachedBuffer(_targetBuffer_) is *true*, throw a *TypeError* exception.
1. Perform SetValueInBuffer(_targetBuffer_, _targetByteIndex_, _targetType_, _value_, *true*, `"Unordered"`).
1. Set _k_ to _k_ + 1.
Expand Down Expand Up @@ -36967,7 +36971,7 @@ <h1>DataView.prototype.getBigInt64 ( _byteOffset_ [ , _littleEndian_ ] )</h1>
<p>When the `getBigInt64` method is called with argument _byteOffset_ and optional argument _littleEndian_, the following steps are taken:</p>
<emu-alg>
1. Let _v_ be the *this* value.
1. If _littleEndian_ is not present, let _littleEndian_ be *undefined*.
1. If _littleEndian_ is not present, set _littleEndian_ to *undefined*.
1. Return ? GetViewValue(_v_, _byteOffset_, _littleEndian_, `"BigInt64"`).
</emu-alg>
</emu-clause>
Expand All @@ -36977,7 +36981,7 @@ <h1>DataView.prototype.getBigUint64 ( _byteOffset_ [ , _littleEndian_ ] )</h1>
<p>When the `getBigUint64` method is called with argument _byteOffset_ and optional argument _littleEndian_, the following steps are taken:</p>
<emu-alg>
1. Let _v_ be the *this* value.
1. If _littleEndian_ is not present, let _littleEndian_ be *undefined*.
1. If _littleEndian_ is not present, set _littleEndian_ to *undefined*.
1. Return ? GetViewValue(_v_, _byteOffset_, _littleEndian_, `"BigUint64"`).
</emu-alg>
</emu-clause>
Expand Down Expand Up @@ -37065,7 +37069,7 @@ <h1>DataView.prototype.setBigInt64 ( _byteOffset_, _value_ [ , _littleEndian_ ]
<p>When the `setBigInt64` method is called with arguments _byteOffset_ and _value_ and optional argument _littleEndian_, the following steps are taken:</p>
<emu-alg>
1. Let _v_ be the *this* value.
1. If _littleEndian_ is not present, let _littleEndian_ be *undefined*.
1. If _littleEndian_ is not present, set _littleEndian_ to *undefined*.
1. Return ? SetViewValue(_v_, _byteOffset_, _littleEndian_, `"BigInt64"`, _value_).
</emu-alg>
</emu-clause>
Expand All @@ -37075,7 +37079,7 @@ <h1>DataView.prototype.setBigUint64 ( _byteOffset_, _value_ [ , _littleEndian_ ]
<p>When the `setBigUint64` method is called with arguments _byteOffset_ and _value_ and optional argument _littleEndian_, the following steps are taken:</p>
<emu-alg>
1. Let _v_ be the *this* value.
1. If _littleEndian_ is not present, let _littleEndian_ be *undefined*.
1. If _littleEndian_ is not present, set _littleEndian_ to *undefined*.
1. Return ? SetViewValue(_v_, _byteOffset_, _littleEndian_, `"BigUint64"`, _value_).
</emu-alg>
</emu-clause>
Expand Down Expand Up @@ -37338,7 +37342,7 @@ <h1>AtomicReadModifyWrite ( _typedArray_, _index_, _value_, _op_ )</h1>
1. Let _buffer_ be ? ValidateSharedIntegerTypedArray(_typedArray_).
1. Let _i_ be ? ValidateAtomicAccess(_typedArray_, _index_).
1. Let _arrayTypeName_ be _typedArray_.[[TypedArrayName]].
1. If _typedArray_.[[ContentType]] is `"BigInt"`, let _v_ be ? ToBigInt(_v_).
1. If _typedArray_.[[ContentType]] is `"BigInt"`, let _v_ be ? ToBigInt(_value_).
1. Otherwise, let _v_ be ? ToInteger(_value_).
1. Let _elementSize_ be the Element Size value specified in <emu-xref href="#table-49"></emu-xref> for _arrayTypeName_.
1. Let _elementType_ be the String value of the Element Type value in <emu-xref href="#table-49"></emu-xref> for _arrayTypeName_.
Expand Down Expand Up @@ -37456,9 +37460,9 @@ <h1>Atomics.store ( _typedArray_, _index_, _value_ )</h1>
<emu-alg>
1. Let _buffer_ be ? ValidateSharedIntegerTypedArray(_typedArray_).
1. Let _i_ be ? ValidateAtomicAccess(_typedArray_, _index_).
1. Let _arrayTypeName_ be _typedArray_.[[TypedArrayName]].
1. If _arrayTypeName_ is `"BigUint64Array"` or `"BigInt64Array"`, let _v_ be ? ToBigInt(_value_).
1. Otherwise, let _v_ be ? ToInteger(_value_).
1. Let _arrayTypeName_ be _typedArray_.[[TypedArrayName]].
1. Let _elementSize_ be the Element Size value specified in <emu-xref href="#table-49"></emu-xref> for _arrayTypeName_.
1. Let _elementType_ be the String value of the Element Type value in <emu-xref href="#table-49"></emu-xref> for _arrayTypeName_.
1. Let _offset_ be _typedArray_.[[ByteOffset]].
Expand All @@ -37483,7 +37487,8 @@ <h1>Atomics.wait ( _typedArray_, _index_, _value_, _timeout_ )</h1>
<emu-alg>
1. Let _buffer_ be ? ValidateSharedIntegerTypedArray(_typedArray_, *true*).
1. Let _i_ be ? ValidateAtomicAccess(_typedArray_, _index_).
1. If _typedArray_.[[TypedArrayName]] is `"BigInt64Array"`, let _v_ be ? ToBigInt64(_value_).
1. Let _arrayTypeName_ be _typedArray_.[[TypedArrayName]].
1. If _arrayTypeName_ is `"BigInt64Array"`, let _v_ be ? ToBigInt64(_value_).
1. Otherwise, let _v_ be ? ToInt32(_value_).
1. Let _q_ be ? ToNumber(_timeout_).
1. If _q_ is *NaN*, let _t_ be *+&infin;*; else let _t_ be max(_q_, 0).
Expand Down Expand Up @@ -37524,6 +37529,7 @@ <h1>Atomics.notify ( _typedArray_, _index_, _count_ )</h1>
1. Let _c_ be max(_intCount_, 0).
1. Let _block_ be _buffer_.[[ArrayBufferData]].
1. Let _offset_ be _typedArray_.[[ByteOffset]].
1. Let _arrayTypeName_ be _typedArray_.[[TypedArrayName]].
1. Let _elementSize_ be the Element Size value specified in <emu-xref href="#table-49"></emu-xref> for _arrayTypeName_.
1. Let _indexedPosition_ be (_i_ &times; _elementSize_) + _offset_.
1. Let _WL_ be GetWaiterList(_block_, _indexedPosition_).
Expand Down

0 comments on commit 55c611d

Please sign in to comment.