]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: enable late expansion for closure calls
authorDavid Chase <drchase@google.com>
Mon, 10 Aug 2020 22:30:11 +0000 (18:30 -0400)
committerDavid Chase <drchase@google.com>
Thu, 1 Oct 2020 17:48:42 +0000 (17:48 +0000)
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 <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/compile/internal/gc/ssa.go

index e01ebd6e8957606f4fd3e58b3c38f6d20cdcfdd0..7e377f9b84455c13f2ffd22e661efde17d0ae61a 100644 (file)
@@ -4386,6 +4386,9 @@ func (s *state) call(n *Node, k callKind, returnResultAddr bool) *ssa.Value {
                        // Deferred nil function needs to panic when the function is invoked,
                        // not the point of defer statement.
                        s.maybeNilCheckClosure(closure, k)
+                       if k == callNormal && ssa.LateCallExpansionEnabledWithin(s.f) {
+                               testLateExpansion = true
+                       }
                }
        case OCALLMETH:
                if fn.Op != ODOTMETH {
@@ -4556,7 +4559,13 @@ func (s *state) call(n *Node, k callKind, returnResultAddr bool) *ssa.Value {
                        // critical that we not clobber any arguments already
                        // stored onto the stack.
                        codeptr = s.rawLoad(types.Types[TUINTPTR], closure)
-                       call = s.newValue3A(ssa.OpClosureCall, types.TypeMem, ssa.ClosureAuxCall(ACArgs, ACResults), codeptr, closure, s.mem())
+                       if testLateExpansion {
+                               aux := ssa.ClosureAuxCall(ACArgs, ACResults)
+                               call = s.newValue2A(ssa.OpClosureLECall, aux.LateExpansionResultType(), aux, codeptr, closure)
+                               call.AddArgs(callArgs...)
+                       } else {
+                               call = s.newValue3A(ssa.OpClosureCall, types.TypeMem, ssa.ClosureAuxCall(ACArgs, ACResults), codeptr, closure, s.mem())
+                       }
                case codeptr != nil:
                        if testLateExpansion {
                                aux := ssa.InterfaceAuxCall(ACArgs, ACResults)