mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: optimize abi.Type.GCData loads
This fires in just one place; stkframe.go's stkobjinit. But, it does make the struct literal entirely constants. Change-Id: Ice76cb3cddd97adee011fdaab40597839da2e89f Reviewed-on: https://go-review.googlesource.com/c/go/+/701300 Reviewed-by: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Mark Freeman <markfreeman@google.com> Auto-Submit: Michael Pratt <mpratt@google.com>
This commit is contained in:
parent
dc960d0bfe
commit
f1fd13016a
3 changed files with 10 additions and 4 deletions
|
|
@ -1493,7 +1493,7 @@ func (lv *Liveness) emitStackObjects() *obj.LSym {
|
||||||
if sz != int64(int32(sz)) {
|
if sz != int64(int32(sz)) {
|
||||||
base.Fatalf("stack object too big: %v of type %v, size %d", v, t, sz)
|
base.Fatalf("stack object too big: %v of type %v, size %d", v, t, sz)
|
||||||
}
|
}
|
||||||
lsym, ptrBytes := reflectdata.GCSym(t)
|
lsym, ptrBytes := reflectdata.GCSym(t, false)
|
||||||
off = objw.Uint32(x, off, uint32(sz))
|
off = objw.Uint32(x, off, uint32(sz))
|
||||||
off = objw.Uint32(x, off, uint32(ptrBytes))
|
off = objw.Uint32(x, off, uint32(ptrBytes))
|
||||||
off = objw.SymPtrOff(x, off, lsym)
|
off = objw.SymPtrOff(x, off, lsym)
|
||||||
|
|
|
||||||
|
|
@ -1229,7 +1229,7 @@ func typesStrCmp(a, b typeAndStr) int {
|
||||||
// GC information is always a bitmask, never a gc program.
|
// GC information is always a bitmask, never a gc program.
|
||||||
// GCSym may be called in concurrent backend, so it does not emit the symbol
|
// GCSym may be called in concurrent backend, so it does not emit the symbol
|
||||||
// content.
|
// content.
|
||||||
func GCSym(t *types.Type) (lsym *obj.LSym, ptrdata int64) {
|
func GCSym(t *types.Type, onDemandAllowed bool) (lsym *obj.LSym, ptrdata int64) {
|
||||||
// Record that we need to emit the GC symbol.
|
// Record that we need to emit the GC symbol.
|
||||||
gcsymmu.Lock()
|
gcsymmu.Lock()
|
||||||
if _, ok := gcsymset[t]; !ok {
|
if _, ok := gcsymset[t]; !ok {
|
||||||
|
|
@ -1237,7 +1237,7 @@ func GCSym(t *types.Type) (lsym *obj.LSym, ptrdata int64) {
|
||||||
}
|
}
|
||||||
gcsymmu.Unlock()
|
gcsymmu.Unlock()
|
||||||
|
|
||||||
lsym, _, ptrdata = dgcsym(t, false, false)
|
lsym, _, ptrdata = dgcsym(t, false, onDemandAllowed)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2067,7 +2067,7 @@ func isFixedLoad(v *Value, sym Sym, off int64) bool {
|
||||||
for _, f := range rttype.Type.Fields() {
|
for _, f := range rttype.Type.Fields() {
|
||||||
if f.Offset == off && copyCompatibleType(v.Type, f.Type) {
|
if f.Offset == off && copyCompatibleType(v.Type, f.Type) {
|
||||||
switch f.Sym.Name {
|
switch f.Sym.Name {
|
||||||
case "Size_", "PtrBytes", "Hash", "Kind_":
|
case "Size_", "PtrBytes", "Hash", "Kind_", "GCData":
|
||||||
return true
|
return true
|
||||||
default:
|
default:
|
||||||
// fmt.Println("unknown field", f.Sym.Name)
|
// fmt.Println("unknown field", f.Sym.Name)
|
||||||
|
|
@ -2147,6 +2147,12 @@ func rewriteFixedLoad(v *Value, sym Sym, sb *Value, off int64) *Value {
|
||||||
v.reset(OpConst8)
|
v.reset(OpConst8)
|
||||||
v.AuxInt = int64(reflectdata.ABIKindOfType(t))
|
v.AuxInt = int64(reflectdata.ABIKindOfType(t))
|
||||||
return v
|
return v
|
||||||
|
case "GCData":
|
||||||
|
gcdata, _ := reflectdata.GCSym(t, true)
|
||||||
|
v.reset(OpAddr)
|
||||||
|
v.Aux = symToAux(gcdata)
|
||||||
|
v.AddArg(sb)
|
||||||
|
return v
|
||||||
default:
|
default:
|
||||||
base.Fatalf("unknown field %s for fixedLoad of %s at offset %d", f.Sym.Name, lsym.Name, off)
|
base.Fatalf("unknown field %s for fixedLoad of %s at offset %d", f.Sym.Name, lsym.Name, off)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue