Repository navigation
codegen: a contents proof only for a contents-stable binding (F13) - #14059
Merged
Merged
Conversation
A binding-level proof about an object's contents (an Object, an alias or interface of one, a union or an array whose element claims one) was recorded once at the binding, so a later delete, a store of another type, a write through an alias, a callee, a closure, Object.assign or defineProperty left a stale number proof behind (`delete o.y; o.y * 10` printed a number instead of NaN). collectors::contents_stable_bindings is one module-wide definition of a binding whose object no code can write for its whole life (aliases by union-find; writes, escapes, handed-out non-primitive children, a known callee whose parameter is itself stable; an entry-aliased class also needs a body with no unknown code and no store through a foreign root). The let and inlined-parameter proofs and the guard_blocked choice of guarded parameter clones both read it. Class identities and primitive arrays claim no contents and are not gated.
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
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.
Bug on main
A proof about an object's contents (its property types) is recorded once, at the binding, and kept for the binding's whole life. Any later write that changes a property without touching the binding leaves a stale proof behind, and the read is lowered as a number slot load:
The same holds for a store of another type, a write through an alias (
const t = o; t.y = "s"), a write in a callee or a closure, a store through a held reference,Object.assign,Object.defineProperty, an array alias and a child alias (t = o.a; t.b = ...). The guarded parameter clones had the same gap:guard_blockedusedhas_any_mutation || (body calls && reference-like), so a body that stores through another parameter that aliases this one (f5(z, z)) kept the clone. The new gap fixture differs from node on main; probe p1.ts differed on 13 of its 18 lines.The rule
collectors::contents_stable_bindingsgives one module-wide definition of a binding whose object no code can write for its whole life:const t = o,t = o);return ofrom its own frame do not;g(o.a),const t = o.a, a callee'sreturn p.a) escapes its parent;Both consumers read it: the let proof and the inlined-parameter proofs through
FnCtx::admits_contents_proof(it gates only proofs that claim contents: Object, an alias or interface of one, a union, tuple or array whose element claims one; a class identity and an array of primitives are not gated), and the cloneguard_blockedof a reference-like parameter. A primitive parameter keepshas_any_mutation.Proofs this drops, and what they cost
console.log(o), a callee outside the module) keeps no contents proof.Measured on qb9 against main a119084 (load 13, memcg counters unchanged):
.text/perry_js_text.text)Binaries that grow are only the fixtures main got wrong: the reads that lost their proof now go through
js_dynamic_mul,js_dynamic_negandto_numeric_pair(fixture +2,768 B, F13 +1,595 B, p1 +529 B, all in those symbols and the call sites inmain, f3 and f4).Tests
test-files/test_gap_property_value_contents_stable.ts(19 lines, = node).collectors/contents_stable_tests.rs: 8 unit tests (delete and store, alias, child, call arguments, a callee returning a child, parameter hazards, closure write).stmt/contents_stable_ir_tests.rs: a literal handed to a read-only callee multiplies its slots as a barefmul double; after adeleteit goes throughjs_dynamic_mul.deleteturns the delete/store unit test, the IR test and 3 fixture lines red; ignoring aliases turns the alias unit test and 2 fixture lines red.