Skip to content

Commit

Permalink
bakkot review
Browse files Browse the repository at this point in the history
  • Loading branch information
syg committed Sep 18, 2024
1 parent 7c722a6 commit df7d0c8
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions spec/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1525,7 +1525,9 @@ <h1>
1. Assert: _mutex_ has a [[MutexWaiterList]] internal slot.
1. If _token_ is *undefined*, then
1. Set _token_ to OrdinaryObjectCreate(%MutexUnlockTokenPrototype%, « [[LockedMutex]] »).
1. Assert: _token_ has a [[LockedMutex]] internal slot.
1. Else,
1. Assert: _token_ has a [[LockedMutex]] internal slot.
1. Assert: _token_.[[LockedMutex]] is ~empty~.
1. Set _token_.[[LockedMutex]] to _mutex_.
1. Return _token_.
</emu-alg>
Expand All @@ -1535,7 +1537,7 @@ <h1>
<h1>
LockMutex (
_mutex_: an Object,
_t_: a mathematical value,
_tMillis_: a mathematical value,
) : ~acquired~ or ~timed-out~
</h1>
<dl class="header">
Expand All @@ -1552,8 +1554,8 @@ <h1>
1. Let _thisAgent_ be AgentSignifier().
1. Let _now_ be the time value (UTC) identifying the current time.
1. Let _additionalTimeout_ be an implementation-defined non-negative mathematical value.
1. Let _timeoutTime_ be ℝ(_now_) + _t_ + _additionalTimeout_.
1. NOTE: When _t_ is +∞, _timeoutTime_ is also +∞.
1. Let _timeoutTime_ be ℝ(_now_) + _tMillis_ + _additionalTimeout_.
1. NOTE: When _tMillis_ is +∞, _timeoutTime_ is also +∞.
1. Let _done_ be *false*.
1. Repeat, while _done_ is *false*,
1. Let _waiterRecord_ be a new Waiter Record { [[AgentSignifier]]: _thisAgent_, [[PromiseCapability]]: ~blocking~, [[TimeoutTime]]: _timeoutTime_, [[Result]]: *"ok"* }.
Expand Down Expand Up @@ -1645,9 +1647,9 @@ <h1>Atomics.Mutex.lock ( _mutex_ [ , _unlockToken_ [ , _timeout_ ] ] )</h1>
1. If _unlockToken_.[[LockedMutex]] is not ~empty~, throw a *TypeError* exception.
1. If _timeout_ is *undefined*, set _timeout_ to *+∞*<sub>𝔽</sub>.
1. If _timeout_ is not a Number, throw a *TypeError* exception.
1. If _timeout_ is either *NaN* or *+∞*<sub>𝔽</sub>, let _t_ be +∞; else if _timeout_ is *-∞*<sub>𝔽</sub>, let _t_ be 0; else let _t_ be max(ℝ(_timeout_), 0).
1. If _timeout_ is either *NaN* or *+∞*<sub>𝔽</sub>, let _tMillis_ be +∞; else if _timeout_ is *-∞*<sub>𝔽</sub>, let _tMillis_ be 0; else let _tMillis_ be max(ℝ(_timeout_), 0).
1. If AgentCanSuspend() is *false*, throw a *TypeError* exception.
1. Let _result_ be LockMutex(_mutex_, _t_).
1. Let _result_ be LockMutex(_mutex_, _tMillis_).
1. If _result_ is ~acquired~, then
1. Return UnlockTokenCreateIfNeeded(_unlockToken_, _mutex_).
1. Else,
Expand All @@ -1672,7 +1674,7 @@ <h1>Atomics.Mutex.tryLock ( _mutex_ [ , _unlockToken_ ] )</h1>
1. Set _mutex_.[[IsLocked]] to *true*.
1. Let _result_ be UnlockTokenCreateIfNeeded(_unlockToken_, _mutex_).
1. Else,
1. Let _result_ be *undefined*.
1. Let _result_ be *"already-locked"*.
1. Perform LeaveCriticalSection(_WL_).
1. Return _result_.
</emu-alg>
Expand All @@ -1688,9 +1690,9 @@ <h1>Atomics.Mutex.withLock ( _mutex_, _callback_ [ , _thisArg_ ] )</h1>
1. If AgentCanSuspend() is *false*, throw a *TypeError* exception.
1. Let _lockResult_ be LockMutex(_mutex_, +∞).
1. Assert: _lockResult_ is ~acquired~.
1. Let _callbackResult_ be ? Call(_callback_, _thisArg_, « »).
1. Let _callbackResult_ be Completion(Call(_callback_, _thisArg_, « »)).
1. Perform UnlockMutex(_mutex_).
1. Return _callbackResult_.
1. Return Completion(_callbackResult_).
</emu-alg>
</emu-clause>
</emu-clause>
Expand All @@ -1704,6 +1706,16 @@ <h1>The %MutexUnlockTokenPrototype% Object</h1>
<li>has the following properties:</li>
</ul>
<emu-clause id="sec-get-%mutexunlocktokenprototype%.locked">
<h1>get %MutexUnlockTokenPrototype%.locked</h1>
<p>%MutexUnlockTokenPrototype%.locked is an accessor property whose set accessor is *undefined*. Its get accessor function performs the following steps when called:</p>
<emu-alg>
1. Let _token_ be the *this* value.
1. Perform ? RequireInternalSlot(_token_, [[LockedMutex]]).
1. If _token_.[[LockedMutex]] is ~empty~, return *false*; else return *true*.
</emu-alg>
</emu-clause>
<emu-clause id="sec-%mutexunlocktokenprototype%.unlock">
<h1>%MutexUnlockTokenPrototype%.unlock ( )</h1>
<p>This function performs the following steps when called:</p>
Expand All @@ -1715,7 +1727,8 @@ <h1>%MutexUnlockTokenPrototype%.unlock ( )</h1>
1. If _mutex_ is not ~empty~, then
1. Set _token_.[[LockedMutex]] to ~empty~.
1. Perform UnlockMutex(_mutex_).
1. Return *undefined*.
1. Return *true*.
1. Return *false*.
</emu-alg>
</emu-clause>
</emu-clause>
Expand Down

0 comments on commit df7d0c8

Please sign in to comment.