You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Browse filesBrowse the repository at this point in the historyBrowse files
Ralph Küpper
committed
perf(codegen): reach user-written constructors with the dead-field-init elision (#7512)
#7469's `ctor_prologue_param_assigned_fields` matched the constructor prologue
on `Expr::PropertySet`. No user syntax lowers to that node — `lower_expr`'s
assignment arm turns every source `obj.prop = value` into `Expr::PutValueSet`,
and `PropertySet` is emitted only by synthesized HIR (the anon-shape
object-literal ctor). The elision therefore fired on object literals and was
structurally unreachable for the declared class its changelog claimed to cover.
That is the #7512 anomaly: `new Node(v, w)` with two declared `number` fields
emitted FOUR field-store IC diamonds per construction against the equivalent
`{v, w}` literal's two — two of them storing a compile-time-constant
`undefined` that the next two statements overwrite. Both dead diamonds took the
cold arm on every construction, not occasionally: a fresh instance has no
typed-shape descriptor yet (`js_gc_init_typed_shape_layout` runs after the ctor
returns), so a `requires_raw_f64` set-guard cannot pass and
`js_class_field_set_fallback` — record-fallback plus a linear-key-search
by-name store — ran twice per object.
One recognizer, `prologue_assigned_field`, now accepts both spellings of
`this.<field> = <plain parameter>`. The proof obligation is unchanged and is
about the operands rather than the store opcode: `This` and `LocalGet` of a
plain parameter cannot throw, allocate, or observe `this`. `PutValueSet`
additionally requires a constant string key and a `This` receiver.
Emitted-IR census, same workload and compiler: the class constructor drops from
314 to 157 IR lines and from 4 store diamonds to 2, matching the literal's 2;
the literal's constructor is byte-identical to before.
Claude-Session: https://claude.ai/code/session_019EHcmXKArA7m42SihYCcgH
0 commit comments