1
0
mirror of https://github.com/golang/go synced 2024-10-01 01:28:32 -06:00
go/oracle
Alan Donovan fec252214b go.tools/ssa: create thunks for method expressions T.f.
Until now, the same Function was used to represent a method
(T)func() and the "method expression" function func(T) formed
from it. So the SSA code for this:

    var buf bytes.Buffer
    f := Buffer.Bytes
    f(buf)
    buf.Bytes()

would involve an implicit cast (ChangeType) on line 2.
However, compilers based on go/ssa may want to use different
calling conventions for them, like gccgo does (see issue
7839).  This change decouples them by using an anonymous
function called a "thunk", rather like this:

    f := func(r *bytes.Buffer) []byte { return r.Bytes() }

Thunks are similar to method wrappers; both are created by
makeWrapper.

"Interface method wrappers" were a special case of thunks for
direct calls (no indirection/fields) of interface methods.
They are now subsumed by thunks and have been deleted.  Now
that only the needed thunks are built, we don't need to
populate the concrete method sets of interface types at all,
so (*Program).Method and LookupMethod return nil for them.
This results in a slight reduction in function count (>1%) and
instruction count (<<1%).

Details:

go/ssa:
- API: ChangeType no longer supports func/method conversions.
- API: (*Program).FuncValue now returns nil for abstract
  (interface) methods.
- API: (*Function).RelString simplified.
  "$bound" is now a suffix not a prefix, and the receiver
  type is rendered package-relative.
- API: Function.Object is now defined for all wrappers too.
- API: (*Program).Method and LookupMethod return nil for
  abstract methods.
- emitConv no longer permits (non-identical)
  Signature->Signature conversions.  Added assertion.
- add and use isInterface helper
- sanity: we check packages after Build, not Create, otherwise
  cross-package refs might fail.

go/pointer:
- update tests for new function strings.
- pointer_test: don't add non-pointerlike probes to analysis.
  (The error was checked, but too late, causing a panic.)
- fixed a minor bug: if a test probe print(x) was the sole
  reference to x, no nodes were generated for x.
- (reflect.Type).MethodByName: updated due to ssa API changes.
  Also, fixed incorrect testdata/funcreflect.go expectation
  for MethodByName on interfaces.

oracle:
- fix for new FuncValue semantics.
- a "pointsto" query on an I.f thunk now returns an error.

Fixes golang/go#7839

LGTM=gri
R=gri
CC=golang-codereviews, pcc
https://golang.org/cl/93780044
2014-06-11 13:10:26 -04:00
..
serial go.tools/oracle: implements: now shows whole-program implements relation for selected type. 2013-12-13 18:00:55 -05:00
testdata/src go.tools/ssa: create thunks for method expressions T.f. 2014-06-11 13:10:26 -04:00
callees.go go.tools/oracle: optionally restrict 'callgraph' query to a single package. 2014-02-21 10:46:02 -05:00
callers.go go.tools/oracle: optionally restrict 'callgraph' query to a single package. 2014-02-21 10:46:02 -05:00
callgraph.go go.tools/oracle: callgraph: fix crash caused by sparse node numbering. 2014-06-10 12:36:40 -04:00
callstack.go go.tools/oracle: optionally restrict 'callgraph' query to a single package. 2014-02-21 10:46:02 -05:00
definition.go go.tools/oracle: improvements to command set and performance. 2013-12-13 10:04:55 -05:00
describe.go go.tools/go/oracle: show import path (not just name) when describing an import. 2014-04-15 15:37:44 -04:00
freevars.go go.tools/oracle: improvements to command set and performance. 2013-12-13 10:04:55 -05:00
implements.go go.tools: various comments + doc tweaks. 2014-03-11 18:24:39 -04:00
oracle_test.go go.tools/oracle: don't discard /usr/bin/diff's stderr 2014-04-15 15:39:38 -04:00
oracle.go go.tools/oracle: fix bug in reduceScope on ad-hoc main packages. 2014-03-19 14:00:35 -04:00
peers.go go.tools: fix various typos 2014-05-02 14:38:08 -07:00
pointsto.go go.tools/ssa: create thunks for method expressions T.f. 2014-06-11 13:10:26 -04:00
pos.go go.tools/oracle: improvements to command set and performance. 2013-12-13 10:04:55 -05:00
referrers.go go.tools: fix various typos 2014-05-02 14:38:08 -07:00
TODO go.tools/oracle: implements: now shows whole-program implements relation for selected type. 2013-12-13 18:00:55 -05:00
what.go go.tools/oracle: implements: now shows whole-program implements relation for selected type. 2013-12-13 18:00:55 -05:00