1
0
mirror of https://github.com/golang/go synced 2024-11-06 06:36:20 -07:00

[dev.link] cmd/internal/goobj2: move NoSplit to symbol flag

Move NoSplit flag from FuncInfo to symbol flag, so this can be
accessed easily without reading the FuncInfo.

The CFunc flag is never used. Remove.

Change-Id: I8bf4fcb2f209434bb90ccc4987a4c3f28f003323
Reviewed-on: https://go-review.googlesource.com/c/go/+/220058
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
Cherry Zhang 2020-02-17 01:27:11 -05:00
parent c4ccd08a25
commit 0f99ab4e86
5 changed files with 13 additions and 20 deletions

View File

@ -149,7 +149,7 @@ func (r *objReader) readNew() {
f := &Func{
Args: int64(info.Args),
Frame: int64(info.Locals),
NoSplit: info.NoSplit != 0,
NoSplit: osym.NoSplit(),
Leaf: osym.Leaf(),
TopFrame: osym.TopFrame(),
PCSP: Data{int64(pcdataBase + info.Pcsp), int64(info.Pcfile - info.Pcsp)},

View File

@ -14,8 +14,6 @@ import (
//
// TODO: make each pcdata a separate symbol?
type FuncInfo struct {
NoSplit uint8
Args uint32
Locals uint32
@ -32,8 +30,6 @@ type FuncInfo struct {
}
func (a *FuncInfo) Write(w *bytes.Buffer) {
w.WriteByte(a.NoSplit)
var b [4]byte
writeUint32 := func(x uint32) {
binary.LittleEndian.PutUint32(b[:], x)
@ -68,9 +64,6 @@ func (a *FuncInfo) Write(w *bytes.Buffer) {
}
func (a *FuncInfo) Read(b []byte) {
a.NoSplit = b[0]
b = b[1:]
readUint32 := func() uint32 {
x := binary.LittleEndian.Uint32(b)
b = b[4:]

View File

@ -203,7 +203,7 @@ const (
SymFlagLocal
SymFlagTypelink
SymFlagLeaf
SymFlagCFunc
SymFlagNoSplit
SymFlagReflectMethod
SymFlagGoType
SymFlagTopFrame
@ -247,7 +247,7 @@ func (s *Sym) Dupok() bool { return s.Flag&SymFlagDupok != 0 }
func (s *Sym) Local() bool { return s.Flag&SymFlagLocal != 0 }
func (s *Sym) Typelink() bool { return s.Flag&SymFlagTypelink != 0 }
func (s *Sym) Leaf() bool { return s.Flag&SymFlagLeaf != 0 }
func (s *Sym) CFunc() bool { return s.Flag&SymFlagCFunc != 0 }
func (s *Sym) NoSplit() bool { return s.Flag&SymFlagNoSplit != 0 }
func (s *Sym) ReflectMethod() bool { return s.Flag&SymFlagReflectMethod != 0 }
func (s *Sym) IsGoType() bool { return s.Flag&SymFlagGoType != 0 }
func (s *Sym) TopFrame() bool { return s.Flag&SymFlagTopFrame != 0 }

View File

@ -229,8 +229,8 @@ func (w *writer) Sym(s *LSym) {
if s.Leaf() {
flag |= goobj2.SymFlagLeaf
}
if s.CFunc() {
flag |= goobj2.SymFlagCFunc
if s.NoSplit() {
flag |= goobj2.SymFlagNoSplit
}
if s.ReflectMethod() {
flag |= goobj2.SymFlagReflectMethod
@ -366,14 +366,9 @@ func genFuncInfoSyms(ctxt *Link) {
if s.Func == nil {
continue
}
nosplit := uint8(0)
if s.NoSplit() {
nosplit = 1
}
o := goobj2.FuncInfo{
NoSplit: nosplit,
Args: uint32(s.Func.Args),
Locals: uint32(s.Func.Locals),
Args: uint32(s.Func.Args),
Locals: uint32(s.Func.Locals),
}
pc := &s.Func.Pcln
o.Pcsp = pcdataoff

View File

@ -940,6 +940,11 @@ func (l *Loader) IsReflectMethod(i Sym) bool {
return l.SymAttr(i)&goobj2.SymFlagReflectMethod != 0
}
// Returns whether the i-th symbol is nosplit.
func (l *Loader) IsNoSplit(i Sym) bool {
return l.SymAttr(i)&goobj2.SymFlagNoSplit != 0
}
// Returns whether this is a Go type symbol.
func (l *Loader) IsGoType(i Sym) bool {
return l.SymAttr(i)&goobj2.SymFlagGoType != 0
@ -2189,7 +2194,7 @@ func loadObjFull(l *Loader, r *oReader) {
info := goobj2.FuncInfo{}
info.Read(b)
if info.NoSplit != 0 {
if osym.NoSplit() {
s.Attr |= sym.AttrNoSplit
}
if osym.ReflectMethod() {