From 8a634c58319a74d0acd921dfdc4a4fe631a35dbc Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Tue, 7 Apr 2015 18:18:44 -0400 Subject: [PATCH] go/ssa/interp: don't let target calls to runtime.GOMAXPROCS set host state ...otherwise the interpreted program can make the whole test suite slow. Just ignore the argument and return the current GOMAXPROCS value. Change-Id: Ife2ad6c53e6fdf9feea1d1b231d8d796b3db3a24 Also: add missing intrinsic for os.runtime_beforeExit. Reviewed-on: https://go-review.googlesource.com/8591 Reviewed-by: Robert Griesemer --- go/ssa/interp/external.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/go/ssa/interp/external.go b/go/ssa/interp/external.go index fc43366a00..627aa5a81e 100644 --- a/go/ssa/interp/external.go +++ b/go/ssa/interp/external.go @@ -79,6 +79,7 @@ func init() { "math.Log": ext۰math۰Log, "math.Min": ext۰math۰Min, "os.runtime_args": ext۰os۰runtime_args, + "os.runtime_beforeExit": ext۰os۰runtime_beforeExit, "reflect.New": ext۰reflect۰New, "reflect.SliceOf": ext۰reflect۰SliceOf, "reflect.TypeOf": ext۰reflect۰TypeOf, @@ -228,6 +229,10 @@ func ext۰os۰runtime_args(fr *frame, args []value) value { return fr.i.osArgs } +func ext۰os۰runtime_beforeExit(fr *frame, args []value) value { + return nil +} + func ext۰runtime۰Breakpoint(fr *frame, args []value) value { runtime.Breakpoint() return nil @@ -328,7 +333,9 @@ func ext۰sync۰runtime_Semrelease(fr *frame, args []value) value { } func ext۰runtime۰GOMAXPROCS(fr *frame, args []value) value { - return runtime.GOMAXPROCS(args[0].(int)) + // Ignore args[0]; don't let the interpreted program + // set the interpreter's GOMAXPROCS! + return runtime.GOMAXPROCS(0) } func ext۰runtime۰Goexit(fr *frame, args []value) value {