Implement JS Promise and microtask queue
Add Promise constructor, prototype methods, and static methods to the
JavaScript engine, with a microtask queue for asynchronous execution:
- Promise constructor (via JS preamble so executor runs as bytecode)
- Promise.prototype.then/catch/finally with chaining
- Promise.resolve/reject static methods
- Promise.all/allSettled/race/any static methods
- Microtask queue: thread-local queue drained after each vm.execute()
- VM.call_function: invoke GC-managed functions (native or bytecode)
from outside the execution loop, used by microtask drain
- SameValueZero key equality preserved, insertion order maintained
Internal storage uses hidden properties (__promise_state__,
__promise_result__, __promise_reactions__) on GC-heap objects.
Promise.prototype stored as a GC root on the VM to survive collection.
29 new integration tests covering resolve/reject, constructor,
executor synchronous execution, then chaining, catch/finally,
error propagation, Promise.all/race/any/allSettled, identity
passthrough, and double-resolve prevention.
Removes Promise from test262 unsupported features list.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
authored by
tangled.org
de695154
34985477