mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/internal/obj: replace Addr.U struct {...} with Val interface{}
An interface{} is more in the spirit of the original union.
By my calculations, on 64-bit systems this reduces
Addr from 120 to 80 bytes, and Prog from 592 to 424 bytes.
Change-Id: I0d7b0981513c2a3c94c9ac76bb4f8816485b5a3c
Reviewed-on: https://go-review.googlesource.com/7744
Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
parent
631d6a33bf
commit
532ccae154
33 changed files with 164 additions and 164 deletions
|
|
@ -389,8 +389,8 @@ func Dconv(p *Prog, a *Addr) string {
|
|||
str = fmt.Sprintf("%s(SB)", a.Sym.Name)
|
||||
} else if p != nil && p.Pcond != nil {
|
||||
str = fmt.Sprintf("%d", p.Pcond.Pc)
|
||||
} else if a.U.Branch != nil {
|
||||
str = fmt.Sprintf("%d", a.U.Branch.Pc)
|
||||
} else if a.Val != nil {
|
||||
str = fmt.Sprintf("%d", a.Val.(*Prog).Pc)
|
||||
} else {
|
||||
str = fmt.Sprintf("%d(PC)", a.Offset)
|
||||
}
|
||||
|
|
@ -412,14 +412,14 @@ func Dconv(p *Prog, a *Addr) string {
|
|||
}
|
||||
|
||||
case TYPE_TEXTSIZE:
|
||||
if a.U.Argsize == ArgsSizeUnknown {
|
||||
if a.Val.(int32) == ArgsSizeUnknown {
|
||||
str = fmt.Sprintf("$%d", a.Offset)
|
||||
} else {
|
||||
str = fmt.Sprintf("$%d-%d", a.Offset, a.U.Argsize)
|
||||
str = fmt.Sprintf("$%d-%d", a.Offset, a.Val.(int32))
|
||||
}
|
||||
|
||||
case TYPE_FCONST:
|
||||
str = fmt.Sprintf("%.17g", a.U.Dval)
|
||||
str = fmt.Sprintf("%.17g", a.Val.(float64))
|
||||
// Make sure 1 prints as 1.0
|
||||
if !strings.ContainsAny(str, ".e") {
|
||||
str += ".0"
|
||||
|
|
@ -427,7 +427,7 @@ func Dconv(p *Prog, a *Addr) string {
|
|||
str = fmt.Sprintf("$(%s)", str)
|
||||
|
||||
case TYPE_SCONST:
|
||||
str = fmt.Sprintf("$%q", a.U.Sval)
|
||||
str = fmt.Sprintf("$%q", a.Val.(string))
|
||||
|
||||
case TYPE_ADDR:
|
||||
str = fmt.Sprintf("$%s", Mconv(a))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue