go/ssa/interp: add no-op intrinsic for runtime.init().
Recent changes in the runtime caused the interpreter to call 'getg', and it should never have gotten that far. Also, delete bodies of "runtime" functions, since they're too magical. This makes missing intrinsics cause very obvious failures. LGTM=gri R=gri CC=golang-codereviews https://golang.org/cl/135330043
This commit is contained in:
parent
95bd0c4fdf
commit
79df80a148
|
|
@ -91,6 +91,7 @@ func init() {
|
|||
"runtime.GOMAXPROCS": ext۰runtime۰GOMAXPROCS,
|
||||
"runtime.Goexit": ext۰runtime۰Goexit,
|
||||
"runtime.Gosched": ext۰runtime۰Gosched,
|
||||
"runtime.init": ext۰runtime۰init,
|
||||
"runtime.NumCPU": ext۰runtime۰NumCPU,
|
||||
"runtime.ReadMemStats": ext۰runtime۰ReadMemStats,
|
||||
"runtime.SetFinalizer": ext۰runtime۰SetFinalizer,
|
||||
|
|
@ -344,6 +345,10 @@ func ext۰runtime۰Gosched(fr *frame, args []value) value {
|
|||
return nil
|
||||
}
|
||||
|
||||
func ext۰runtime۰init(fr *frame, args []value) value {
|
||||
return nil
|
||||
}
|
||||
|
||||
func ext۰runtime۰NumCPU(fr *frame, args []value) value {
|
||||
return runtime.NumCPU()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -670,6 +670,19 @@ func Interpret(mainpkg *ssa.Package, mode Mode, sizes types.Sizes, filename stri
|
|||
sz := sizes.Sizeof(pkg.Object.Scope().Lookup("MemStats").Type())
|
||||
setGlobal(i, pkg, "sizeof_C_MStats", uintptr(sz))
|
||||
|
||||
// Delete the bodies of almost all "runtime" functions since they're magic.
|
||||
// A missing intrinsic leads to a very clear error.
|
||||
for _, mem := range pkg.Members {
|
||||
if fn, ok := mem.(*ssa.Function); ok {
|
||||
switch fn.Name() {
|
||||
case "GOROOT", "gogetenv":
|
||||
// keep
|
||||
default:
|
||||
fn.Blocks = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
case "os":
|
||||
Args := []value{filename}
|
||||
for _, s := range args {
|
||||
|
|
|
|||
Loading…
Reference in New Issue