mirror of
https://github.com/golang/go
synced 2024-11-18 22:34:45 -07:00
go/ssa/interp: add two intrinsics to fix tests
(specifically: strings.Count, testing.callerEntry) The interpreter tests were very useful for finding bugs during development of go/ssa but now seem to be all cost and no benefit. It may be time to delete this package. Change-Id: I22348be9fb37bb0fd0c572c3e6f57e70fc069e02 Reviewed-on: https://go-review.googlesource.com/40871 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
3bcb6efb39
commit
fc77adfcad
@ -113,6 +113,7 @@ func init() {
|
|||||||
"runtime.environ": ext۰runtime۰environ,
|
"runtime.environ": ext۰runtime۰environ,
|
||||||
"runtime.getgoroot": ext۰runtime۰getgoroot,
|
"runtime.getgoroot": ext۰runtime۰getgoroot,
|
||||||
"strings.init": ext۰nop, // avoid asm dependency
|
"strings.init": ext۰nop, // avoid asm dependency
|
||||||
|
"strings.Count": ext۰strings۰Count,
|
||||||
"strings.Index": ext۰strings۰Index,
|
"strings.Index": ext۰strings۰Index,
|
||||||
"strings.IndexByte": ext۰strings۰IndexByte,
|
"strings.IndexByte": ext۰strings۰IndexByte,
|
||||||
"sync.runtime_Semacquire": ext۰nop, // unimplementable
|
"sync.runtime_Semacquire": ext۰nop, // unimplementable
|
||||||
@ -136,6 +137,7 @@ func init() {
|
|||||||
"sync/atomic.LoadUint64": ext۰atomic۰LoadUint64,
|
"sync/atomic.LoadUint64": ext۰atomic۰LoadUint64,
|
||||||
"sync/atomic.StoreInt64": ext۰atomic۰StoreInt64,
|
"sync/atomic.StoreInt64": ext۰atomic۰StoreInt64,
|
||||||
"sync/atomic.StoreUint64": ext۰atomic۰StoreUint64,
|
"sync/atomic.StoreUint64": ext۰atomic۰StoreUint64,
|
||||||
|
"testing.callerEntry": ext۰testing۰callerEntry,
|
||||||
"testing.runExample": ext۰testing۰runExample,
|
"testing.runExample": ext۰testing۰runExample,
|
||||||
"time.Sleep": ext۰time۰Sleep,
|
"time.Sleep": ext۰time۰Sleep,
|
||||||
"time.now": ext۰time۰now,
|
"time.now": ext۰time۰now,
|
||||||
@ -279,7 +281,7 @@ func ext۰runtime۰Callers(fr *frame, args []value) value {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
i := 0
|
i := 0
|
||||||
for fr != nil {
|
for fr != nil && i < len(pc) {
|
||||||
pc[i] = uintptr(unsafe.Pointer(fr.fn))
|
pc[i] = uintptr(unsafe.Pointer(fr.fn))
|
||||||
i++
|
i++
|
||||||
fr = fr.caller
|
fr = fr.caller
|
||||||
@ -308,6 +310,11 @@ func ext۰runtime۰getgoroot(fr *frame, args []value) value {
|
|||||||
return os.Getenv("GOROOT")
|
return os.Getenv("GOROOT")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ext۰strings۰Count(fr *frame, args []value) value {
|
||||||
|
// Call compiled version to avoid asm dependency.
|
||||||
|
return strings.Count(args[0].(string), args[1].(string))
|
||||||
|
}
|
||||||
|
|
||||||
func ext۰strings۰IndexByte(fr *frame, args []value) value {
|
func ext۰strings۰IndexByte(fr *frame, args []value) value {
|
||||||
// Call compiled version to avoid asm dependency.
|
// Call compiled version to avoid asm dependency.
|
||||||
return strings.IndexByte(args[0].(string), args[1].(byte))
|
return strings.IndexByte(args[0].(string), args[1].(byte))
|
||||||
@ -515,6 +522,10 @@ func ext۰testing۰runExample(fr *frame, args []value) value {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ext۰testing۰callerEntry(fr *frame, args []value) value {
|
||||||
|
return uintptr(0) // bogus implementation for now
|
||||||
|
}
|
||||||
|
|
||||||
func ext۰time۰now(fr *frame, args []value) value {
|
func ext۰time۰now(fr *frame, args []value) value {
|
||||||
nano := time.Now().UnixNano()
|
nano := time.Now().UnixNano()
|
||||||
return tuple{int64(nano / 1e9), int32(nano % 1e9), int64(0)}
|
return tuple{int64(nano / 1e9), int32(nano % 1e9), int64(0)}
|
||||||
|
Loading…
Reference in New Issue
Block a user