Commit 98d0634b authored by Keith Randall's avatar Keith Randall

runtime: remove bad field from itab

Just use fun[0]==0 to indicate a bad itab.

Change-Id: I28ecb2d2d857090c1ecc40b1d1866ac24a844848
Reviewed-on: https://go-review.googlesource.com/44473Reviewed-by: default avatarJosh Bleecher Snyder <josharian@gmail.com>
parent 3d1699ea
...@@ -1459,16 +1459,14 @@ func dumptabs() { ...@@ -1459,16 +1459,14 @@ func dumptabs() {
// _type *_type // _type *_type
// _ uintptr TODO: remove // _ uintptr TODO: remove
// hash uint32 // hash uint32
// bad bool // _ [4]byte
// _ [3]byte
// fun [1]uintptr // variable sized // fun [1]uintptr // variable sized
// } // }
o := dsymptr(i.lsym, 0, dtypesym(i.itype).Linksym(), 0) o := dsymptr(i.lsym, 0, dtypesym(i.itype).Linksym(), 0)
o = dsymptr(i.lsym, o, dtypesym(i.t).Linksym(), 0) o = dsymptr(i.lsym, o, dtypesym(i.t).Linksym(), 0)
o = duintptr(i.lsym, o, 0) // unused o = duintptr(i.lsym, o, 0) // unused
o = duint32(i.lsym, o, typehash(i.t)) // copy of type hash o = duint32(i.lsym, o, typehash(i.t)) // copy of type hash
o += 1 // bad is false o += 4 // skip unused field
o += 3 // skip unused fields
o += len(imethods(i.itype)) * Widthptr // skip fun method pointers o += len(imethods(i.itype)) * Widthptr // skip fun method pointers
// at runtime the itab will contain pointers to types, other itabs and // 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. // method functions. None are allocated on heap, so we can use obj.NOPTR.
......
...@@ -184,8 +184,7 @@ type nonEmptyInterface struct { ...@@ -184,8 +184,7 @@ type nonEmptyInterface struct {
typ *rtype // dynamic concrete type typ *rtype // dynamic concrete type
_ uintptr _ uintptr
hash uint32 // copy of typ.hash hash uint32 // copy of typ.hash
bad bool _ [4]byte
_ [3]byte
fun [100000]unsafe.Pointer // method table fun [100000]unsafe.Pointer // method table
} }
word unsafe.Pointer word unsafe.Pointer
......
...@@ -70,7 +70,7 @@ func getitab(inter *interfacetype, typ *_type, canfail bool) *itab { ...@@ -70,7 +70,7 @@ func getitab(inter *interfacetype, typ *_type, canfail bool) *itab {
itabAdd(m) itabAdd(m)
unlock(&itabLock) unlock(&itabLock)
finish: finish:
if !m.bad { if m.fun[0] != 0 {
return m return m
} }
if canfail { if canfail {
...@@ -219,7 +219,7 @@ imethods: ...@@ -219,7 +219,7 @@ imethods:
} }
} }
// didn't find method // didn't find method
m.bad = true m.fun[0] = 0
return iname return iname
} }
return "" return ""
......
...@@ -628,9 +628,8 @@ type itab struct { ...@@ -628,9 +628,8 @@ type itab struct {
_type *_type _type *_type
_ uintptr _ uintptr
hash uint32 // copy of _type.hash. Used for type switches. hash uint32 // copy of _type.hash. Used for type switches.
bad bool // type does not implement interface _ [4]byte
_ [3]byte fun [1]uintptr // variable sized. fun[0]==0 means _type does not implement inter.
fun [1]uintptr // variable sized
} }
// Lock-free stack node. // Lock-free stack node.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment