← All issues

JSC: PerformPromiseThenOneHandler for single-handler .then()

c3276f4

+function fulfillOnly(p) { return p.then(v => v + 1); }
+function rejectOnlyUndefined(p) { return p.then(undefined, e => 'caught:' + e); }
+function bothHandlers(p) { return p.then(v => 'ok:' + v, e => 'err:' + e); }

PerformPromiseThen is the generic four-child DFG IR node (promise, fulfill handler, reject handler, result capability) and is conservative because either handler can be callable or null/undefined at runtime. The Abstract Interpreter propagates type predictions using SpeculatedType bit sets — SpecFunction for callables, SpecOther for null/undefined. When DFGConstantFoldingPhase proves one handler slot is SpecOther, it converts the node to PerformPromiseThenOneHandler, encoding handler kind in a flag and emitting direct flag-and-slot writes instead of allocating a reaction cell.

This puts JIT-emitted code directly into promise handler dispatch — a security-sensitive path where a misclassified handler can silently drop or misroute a callback.

🔒

New JIT fast path for promise handler dispatch — type proof boundaries and inline write correctness are worth security investigation.

Subscribe to read more