Skip to content

Commit 14537e6

Browse files
committed
[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>
1 parent ab523fc commit 14537e6

File tree

2 files changed

+3
-21
lines changed

2 files changed

+3
-21
lines changed

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"cmd/compile/internal/base"
1414
"cmd/compile/internal/ir"
1515
"cmd/compile/internal/liveness"
16-
"cmd/compile/internal/reflectdata"
1716
"cmd/compile/internal/ssagen"
1817
"cmd/compile/internal/typecheck"
1918
"cmd/compile/internal/types"
@@ -84,21 +83,6 @@ func prepareFunc(fn *ir.Func) {
8483
walk.Walk(fn)
8584
ir.CurFunc = nil // enforce no further uses of CurFunc
8685
typecheck.DeclContext = ir.PEXTERN
87-
88-
// Make sure type syms are declared for all types that might
89-
// be types of stack objects. We need to do this here
90-
// because symbols must be allocated before the parallel
91-
// phase of the compiler.
92-
for _, n := range fn.Dcl {
93-
if liveness.ShouldTrack(n) && n.Addrtaken() {
94-
reflectdata.WriteType(n.Type())
95-
// Also make sure we allocate a linker symbol
96-
// for the stack object data, for the same reason.
97-
if fn.LSym.Func().StackObjects == nil {
98-
fn.LSym.Func().StackObjects = base.Ctxt.Lookup(fn.LSym.Name + ".stkobj")
99-
}
100-
}
101-
}
10286
}
10387

10488
// compileFunctions compiles all functions in compilequeue.

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6494,18 +6494,16 @@ func emitStackObjects(e *ssafn, pp *objw.Progs) {
64946494

64956495
// Populate the stack object data.
64966496
// Format must match runtime/stack.go:stackObjectRecord.
6497-
x := e.curfn.LSym.Func().StackObjects
6497+
x := base.Ctxt.Lookup(e.curfn.LSym.Name + ".stkobj")
6498+
e.curfn.LSym.Func().StackObjects = x
64986499
off := 0
64996500
off = objw.Uintptr(x, off, uint64(len(vars)))
65006501
for _, v := range vars {
65016502
// Note: arguments and return values have non-negative Xoffset,
65026503
// in which case the offset is relative to argp.
65036504
// Locals have a negative Xoffset, in which case the offset is relative to varp.
65046505
off = objw.Uintptr(x, off, uint64(v.FrameOffset()))
6505-
if !types.TypeSym(v.Type()).Siggen() {
6506-
e.Fatalf(v.Pos(), "stack object's type symbol not generated for type %s", v.Type())
6507-
}
6508-
off = objw.SymPtr(x, off, reflectdata.WriteType(v.Type()), 0)
6506+
off = objw.SymPtr(x, off, reflectdata.TypeLinksym(v.Type()), 0)
65096507
}
65106508

65116509
// Emit a funcdata pointing at the stack object data.

0 commit comments

Comments
 (0)