go/ssa/interp: use *ssa.Global as key type for interpreter.globals
All keys are *ssa.Global pointers already anyway, so using *ssa.Global
instead of ssa.Value as the map key type allows for using the
runtime's fastmap implementation for fixed-size keys instead of
falling back to hashing interface values.
Change-Id: Ib5b25dba5e646a8458cfae7cacd8b91a4cd2721a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/400834
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tim King <taking@google.com>
diff --git a/go/ssa/interp/interp.go b/go/ssa/interp/interp.go
index aa5918f..0f6a21f 100644
--- a/go/ssa/interp/interp.go
+++ b/go/ssa/interp/interp.go
@@ -76,16 +76,16 @@
// State shared between all interpreted goroutines.
type interpreter struct {
- osArgs []value // the value of os.Args
- prog *ssa.Program // the SSA program
- globals map[ssa.Value]*value // addresses of global variables (immutable)
- mode Mode // interpreter options
- reflectPackage *ssa.Package // the fake reflect package
- errorMethods methodSet // the method set of reflect.error, which implements the error interface.
- rtypeMethods methodSet // the method set of rtype, which implements the reflect.Type interface.
- runtimeErrorString types.Type // the runtime.errorString type
- sizes types.Sizes // the effective type-sizing function
- goroutines int32 // atomically updated
+ osArgs []value // the value of os.Args
+ prog *ssa.Program // the SSA program
+ globals map[*ssa.Global]*value // addresses of global variables (immutable)
+ mode Mode // interpreter options
+ reflectPackage *ssa.Package // the fake reflect package
+ errorMethods methodSet // the method set of reflect.error, which implements the error interface.
+ rtypeMethods methodSet // the method set of rtype, which implements the reflect.Type interface.
+ runtimeErrorString types.Type // the runtime.errorString type
+ sizes types.Sizes // the effective type-sizing function
+ goroutines int32 // atomically updated
}
type deferred struct {
@@ -640,7 +640,7 @@
func Interpret(mainpkg *ssa.Package, mode Mode, sizes types.Sizes, filename string, args []string) (exitCode int) {
i := &interpreter{
prog: mainpkg.Prog,
- globals: make(map[ssa.Value]*value),
+ globals: make(map[*ssa.Global]*value),
mode: mode,
sizes: sizes,
goroutines: 1,