From 47e3c4bc74f5f260cbc9c5e6d1ababde0a114a97 Mon Sep 17 00:00:00 2001 From: Dan Scales Date: Mon, 8 Nov 2021 18:10:30 -0800 Subject: [PATCH] cmd/compile: disable doubleCheck and remove unused checkDictionary In stencil.go, change doubleCheck to false, which will turn off some double-checking code which isn't needed generally, now that we have lots of tests of end-to-end runs. Also, removed checkDictionary() which is unused and is unlikely to be useful in the future. Change-Id: I4e5acceab80f4904b174422bae21ca82cf04f943 Reviewed-on: https://go-review.googlesource.com/c/go/+/361923 Trust: Dan Scales Run-TryBot: Dan Scales Reviewed-by: Keith Randall TryBot-Result: Go Bot --- src/cmd/compile/internal/noder/stencil.go | 50 +---------------------- 1 file changed, 1 insertion(+), 49 deletions(-) diff --git a/src/cmd/compile/internal/noder/stencil.go b/src/cmd/compile/internal/noder/stencil.go index 4ebd607c16..cfbbee3ceb 100644 --- a/src/cmd/compile/internal/noder/stencil.go +++ b/src/cmd/compile/internal/noder/stencil.go @@ -22,7 +22,7 @@ import ( ) // Enable extra consistency checks. -const doubleCheck = true +const doubleCheck = false func assert(p bool) { base.Assert(p) @@ -802,11 +802,6 @@ func (g *genInst) genericSubst(newsym *types.Sym, nameNode *ir.Name, shapes []*t // Make sure name/type of newf is set before substituting the body. newf.Body = subst.list(gf.Body) - // Add code to check that the dictionary is correct. - // TODO: must be adjusted to deal with shapes, but will go away soon when we move - // to many->1 shape to concrete mapping. - // newf.Body.Prepend(subst.checkDictionary(dictionaryName, shapes)...) - if len(subst.defnMap) > 0 { base.Fatalf("defnMap is not empty") } @@ -859,49 +854,6 @@ func (subst *subster) localvar(name *ir.Name) *ir.Name { return m } -// checkDictionary returns code that does runtime consistency checks -// between the dictionary and the types it should contain. -func (subst *subster) checkDictionary(name *ir.Name, targs []*types.Type) (code []ir.Node) { - if false { - return // checking turned off - } - // TODO: when moving to GCshape, this test will become harder. Call into - // runtime to check the expected shape is correct? - pos := name.Pos() - // Convert dictionary to *[N]uintptr - d := ir.NewConvExpr(pos, ir.OCONVNOP, types.Types[types.TUNSAFEPTR], name) - d.SetTypecheck(1) - d = ir.NewConvExpr(pos, ir.OCONVNOP, types.NewArray(types.Types[types.TUINTPTR], int64(len(targs))).PtrTo(), d) - d.SetTypecheck(1) - types.CheckSize(d.Type().Elem()) - - // Check that each type entry in the dictionary is correct. - for i, t := range targs { - if t.HasShape() { - // Check the concrete type, not the shape type. - base.Fatalf("shape type in dictionary %s %+v\n", name.Sym().Name, t) - } - want := reflectdata.TypePtr(t) - typed(types.Types[types.TUINTPTR], want) - deref := ir.NewStarExpr(pos, d) - typed(d.Type().Elem(), deref) - idx := ir.NewConstExpr(constant.MakeUint64(uint64(i)), name) // TODO: what to set orig to? - typed(types.Types[types.TUINTPTR], idx) - got := ir.NewIndexExpr(pos, deref, idx) - typed(types.Types[types.TUINTPTR], got) - cond := ir.NewBinaryExpr(pos, ir.ONE, want, got) - typed(types.Types[types.TBOOL], cond) - panicArg := ir.NewNilExpr(pos) - typed(types.NewInterface(types.LocalPkg, nil, false), panicArg) - then := ir.NewUnaryExpr(pos, ir.OPANIC, panicArg) - then.SetTypecheck(1) - x := ir.NewIfStmt(pos, cond, []ir.Node{then}, nil) - x.SetTypecheck(1) - code = append(code, x) - } - return -} - // getDictionaryEntry gets the i'th entry in the dictionary dict. func getDictionaryEntry(pos src.XPos, dict *ir.Name, i int, size int) ir.Node { // Convert dictionary to *[N]uintptr -- 2.48.1