mirror of
https://github.com/golang/go
synced 2024-11-18 18:24:48 -07:00
fec252214b
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 |
||
---|---|---|
.. | ||
serial | ||
testdata/src | ||
callees.go | ||
callers.go | ||
callgraph.go | ||
callstack.go | ||
definition.go | ||
describe.go | ||
freevars.go | ||
implements.go | ||
oracle_test.go | ||
oracle.go | ||
peers.go | ||
pointsto.go | ||
pos.go | ||
referrers.go | ||
TODO | ||
what.go |