From 1c59bc354db124c4a797df6930a19c7a3cf8008c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20M=C3=B6hrmann?= Date: Fri, 12 May 2017 08:21:13 +0200 Subject: [PATCH] go/ssa/interp: add internal/cpu.cpuid to fix short tests http://golang.org/cl/41476 added the internal/cpu package to unify cpu feature flag detection in the standard library. Add a replacement for the assembler function internal/cpu.cpuid that simulates a x86 cpu with no feature detection capabilities. Remove bytes.init and strings.init from the external function list because they do not depend on assembler functions anymore. Remove hash/crc32.haveSSE42 and math.hasSSE4 because they have been removed from the go standard library. Change-Id: Icab6ed3cb13eb14b28d23f2b9c5ae94688f2dc95 Reviewed-on: https://go-review.googlesource.com/43350 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- go/ssa/interp/external.go | 17 +++++------------ go/ssa/interp/interp_test.go | 2 +- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/go/ssa/interp/external.go b/go/ssa/interp/external.go index 84c1dd81c0b..7241522a5a2 100644 --- a/go/ssa/interp/external.go +++ b/go/ssa/interp/external.go @@ -69,10 +69,9 @@ func init() { "(reflect.rtype).Out": ext۰reflect۰rtype۰Out, "(reflect.rtype).Size": ext۰reflect۰rtype۰Size, "(reflect.rtype).String": ext۰reflect۰rtype۰String, - "bytes.init": ext۰nop, // avoid asm dependency "bytes.Equal": ext۰bytes۰Equal, "bytes.IndexByte": ext۰bytes۰IndexByte, - "hash/crc32.haveSSE42": ext۰crc32۰haveSSE42, + "internal/cpu.cpuid": ext۰cpu۰cpuid, "math.Abs": ext۰math۰Abs, "math.Exp": ext۰math۰Exp, "math.Float32bits": ext۰math۰Float32bits, @@ -82,7 +81,6 @@ func init() { "math.Ldexp": ext۰math۰Ldexp, "math.Log": ext۰math۰Log, "math.Min": ext۰math۰Min, - "math.hasSSE4": ext۰math۰hasSSE4, "os.runtime_args": ext۰os۰runtime_args, "os.runtime_beforeExit": ext۰nop, "os/signal.init": ext۰nop, @@ -112,7 +110,6 @@ func init() { "(*runtime.Func).Name": ext۰runtime۰Func۰Name, "runtime.environ": ext۰runtime۰environ, "runtime.getgoroot": ext۰runtime۰getgoroot, - "strings.init": ext۰nop, // avoid asm dependency "strings.Count": ext۰strings۰Count, "strings.Index": ext۰strings۰Index, "strings.IndexByte": ext۰strings۰IndexByte, @@ -193,10 +190,6 @@ func ext۰bytes۰IndexByte(fr *frame, args []value) value { return -1 } -func ext۰crc32۰haveSSE42(fr *frame, args []value) value { - return false -} - func ext۰math۰Float64frombits(fr *frame, args []value) value { return math.Float64frombits(args[0].(uint64)) } @@ -225,10 +218,6 @@ func ext۰math۰Min(fr *frame, args []value) value { return math.Min(args[0].(float64), args[1].(float64)) } -func ext۰math۰hasSSE4(fr *frame, args []value) value { - return false -} - func ext۰math۰Ldexp(fr *frame, args []value) value { return math.Ldexp(args[0].(float64), args[1].(int)) } @@ -476,6 +465,10 @@ func ext۰atomic۰AddUint64(fr *frame, args []value) value { return newv } +func ext۰cpu۰cpuid(fr *frame, args []value) value { + return tuple{uint32(0), uint32(0), uint32(0), uint32(0)} +} + // Pretend: type runtime.Func struct { entry *ssa.Function } func ext۰runtime۰Func۰FileLine(fr *frame, args []value) value { diff --git a/go/ssa/interp/interp_test.go b/go/ssa/interp/interp_test.go index 6e9f7b2f16c..ea8fccad5a8 100644 --- a/go/ssa/interp/interp_test.go +++ b/go/ssa/interp/interp_test.go @@ -158,7 +158,7 @@ var gorootSrcTests = []string{ "encoding/hex", // "encoding/pem", // TODO(adonovan): implement (reflect.Value).SetString // "testing", // TODO(adonovan): implement runtime.Goexit correctly - // "hash/crc32", // TODO(adonovan): implement hash/crc32.haveCLMUL + "hash/crc32", // "log", // TODO(adonovan): implement runtime.Callers correctly // Too slow: