mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: cleanup funccompile and compile
Bring these functions next to each other, and clean them up a little bit. Also, change emitptrargsmap to take Curfn as a parameter instead of a global. Passes toolstash-check. Change-Id: Ib9c94fda3b2cb6f0dcec1585622b33b4f311b5e9 Reviewed-on: https://go-review.googlesource.com/99075 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
b75e8a2a3b
commit
aa00ca12fe
2 changed files with 39 additions and 39 deletions
|
|
@ -27,32 +27,32 @@ var (
|
|||
compilequeue []*Node // functions waiting to be compiled
|
||||
)
|
||||
|
||||
func emitptrargsmap() {
|
||||
if Curfn.funcname() == "_" {
|
||||
func emitptrargsmap(fn *Node) {
|
||||
if fn.funcname() == "_" {
|
||||
return
|
||||
}
|
||||
sym := lookup(fmt.Sprintf("%s.args_stackmap", Curfn.funcname()))
|
||||
sym := lookup(fmt.Sprintf("%s.args_stackmap", fn.funcname()))
|
||||
lsym := sym.Linksym()
|
||||
|
||||
nptr := int(Curfn.Type.ArgWidth() / int64(Widthptr))
|
||||
nptr := int(fn.Type.ArgWidth() / int64(Widthptr))
|
||||
bv := bvalloc(int32(nptr) * 2)
|
||||
nbitmap := 1
|
||||
if Curfn.Type.NumResults() > 0 {
|
||||
if fn.Type.NumResults() > 0 {
|
||||
nbitmap = 2
|
||||
}
|
||||
off := duint32(lsym, 0, uint32(nbitmap))
|
||||
off = duint32(lsym, off, uint32(bv.n))
|
||||
|
||||
if Curfn.IsMethod() {
|
||||
onebitwalktype1(Curfn.Type.Recvs(), 0, bv)
|
||||
if fn.IsMethod() {
|
||||
onebitwalktype1(fn.Type.Recvs(), 0, bv)
|
||||
}
|
||||
if Curfn.Type.NumParams() > 0 {
|
||||
onebitwalktype1(Curfn.Type.Params(), 0, bv)
|
||||
if fn.Type.NumParams() > 0 {
|
||||
onebitwalktype1(fn.Type.Params(), 0, bv)
|
||||
}
|
||||
off = dbvec(lsym, off, bv)
|
||||
|
||||
if Curfn.Type.NumResults() > 0 {
|
||||
onebitwalktype1(Curfn.Type.Results(), 0, bv)
|
||||
if fn.Type.NumResults() > 0 {
|
||||
onebitwalktype1(fn.Type.Results(), 0, bv)
|
||||
off = dbvec(lsym, off, bv)
|
||||
}
|
||||
|
||||
|
|
@ -183,15 +183,38 @@ func (s *ssafn) AllocFrame(f *ssa.Func) {
|
|||
s.stkptrsize = Rnd(s.stkptrsize, int64(Widthreg))
|
||||
}
|
||||
|
||||
func compile(fn *Node) {
|
||||
Curfn = fn
|
||||
dowidth(fn.Type)
|
||||
func funccompile(fn *Node) {
|
||||
if Curfn != nil {
|
||||
Fatalf("funccompile %v inside %v", fn.Func.Nname.Sym, Curfn.Func.Nname.Sym)
|
||||
}
|
||||
|
||||
if fn.Nbody.Len() == 0 {
|
||||
emitptrargsmap()
|
||||
if fn.Type == nil {
|
||||
if nerrors == 0 {
|
||||
Fatalf("funccompile missing type")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// assign parameter offsets
|
||||
dowidth(fn.Type)
|
||||
|
||||
if fn.Nbody.Len() == 0 {
|
||||
emitptrargsmap(fn)
|
||||
return
|
||||
}
|
||||
|
||||
dclcontext = PAUTO
|
||||
funcdepth = fn.Func.Depth + 1
|
||||
Curfn = fn
|
||||
|
||||
compile(fn)
|
||||
|
||||
Curfn = nil
|
||||
funcdepth = 0
|
||||
dclcontext = PEXTERN
|
||||
}
|
||||
|
||||
func compile(fn *Node) {
|
||||
saveerrors()
|
||||
|
||||
order(fn)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue