mirror of
https://github.com/golang/go
synced 2024-11-23 07:10:05 -07:00
[dev.regabi] cmd/compile: move stkobj symbol generation to SSA
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>
This commit is contained in:
parent
ab523fc510
commit
14537e6e54
@ -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.
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user