Skip to content

v1.1: stabilize static-call lowering and SafeRegAlloc guards#131

Merged
egecanakincioglu merged 4 commits into
mainfrom
chore/v1.1-safe-regalloc-bootstrap-cleanup
Jun 8, 2026
Merged

v1.1: stabilize static-call lowering and SafeRegAlloc guards#131
egecanakincioglu merged 4 commits into
mainfrom
chore/v1.1-safe-regalloc-bootstrap-cleanup

Conversation

@egecanakincioglu

Copy link
Copy Markdown
Owner

Summary

Four atomic commits fixing static method call routing and hardening SafeRegAlloc against slot corruption.

Atomic Commits

  1. db89158fix(ir): restore clean IRLower self-host safe-regalloc patches

    • Clean IRLower.arm recovery: loweringError, emitFieldPtr guard, static fields, File/Process cases, generateFileExists
    • Removes overbroad classIdxOf redirect (re-added with varLookup guard in d4ea690)
  2. c785cd7fix(ir): CTOR fallback to static method call for unregistered class names

    • Parser always generates CTOR for IDENT(). When class not registered, fall back to static method call on current class.
    • Fixes foo() generating foo__init instead of T__foo
  3. 4116e64fix(regalloc): reject unknown spill slots and frame offset zero

    • SafeRegAlloc: errorCode field, slotOffsetByName sentinel for unknown names
    • assertKnown/assertWritten set errorCode instead of silent continue
    • IRToX64: safeLoadVal/safeStoreDst set errorCode=3 on offset=0 (prevents frame corruption)
  4. d4ea690fix(ir): restore classIdxOf redirect with varLookup guard for qualified static calls

    • Re-adds classIdxOf redirect in lowerMethodCall with varLookup guard
    • Resolves ClassName.method() to static calls without false-positive variable redirects

Validation

All tests compiled with --target linux --safe-regalloc:

Test Result
static_method_call PASS
receiver2 PASS
spill PASS
lexerloop PASS
bigframe (153 slots, 1232B frame) PASS
streq PASS
hello built-in ELF PASS

Bootstrap: S1 Rust compiler builds current source → 295K dynamic S3.

Known Remaining Blockers

  • Self-hosted S3→S4 requires File.read/File.write/Process.exec implementation
  • S1 compiler used as authorized Stage 1 bootstrap only

Rules

  • No binary patching
  • No temporary IRLower split
  • No old RegAlloc result counted as final validation
  • v1.1

🤖 Generated with Claude Code

…ames

When parser generates CTOR for IDENT(), check if class is registered.
If not and current class context exists, fall back to static method call
on current class (e.g., foo() → T.foo() instead of foo__init).

Fixes foo__init unresolved label for static method calls.
SafeRegAlloc.arm:
- Add errorCode field (0=ok, 1=unknown slot, 2=unwritten slot)
- slotOffsetByName returns safe sentinel -(slotCnt+100)*8 for unknown names
- assertKnown/assertWritten set errorCode instead of only printing

IRToX64.arm:
- safeLoadVal/safeStoreDst set errorCode=3 when offset=0
  (offset 0 maps to saved RBP, corrupting frame chain)
…ed static calls

Parser always generates METHOD_CALL for X.method(), cannot distinguish
class names from object references. The classIdxOf redirect in
lowerMethodCall resolves ClassName.method() to static calls.

Guard: varLookup(obj.strVal) == '' ensures variable names are never
redirected (prevents the original overbroad-redirect bug).
@egecanakincioglu egecanakincioglu merged commit 2b50055 into main Jun 8, 2026
1 check passed
@egecanakincioglu egecanakincioglu deleted the chore/v1.1-safe-regalloc-bootstrap-cleanup branch June 8, 2026 00:24
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