Skip to content

Commit 8c84dcf

Browse files
committed
cmd/compile: enable late expansion for closure calls
This works for "normal" calls. Defer func() and Go func() still pending. RT calls still pending. Change-Id: I29cbdad8c877d12c08bbf7f3f0696611de877da9 Reviewed-on: https://go-review.googlesource.com/c/go/+/247771 Trust: David Chase <[email protected]> Run-TryBot: David Chase <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Cherry Zhang <[email protected]>
1 parent adef4de commit 8c84dcf

File tree

1 file changed

+10
-1
lines changed
  • src/cmd/compile/internal/gc

1 file changed

+10
-1
lines changed

src/cmd/compile/internal/gc/ssa.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4386,6 +4386,9 @@ func (s *state) call(n *Node, k callKind, returnResultAddr bool) *ssa.Value {
43864386
// Deferred nil function needs to panic when the function is invoked,
43874387
// not the point of defer statement.
43884388
s.maybeNilCheckClosure(closure, k)
4389+
if k == callNormal && ssa.LateCallExpansionEnabledWithin(s.f) {
4390+
testLateExpansion = true
4391+
}
43894392
}
43904393
case OCALLMETH:
43914394
if fn.Op != ODOTMETH {
@@ -4556,7 +4559,13 @@ func (s *state) call(n *Node, k callKind, returnResultAddr bool) *ssa.Value {
45564559
// critical that we not clobber any arguments already
45574560
// stored onto the stack.
45584561
codeptr = s.rawLoad(types.Types[TUINTPTR], closure)
4559-
call = s.newValue3A(ssa.OpClosureCall, types.TypeMem, ssa.ClosureAuxCall(ACArgs, ACResults), codeptr, closure, s.mem())
4562+
if testLateExpansion {
4563+
aux := ssa.ClosureAuxCall(ACArgs, ACResults)
4564+
call = s.newValue2A(ssa.OpClosureLECall, aux.LateExpansionResultType(), aux, codeptr, closure)
4565+
call.AddArgs(callArgs...)
4566+
} else {
4567+
call = s.newValue3A(ssa.OpClosureCall, types.TypeMem, ssa.ClosureAuxCall(ACArgs, ACResults), codeptr, closure, s.mem())
4568+
}
45604569
case codeptr != nil:
45614570
if testLateExpansion {
45624571
aux := ssa.InterfaceAuxCall(ACArgs, ACResults)

0 commit comments

Comments
 (0)