fix(runtime): Date.now/parse/UTC usable as first-class function values#4622
Merged
Conversation
Two bugs made the dotted static reads broken: 1. The #973/#4139 reroute-undo collapsed value reads of Date.now/parse/UTC to GlobalGet(0).<name>, for which codegen has no intrinsic handler (unlike Object.keys / Math.max), so they mis-folded to a number (typeof 'number'). Add a Date now/parse/UTC exception to the reroute-undo so the read hits the reified Date constructor object (the aliased/computed forms already did). Direct calls (Date.now()) stay on the Expr::DateNow fast path (unaffected). 2. date_utc_static collects all args into its rest param, but Date.UTC was registered with call-arity 7 (7 fixed params before rest), so Date.UTC(2020,0) put nothing in the rest array → js_date_utc([]) → NaN. Register call-arity 0 (all args → rest) while keeping spec .length = 7. Now byte-identical to node: typeof Date.now/parse/UTC === 'function', correct .name/.length, value-calls (const u=Date.UTC; u(2020,0)) work, direct calls unchanged. Fixes test262 Date/{now,parse,UTC}/{name,length}, Date/now/15.9.4.4-0-1/3.
proggeramlug
added a commit
that referenced
this pull request
Jun 5, 2026
…lues (#4626) Same reroute-undo issue as Date.now (#4622): value reads of Array.isArray / Array.from / Array.of collapsed to GlobalGet(0).<name>, whose intrinsic path drops the function metadata — typeof was 'function' but .name was undefined and .length undefined. They are installed with metadata via install_constructor_static, so add Array to the reified-static reroute-undo exception. Array.fromAsync is unreified and unchanged; direct calls keep the intrinsic fast path via the !member_is_call_callee gate. Byte-identical to node: Array.isArray.name==='isArray'/.length===1, Array.from.name==='from'/.length===1, Array.of.name==='of'/.length===0, value-calls and direct calls work. Fixes test262 Array/{isArray,from,of}/{name,length}. Co-authored-by: Ralph Küpper <ralph@skelpo.com>
proggeramlug
added a commit
that referenced
this pull request
Jun 5, 2026
…nction values (#4631) Same reroute-undo issue as Date.now (#4622) / Array.isArray (#4626). All six Number statics (isFinite/isInteger/isNaN/isSafeInteger/parseFloat/parseInt) are reified with metadata via install_constructor_static, but the #973/#4139 reroute-undo collapsed value reads to GlobalGet(0).<name>, whose intrinsic path dropped the metadata for isInteger/isSafeInteger (.name/.length undefined). Add Number to the reified-static reroute-undo exception. The already-named siblings (isFinite/isNaN/parseFloat/parseInt) are also reified, so routing them to the reified receiver preserves their names; direct calls keep the intrinsic fast path via the !member_is_call_callee gate. Byte-identical to node: Number.isInteger.name==='isInteger'/.length===1, isSafeInteger likewise; value-calls and direct calls work. Fixes test262 Number/{isInteger,isSafeInteger}/{name,length}. (String.fromCharCode/etc. are not reified yet — tracked in #4627.) Co-authored-by: Ralph Küpper <ralph@skelpo.com>
proggeramlug
added a commit
that referenced
this pull request
Jun 5, 2026
… function values (#4634) Completes the static-function-values series (#4622 Date, #4626 Array, #4631 Number). Unlike those, String.fromCharCode/fromCodePoint were not reified at all, so this both reifies them and wires the reroute-undo exception: - New js_string_from_code_point_array runtime helper (variadic fromCodePoint with per-element RangeError validation; lone surrogates → U+FFFD). - Reify fromCharCode/fromCodePoint via install_constructor_static_with_call_arity (call-arity 0 = all args into rest; spec .length 1) — fromCharCode reuses the existing js_string_from_char_code_array. - Explicit String fromCharCode/fromCodePoint exception in the #973/#4139 reroute-undo (NOT the whole namespace — String.raw is not reified and stays on its intrinsic path, unaffected). Byte-identical to node: typeof/name/length, value-calls (incl. astral code points), direct calls, RangeError on invalid code points; String.raw unchanged. Fixes test262 String/{fromCharCode,fromCodePoint}/{name,length}. (String.raw .name /.length tracked in #4627.) Co-authored-by: Ralph Küpper <ralph@skelpo.com>
proggeramlug
added a commit
that referenced
this pull request
Jun 5, 2026
Completes the static-function-values series (Date #4622, Array #4626, Number #4631, String.fromCharCode/fromCodePoint #4634). Reify String.raw as a real function value: a thunk taking the template/cooked object as a fixed param plus a rest of substitutions (call-arity 1, spec .length 1), forwarding to js_string_raw. Add 'raw' to the String reroute-undo exception so value reads hit the reified receiver. Byte-identical to node: String.raw.name==='raw'/.length===1, value-calls (const r=String.raw; r({raw:[...]}, ...)) and tagged-template calls (String.raw`x${10}y`) work. Fixes test262 String/raw/{name,length}; closes the String portion of #4627. Co-authored-by: Ralph Küpper <ralph@skelpo.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.
Problem
Root causes (two)
Date.now/.parse/.UTCtoGlobalGet(0).<name>, for which codegen has no intrinsic handler (unlikeObject.keys/Math.max), so they mis-folded to a number. Added a Date now/parse/UTC exception to the reroute-undo so the read hits the reified Date constructor object (the aliasedconst D=Date; D.nowand computedDate['now']forms already worked). Direct callsDate.now()stay on theExpr::DateNowfast path — unaffected.date_utc_staticcollects all args into itsrestparam, butDate.UTCwas registered with call-arity 7 (7 fixed params before the rest), soDate.UTC(2020,0)(fewer than 7 args) put nothing in the rest array →js_date_utc([])→ NaN. Registered call-arity 0 (all args → rest) while keeping spec.length = 7.Verification
Byte-identical to
node --experimental-strip-types: typeof/name/length, value-calls (const u=Date.UTC; u(2020,0)), and direct calls. Fixes test262Date/{now,parse,UTC}/{name,length},Date/now/15.9.4.4-0-1,15.9.4.4-0-3(8 tests). Date general usage (construction, getters, instanceof) unchanged.