From 0a02371b0576964e81c3b40d328db9a3ef3b031b Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Mon, 14 Dec 2020 09:45:44 +0700 Subject: cmd/compile: set correct type for OpIData MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since CL 270057, there're many attempts to fix the expand_calls pass with interface{}-typed. But all of them did not fix the root cause. The main issue is during SSA conversion in gc/ssa.go, for empty interface case, we make its type as n.Type, instead of BytePtr. To fix these, we can just use BytePtr for now, since when itab fields are treated as scalar. No significal changes on compiler speed, size. cmd/compile/internal/ssa expandCalls.func6 9488 -> 9232 (-2.70%) file before after Δ % cmd/compile/internal/ssa.s 3992893 3992637 -256 -0.006% total 20500447 20500191 -256 -0.001% Fixes #43112 Updates #42784 Updates #42727 Updates #42568 Change-Id: I0b15d9434e0be5448453e61f98ef9c2d6cd93792 Reviewed-on: https://go-review.googlesource.com/c/go/+/276952 Trust: Cuong Manh Le Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: Keith Randall --- test/fixedbugs/issue43112.go | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 test/fixedbugs/issue43112.go (limited to 'test') diff --git a/test/fixedbugs/issue43112.go b/test/fixedbugs/issue43112.go new file mode 100644 index 0000000000..e36627a015 --- /dev/null +++ b/test/fixedbugs/issue43112.go @@ -0,0 +1,41 @@ +// compile + +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package p + +type Symbol interface{} + +type Value interface { + String() string +} + +type Object interface { + String() string +} + +type Scope struct { + outer *Scope + elems map[string]Object +} + +func (s *Scope) findouter(name string) (*Scope, Object) { + return s.outer.findouter(name) +} + +func (s *Scope) Resolve(name string) (sym Symbol) { + if _, obj := s.findouter(name); obj != nil { + sym = obj.(Symbol) + } + return +} + +type ScopeName struct { + scope *Scope +} + +func (n *ScopeName) Get(name string) (Value, error) { + return n.scope.Resolve(name).(Value), nil +} -- cgit v1.2.3-54-g00ecf