]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal: pass LocalSlot values, not pointers
authorHeschi Kreinick <heschi@google.com>
Tue, 30 Jan 2018 00:21:25 +0000 (19:21 -0500)
committerHeschi Kreinick <heschi@google.com>
Wed, 14 Feb 2018 18:29:24 +0000 (18:29 +0000)
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: David Chase <drchase@google.com>
src/cmd/compile/internal/gc/pgen.go
src/cmd/compile/internal/ssa/debug.go

index 80b771a831b53c8a5ed07737f79759dea6ce85ff..315321b06de3307d94d2091fa357fe6092e9281d 100644 (file)
@@ -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(),
index 8a71d725c988caa54b6c91e96ef43965dc527cc8..807d47d9654bff8cd50ba4d19ff7d6d1b5ebd086 100644 (file)
@@ -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