mirror of
https://github.com/golang/go
synced 2024-11-20 10:24:40 -07:00
cmd/compile: more compact DWARF location for locals and arguments
Now that all functions have a DW_AT_frame_base defined we can use DW_OP_fbreg to specify the location of variables and formal parameters, instead of the DW_OP_call_frame_cfa/DW_OP_consts/DW_OP_plus, saving 2 bytes for every variable and 2 bytes for every formal parameter after the first one. Change-Id: I2c7395b67e4a814a0131ab1520df11ca48ff9327 Reviewed-on: https://go-review.googlesource.com/60550 Run-TryBot: Heschi Kreinick <heschi@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
This commit is contained in:
parent
84188296e9
commit
31ddd8a39d
@ -804,12 +804,14 @@ func putvar(ctxt Context, info, loc Sym, v *Var, startPC Sym, encbuf []byte) {
|
|||||||
putattr(ctxt, info, v.Abbrev, DW_FORM_sec_offset, DW_CLS_PTR, int64(loc.Len()), loc)
|
putattr(ctxt, info, v.Abbrev, DW_FORM_sec_offset, DW_CLS_PTR, int64(loc.Len()), loc)
|
||||||
addLocList(ctxt, loc, startPC, v, encbuf)
|
addLocList(ctxt, loc, startPC, v, encbuf)
|
||||||
} else {
|
} else {
|
||||||
loc := append(encbuf[:0], DW_OP_call_frame_cfa)
|
loc := encbuf[:0]
|
||||||
if v.StackOffset != 0 {
|
if v.StackOffset == 0 {
|
||||||
loc = append(loc, DW_OP_consts)
|
loc = append(loc, DW_OP_call_frame_cfa)
|
||||||
|
} else {
|
||||||
|
loc = append(loc, DW_OP_fbreg)
|
||||||
loc = AppendSleb128(loc, int64(v.StackOffset))
|
loc = AppendSleb128(loc, int64(v.StackOffset))
|
||||||
loc = append(loc, DW_OP_plus)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
putattr(ctxt, info, v.Abbrev, DW_FORM_block1, DW_CLS_BLOCK, int64(len(loc)), loc)
|
putattr(ctxt, info, v.Abbrev, DW_FORM_block1, DW_CLS_BLOCK, int64(len(loc)), loc)
|
||||||
}
|
}
|
||||||
putattr(ctxt, info, v.Abbrev, DW_FORM_ref_addr, DW_CLS_REFERENCE, 0, v.Type)
|
putattr(ctxt, info, v.Abbrev, DW_FORM_ref_addr, DW_CLS_REFERENCE, 0, v.Type)
|
||||||
@ -826,8 +828,12 @@ func addLocList(ctxt Context, listSym, startPC Sym, v *Var, encbuf []byte) {
|
|||||||
for _, piece := range entry.Pieces {
|
for _, piece := range entry.Pieces {
|
||||||
if !piece.Missing {
|
if !piece.Missing {
|
||||||
if piece.OnStack {
|
if piece.OnStack {
|
||||||
locBuf = append(locBuf, DW_OP_fbreg)
|
if piece.StackOffset == 0 {
|
||||||
locBuf = AppendSleb128(locBuf, int64(piece.StackOffset))
|
locBuf = append(locBuf, DW_OP_call_frame_cfa)
|
||||||
|
} else {
|
||||||
|
locBuf = append(locBuf, DW_OP_fbreg)
|
||||||
|
locBuf = AppendSleb128(locBuf, int64(piece.StackOffset))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if piece.RegNum < 32 {
|
if piece.RegNum < 32 {
|
||||||
locBuf = append(locBuf, DW_OP_reg0+byte(piece.RegNum))
|
locBuf = append(locBuf, DW_OP_reg0+byte(piece.RegNum))
|
||||||
|
Loading…
Reference in New Issue
Block a user