Skip to content

Remove redundant bound-method-field check in GlobalOpLowering - #250

Merged
ASDAlexander77 merged 1 commit into
mainfrom
object-literal-boxing-cleanup
Jul 18, 2026
Merged

Remove redundant bound-method-field check in GlobalOpLowering#250
ASDAlexander77 merged 1 commit into
mainfrom
object-literal-boxing-cleanup

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Summary

  • Third of three staged PRs generalizing the generator-wrapper's boxing (design in docs/object-literal-boxing-design.md) — this is the cleanup pass, but narrower than originally planned.
  • Removes the Fix crash lowering a global const object literal with a mutating method #246 isBoundMethodTupleConstant special case in GlobalOpLowering: confirmed redundant since every boxed literal's initializer region now unconditionally contains a NewOp (the boxing recipe from PR Box object literals with methods/accessors as reference-typed ObjectType #249), which the walk's existing NewOp case already routes onto the global-constructor path.
  • Did NOT remove needsIdentityStorage/boundRefMaterializedCache as the design doc originally planned — investigation showed they're still load-bearing. Whenever a boxed ObjectType literal is unboxed back into a plain tuple to match a declared/inferred type (an annotated const, a function parameter, an interface-cast fallback, a generic intersection/inference result), the resulting tuple's method field is still bound-method-shaped even though the tuple itself is a plain value — that machinery is what makes calling through it work correctly instead of crash. This is documented in the design doc (§5, §6) so it isn't re-attempted without re-deriving the finding.

Test plan

  • Verified the GlobalOpLowering removal is safe via a diagnostic (non-fatal) probe run against every test file in the suite directly through the JIT (not just ctest) — zero hits at that specific call site — before removing it for real.
  • Verified needsIdentityStorage/boundRefMaterializedCache are not dead via the same probe technique: 5+ test files (00interface_object5, 00object_ref_semantics, 00question_question, 00type_aliases_in_generics, 00object_boxed_infra) still exercise Tuple()'s isBoundRef branch.
  • Full suite green: 353/353 JIT + 357/357 AOT (ctest --test-dir <builddir> -C Debug -R "^test-jit-" / "^test-compile-" -j8).

🤖 Generated with Claude Code

The #246 isBoundMethodTupleConstant special case in GlobalOpLowering
decided whether a global's initializer needs the constructor path based on
whether any ConstantOp in it had a bound-method-shaped tuple field. Since
PR #249 boxes every method-bearing object literal, such a literal's
initializer always contains a NewOp (the boxing recipe), which the walk's
existing NewOp case already forces onto the constructor path -- making the
bound-method check redundant. Verified via a diagnostic probe at that call
site across every test file (zero hits) before removing it for real.

Investigated but did NOT remove needsIdentityStorage/boundRefMaterializedCache:
contrary to the original plan (docs/object-literal-boxing-design.md), these
are still load-bearing. Whenever a boxed literal is unboxed back into a
plain tuple to match a declared/inferred type (annotated const, parameter,
interface-cast fallback, generic intersection/inference), the resulting
tuple's method field is still bound-method-shaped even though the tuple
itself is a plain value -- that machinery is what makes calling through it
work correctly instead of crash. Root-caused via site-tagged diagnostic
probes across the full test corpus; documented in the design doc so this
isn't re-attempted without re-deriving the same finding.

Full suite green: 353/353 JIT + 357/357 AOT.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit d9eea66 into main Jul 18, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the object-literal-boxing-cleanup branch July 18, 2026 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant