Commit 9c4fd462 authored by Heschi Kreinick's avatar Heschi Kreinick

cmd/compile/internal: pass LocalSlot values, not pointers

Because getStackOffset is a function pointer, the compiler assumes that
its arguments escape. Pass a value instead to avoid heap allocations.

Change-Id: Ib94e5941847f134cd00e873040a4d7fcf15ced26
Reviewed-on: https://go-review.googlesource.com/92397
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarDavid Chase <drchase@google.com>
parent b8644e32
......@@ -596,7 +596,7 @@ func (s byNodeName) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
// stackOffset returns the stack location of a LocalSlot relative to the
// stack pointer, suitable for use in a DWARF location entry. This has nothing
// to do with its offset in the user variable.
func stackOffset(slot *ssa.LocalSlot) int32 {
func stackOffset(slot ssa.LocalSlot) int32 {
n := slot.N.(*Node)
var base int64
switch n.Class() {
......@@ -650,7 +650,7 @@ func createComplexVar(fn *Func, varID ssa.VarID) *dwarf.Var {
// variables just give it the first one. It's not used otherwise.
// This won't work well if the first slot hasn't been assigned a stack
// location, but it's not obvious how to do better.
StackOffset: stackOffset(debug.Slots[debug.VarSlots[varID][0]]),
StackOffset: stackOffset(*debug.Slots[debug.VarSlots[varID][0]]),
DeclFile: declpos.Base().SymFilename(),
DeclLine: declpos.Line(),
DeclCol: declpos.Col(),
......
......@@ -170,7 +170,7 @@ type debugState struct {
loggingEnabled bool
cache *Cache
registers []Register
stackOffset func(*LocalSlot) int32
stackOffset func(LocalSlot) int32
// The names (slots) associated with each value, indexed by Value ID.
valueNames [][]SlotID
......@@ -280,7 +280,7 @@ func (s *debugState) stateString(b *BlockDebug, state stateAtPC) string {
// BuildFuncDebug returns debug information for f.
// f must be fully processed, so that each Value is where it will be when
// machine code is emitted.
func BuildFuncDebug(ctxt *obj.Link, f *Func, loggingEnabled bool, stackOffset func(*LocalSlot) int32) *FuncDebug {
func BuildFuncDebug(ctxt *obj.Link, f *Func, loggingEnabled bool, stackOffset func(LocalSlot) int32) *FuncDebug {
if f.RegAlloc == nil {
f.Fatalf("BuildFuncDebug on func %v that has not been fully processed", f)
}
......@@ -336,7 +336,7 @@ func BuildFuncDebug(ctxt *obj.Link, f *Func, loggingEnabled bool, stackOffset fu
}
blockLocs := state.liveness()
lists := state.buildLocationLists(ctxt, stackOffset, blockLocs)
lists := state.buildLocationLists(ctxt, blockLocs)
return &FuncDebug{
Slots: state.slots,
......@@ -582,7 +582,7 @@ func (state *debugState) processValue(v *Value, vSlots []SlotID, vReg *Register)
switch {
case v.Op == OpArg:
home := state.f.getHome(v.ID).(LocalSlot)
stackOffset := state.stackOffset(&home)
stackOffset := state.stackOffset(home)
for _, slot := range vSlots {
if state.loggingEnabled {
state.logf("at %v: arg %v now on stack in location %v\n", v.ID, state.slots[slot], home)
......@@ -596,7 +596,7 @@ func (state *debugState) processValue(v *Value, vSlots []SlotID, vReg *Register)
case v.Op == OpStoreReg:
home := state.f.getHome(v.ID).(LocalSlot)
stackOffset := state.stackOffset(&home)
stackOffset := state.stackOffset(home)
for _, slot := range vSlots {
last := locs.slots[slot]
if last.absent() {
......@@ -721,7 +721,7 @@ func firstReg(set RegisterSet) uint8 {
// The returned location lists are not fully complete. They are in terms of
// SSA values rather than PCs, and have no base address/end entries. They will
// be finished by PutLocationList.
func (state *debugState) buildLocationLists(Ctxt *obj.Link, stackOffset func(*LocalSlot) int32, blockLocs []*BlockDebug) [][]byte {
func (state *debugState) buildLocationLists(Ctxt *obj.Link, blockLocs []*BlockDebug) [][]byte {
lists := make([][]byte, len(state.vars))
pendingEntries := state.cache.pendingEntries
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment