mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: eliminate Prog-related globals
Introduce a new type, gc.Progs, to manage generation of Progs for a function. Use it to replace globals pc and pcloc. Passes toolstash-check -all. Updates #15756 Change-Id: I2206998d7c58fe2a76b620904909f2e1cec8a57d Reviewed-on: https://go-review.googlesource.com/38418 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
27bc723b51
commit
c3a50ad3c7
13 changed files with 285 additions and 262 deletions
|
|
@ -8,7 +8,6 @@ import (
|
|||
"cmd/compile/internal/ssa"
|
||||
"cmd/internal/dwarf"
|
||||
"cmd/internal/obj"
|
||||
"cmd/internal/src"
|
||||
"cmd/internal/sys"
|
||||
"fmt"
|
||||
"sort"
|
||||
|
|
@ -18,10 +17,10 @@ import (
|
|||
|
||||
var makefuncdatasym_nsym int
|
||||
|
||||
func makefuncdatasym(nameprefix string, funcdatakind int64) *Sym {
|
||||
func makefuncdatasym(pp *Progs, nameprefix string, funcdatakind int64) *Sym {
|
||||
sym := lookupN(nameprefix, makefuncdatasym_nsym)
|
||||
makefuncdatasym_nsym++
|
||||
p := Prog(obj.AFUNCDATA)
|
||||
p := pp.Prog(obj.AFUNCDATA)
|
||||
Addrconst(&p.From, funcdatakind)
|
||||
p.To.Type = obj.TYPE_MEM
|
||||
p.To.Name = obj.NAME_EXTERN
|
||||
|
|
@ -269,10 +268,6 @@ func compile(fn *Node) {
|
|||
assertI2I2 = Sysfunc("assertI2I2")
|
||||
}
|
||||
|
||||
defer func(lno src.XPos) {
|
||||
lineno = lno
|
||||
}(setlineno(fn))
|
||||
|
||||
Curfn = fn
|
||||
dowidth(fn.Type)
|
||||
|
||||
|
|
@ -309,58 +304,10 @@ func compile(fn *Node) {
|
|||
return
|
||||
}
|
||||
|
||||
plist := new(obj.Plist)
|
||||
pc = Ctxt.NewProg()
|
||||
Clearp(pc)
|
||||
plist.Firstpc = pc
|
||||
|
||||
setlineno(fn)
|
||||
|
||||
ptxt := Prog(obj.ATEXT)
|
||||
if nam := fn.Func.Nname; !isblank(nam) {
|
||||
ptxt.From.Type = obj.TYPE_MEM
|
||||
ptxt.From.Name = obj.NAME_EXTERN
|
||||
ptxt.From.Sym = Linksym(nam.Sym)
|
||||
if fn.Func.Pragma&Systemstack != 0 {
|
||||
ptxt.From.Sym.Set(obj.AttrCFunc, true)
|
||||
}
|
||||
}
|
||||
|
||||
ptxt.From3 = new(obj.Addr)
|
||||
if fn.Func.Dupok() {
|
||||
ptxt.From3.Offset |= obj.DUPOK
|
||||
}
|
||||
if fn.Func.Wrapper() {
|
||||
ptxt.From3.Offset |= obj.WRAPPER
|
||||
}
|
||||
if fn.Func.NoFramePointer() {
|
||||
ptxt.From3.Offset |= obj.NOFRAME
|
||||
}
|
||||
if fn.Func.Needctxt() {
|
||||
ptxt.From3.Offset |= obj.NEEDCTXT
|
||||
}
|
||||
if fn.Func.Pragma&Nosplit != 0 {
|
||||
ptxt.From3.Offset |= obj.NOSPLIT
|
||||
}
|
||||
if fn.Func.ReflectMethod() {
|
||||
ptxt.From3.Offset |= obj.REFLECTMETHOD
|
||||
}
|
||||
|
||||
// Clumsy but important.
|
||||
// See test/recover.go for test cases and src/reflect/value.go
|
||||
// for the actual functions being considered.
|
||||
if myimportpath == "reflect" {
|
||||
if fn.Func.Nname.Sym.Name == "callReflect" || fn.Func.Nname.Sym.Name == "callMethod" {
|
||||
ptxt.From3.Offset |= obj.WRAPPER
|
||||
}
|
||||
}
|
||||
|
||||
genssa(ssafn, ptxt)
|
||||
|
||||
fieldtrack(ptxt.From.Sym, fn.Func.FieldTrack)
|
||||
|
||||
obj.Flushplist(Ctxt, plist) // convert from Prog list to machine code
|
||||
ptxt = nil // nil to prevent misuse; Prog may have been freed by Flushplist
|
||||
pp := newProgs(fn)
|
||||
genssa(ssafn, pp)
|
||||
fieldtrack(pp.Text.From.Sym, fn.Func.FieldTrack)
|
||||
pp.Flush()
|
||||
}
|
||||
|
||||
func debuginfo(fnsym *obj.LSym) []*dwarf.Var {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue