Skip to content

Commit d5a0487

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 0591876 + 93e4e26 commit d5a0487

File tree

26 files changed

+300
-426
lines changed

26 files changed

+300
-426
lines changed

src/cmd/compile/internal/ssa/_gen/generic.rules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@
139139
(Mul64 (Const64 [c]) (Const64 [d])) => (Const64 [c*d])
140140
(Mul32F (Const32F [c]) (Const32F [d])) && c*d == c*d => (Const32F [c*d])
141141
(Mul64F (Const64F [c]) (Const64F [d])) && c*d == c*d => (Const64F [c*d])
142+
(Mul32uhilo (Const32 [c]) (Const32 [d])) => (MakeTuple (Const32 <typ.UInt32> [bitsMulU32(c, d).hi]) (Const32 <typ.UInt32> [bitsMulU32(c,d).lo]))
143+
(Mul64uhilo (Const64 [c]) (Const64 [d])) => (MakeTuple (Const64 <typ.UInt64> [bitsMulU64(c, d).hi]) (Const64 <typ.UInt64> [bitsMulU64(c,d).lo]))
144+
(Mul32uover (Const32 [c]) (Const32 [d])) => (MakeTuple (Const32 <typ.UInt32> [bitsMulU32(c, d).lo]) (ConstBool <typ.Bool> [bitsMulU32(c,d).hi != 0]))
145+
(Mul64uover (Const64 [c]) (Const64 [d])) => (MakeTuple (Const64 <typ.UInt64> [bitsMulU64(c, d).lo]) (ConstBool <typ.Bool> [bitsMulU64(c,d).hi != 0]))
142146

143147
(And8 (Const8 [c]) (Const8 [d])) => (Const8 [c&d])
144148
(And16 (Const16 [c]) (Const16 [d])) => (Const16 [c&d])

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2584,3 +2584,14 @@ func bitsAdd64(x, y, carry int64) (r struct{ sum, carry int64 }) {
25842584
r.sum, r.carry = int64(s), int64(c)
25852585
return
25862586
}
2587+
2588+
func bitsMulU64(x, y int64) (r struct{ hi, lo int64 }) {
2589+
hi, lo := bits.Mul64(uint64(x), uint64(y))
2590+
r.hi, r.lo = int64(hi), int64(lo)
2591+
return
2592+
}
2593+
func bitsMulU32(x, y int32) (r struct{ hi, lo int32 }) {
2594+
hi, lo := bits.Mul32(uint32(x), uint32(y))
2595+
r.hi, r.lo = int32(hi), int32(lo)
2596+
return
2597+
}

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

Lines changed: 108 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cmd/link/internal/loader/loader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2359,8 +2359,8 @@ var blockedLinknames = map[string][]string{
23592359
"crypto/internal/sysrand.fatal": {"crypto/internal/sysrand"},
23602360
"crypto/rand.fatal": {"crypto/rand"},
23612361
"internal/runtime/maps.errNilAssign": {"internal/runtime/maps"},
2362+
"internal/runtime/maps.typeString": {"internal/runtime/maps"},
23622363
"internal/runtime/maps.fatal": {"internal/runtime/maps"},
2363-
"internal/runtime/maps.mapKeyError": {"internal/runtime/maps"},
23642364
"internal/runtime/maps.newarray": {"internal/runtime/maps"},
23652365
"internal/runtime/maps.newobject": {"internal/runtime/maps"},
23662366
"internal/runtime/maps.typedmemclr": {"internal/runtime/maps"},

src/internal/abi/iface.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,9 @@ type EmptyInterface struct {
2525
Type *Type
2626
Data unsafe.Pointer
2727
}
28+
29+
// EmptyInterface describes the layout of an interface that contains any methods.
30+
type NonEmptyInterface struct {
31+
ITab *ITab
32+
Data unsafe.Pointer
33+
}

src/internal/buildcfg/exp.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ func ParseGOEXPERIMENT(goos, goarch, goexp string) (*ExperimentFlags, error) {
6767
regabiSupported = true
6868
}
6969

70-
haveThreads := goarch != "wasm"
71-
7270
// Older versions (anything before V16) of dsymutil don't handle
7371
// the .debug_rnglists section in DWARF5. See
7472
// https://github.com/golang/go/issues/26379#issuecomment-2677068742
@@ -85,7 +83,6 @@ func ParseGOEXPERIMENT(goos, goarch, goexp string) (*ExperimentFlags, error) {
8583
RegabiArgs: regabiSupported,
8684
AliasTypeParams: true,
8785
SwissMap: true,
88-
SpinbitMutex: haveThreads,
8986
SyncHashTrieMap: true,
9087
Dwarf5: dwarf5Supported,
9188
}

src/internal/goexperiment/exp_spinbitmutex_off.go

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/internal/goexperiment/exp_spinbitmutex_on.go

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/internal/goexperiment/flags.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,6 @@ type Flags struct {
115115
// SwissMap enables the SwissTable-based map implementation.
116116
SwissMap bool
117117

118-
// SpinbitMutex enables the new "spinbit" mutex implementation on supported
119-
// platforms. See https://go.dev/issue/68578.
120-
SpinbitMutex bool
121-
122118
// SyncHashTrieMap enables the HashTrieMap sync.Map implementation.
123119
SyncHashTrieMap bool
124120

src/internal/runtime/maps/map.go

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,3 +806,89 @@ func (m *Map) Clone(typ *abi.SwissMapType) *Map {
806806

807807
return m
808808
}
809+
810+
func OldMapKeyError(t *abi.OldMapType, p unsafe.Pointer) error {
811+
if !t.HashMightPanic() {
812+
return nil
813+
}
814+
return mapKeyError2(t.Key, p)
815+
}
816+
817+
func mapKeyError(t *abi.SwissMapType, p unsafe.Pointer) error {
818+
if !t.HashMightPanic() {
819+
return nil
820+
}
821+
return mapKeyError2(t.Key, p)
822+
}
823+
824+
func mapKeyError2(t *abi.Type, p unsafe.Pointer) error {
825+
if t.TFlag&abi.TFlagRegularMemory != 0 {
826+
return nil
827+
}
828+
switch t.Kind() {
829+
case abi.Float32, abi.Float64, abi.Complex64, abi.Complex128, abi.String:
830+
return nil
831+
case abi.Interface:
832+
i := (*abi.InterfaceType)(unsafe.Pointer(t))
833+
var t *abi.Type
834+
var pdata *unsafe.Pointer
835+
if len(i.Methods) == 0 {
836+
a := (*abi.EmptyInterface)(p)
837+
t = a.Type
838+
if t == nil {
839+
return nil
840+
}
841+
pdata = &a.Data
842+
} else {
843+
a := (*abi.NonEmptyInterface)(p)
844+
if a.ITab == nil {
845+
return nil
846+
}
847+
t = a.ITab.Type
848+
pdata = &a.Data
849+
}
850+
851+
if t.Equal == nil {
852+
return unhashableTypeError{t}
853+
}
854+
855+
if t.Kind_&abi.KindDirectIface != 0 {
856+
return mapKeyError2(t, unsafe.Pointer(pdata))
857+
} else {
858+
return mapKeyError2(t, *pdata)
859+
}
860+
case abi.Array:
861+
a := (*abi.ArrayType)(unsafe.Pointer(t))
862+
for i := uintptr(0); i < a.Len; i++ {
863+
if err := mapKeyError2(a.Elem, unsafe.Pointer(uintptr(p)+i*a.Elem.Size_)); err != nil {
864+
return err
865+
}
866+
}
867+
return nil
868+
case abi.Struct:
869+
s := (*abi.StructType)(unsafe.Pointer(t))
870+
for _, f := range s.Fields {
871+
if f.Name.IsBlank() {
872+
continue
873+
}
874+
if err := mapKeyError2(f.Typ, unsafe.Pointer(uintptr(p)+f.Offset)); err != nil {
875+
return err
876+
}
877+
}
878+
return nil
879+
default:
880+
// Should never happen, keep this case for robustness.
881+
return unhashableTypeError{t}
882+
}
883+
}
884+
885+
type unhashableTypeError struct{ typ *abi.Type }
886+
887+
func (unhashableTypeError) RuntimeError() {}
888+
889+
func (e unhashableTypeError) Error() string { return "hash of unhashable type: " + typeString(e.typ) }
890+
891+
// Pushed from runtime
892+
//
893+
//go:linkname typeString
894+
func typeString(typ *abi.Type) string

0 commit comments

Comments
 (0)