Repository navigation
Atomics.load/store use atomic load/store; Promise functions over settled values - #65
Merged
Merged
Conversation
…ons over settled values Atomics.load was an atomic `or 0` (a locked write) and Atomics.store an exchange whose result was dropped; they are now `atomicload` and `atomicstore` (TypeScriptCompiler#767). The atomics test no longer declares each array's type (`new Uint8Array([250])` now keeps u8) and checks that a value wraps to the element's width as in JavaScript. Promise: the compiler takes Promise<T> as T, so these are functions over values that have already settled: resolve, reject (throws its reason, keeping its class), all (a new array, so the result can leave an `await` under -mm=own), allSettled, race and any. No then/catch/finally. promise_reject.ts is `// not own`: under -mm=own a thrown parameter does not build, and a string Promise.resolve returns borrows its argument and cannot leave an `await`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TypeScriptCompiler#768 keeps a thrown parameter and copies an awaited string that borrows its argument, so Promise.reject and `await Promise.resolve(someString)` build under own. Needs #768. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to ASDAlexander77/TypeScriptCompiler#767 (atomic builtins) and #64 (Atomics).
Atomics
Atomics.loadis now an atomicload(atomicload). It was an atomicor 0, a locked write to the element.Atomics.storeis now an atomicstore(atomicstore) instead of an exchange whose result was dropped.tests/atomics.ts: the arrays aren't declared with their type any more (new Uint8Array([250])keepsu8since #767), and new cases check that a value wraps to the element width as in JavaScript (adding 300 to aUint8Arrayelement adds 44, subtracting -1 adds 1) and coverload/storeon a narrow element.Promise
The compiler takes
Promise<T>asT: an async function returns its value andawaitgives it back. Aclass Promise<T>in the library would take precedence over that and break everyasync function f(): Promise<int>. SoPromiseis a namespace of functions over values that have already settled:resolve(value): the value.reject(reason): throws the reason, keeping its class, socatch (e: RangeError)catches it.all(values): a new array, as in JavaScript. Under-mm=ownthis lets the result leave anawait.allSettled(values):{ status: "fulfilled", value }for each.race(values)/any(values): the first value; both throw on an empty array.There is no
then/catch/finally. The README lists both namespaces.tests/promise_reject.tsran into two-mm=owngaps. Both are fixed in ASDAlexander77/TypeScriptCompiler#768, which this PR now needs:Promise.reject: without@keepsthe thrown parameter is "kept, but -mm=own cannot make the callers give it up"; with@keeps("reason")it is "its body keeps nothing".await Promise.resolve(someString): the result borrows the argument and can't leave theawait.Verification
Built with the compiler at #768 (main + the own fixes).
tests.ps1release compile + jit:🤖 Generated with Claude Code