diff options
author | David Chase <drchase@google.com> | 2017-03-13 21:09:27 +0000 |
---|---|---|
committer | David Chase <drchase@google.com> | 2017-03-13 21:15:32 +0000 |
commit | b59a405656bbd79aefe3620553bee771628f9209 (patch) | |
tree | 4ae95d47c49860604c6a9dad42cb6bc5eb0de9b9 /src/cmd/compile/internal/ssa | |
parent | 118b3fe7bbf855196db727daefbb403b84a4f67d (diff) | |
download | go-b59a405656bbd79aefe3620553bee771628f9209.tar.gz go-b59a405656bbd79aefe3620553bee771628f9209.zip |
Revert "cmd/compile: de-virtualize interface calls"
This reverts commit 4e0c7c3f61475116c4ae8d11ef796819d9c404f0.
Reason for revert: The presence-of-optimization test program is fragile, breaks under noopt, and might break if the Go libraries are tweaked. It needs to be (re)written without reference to other packages.
Change-Id: I3aaf1ab006a1a255f961a978e9c984341740e3c7
Reviewed-on: https://go-review.googlesource.com/38097
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/ssa')
-rw-r--r-- | src/cmd/compile/internal/ssa/config.go | 6 | ||||
-rw-r--r-- | src/cmd/compile/internal/ssa/export_test.go | 31 | ||||
-rw-r--r-- | src/cmd/compile/internal/ssa/gen/generic.rules | 7 | ||||
-rw-r--r-- | src/cmd/compile/internal/ssa/rewrite.go | 20 | ||||
-rw-r--r-- | src/cmd/compile/internal/ssa/rewritegeneric.go | 48 |
5 files changed, 15 insertions, 97 deletions
diff --git a/src/cmd/compile/internal/ssa/config.go b/src/cmd/compile/internal/ssa/config.go index 53d9bdd61c..6a8101a562 100644 --- a/src/cmd/compile/internal/ssa/config.go +++ b/src/cmd/compile/internal/ssa/config.go @@ -121,12 +121,6 @@ type Frontend interface { SplitArray(LocalSlot) LocalSlot // array must be length 1 SplitInt64(LocalSlot) (LocalSlot, LocalSlot) // returns (hi, lo) - // DerefItab dereferences an itab function - // entry, given the symbol of the itab and - // the byte offset of the function pointer. - // It may return nil. - DerefItab(sym *obj.LSym, offset int64) *obj.LSym - // Line returns a string describing the given position. Line(src.XPos) string diff --git a/src/cmd/compile/internal/ssa/export_test.go b/src/cmd/compile/internal/ssa/export_test.go index b687076a28..74bb08d5c2 100644 --- a/src/cmd/compile/internal/ssa/export_test.go +++ b/src/cmd/compile/internal/ssa/export_test.go @@ -97,22 +97,21 @@ func (d DummyFrontend) Warnl(_ src.XPos, msg string, args ...interface{}) { d.t func (d DummyFrontend) Debug_checknil() bool { return false } func (d DummyFrontend) Debug_wb() bool { return false } -func (d DummyFrontend) TypeBool() Type { return TypeBool } -func (d DummyFrontend) TypeInt8() Type { return TypeInt8 } -func (d DummyFrontend) TypeInt16() Type { return TypeInt16 } -func (d DummyFrontend) TypeInt32() Type { return TypeInt32 } -func (d DummyFrontend) TypeInt64() Type { return TypeInt64 } -func (d DummyFrontend) TypeUInt8() Type { return TypeUInt8 } -func (d DummyFrontend) TypeUInt16() Type { return TypeUInt16 } -func (d DummyFrontend) TypeUInt32() Type { return TypeUInt32 } -func (d DummyFrontend) TypeUInt64() Type { return TypeUInt64 } -func (d DummyFrontend) TypeFloat32() Type { return TypeFloat32 } -func (d DummyFrontend) TypeFloat64() Type { return TypeFloat64 } -func (d DummyFrontend) TypeInt() Type { return TypeInt64 } -func (d DummyFrontend) TypeUintptr() Type { return TypeUInt64 } -func (d DummyFrontend) TypeString() Type { panic("unimplemented") } -func (d DummyFrontend) TypeBytePtr() Type { return TypeBytePtr } -func (d DummyFrontend) DerefItab(sym *obj.LSym, off int64) *obj.LSym { return nil } +func (d DummyFrontend) TypeBool() Type { return TypeBool } +func (d DummyFrontend) TypeInt8() Type { return TypeInt8 } +func (d DummyFrontend) TypeInt16() Type { return TypeInt16 } +func (d DummyFrontend) TypeInt32() Type { return TypeInt32 } +func (d DummyFrontend) TypeInt64() Type { return TypeInt64 } +func (d DummyFrontend) TypeUInt8() Type { return TypeUInt8 } +func (d DummyFrontend) TypeUInt16() Type { return TypeUInt16 } +func (d DummyFrontend) TypeUInt32() Type { return TypeUInt32 } +func (d DummyFrontend) TypeUInt64() Type { return TypeUInt64 } +func (d DummyFrontend) TypeFloat32() Type { return TypeFloat32 } +func (d DummyFrontend) TypeFloat64() Type { return TypeFloat64 } +func (d DummyFrontend) TypeInt() Type { return TypeInt64 } +func (d DummyFrontend) TypeUintptr() Type { return TypeUInt64 } +func (d DummyFrontend) TypeString() Type { panic("unimplemented") } +func (d DummyFrontend) TypeBytePtr() Type { return TypeBytePtr } func (d DummyFrontend) CanSSA(t Type) bool { // There are no un-SSAable types in dummy land. diff --git a/src/cmd/compile/internal/ssa/gen/generic.rules b/src/cmd/compile/internal/ssa/gen/generic.rules index 73341a52d7..53f0490c4c 100644 --- a/src/cmd/compile/internal/ssa/gen/generic.rules +++ b/src/cmd/compile/internal/ssa/gen/generic.rules @@ -1431,10 +1431,3 @@ && c == config.ctxt.FixedFrameSize() + config.RegSize // offset of return value && warnRule(config.Debug_checknil() && v.Pos.Line() > 1, v, "removed nil check") -> (Invalid) - -// De-virtualize interface calls into static calls. -// Note that (ITab (IMake)) doesn't get -// rewritten until after the first opt pass, -// so this rule should trigger reliably. -(InterCall [argsize] (Load (OffPtr [off] (ITab (IMake (Addr {itab} (SB)) _))) _) mem) && devirt(v, itab, off) != nil -> - (StaticCall [argsize] {devirt(v, itab, off)} mem) diff --git a/src/cmd/compile/internal/ssa/rewrite.go b/src/cmd/compile/internal/ssa/rewrite.go index 26c6518eeb..9c9c6b5ecc 100644 --- a/src/cmd/compile/internal/ssa/rewrite.go +++ b/src/cmd/compile/internal/ssa/rewrite.go @@ -5,7 +5,6 @@ package ssa import ( - "cmd/internal/obj" "crypto/sha1" "fmt" "math" @@ -385,25 +384,6 @@ func uaddOvf(a, b int64) bool { return uint64(a)+uint64(b) < uint64(a) } -// de-virtualize an InterCall -// 'sym' is the symbol for the itab -func devirt(v *Value, sym interface{}, offset int64) *obj.LSym { - f := v.Block.Func - ext, ok := sym.(*ExternSymbol) - if !ok { - return nil - } - lsym := f.Config.Frontend().DerefItab(ext.Sym, offset) - if f.pass.debug > 0 { - if lsym != nil { - f.Config.Warnl(v.Pos, "de-virtualizing call") - } else { - f.Config.Warnl(v.Pos, "couldn't de-virtualize call") - } - } - return lsym -} - // isSamePtr reports whether p1 and p2 point to the same address. func isSamePtr(p1, p2 *Value) bool { if p1 == p2 { diff --git a/src/cmd/compile/internal/ssa/rewritegeneric.go b/src/cmd/compile/internal/ssa/rewritegeneric.go index b998266f2b..10a4a4383c 100644 --- a/src/cmd/compile/internal/ssa/rewritegeneric.go +++ b/src/cmd/compile/internal/ssa/rewritegeneric.go @@ -124,8 +124,6 @@ func rewriteValuegeneric(v *Value, config *Config) bool { return rewriteValuegeneric_OpGreater8U(v, config) case OpIMake: return rewriteValuegeneric_OpIMake(v, config) - case OpInterCall: - return rewriteValuegeneric_OpInterCall(v, config) case OpIsInBounds: return rewriteValuegeneric_OpIsInBounds(v, config) case OpIsNonNil: @@ -5738,52 +5736,6 @@ func rewriteValuegeneric_OpIMake(v *Value, config *Config) bool { } return false } -func rewriteValuegeneric_OpInterCall(v *Value, config *Config) bool { - b := v.Block - _ = b - // match: (InterCall [argsize] (Load (OffPtr [off] (ITab (IMake (Addr {itab} (SB)) _))) _) mem) - // cond: devirt(v, itab, off) != nil - // result: (StaticCall [argsize] {devirt(v, itab, off)} mem) - for { - argsize := v.AuxInt - v_0 := v.Args[0] - if v_0.Op != OpLoad { - break - } - v_0_0 := v_0.Args[0] - if v_0_0.Op != OpOffPtr { - break - } - off := v_0_0.AuxInt - v_0_0_0 := v_0_0.Args[0] - if v_0_0_0.Op != OpITab { - break - } - v_0_0_0_0 := v_0_0_0.Args[0] - if v_0_0_0_0.Op != OpIMake { - break - } - v_0_0_0_0_0 := v_0_0_0_0.Args[0] - if v_0_0_0_0_0.Op != OpAddr { - break - } - itab := v_0_0_0_0_0.Aux - v_0_0_0_0_0_0 := v_0_0_0_0_0.Args[0] - if v_0_0_0_0_0_0.Op != OpSB { - break - } - mem := v.Args[1] - if !(devirt(v, itab, off) != nil) { - break - } - v.reset(OpStaticCall) - v.AuxInt = argsize - v.Aux = devirt(v, itab, off) - v.AddArg(mem) - return true - } - return false -} func rewriteValuegeneric_OpIsInBounds(v *Value, config *Config) bool { b := v.Block _ = b |