cl,ssa,runtime: stack-object finalizer liveness#2036
Draft
cpunion wants to merge 2 commits into
Draft
Conversation
This was referenced Jul 6, 2026
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
cpunion
force-pushed
the
codex/stage5-finalizer-liveness
branch
2 times, most recently
from
July 8, 2026 07:04
831cf7f to
05dc73a
Compare
cpunion
force-pushed
the
codex/stage5-finalizer-liveness
branch
2 times, most recently
from
July 9, 2026 05:31
d877a90 to
4a23ec7
Compare
8 tasks
20 tasks
cpunion
force-pushed
the
codex/stage5-finalizer-liveness
branch
from
July 17, 2026 12:28
4a23ec7 to
4d535b8
Compare
cpunion
commented
Jul 21, 2026
cpunion
left a comment
Collaborator
Author
There was a problem hiding this comment.
Need full explaination in PR body about how this PR works
| *cur = 0; | ||
| } | ||
| } | ||
| } |
Collaborator
Author
There was a problem hiding this comment.
Is this funcion safe?
|
|
||
| func SetFinalizer(obj any, finalizer any) { | ||
| objFace := (*eface)(unsafe.Pointer(&obj)) | ||
| objFace := *(*eface)(unsafe.Pointer(&obj)) |
Collaborator
Author
There was a problem hiding this comment.
Why deref and get addr later? How about remove deref here?
| return plans | ||
| } | ||
|
|
||
| func (p *context) compileLateValue(b llssa.Builder, v ssa.Value) llssa.Expr { |
Collaborator
Author
There was a problem hiding this comment.
What's the difference between compileLateValue and compileValue?
cpunion
marked this pull request as draft
July 21, 2026 01:47
Re-expresses xgo-dev#1906 on the xgo-dev#2023 base (its remaining ~11k diff lines were the pre-xgo-dev#2012 funcinfo draft, superseded by the stage-5 chain): - cl gains a liveness analysis for stack-allocated objects: allocas whose last use has passed are cleared so bdwgc's conservative stack scan stops keeping dead stack objects (and what they point to) alive; pointer registers are clobbered around the trigger points (llgo_clobber_pointer_regs) and dead stack slots holding the target are zeroed (llgo_clear_stack_ptr, pthread stack-bounds walk). - runtime.SetFinalizer paths (mfinal, runtime_gc, bdwgc binding) hook the cleared-slot machinery so finalizers for dead stack objects run. - xfail: retire deferfin.go, stackobj.go, stackobj3.go, validated on darwin/arm64 go1.24 + go1.26 (stackobj2 already passed). Carries the xgo-dev#2035 shared-GOCACHE commit temporarily (same patch-id, auto-dedups when the chain rebases after xgo-dev#2035 merges). Supersedes xgo-dev#1906.
With the shared go-build cache the four heavy test packages (cl, ssa, internal/cabi, test/go) no longer stagger naturally on cold caches; their compile phases overlap fully, and the burst of concurrent clang/lld children has been killing ubuntu runners mid-run (three consecutive 'runner received a shutdown signal' deaths on this branch, each ~8 minutes into the heavy-package phase) and showing up on mac as go-list WaitDelay expirations. -p 2 caps the concurrent package count; wall time is dominated by the cl package either way.
cpunion
force-pushed
the
codex/stage5-finalizer-liveness
branch
from
July 23, 2026 09:32
4d535b8 to
9cc8498
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.
Re-expresses the surviving value of #1906; its remaining ~11k diff lines were the pre-#2012 funcinfo draft, superseded by the stage-5 chain.
What changes
clgains a liveness analysis over stack allocations; once a stack object's last use has passed, its slot is cleared so bdwgc's conservative stack scan stops keeping the dead object (and everything it points to) alive. Around the trigger points, pointer registers are clobbered (llgo_clobber_pointer_regs) and dead stack slots still holding the target are zeroed (llgo_clear_stack_ptr, pthread stack-bounds walk on darwin/linux).runtime.SetFinalizerconformance: mfinal/runtime_gc/bdwgc-binding hook the cleared-slot machinery, so finalizers for dead stack objects actually run (gc semantics).clliveness unit suite +test/gofinalizer regressions.goroot conformance
Retired xfails, validated darwin/arm64 (go1.24 + go1.26) and linux/arm64 (go1.24):
deferfin.go,stackobj.go,stackobj3.go(stackobj2.goalready passed and stays green).Validation
ssa(128s) andcl(389s) suites green (no golden drift — the analysis only clears dead slots, existing goldens unchanged);test/goFinalizer set green underllgo test.The existing multi-package coverage command is capped at
-p 2to avoid overlapping the heaviest compiler test packages. The current main test matrix and the separatetest/gocoverage command are otherwise unchanged.Supersedes #1906.
🤖 Generated with Claude Code