go.tools/go/ssa/interp: add no-op intrinsic sync.runtime_registerPoolCleanup

Also, compute correct index of struct field sync.Pool.New, which just changed.

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/87780043
This commit is contained in:
Alan Donovan 2014-04-14 17:53:58 -04:00
parent b5d07c813b
commit 647d17e45f
1 changed files with 107 additions and 96 deletions

View File

@ -16,6 +16,7 @@ import (
"unsafe"
"code.google.com/p/go.tools/go/ssa"
"code.google.com/p/go.tools/go/types"
)
type externalFn func(fr *frame, args []value) value
@ -101,6 +102,7 @@ func init() {
"sync.runtime_Semacquire": ext۰sync۰runtime_Semacquire,
"sync.runtime_Semrelease": ext۰sync۰runtime_Semrelease,
"sync.runtime_Syncsemcheck": ext۰sync۰runtime_Syncsemcheck,
"sync.runtime_registerPoolCleanup": ext۰sync۰runtime_registerPoolCleanup,
"sync/atomic.AddInt32": ext۰atomic۰AddInt32,
"sync/atomic.AddUint32": ext۰atomic۰AddUint32,
"sync/atomic.AddUint64": ext۰atomic۰AddUint64,
@ -137,7 +139,12 @@ func wrapError(err error) value {
}
func ext۰sync۰Pool۰Get(fr *frame, args []value) value {
if New := (*args[0].(*value)).(structure)[4]; New != nil {
// It would be nice if this were less verbose.
sync := fr.i.prog.ImportedPackage("sync")
Pool := sync.Type("Pool").Type()
_, newIndex, _ := types.LookupFieldOrMethod(Pool, sync.Object, "New")
if New := (*args[0].(*value)).(structure)[newIndex[0]]; New != nil {
return call(fr.i, fr, 0, New, nil)
}
return nil
@ -294,6 +301,10 @@ func ext۰sync۰runtime_Syncsemcheck(fr *frame, args []value) value {
return nil
}
func ext۰sync۰runtime_registerPoolCleanup(fr *frame, args []value) value {
return nil
}
func ext۰sync۰runtime_Semacquire(fr *frame, args []value) value {
// TODO(adonovan): fix: implement.
return nil