Skip to content

Commit 82a1921

Browse files
prattmicgopherbot
authored andcommitted
all: remove redundant Swiss prefixes
Now that there is only one map implementation we can simplify names. For #54766. Change-Id: I6a6a636cc6a8fc5e7712c27782fc0ced7467b939 Reviewed-on: https://go-review.googlesource.com/c/go/+/691596 Reviewed-by: Keith Randall <[email protected]> Auto-Submit: Michael Pratt <[email protected]> Reviewed-by: Keith Randall <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 2ae059c commit 82a1921

37 files changed

+286
-286
lines changed

src/cmd/compile/internal/reflectdata/map.go

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ import (
1515
"internal/abi"
1616
)
1717

18-
// SwissMapGroupType makes the map slot group type given the type of the map.
19-
func SwissMapGroupType(t *types.Type) *types.Type {
20-
if t.MapType().SwissGroup != nil {
21-
return t.MapType().SwissGroup
18+
// MapGroupType makes the map slot group type given the type of the map.
19+
func MapGroupType(t *types.Type) *types.Type {
20+
if t.MapType().Group != nil {
21+
return t.MapType().Group
2222
}
2323

2424
// Builds a type representing a group structure for the given map type.
@@ -29,7 +29,7 @@ func SwissMapGroupType(t *types.Type) *types.Type {
2929
//
3030
// type group struct {
3131
// ctrl uint64
32-
// slots [abi.SwissMapGroupSlots]struct {
32+
// slots [abi.MapGroupSlots]struct {
3333
// key keyType
3434
// elem elemType
3535
// }
@@ -39,10 +39,10 @@ func SwissMapGroupType(t *types.Type) *types.Type {
3939
elemtype := t.Elem()
4040
types.CalcSize(keytype)
4141
types.CalcSize(elemtype)
42-
if keytype.Size() > abi.SwissMapMaxKeyBytes {
42+
if keytype.Size() > abi.MapMaxKeyBytes {
4343
keytype = types.NewPtr(keytype)
4444
}
45-
if elemtype.Size() > abi.SwissMapMaxElemBytes {
45+
if elemtype.Size() > abi.MapMaxElemBytes {
4646
elemtype = types.NewPtr(elemtype)
4747
}
4848

@@ -53,7 +53,7 @@ func SwissMapGroupType(t *types.Type) *types.Type {
5353
slot := types.NewStruct(slotFields)
5454
slot.SetNoalg(true)
5555

56-
slotArr := types.NewArray(slot, abi.SwissMapGroupSlots)
56+
slotArr := types.NewArray(slot, abi.MapGroupSlots)
5757
slotArr.SetNoalg(true)
5858

5959
fields := []*types.Field{
@@ -76,25 +76,25 @@ func SwissMapGroupType(t *types.Type) *types.Type {
7676
// the end to ensure pointers are valid.
7777
base.Fatalf("bad group size for %v", t)
7878
}
79-
if t.Key().Size() > abi.SwissMapMaxKeyBytes && !keytype.IsPtr() {
79+
if t.Key().Size() > abi.MapMaxKeyBytes && !keytype.IsPtr() {
8080
base.Fatalf("key indirect incorrect for %v", t)
8181
}
82-
if t.Elem().Size() > abi.SwissMapMaxElemBytes && !elemtype.IsPtr() {
82+
if t.Elem().Size() > abi.MapMaxElemBytes && !elemtype.IsPtr() {
8383
base.Fatalf("elem indirect incorrect for %v", t)
8484
}
8585

86-
t.MapType().SwissGroup = group
86+
t.MapType().Group = group
8787
group.StructType().Map = t
8888
return group
8989
}
9090

91-
var cachedSwissTableType *types.Type
91+
var cachedMapTableType *types.Type
9292

93-
// swissTableType returns a type interchangeable with internal/runtime/maps.table.
93+
// mapTableType returns a type interchangeable with internal/runtime/maps.table.
9494
// Make sure this stays in sync with internal/runtime/maps/table.go.
95-
func swissTableType() *types.Type {
96-
if cachedSwissTableType != nil {
97-
return cachedSwissTableType
95+
func mapTableType() *types.Type {
96+
if cachedMapTableType != nil {
97+
return cachedMapTableType
9898
}
9999

100100
// type table struct {
@@ -135,17 +135,17 @@ func swissTableType() *types.Type {
135135
base.Fatalf("internal/runtime/maps.table size not correct: got %d, want %d", table.Size(), size)
136136
}
137137

138-
cachedSwissTableType = table
138+
cachedMapTableType = table
139139
return table
140140
}
141141

142-
var cachedSwissMapType *types.Type
142+
var cachedMapType *types.Type
143143

144-
// SwissMapType returns a type interchangeable with internal/runtime/maps.Map.
144+
// MapType returns a type interchangeable with internal/runtime/maps.Map.
145145
// Make sure this stays in sync with internal/runtime/maps/map.go.
146-
func SwissMapType() *types.Type {
147-
if cachedSwissMapType != nil {
148-
return cachedSwissMapType
146+
func MapType() *types.Type {
147+
if cachedMapType != nil {
148+
return cachedMapType
149149
}
150150

151151
// type Map struct {
@@ -191,23 +191,23 @@ func SwissMapType() *types.Type {
191191
base.Fatalf("internal/runtime/maps.Map size not correct: got %d, want %d", m.Size(), size)
192192
}
193193

194-
cachedSwissMapType = m
194+
cachedMapType = m
195195
return m
196196
}
197197

198-
var cachedSwissIterType *types.Type
198+
var cachedMapIterType *types.Type
199199

200-
// SwissMapIterType returns a type interchangeable with runtime.hiter.
201-
// Make sure this stays in sync with runtime/map.go.
202-
func SwissMapIterType() *types.Type {
203-
if cachedSwissIterType != nil {
204-
return cachedSwissIterType
200+
// MapIterType returns a type interchangeable with internal/runtime/maps.Iter.
201+
// Make sure this stays in sync with internal/runtime/maps/table.go.
202+
func MapIterType() *types.Type {
203+
if cachedMapIterType != nil {
204+
return cachedMapIterType
205205
}
206206

207207
// type Iter struct {
208208
// key unsafe.Pointer // *Key
209209
// elem unsafe.Pointer // *Elem
210-
// typ unsafe.Pointer // *SwissMapType
210+
// typ unsafe.Pointer // *MapType
211211
// m *Map
212212
//
213213
// groupSlotOffset uint64
@@ -231,13 +231,13 @@ func SwissMapIterType() *types.Type {
231231
makefield("key", types.Types[types.TUNSAFEPTR]), // Used in range.go for TMAP.
232232
makefield("elem", types.Types[types.TUNSAFEPTR]), // Used in range.go for TMAP.
233233
makefield("typ", types.Types[types.TUNSAFEPTR]),
234-
makefield("m", types.NewPtr(SwissMapType())),
234+
makefield("m", types.NewPtr(MapType())),
235235
makefield("groupSlotOffset", types.Types[types.TUINT64]),
236236
makefield("dirOffset", types.Types[types.TUINT64]),
237237
makefield("clearSeq", types.Types[types.TUINT64]),
238238
makefield("globalDepth", types.Types[types.TUINT8]),
239239
makefield("dirIdx", types.Types[types.TINT]),
240-
makefield("tab", types.NewPtr(swissTableType())),
240+
makefield("tab", types.NewPtr(mapTableType())),
241241
makefield("group", types.Types[types.TUNSAFEPTR]),
242242
makefield("entryIdx", types.Types[types.TUINT64]),
243243
}
@@ -257,13 +257,13 @@ func SwissMapIterType() *types.Type {
257257
base.Fatalf("internal/runtime/maps.Iter size not correct: got %d, want %d", iter.Size(), size)
258258
}
259259

260-
cachedSwissIterType = iter
260+
cachedMapIterType = iter
261261
return iter
262262
}
263263

264-
func writeSwissMapType(t *types.Type, lsym *obj.LSym, c rttype.Cursor) {
265-
// internal/abi.SwissMapType
266-
gtyp := SwissMapGroupType(t)
264+
func writeMapType(t *types.Type, lsym *obj.LSym, c rttype.Cursor) {
265+
// internal/abi.MapType
266+
gtyp := MapGroupType(t)
267267
s1 := writeType(t.Key())
268268
s2 := writeType(t.Elem())
269269
s3 := writeType(gtyp)
@@ -287,16 +287,16 @@ func writeSwissMapType(t *types.Type, lsym *obj.LSym, c rttype.Cursor) {
287287
c.Field("ElemOff").WriteUintptr(uint64(elemOff))
288288
var flags uint32
289289
if needkeyupdate(t.Key()) {
290-
flags |= abi.SwissMapNeedKeyUpdate
290+
flags |= abi.MapNeedKeyUpdate
291291
}
292292
if hashMightPanic(t.Key()) {
293-
flags |= abi.SwissMapHashMightPanic
293+
flags |= abi.MapHashMightPanic
294294
}
295-
if t.Key().Size() > abi.SwissMapMaxKeyBytes {
296-
flags |= abi.SwissMapIndirectKey
295+
if t.Key().Size() > abi.MapMaxKeyBytes {
296+
flags |= abi.MapIndirectKey
297297
}
298-
if t.Elem().Size() > abi.SwissMapMaxKeyBytes {
299-
flags |= abi.SwissMapIndirectElem
298+
if t.Elem().Size() > abi.MapMaxKeyBytes {
299+
flags |= abi.MapIndirectElem
300300
}
301301
c.Field("Flags").WriteUint32(flags)
302302

src/cmd/compile/internal/reflectdata/reflect.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ func writeType(t *types.Type) *obj.LSym {
872872
}
873873

874874
case types.TMAP:
875-
writeSwissMapType(t, lsym, c)
875+
writeMapType(t, lsym, c)
876876

877877
case types.TPTR:
878878
// internal/abi.PtrType

src/cmd/compile/internal/rttype/rttype.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func Init() {
5454
ChanType = FromReflect(reflect.TypeOf(abi.ChanType{}))
5555
FuncType = FromReflect(reflect.TypeOf(abi.FuncType{}))
5656
InterfaceType = FromReflect(reflect.TypeOf(abi.InterfaceType{}))
57-
MapType = FromReflect(reflect.TypeOf(abi.SwissMapType{}))
57+
MapType = FromReflect(reflect.TypeOf(abi.MapType{}))
5858
PtrType = FromReflect(reflect.TypeOf(abi.PtrType{}))
5959
SliceType = FromReflect(reflect.TypeOf(abi.SliceType{}))
6060
StructType = FromReflect(reflect.TypeOf(abi.StructType{}))

src/cmd/compile/internal/ssagen/intrinsics.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1508,7 +1508,7 @@ func initIntrinsics(cfg *intrinsicBuildConfig) {
15081508
// No PSIGNB, simply do byte equality with ctrlEmpty.
15091509

15101510
// Load ctrlEmpty into each byte of a control word.
1511-
var ctrlsEmpty uint64 = abi.SwissMapCtrlEmpty
1511+
var ctrlsEmpty uint64 = abi.MapCtrlEmpty
15121512
e := s.constInt64(types.Types[types.TUINT64], int64(ctrlsEmpty))
15131513
// Explicit copy to fp register. See
15141514
// https://go.dev/issue/70451.

src/cmd/compile/internal/ssagen/ssa.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func InitConfig() {
9494
_ = types.NewPtr(types.Types[types.TINT16]) // *int16
9595
_ = types.NewPtr(types.Types[types.TINT64]) // *int64
9696
_ = types.NewPtr(types.ErrorType) // *error
97-
_ = types.NewPtr(reflectdata.SwissMapType()) // *internal/runtime/maps.Map
97+
_ = types.NewPtr(reflectdata.MapType()) // *internal/runtime/maps.Map
9898
_ = types.NewPtr(deferstruct()) // *runtime._defer
9999
types.NewPtrCacheEnabled = false
100100
ssaConfig = ssa.NewConfig(base.Ctxt.Arch.Name, *types_, base.Ctxt, base.Flag.N == 0, Arch.SoftFloat)
@@ -3080,7 +3080,7 @@ func (s *state) exprCheckPtr(n ir.Node, checkPtrOK bool) *ssa.Value {
30803080
}
30813081

30823082
// map <--> *internal/runtime/maps.Map
3083-
mt := types.NewPtr(reflectdata.SwissMapType())
3083+
mt := types.NewPtr(reflectdata.MapType())
30843084
if to.Kind() == types.TMAP && from == mt {
30853085
return v
30863086
}
@@ -5752,7 +5752,7 @@ func (s *state) referenceTypeBuiltin(n *ir.UnaryExpr, x *ssa.Value) *ssa.Value {
57525752
case ir.OLEN:
57535753
if n.X.Type().IsMap() {
57545754
// length is stored in the first word, but needs conversion to int.
5755-
loadType := reflectdata.SwissMapType().Field(0).Type // uint64
5755+
loadType := reflectdata.MapType().Field(0).Type // uint64
57565756
load := s.load(loadType, x)
57575757
s.vars[n] = s.conv(nil, load, loadType, lenType) // integer conversion doesn't need Node
57585758
} else {

src/cmd/compile/internal/types/fmt.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ func tconv2(b *bytes.Buffer, t *Type, verb rune, mode fmtMode, visited map[*Type
474474
// Format the bucket struct for map[x]y as map.group[x]y.
475475
// This avoids a recursive print that generates very long names.
476476
switch t {
477-
case mt.SwissGroup:
477+
case mt.Group:
478478
b.WriteString("map.group[")
479479
default:
480480
base.Fatalf("unknown internal map type")

src/cmd/compile/internal/types/type.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ type Map struct {
280280
Key *Type // Key type
281281
Elem *Type // Val (elem) type
282282

283-
SwissGroup *Type // internal struct type representing a slot group
283+
Group *Type // internal struct type representing a slot group
284284
}
285285

286286
// MapType returns t's extra map-specific fields.

src/cmd/compile/internal/walk/builtin.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ func walkMakeChan(n *ir.MakeExpr, init *ir.Nodes) ir.Node {
313313
// walkMakeMap walks an OMAKEMAP node.
314314
func walkMakeMap(n *ir.MakeExpr, init *ir.Nodes) ir.Node {
315315
t := n.Type()
316-
mapType := reflectdata.SwissMapType()
316+
mapType := reflectdata.MapType()
317317
hint := n.Len
318318

319319
// var m *Map
@@ -326,38 +326,38 @@ func walkMakeMap(n *ir.MakeExpr, init *ir.Nodes) ir.Node {
326326
m = stackTempAddr(init, mapType)
327327

328328
// Allocate one group pointed to by m.dirPtr on stack if hint
329-
// is not larger than SwissMapGroupSlots. In case hint is
329+
// is not larger than MapGroupSlots. In case hint is
330330
// larger, runtime.makemap will allocate on the heap.
331331
// Maximum key and elem size is 128 bytes, larger objects
332332
// are stored with an indirection. So max bucket size is 2048+eps.
333333
if !ir.IsConst(hint, constant.Int) ||
334-
constant.Compare(hint.Val(), token.LEQ, constant.MakeInt64(abi.SwissMapGroupSlots)) {
334+
constant.Compare(hint.Val(), token.LEQ, constant.MakeInt64(abi.MapGroupSlots)) {
335335

336-
// In case hint is larger than SwissMapGroupSlots
336+
// In case hint is larger than MapGroupSlots
337337
// runtime.makemap will allocate on the heap, see
338338
// #20184
339339
//
340-
// if hint <= abi.SwissMapGroupSlots {
340+
// if hint <= abi.MapGroupSlots {
341341
// var gv group
342342
// g = &gv
343-
// g.ctrl = abi.SwissMapCtrlEmpty
343+
// g.ctrl = abi.MapCtrlEmpty
344344
// m.dirPtr = g
345345
// }
346346

347-
nif := ir.NewIfStmt(base.Pos, ir.NewBinaryExpr(base.Pos, ir.OLE, hint, ir.NewInt(base.Pos, abi.SwissMapGroupSlots)), nil, nil)
347+
nif := ir.NewIfStmt(base.Pos, ir.NewBinaryExpr(base.Pos, ir.OLE, hint, ir.NewInt(base.Pos, abi.MapGroupSlots)), nil, nil)
348348
nif.Likely = true
349349

350-
groupType := reflectdata.SwissMapGroupType(t)
350+
groupType := reflectdata.MapGroupType(t)
351351

352352
// var gv group
353353
// g = &gv
354354
g := stackTempAddr(&nif.Body, groupType)
355355

356356
// Can't use ir.NewInt because bit 63 is set, which
357357
// makes conversion to uint64 upset.
358-
empty := ir.NewBasicLit(base.Pos, types.UntypedInt, constant.MakeUint64(abi.SwissMapCtrlEmpty))
358+
empty := ir.NewBasicLit(base.Pos, types.UntypedInt, constant.MakeUint64(abi.MapCtrlEmpty))
359359

360-
// g.ctrl = abi.SwissMapCtrlEmpty
360+
// g.ctrl = abi.MapCtrlEmpty
361361
csym := groupType.Field(0).Sym // g.ctrl see reflectdata/map.go
362362
ca := ir.NewAssignStmt(base.Pos, ir.NewSelectorExpr(base.Pos, ir.ODOT, g, csym), empty)
363363
nif.Body.Append(ca)
@@ -370,12 +370,12 @@ func walkMakeMap(n *ir.MakeExpr, init *ir.Nodes) ir.Node {
370370
}
371371
}
372372

373-
if ir.IsConst(hint, constant.Int) && constant.Compare(hint.Val(), token.LEQ, constant.MakeInt64(abi.SwissMapGroupSlots)) {
373+
if ir.IsConst(hint, constant.Int) && constant.Compare(hint.Val(), token.LEQ, constant.MakeInt64(abi.MapGroupSlots)) {
374374
// Handling make(map[any]any) and
375-
// make(map[any]any, hint) where hint <= abi.SwissMapGroupSlots
375+
// make(map[any]any, hint) where hint <= abi.MapGroupSlots
376376
// specially allows for faster map initialization and
377377
// improves binary size by using calls with fewer arguments.
378-
// For hint <= abi.SwissMapGroupSlots no groups will be
378+
// For hint <= abi.MapGroupSlots no groups will be
379379
// allocated by makemap. Therefore, no groups need to be
380380
// allocated in this code path.
381381
if n.Esc() == ir.EscNone {

src/cmd/compile/internal/walk/order.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -966,8 +966,8 @@ func (o *orderState) stmt(n ir.Node) {
966966
n.X = o.copyExpr(r)
967967

968968
// n.Prealloc is the temp for the iterator.
969-
// SwissMapIterType contains pointers and needs to be zeroed.
970-
n.Prealloc = o.newTemp(reflectdata.SwissMapIterType(), true)
969+
// MapIterType contains pointers and needs to be zeroed.
970+
n.Prealloc = o.newTemp(reflectdata.MapIterType(), true)
971971
}
972972
n.Key = o.exprInPlace(n.Key)
973973
n.Value = o.exprInPlace(n.Value)

src/cmd/compile/internal/walk/range.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ func walkRange(nrange *ir.RangeStmt) ir.Node {
246246
hit := nrange.Prealloc
247247
th := hit.Type()
248248
// depends on layout of iterator struct.
249-
// See cmd/compile/internal/reflectdata/map.go:SwissMapIterType
249+
// See cmd/compile/internal/reflectdata/map.go:MapIterType
250250
keysym := th.Field(0).Sym
251251
elemsym := th.Field(1).Sym // ditto
252252
iterInit := "mapIterStart"

0 commit comments

Comments
 (0)