diff options
author | Matthew Dempsky <mdempsky@google.com> | 2015-10-21 12:12:25 -0700 |
---|---|---|
committer | Matthew Dempsky <mdempsky@google.com> | 2015-10-21 23:08:22 +0000 |
commit | 84afa1be76f89a602c1aef73603175e644f1dc2f (patch) | |
tree | 090b42d927619808e5c4bb61461dfc20b5857463 /src/runtime/mfinal.go | |
parent | 03b0065204df9cd141919890b23de6291ab52885 (diff) | |
download | go-84afa1be76f89a602c1aef73603175e644f1dc2f.tar.gz go-84afa1be76f89a602c1aef73603175e644f1dc2f.zip |
runtime: make iface/eface handling more type safe
Change compiler-invoked interface functions to directly take
iface/eface parameters instead of fInterface/interface{} to avoid
needing to always convert.
For the handful of functions that legitimately need to take an
interface{} parameter, add efaceOf to type-safely convert *interface{}
to *eface.
Change-Id: I8928761a12fd3c771394f36adf93d3006a9fcf39
Reviewed-on: https://go-review.googlesource.com/16166
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/mfinal.go')
-rw-r--r-- | src/runtime/mfinal.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/runtime/mfinal.go b/src/runtime/mfinal.go index a753ceda52..24f35d2163 100644 --- a/src/runtime/mfinal.go +++ b/src/runtime/mfinal.go @@ -187,7 +187,7 @@ func runfinq() { if len(ityp.mhdr) != 0 { // convert to interface with methods // this conversion is guaranteed to succeed - we checked in SetFinalizer - assertE2I(ityp, *(*interface{})(frame), (*fInterface)(frame)) + assertE2I(ityp, *(*eface)(frame), (*iface)(frame)) } default: throw("bad kind in runfinq") @@ -264,7 +264,7 @@ func SetFinalizer(obj interface{}, finalizer interface{}) { // (and we don't have the data structures to record them). return } - e := (*eface)(unsafe.Pointer(&obj)) + e := efaceOf(&obj) etyp := e._type if etyp == nil { throw("runtime.SetFinalizer: first argument is nil") @@ -313,7 +313,7 @@ func SetFinalizer(obj interface{}, finalizer interface{}) { } } - f := (*eface)(unsafe.Pointer(&finalizer)) + f := efaceOf(&finalizer) ftyp := f._type if ftyp == nil { // switch to system stack and remove finalizer @@ -347,7 +347,7 @@ func SetFinalizer(obj interface{}, finalizer interface{}) { // ok - satisfies empty interface goto okarg } - if assertE2I2(ityp, obj, nil) { + if assertE2I2(ityp, *efaceOf(&obj), nil) { goto okarg } } |