reflect: prevent the callXX routines from calling makeFuncStub

and methodValueCall directly.  Instead, we inline their behavior
inside of reflect.call.

This change is required because otherwise we have a situation where
reflect.callXX calls makeFuncStub, neither of which knows the
layout of the args passed between them.  That's bad for
precise gc & stack copying.

Fixes #6619.

R=golang-dev, dvyukov, rsc, iant, khr
CC=golang-dev
https://golang.org/cl/26970044
This commit is contained in:
Keith Randall 2013-12-02 13:36:50 -08:00
parent c792bde9ef
commit 85138da832
2 changed files with 56 additions and 0 deletions

View file

@ -3616,3 +3616,27 @@ func (x *exhaustive) Choose(max int) int {
func (x *exhaustive) Maybe() bool {
return x.Choose(2) == 1
}
func GCFunc(args []Value) []Value {
runtime.GC()
return []Value{}
}
func TestReflectFuncTraceback(t *testing.T) {
f := MakeFunc(TypeOf(func() {}), GCFunc)
f.Call([]Value{})
}
func (p Point) GCMethod(k int) int {
runtime.GC()
return k + p.x
}
func TestReflectMethodTraceback(t *testing.T) {
p := Point{3, 4}
m := ValueOf(p).MethodByName("GCMethod")
i := ValueOf(m.Interface()).Call([]Value{ValueOf(5)})[0].Int()
if i != 8 {
t.Errorf("Call returned %d; want 8", i)
}
}