]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: remove bad field from itab
authorKeith Randall <khr@golang.org>
Wed, 31 May 2017 16:02:40 +0000 (09:02 -0700)
committerKeith Randall <khr@golang.org>
Tue, 15 Aug 2017 01:52:29 +0000 (01:52 +0000)
Just use fun[0]==0 to indicate a bad itab.

Change-Id: I28ecb2d2d857090c1ecc40b1d1866ac24a844848
Reviewed-on: https://go-review.googlesource.com/44473
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
src/cmd/compile/internal/gc/reflect.go
src/reflect/value.go
src/runtime/iface.go
src/runtime/runtime2.go

index 4490daba24acbd7e2391af5f921d47657ea02733..1b4198d03db92fc509fa9291c261b757b6a3d5ce 100644 (file)
@@ -1459,16 +1459,14 @@ func dumptabs() {
                //   _type  *_type
                //   _      uintptr TODO: remove
                //   hash   uint32
-               //   bad    bool
-               //   _      [3]byte
+               //   _      [4]byte
                //   fun    [1]uintptr // variable sized
                // }
                o := dsymptr(i.lsym, 0, dtypesym(i.itype).Linksym(), 0)
                o = dsymptr(i.lsym, o, dtypesym(i.t).Linksym(), 0)
                o = duintptr(i.lsym, o, 0)             // unused
                o = duint32(i.lsym, o, typehash(i.t))  // copy of type hash
-               o += 1                                 // bad is false
-               o += 3                                 // skip unused fields
+               o += 4                                 // skip unused field
                o += len(imethods(i.itype)) * Widthptr // skip fun method pointers
                // at runtime the itab will contain pointers to types, other itabs and
                // method functions. None are allocated on heap, so we can use obj.NOPTR.
index 21e0878e8027f716a751d233fd1fc7496c8b0f05..9cc68d610f4797abf0fe5914c959c64b2f9facfc 100644 (file)
@@ -184,8 +184,7 @@ type nonEmptyInterface struct {
                typ  *rtype // dynamic concrete type
                _    uintptr
                hash uint32 // copy of typ.hash
-               bad  bool
-               _    [3]byte
+               _    [4]byte
                fun  [100000]unsafe.Pointer // method table
        }
        word unsafe.Pointer
index 3aa2fe6fde16741d2ce43a90801a53a1846c0c81..bac0b37b3a8c88d5f812d1bc804e2ae4e04cab12 100644 (file)
@@ -70,7 +70,7 @@ func getitab(inter *interfacetype, typ *_type, canfail bool) *itab {
        itabAdd(m)
        unlock(&itabLock)
 finish:
-       if !m.bad {
+       if m.fun[0] != 0 {
                return m
        }
        if canfail {
@@ -219,7 +219,7 @@ imethods:
                        }
                }
                // didn't find method
-               m.bad = true
+               m.fun[0] = 0
                return iname
        }
        return ""
index 456b650f5c77115dced521abfc7f7088bec56d84..ebcbe658207308fc60a17794cbfee1ff1a065268 100644 (file)
@@ -628,9 +628,8 @@ type itab struct {
        _type *_type
        _     uintptr
        hash  uint32 // copy of _type.hash. Used for type switches.
-       bad   bool   // type does not implement interface
-       _     [3]byte
-       fun   [1]uintptr // variable sized
+       _     [4]byte
+       fun   [1]uintptr // variable sized. fun[0]==0 means _type does not implement inter.
 }
 
 // Lock-free stack node.