mirror of
https://github.com/golang/go
synced 2024-11-26 21:31:32 -07:00
cmd/compile: reduce overhead of RParams in types.Type
Changed RParams in types.Type to be a pointer to a slice, rather than a slice itself, in order to reduce it from three words to one words, since the large majority of types will not be generic or instantiated from a generic type. Additional cleanup: remove operation OTYPEINST, which we don't have need of, since all type instantiations are either handled by types2 or happen automatically during some form of stenciling. Both of these are useful cleanups before the Go 1.17 freeze. Change-Id: I61ad56b3c698b30d2cb5a2cdd12263202c54f49c Reviewed-on: https://go-review.googlesource.com/c/go/+/308770 Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> Trust: Dan Scales <danscales@google.com>
This commit is contained in:
parent
4d7d7a4c50
commit
519f223aa2
@ -285,7 +285,6 @@ const (
|
|||||||
// Left is nil if there is no type-switch variable
|
// Left is nil if there is no type-switch variable
|
||||||
OTYPESW
|
OTYPESW
|
||||||
OFUNCINST // instantiation of a generic function
|
OFUNCINST // instantiation of a generic function
|
||||||
OTYPEINST // instantiation of a generic type
|
|
||||||
|
|
||||||
// types
|
// types
|
||||||
OTCHAN // chan int
|
OTCHAN // chan int
|
||||||
|
@ -138,35 +138,34 @@ func _() {
|
|||||||
_ = x[OSWITCH-127]
|
_ = x[OSWITCH-127]
|
||||||
_ = x[OTYPESW-128]
|
_ = x[OTYPESW-128]
|
||||||
_ = x[OFUNCINST-129]
|
_ = x[OFUNCINST-129]
|
||||||
_ = x[OTYPEINST-130]
|
_ = x[OTCHAN-130]
|
||||||
_ = x[OTCHAN-131]
|
_ = x[OTMAP-131]
|
||||||
_ = x[OTMAP-132]
|
_ = x[OTSTRUCT-132]
|
||||||
_ = x[OTSTRUCT-133]
|
_ = x[OTINTER-133]
|
||||||
_ = x[OTINTER-134]
|
_ = x[OTFUNC-134]
|
||||||
_ = x[OTFUNC-135]
|
_ = x[OTARRAY-135]
|
||||||
_ = x[OTARRAY-136]
|
_ = x[OTSLICE-136]
|
||||||
_ = x[OTSLICE-137]
|
_ = x[OINLCALL-137]
|
||||||
_ = x[OINLCALL-138]
|
_ = x[OEFACE-138]
|
||||||
_ = x[OEFACE-139]
|
_ = x[OITAB-139]
|
||||||
_ = x[OITAB-140]
|
_ = x[OIDATA-140]
|
||||||
_ = x[OIDATA-141]
|
_ = x[OSPTR-141]
|
||||||
_ = x[OSPTR-142]
|
_ = x[OCFUNC-142]
|
||||||
_ = x[OCFUNC-143]
|
_ = x[OCHECKNIL-143]
|
||||||
_ = x[OCHECKNIL-144]
|
_ = x[OVARDEF-144]
|
||||||
_ = x[OVARDEF-145]
|
_ = x[OVARKILL-145]
|
||||||
_ = x[OVARKILL-146]
|
_ = x[OVARLIVE-146]
|
||||||
_ = x[OVARLIVE-147]
|
_ = x[ORESULT-147]
|
||||||
_ = x[ORESULT-148]
|
_ = x[OINLMARK-148]
|
||||||
_ = x[OINLMARK-149]
|
_ = x[OLINKSYMOFFSET-149]
|
||||||
_ = x[OLINKSYMOFFSET-150]
|
_ = x[OTAILCALL-150]
|
||||||
_ = x[OTAILCALL-151]
|
_ = x[OGETG-151]
|
||||||
_ = x[OGETG-152]
|
_ = x[OEND-152]
|
||||||
_ = x[OEND-153]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const _Op_name = "XXXNAMENONAMETYPEPACKLITERALNILADDSUBORXORADDSTRADDRANDANDAPPENDBYTES2STRBYTES2STRTMPRUNES2STRSTR2BYTESSTR2BYTESTMPSTR2RUNESASAS2AS2DOTTYPEAS2FUNCAS2MAPRAS2RECVASOPCALLCALLFUNCCALLMETHCALLINTERCALLPARTCAPCLOSECLOSURECOMPLITMAPLITSTRUCTLITARRAYLITSLICELITPTRLITCONVCONVIFACECONVNOPCOPYDCLDCLFUNCDCLCONSTDCLTYPEDELETEDOTDOTPTRDOTMETHDOTINTERXDOTDOTTYPEDOTTYPE2EQNELTLEGEGTDEREFINDEXINDEXMAPKEYSTRUCTKEYLENMAKEMAKECHANMAKEMAPMAKESLICEMAKESLICECOPYMULDIVMODLSHRSHANDANDNOTNEWNOTBITNOTPLUSNEGORORPANICPRINTPRINTNPARENSENDSLICESLICEARRSLICESTRSLICE3SLICE3ARRSLICEHEADERRECOVERRECVRUNESTRSELRECV2IOTAREALIMAGCOMPLEXALIGNOFOFFSETOFSIZEOFMETHEXPRSTMTEXPRBLOCKBREAKCASECONTINUEDEFERFALLFORFORUNTILGOTOIFLABELGORANGERETURNSELECTSWITCHTYPESWFUNCINSTTYPEINSTTCHANTMAPTSTRUCTTINTERTFUNCTARRAYTSLICEINLCALLEFACEITABIDATASPTRCFUNCCHECKNILVARDEFVARKILLVARLIVERESULTINLMARKLINKSYMOFFSETTAILCALLGETGEND"
|
const _Op_name = "XXXNAMENONAMETYPEPACKLITERALNILADDSUBORXORADDSTRADDRANDANDAPPENDBYTES2STRBYTES2STRTMPRUNES2STRSTR2BYTESSTR2BYTESTMPSTR2RUNESASAS2AS2DOTTYPEAS2FUNCAS2MAPRAS2RECVASOPCALLCALLFUNCCALLMETHCALLINTERCALLPARTCAPCLOSECLOSURECOMPLITMAPLITSTRUCTLITARRAYLITSLICELITPTRLITCONVCONVIFACECONVNOPCOPYDCLDCLFUNCDCLCONSTDCLTYPEDELETEDOTDOTPTRDOTMETHDOTINTERXDOTDOTTYPEDOTTYPE2EQNELTLEGEGTDEREFINDEXINDEXMAPKEYSTRUCTKEYLENMAKEMAKECHANMAKEMAPMAKESLICEMAKESLICECOPYMULDIVMODLSHRSHANDANDNOTNEWNOTBITNOTPLUSNEGORORPANICPRINTPRINTNPARENSENDSLICESLICEARRSLICESTRSLICE3SLICE3ARRSLICEHEADERRECOVERRECVRUNESTRSELRECV2IOTAREALIMAGCOMPLEXALIGNOFOFFSETOFSIZEOFMETHEXPRSTMTEXPRBLOCKBREAKCASECONTINUEDEFERFALLFORFORUNTILGOTOIFLABELGORANGERETURNSELECTSWITCHTYPESWFUNCINSTTCHANTMAPTSTRUCTTINTERTFUNCTARRAYTSLICEINLCALLEFACEITABIDATASPTRCFUNCCHECKNILVARDEFVARKILLVARLIVERESULTINLMARKLINKSYMOFFSETTAILCALLGETGEND"
|
||||||
|
|
||||||
var _Op_index = [...]uint16{0, 3, 7, 13, 17, 21, 28, 31, 34, 37, 39, 42, 48, 52, 58, 64, 73, 85, 94, 103, 115, 124, 126, 129, 139, 146, 153, 160, 164, 168, 176, 184, 193, 201, 204, 209, 216, 223, 229, 238, 246, 254, 260, 264, 273, 280, 284, 287, 294, 302, 309, 315, 318, 324, 331, 339, 343, 350, 358, 360, 362, 364, 366, 368, 370, 375, 380, 388, 391, 400, 403, 407, 415, 422, 431, 444, 447, 450, 453, 456, 459, 462, 468, 471, 474, 480, 484, 487, 491, 496, 501, 507, 512, 516, 521, 529, 537, 543, 552, 563, 570, 574, 581, 589, 593, 597, 601, 608, 615, 623, 629, 637, 645, 650, 655, 659, 667, 672, 676, 679, 687, 691, 693, 698, 700, 705, 711, 717, 723, 729, 737, 745, 750, 754, 761, 767, 772, 778, 784, 791, 796, 800, 805, 809, 814, 822, 828, 835, 842, 848, 855, 868, 876, 880, 883}
|
var _Op_index = [...]uint16{0, 3, 7, 13, 17, 21, 28, 31, 34, 37, 39, 42, 48, 52, 58, 64, 73, 85, 94, 103, 115, 124, 126, 129, 139, 146, 153, 160, 164, 168, 176, 184, 193, 201, 204, 209, 216, 223, 229, 238, 246, 254, 260, 264, 273, 280, 284, 287, 294, 302, 309, 315, 318, 324, 331, 339, 343, 350, 358, 360, 362, 364, 366, 368, 370, 375, 380, 388, 391, 400, 403, 407, 415, 422, 431, 444, 447, 450, 453, 456, 459, 462, 468, 471, 474, 480, 484, 487, 491, 496, 501, 507, 512, 516, 521, 529, 537, 543, 552, 563, 570, 574, 581, 589, 593, 597, 601, 608, 615, 623, 629, 637, 645, 650, 655, 659, 667, 672, 676, 679, 687, 691, 693, 698, 700, 705, 711, 717, 723, 729, 737, 742, 746, 753, 759, 764, 770, 776, 783, 788, 792, 797, 801, 806, 814, 820, 827, 834, 840, 847, 860, 868, 872, 875}
|
||||||
|
|
||||||
func (i Op) String() string {
|
func (i Op) String() string {
|
||||||
if i >= Op(len(_Op_index)-1) {
|
if i >= Op(len(_Op_index)-1) {
|
||||||
|
@ -21,7 +21,7 @@ func TestSizeof(t *testing.T) {
|
|||||||
_64bit uintptr // size on 64bit platforms
|
_64bit uintptr // size on 64bit platforms
|
||||||
}{
|
}{
|
||||||
{Sym{}, 44, 72},
|
{Sym{}, 44, 72},
|
||||||
{Type{}, 68, 120},
|
{Type{}, 60, 104},
|
||||||
{Map{}, 20, 40},
|
{Map{}, 20, 40},
|
||||||
{Forward{}, 20, 32},
|
{Forward{}, 20, 32},
|
||||||
{Func{}, 28, 48},
|
{Func{}, 28, 48},
|
||||||
|
@ -178,16 +178,13 @@ type Type struct {
|
|||||||
|
|
||||||
flags bitset8
|
flags bitset8
|
||||||
|
|
||||||
// For defined (named) generic types, the list of type params (in order)
|
// For defined (named) generic types, a pointer to the list of type params
|
||||||
// of this type that need to be instantiated. For fully-instantiated
|
// (in order) of this type that need to be instantiated. For
|
||||||
// generic types, this is the targs used to instantiate them (which are
|
// fully-instantiated generic types, this is the targs used to instantiate
|
||||||
// used when generating the corresponding instantiated methods). rparams
|
// them (which are used when generating the corresponding instantiated
|
||||||
// is only set for named types that are generic or are fully-instantiated
|
// methods). rparams is only set for named types that are generic or are
|
||||||
// from a generic type.
|
// fully-instantiated from a generic type, and is otherwise set to nil.
|
||||||
|
rparams *[]*Type
|
||||||
// TODO(danscales): for space reasons, should probably be a pointer to a
|
|
||||||
// slice, possibly change the name of this field.
|
|
||||||
rparams []*Type
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*Type) CanBeAnSSAAux() {}
|
func (*Type) CanBeAnSSAAux() {}
|
||||||
@ -244,11 +241,17 @@ func (t *Type) Pos() src.XPos {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *Type) RParams() []*Type {
|
func (t *Type) RParams() []*Type {
|
||||||
return t.rparams
|
if t.rparams == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return *t.rparams
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Type) SetRParams(rparams []*Type) {
|
func (t *Type) SetRParams(rparams []*Type) {
|
||||||
t.rparams = rparams
|
if len(rparams) == 0 {
|
||||||
|
base.Fatalf("Setting nil or zero-length rparams")
|
||||||
|
}
|
||||||
|
t.rparams = &rparams
|
||||||
if t.HasTParam() {
|
if t.HasTParam() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user