]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.regabi] cmd/compile: move stkobj symbol generation to SSA
authorMatthew Dempsky <mdempsky@google.com>
Fri, 15 Jan 2021 08:56:02 +0000 (00:56 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Fri, 15 Jan 2021 16:13:14 +0000 (16:13 +0000)
The code for allocating linksyms and recording that we need runtime
type descriptors is now concurrent-safe, so move it to where those
symbols are actually needed to reduce complexity and risk of failing
to generate all needed symbols in advance.

For #43701.

Change-Id: I759d2508213ac9a4e0b504b51a75fa10dfa37a8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/284076
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Matthew Dempsky <mdempsky@google.com>

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

index a8a0106320e94e7681698c1c113148b8b7f068d6..6e347bf0f119f9ef16865f86f44d4b058e559afc 100644 (file)
@@ -13,7 +13,6 @@ import (
        "cmd/compile/internal/base"
        "cmd/compile/internal/ir"
        "cmd/compile/internal/liveness"
-       "cmd/compile/internal/reflectdata"
        "cmd/compile/internal/ssagen"
        "cmd/compile/internal/typecheck"
        "cmd/compile/internal/types"
@@ -84,21 +83,6 @@ func prepareFunc(fn *ir.Func) {
        walk.Walk(fn)
        ir.CurFunc = nil // enforce no further uses of CurFunc
        typecheck.DeclContext = ir.PEXTERN
-
-       // Make sure type syms are declared for all types that might
-       // be types of stack objects. We need to do this here
-       // because symbols must be allocated before the parallel
-       // phase of the compiler.
-       for _, n := range fn.Dcl {
-               if liveness.ShouldTrack(n) && n.Addrtaken() {
-                       reflectdata.WriteType(n.Type())
-                       // Also make sure we allocate a linker symbol
-                       // for the stack object data, for the same reason.
-                       if fn.LSym.Func().StackObjects == nil {
-                               fn.LSym.Func().StackObjects = base.Ctxt.Lookup(fn.LSym.Name + ".stkobj")
-                       }
-               }
-       }
 }
 
 // compileFunctions compiles all functions in compilequeue.
index fe9a1f617bb00408533e6d41bf0e441fe43af6e5..c48ac22d2a1fb3122aeae1c5e0ec7d6f8ec932a5 100644 (file)
@@ -6494,7 +6494,8 @@ func emitStackObjects(e *ssafn, pp *objw.Progs) {
 
        // Populate the stack object data.
        // Format must match runtime/stack.go:stackObjectRecord.
-       x := e.curfn.LSym.Func().StackObjects
+       x := base.Ctxt.Lookup(e.curfn.LSym.Name + ".stkobj")
+       e.curfn.LSym.Func().StackObjects = x
        off := 0
        off = objw.Uintptr(x, off, uint64(len(vars)))
        for _, v := range vars {
@@ -6502,10 +6503,7 @@ func emitStackObjects(e *ssafn, pp *objw.Progs) {
                // in which case the offset is relative to argp.
                // Locals have a negative Xoffset, in which case the offset is relative to varp.
                off = objw.Uintptr(x, off, uint64(v.FrameOffset()))
-               if !types.TypeSym(v.Type()).Siggen() {
-                       e.Fatalf(v.Pos(), "stack object's type symbol not generated for type %s", v.Type())
-               }
-               off = objw.SymPtr(x, off, reflectdata.WriteType(v.Type()), 0)
+               off = objw.SymPtr(x, off, reflectdata.TypeLinksym(v.Type()), 0)
        }
 
        // Emit a funcdata pointing at the stack object data.