]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: disable doubleCheck and remove unused checkDictionary
authorDan Scales <danscales@google.com>
Tue, 9 Nov 2021 02:10:30 +0000 (18:10 -0800)
committerDan Scales <danscales@google.com>
Tue, 9 Nov 2021 16:38:42 +0000 (16:38 +0000)
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 <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

src/cmd/compile/internal/noder/stencil.go

index 4ebd607c160d65c3f296eb1413aab59d1a7ca1a4..cfbbee3cebc99450012ad5833bb797ee2bab96b5 100644 (file)
@@ -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