fix(runtime,hir): built-ins/Function test262 parity (v2) — 67.4% → 93.7%#4868
Merged
Conversation
added 4 commits
June 10, 2026 05:42
- const-prop for Function(...)/new Function(...): single-assignment module vars, toString-bearing object literals (incl counters + poison side effects), Object() wrappers, throw-propagation in ToString order, spec-assembled 'function anonymous(...)' source + name, strict-mode early errors, stray-private-name SyntaxError, Function.call/apply folding, AsyncFunction/GeneratorFunction via fn-literal .constructor - OrdinaryCallBindThis: strict-function registry (codegen-emitted); call/apply/bind box primitive thisArg once for sloppy user callees - reified call/apply/bind: spec .length, non-constructor - proxy-of-callable: typeof 'function', toString/ToString/ToPrimitive NativeFunction form (fixes '' + proxy segfault) - Function.prototype: callable (returns undefined), [object Function], new Function.prototype throws, expando proto-walk from closures - bind: brand-check TypeError, length via own-prop ToIntegerOrInfinity (NaN/Infinity/>int32), name/length attrs non-enumerable - class accessors reflect in getOwnPropertyDescriptor (proto + static); class-ref toString/String/concat → native form, not class id - fn.length()/fn.name() calls throw; caller/arguments writes poison all closures; fn.apply(this, arguments) raw-pointer argArray - module top-level 'this' = fresh CJS-style exports object (matches the node oracle); unresolved ident reads consult globalThis before ReferenceError
…rimitive + js_is_symbol floor, apply(this,arguments) raw argArray + arguments-object unpack, arg-expression const-eval, fn-decl .constructor kinds, PutValue caller poison, class-ref stringification
…imitive + js_is_symbol floor, apply(this,arguments) raw argArray + arguments-object unpack, arg-expression const-eval (p+","+p), fn-decl .constructor kinds, PutValue caller poison, class-ref stringification
- js_proxy_get: call/apply/bind value reads on callable-wrapping proxies
reify with the PROXY as receiver so later invocation routes the apply
trap (built-ins/Proxy/apply/*); fn-proto expando fallback restricted to
user expandos only (numeric keys excluded)
- Object.seal(TypedArray): skip mark_all_keys (TA headers have no
keys_array — garbage deref segfaulted on Linux); is_registered_set
checks the registry before dereferencing the GC header (same latent
Linux crash class)
- hasOwnProperty('prototype') is predicate-only (materializing locked the
slot before a later defineProperty — TypedArrayConstructors custom-proto)
- proxy.rs split (reflect_misc.rs) for the 2000-line gate; #[used]
keepalives for the new generated-code-only runtime entry points
39e6fa5 to
1b78840
Compare
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.
Summary
built-ins/Function test262: 308 → 428 / 457 (67.4% → 93.7%, +120 tests), judged against the node v26 oracle via
scripts/test262_subset.pyon the 48-core box.Zero regressions: broad shard 0/12 over
built-ins language(2645 judged) — base 2358 pass (89.1%) → branch 2388 pass (90.3%), 30 tests fixed outside Function, 0 regressions (failure-set diff, suspicious entries re-verified isolated). Unit tests green: perry-hir, perry-codegen, perry-runtime (1006 passed,RUST_TEST_THREADS=1).Root causes fixed
1.
new Function/Function(...)const-prop (fn_ctor_env.rs, new) — beyond direct literals, arguments now resolve through: single-assignment module vars (shadow-aware whole-module write scan — a harnessfor (var i...)inside a function no longer disqualifies a module-level counter), object literals with constanttoStringbodies (incl."arg" + (++i)counters, leadingp = 1side effects replayed at runtime, throw-propagation in spec ToString order),Object(<lit>)wrappers, arg-level constant expressions (p + "," + p),Function.call/apply(thisArg, ...), andAsyncFunction/GeneratorFunction/AsyncGeneratorFunctionobtained via<fn literal>.constructor(var- or decl-declared). The fold assembles the exact spec sourcefunction anonymous(P\n) {\nbody\n}(comment-in-params safe), registers it fortoString, names the functionanonymous, and raises strict-mode early errors (dup/eval/argumentsparams under a"use strict"body) plus stray-private-name SyntaxErrors. This converted all 20 compile-refusals into spec behavior.2. Module top-level
this(Expr::ModuleTopThis) — the oracle runs assembled cases as CJS where top-levelthisismodule.exports, notglobalThis. Top-levelthisnow lowers to a fresh per-thread exports-like object. Single biggest win (+32 in-dir, plusprop-desc.js-style fixes across Object/String/Array/NativeErrors in the broad shard).3. OrdinaryCallBindThis — codegen emits
js_register_closure_strict_functionper strict function (mirrors the arrow registry);call/apply/bindbox a primitivethisArgonce for sloppy user callees (writes throughthispersist:Function("this.touched=true;return this").apply(1)), while strict callees observe the raw primitive (fun.call("")strict tests).4. Proxy-of-callable —
typeofis"function"(registry check before the heap floor — proxy ids are small pointers);Function.prototype.toString,String(), concat and ToPrimitive yield the NativeFunction form (fixes a"" + proxysegfault);js_proxy_getreifiescall/apply/bindvalue reads with the proxy as receiver so invocation routes the apply trap.5. Function.prototype & reflection —
Function.prototypeis callable (returns undefined),[object Function],new Function.prototypethrows; reifiedcall/apply/bindcarry spec.length(1/2/1) and are non-constructors (new (f.apply)throws); user expandos onFunction.prototype(data + accessors) resolve through any closure; class accessors reflect ingetOwnPropertyDescriptor(prototype + static, via vtable→callable trampolines); class refs stringify asfunction C() { [native code] }instead of their numeric id.6. bind — brand-check TypeError on non-callables;
.lengthhonors an ownlengthoverride with ToIntegerOrInfinity (NaN→0, Infinity, >int32); boundname/lengthattrs non-enumerable.7. Poison pills & misc —
caller/argumentsget and set throw on every closure (both set paths incl. PutValue);fn.length()throws (non-callable doubles no longer reinterpreted as raw pointers injs_native_call_value);fn.apply(this, arguments)works (raw-pointer argArray + arguments-object unpacking; CreateListFromArrayLike TypeError for primitives); unresolved identifier reads consultglobalThisbefore the ReferenceError (runtime-created globals).8. Latent Linux crash fixes (pre-existing, exposed during verification) —
js_is_symboldereferenced registry-handle "pointers" below the heap floor;is_registered_setprobed the GC header before the registry;Object.seal(TypedArray)readkeys_arrayoff a TA header. All three segfaulted on Linux only (mimalloc on macOS retains pages). Also#[used]keepalives for the new generated-code-only entry points, andproxy.rssplit (proxy/reflect_misc.rs) for the 2000-line gate.Remaining in-dir failures (29)
7×
15.3.5.4_2-*gsneed V8's real sloppy.callertracking (node returns the live caller); 3× bound-constructnew.target;Function.prototype.bind.apply(Date, …)construct; 2×internals/Construct(revoked-proxy ctor, derived-return-val);S15.3.4_A4(Object.prototype inheritance-for-reads gap, #4789-deferred); abrupt array-like getters inapply; toString source-exactness for unicode escapes / computed method names;Function.call(this, "return planet;")matching node's global-scope semantics (known deviation, traded for 2 wins).Validation
built-ins/Function: 457 judged, 428 pass / 29 runtime-fail / 0 compile-fail / 0 diffbuilt-ins language: 2645 judged, base 2358 → branch 2388, 0 regressionscargo test(hir, codegen, runtime),cargo fmt --check,scripts/check_file_size.shall green