Skip to content

Commit 391aed0

Browse files
author
Hiro
committed
Merge branch 'master' into chore/github
2 parents ccf6cf8 + f7952bc commit 391aed0

File tree

285 files changed

+7790
-2302
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

285 files changed

+7790
-2302
lines changed

api/next/60665.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pkg crypto/x509, type Certificate struct, Policies []OID #60665
2+
pkg crypto/x509, type OID struct #60665
3+
pkg crypto/x509, method (OID) Equal(OID) bool #60665
4+
pkg crypto/x509, method (OID) EqualASN1OID(asn1.ObjectIdentifier) bool #60665
5+
pkg crypto/x509, method (OID) String() string #60665
6+
pkg crypto/x509, func OIDFromInts([]uint64) (OID, error) #60665

api/next/61716.txt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
pkg math/rand/v2, func ExpFloat64() float64 #61716
2+
pkg math/rand/v2, func Float32() float32 #61716
3+
pkg math/rand/v2, func Float64() float64 #61716
4+
pkg math/rand/v2, func Int() int #61716
5+
pkg math/rand/v2, func Int32() int32 #61716
6+
pkg math/rand/v2, func Int32N(int32) int32 #61716
7+
pkg math/rand/v2, func Int64() int64 #61716
8+
pkg math/rand/v2, func Int64N(int64) int64 #61716
9+
pkg math/rand/v2, func IntN(int) int #61716
10+
pkg math/rand/v2, func N[$0 intType]($0) $0 #61716
11+
pkg math/rand/v2, func New(Source) *Rand #61716
12+
pkg math/rand/v2, func NewPCG(uint64, uint64) *PCG #61716
13+
pkg math/rand/v2, func NewZipf(*Rand, float64, float64, uint64) *Zipf #61716
14+
pkg math/rand/v2, func NormFloat64() float64 #61716
15+
pkg math/rand/v2, func Perm(int) []int #61716
16+
pkg math/rand/v2, func Shuffle(int, func(int, int)) #61716
17+
pkg math/rand/v2, func Uint32() uint32 #61716
18+
pkg math/rand/v2, func Uint32N(uint32) uint32 #61716
19+
pkg math/rand/v2, func Uint64() uint64 #61716
20+
pkg math/rand/v2, func Uint64N(uint64) uint64 #61716
21+
pkg math/rand/v2, func UintN(uint) uint #61716
22+
pkg math/rand/v2, method (*PCG) MarshalBinary() ([]uint8, error) #61716
23+
pkg math/rand/v2, method (*PCG) Seed(uint64, uint64) #61716
24+
pkg math/rand/v2, method (*PCG) Uint64() uint64 #61716
25+
pkg math/rand/v2, method (*PCG) UnmarshalBinary([]uint8) error #61716
26+
pkg math/rand/v2, method (*Rand) ExpFloat64() float64 #61716
27+
pkg math/rand/v2, method (*Rand) Float32() float32 #61716
28+
pkg math/rand/v2, method (*Rand) Float64() float64 #61716
29+
pkg math/rand/v2, method (*Rand) Int() int #61716
30+
pkg math/rand/v2, method (*Rand) Int32() int32 #61716
31+
pkg math/rand/v2, method (*Rand) Int32N(int32) int32 #61716
32+
pkg math/rand/v2, method (*Rand) Int64() int64 #61716
33+
pkg math/rand/v2, method (*Rand) Int64N(int64) int64 #61716
34+
pkg math/rand/v2, method (*Rand) IntN(int) int #61716
35+
pkg math/rand/v2, method (*Rand) NormFloat64() float64 #61716
36+
pkg math/rand/v2, method (*Rand) Perm(int) []int #61716
37+
pkg math/rand/v2, method (*Rand) Shuffle(int, func(int, int)) #61716
38+
pkg math/rand/v2, method (*Rand) Uint32() uint32 #61716
39+
pkg math/rand/v2, method (*Rand) Uint32N(uint32) uint32 #61716
40+
pkg math/rand/v2, method (*Rand) Uint64() uint64 #61716
41+
pkg math/rand/v2, method (*Rand) Uint64N(uint64) uint64 #61716
42+
pkg math/rand/v2, method (*Rand) UintN(uint) uint #61716
43+
pkg math/rand/v2, method (*Zipf) Uint64() uint64 #61716
44+
pkg math/rand/v2, type PCG struct #61716
45+
pkg math/rand/v2, type Rand struct #61716
46+
pkg math/rand/v2, type Source interface { Uint64 } #61716
47+
pkg math/rand/v2, type Source interface, Uint64() uint64 #61716
48+
pkg math/rand/v2, type Zipf struct #61716

api/next/63725.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
pkg debug/elf, const R_LARCH_64_PCREL = 109 #63725
2+
pkg debug/elf, const R_LARCH_64_PCREL R_LARCH #63725
3+
pkg debug/elf, const R_LARCH_ADD6 = 105 #63725
4+
pkg debug/elf, const R_LARCH_ADD6 R_LARCH #63725
5+
pkg debug/elf, const R_LARCH_ADD_ULEB128 = 107 #63725
6+
pkg debug/elf, const R_LARCH_ADD_ULEB128 R_LARCH #63725
7+
pkg debug/elf, const R_LARCH_ALIGN = 102 #63725
8+
pkg debug/elf, const R_LARCH_ALIGN R_LARCH #63725
9+
pkg debug/elf, const R_LARCH_CFA = 104 #63725
10+
pkg debug/elf, const R_LARCH_CFA R_LARCH #63725
11+
pkg debug/elf, const R_LARCH_DELETE = 101 #63725
12+
pkg debug/elf, const R_LARCH_DELETE R_LARCH #63725
13+
pkg debug/elf, const R_LARCH_PCREL20_S2 = 103 #63725
14+
pkg debug/elf, const R_LARCH_PCREL20_S2 R_LARCH #63725
15+
pkg debug/elf, const R_LARCH_SUB6 = 106 #63725
16+
pkg debug/elf, const R_LARCH_SUB6 R_LARCH #63725
17+
pkg debug/elf, const R_LARCH_SUB_ULEB128 = 108 #63725
18+
pkg debug/elf, const R_LARCH_SUB_ULEB128 R_LARCH #63725

doc/go1.22.html

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,7 @@ <h3 id="go-command">Go command</h3>
3939

4040
<h3 id="cgo">Cgo</h3>
4141

42-
<p><!-- CL 497837 --> The special comment that precedes
43-
<code>import</code> <code>"C"</code> may now include two
44-
new <code>#cgo</code> directives.
45-
<ul>
46-
<li>
47-
<code>#cgo</code> <code>noescape</code> <code>cFunctionName</code>
48-
tells cgo that Go pointers passed to the C function
49-
<code>cFunctionName</code> do not escape.
50-
</li>
51-
<li>
52-
<code>#cgo</code> <code>nocallback</code> <code>cFunctionName</code>
53-
tells cgo that the C function <code>cFunctionName</code> does
54-
not call any Go functions.
55-
</li>
56-
</ul>
57-
See <a href="/cmd/cgo#hdr-Optimizing_calls_of_C_code">the <code>cgo</code>
58-
documentation</a> for more details.
59-
</p>
42+
<!-- CL 497837 reverted -->
6043

6144
<h2 id="runtime">Runtime</h2>
6245

doc/go_spec.html

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--{
22
"Title": "The Go Programming Language Specification",
3-
"Subtitle": "Version of Oct 16, 2023",
3+
"Subtitle": "Version of Nov 1, 2023",
44
"Path": "/ref/spec"
55
}-->
66

@@ -6552,8 +6552,9 @@ <h4 id="For_range">For statements with <code>range</code> clause</h4>
65526552

65536553
<p>
65546554
A "for" statement with a "range" clause
6555-
iterates through all entries of an array, slice, string or map,
6556-
or values received on a channel. For each entry it assigns <i>iteration values</i>
6555+
iterates through all entries of an array, slice, string or map, values received on
6556+
a channel, or integer values from zero to an upper limit.
6557+
For each entry it assigns <i>iteration values</i>
65576558
to corresponding <i>iteration variables</i> if present and then executes the block.
65586559
</p>
65596560

@@ -6564,12 +6565,12 @@ <h4 id="For_range">For statements with <code>range</code> clause</h4>
65646565
<p>
65656566
The expression on the right in the "range" clause is called the <i>range expression</i>,
65666567
its <a href="#Core_types">core type</a> must be
6567-
an array, pointer to an array, slice, string, map, or channel permitting
6568-
<a href="#Receive_operator">receive operations</a>.
6568+
an array, pointer to an array, slice, string, map, channel permitting
6569+
<a href="#Receive_operator">receive operations</a>, or an integer.
65696570
As with an assignment, if present the operands on the left must be
65706571
<a href="#Address_operators">addressable</a> or map index expressions; they
6571-
denote the iteration variables. If the range expression is a channel, at most
6572-
one iteration variable is permitted, otherwise there may be up to two.
6572+
denote the iteration variables. If the range expression is a channel or integer,
6573+
at most one iteration variable is permitted, otherwise there may be up to two.
65736574
If the last iteration variable is the <a href="#Blank_identifier">blank identifier</a>,
65746575
the range clause is equivalent to the same clause without that identifier.
65756576
</p>
@@ -6594,6 +6595,7 @@ <h4 id="For_range">For statements with <code>range</code> clause</h4>
65946595
string s string type index i int see below rune
65956596
map m map[K]V key k K m[k] V
65966597
channel c chan E, &lt;-chan E element e E
6598+
integer n integer type I value i I
65976599
</pre>
65986600

65996601
<ol>
@@ -6632,6 +6634,12 @@ <h4 id="For_range">For statements with <code>range</code> clause</h4>
66326634
the channel until the channel is <a href="#Close">closed</a>. If the channel
66336635
is <code>nil</code>, the range expression blocks forever.
66346636
</li>
6637+
6638+
<li>
6639+
For an integer value <code>n</code>, the iteration values 0 through <code>n-1</code>
6640+
are produced in increasing order, with the same type as <code>n</code>.
6641+
If <code>n</code> &lt= 0, the loop does not run any iterations.
6642+
</li>
66356643
</ol>
66366644

66376645
<p>
@@ -6684,6 +6692,12 @@ <h4 id="For_range">For statements with <code>range</code> clause</h4>
66846692

66856693
// empty a channel
66866694
for range ch {}
6695+
6696+
// call f(0), f(1), ... f(9)
6697+
for i := range 10 {
6698+
// type of i is int (default type for untyped constant 10)
6699+
f(i)
6700+
}
66876701
</pre>
66886702

66896703

misc/wasm/go_wasip1_wasm_exec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ case "$GOWASIRUNTIME" in
1414
exec wazero run -mount /:/ -env-inherit -cachedir "${TMPDIR:-/tmp}"/wazero ${GOWASIRUNTIMEARGS:-} "$1" "${@:2}"
1515
;;
1616
"wasmtime" | "")
17-
exec wasmtime run --dir=/ --env PWD="$PWD" --env PATH="$PATH" --max-wasm-stack 1048576 ${GOWASIRUNTIMEARGS:-} "$1" -- "${@:2}"
17+
# TODO(go.dev/issue/63718): Switch to the new CLI offered in the major version 14 of Wasmtime.
18+
exec env WASMTIME_NEW_CLI=0 wasmtime run --dir=/ --env PWD="$PWD" --env PATH="$PATH" --max-wasm-stack 1048576 ${GOWASIRUNTIMEARGS:-} "$1" -- "${@:2}"
1819
;;
1920
*)
2021
echo "Unknown Go WASI runtime specified: $GOWASIRUNTIME"

src/bufio/example_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package bufio_test
66

77
import (
88
"bufio"
9+
"bytes"
910
"fmt"
1011
"os"
1112
"strconv"
@@ -137,3 +138,36 @@ func ExampleScanner_emptyFinalToken() {
137138
}
138139
// Output: "1" "2" "3" "4" ""
139140
}
141+
142+
// Use a Scanner with a custom split function to parse a comma-separated
143+
// list with an empty final value but stops at the token "STOP".
144+
func ExampleScanner_earlyStop() {
145+
onComma := func(data []byte, atEOF bool) (advance int, token []byte, err error) {
146+
i := bytes.IndexByte(data, ',')
147+
if i == -1 {
148+
if !atEOF {
149+
return 0, nil, nil
150+
}
151+
// If we have reached the end, return the last token.
152+
return 0, data, bufio.ErrFinalToken
153+
}
154+
// If the token is "STOP", stop the scanning and ignore the rest.
155+
if string(data[:i]) == "STOP" {
156+
return i + 1, nil, bufio.ErrFinalToken
157+
}
158+
// Otherwise, return the token before the comma.
159+
return i + 1, data[:i], nil
160+
}
161+
const input = "1,2,STOP,4,"
162+
scanner := bufio.NewScanner(strings.NewReader(input))
163+
scanner.Split(onComma)
164+
for scanner.Scan() {
165+
fmt.Printf("Got a token %q\n", scanner.Text())
166+
}
167+
if err := scanner.Err(); err != nil {
168+
fmt.Fprintln(os.Stderr, "reading input:", err)
169+
}
170+
// Output:
171+
// Got a token "1"
172+
// Got a token "2"
173+
}

src/bufio/scan.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ type Scanner struct {
4848
//
4949
// Scanning stops if the function returns an error, in which case some of
5050
// the input may be discarded. If that error is [ErrFinalToken], scanning
51-
// stops with no error.
51+
// stops with no error. A non-nil token delivered with [ErrFinalToken]
52+
// will be the last token, and a nil token with [ErrFinalToken]
53+
// immediately stops the scanning.
5254
//
5355
// Otherwise, the [Scanner] advances the input. If the token is not nil,
5456
// the [Scanner] returns it to the user. If the token is nil, the
@@ -114,18 +116,20 @@ func (s *Scanner) Text() string {
114116
}
115117

116118
// ErrFinalToken is a special sentinel error value. It is intended to be
117-
// returned by a Split function to indicate that the token being delivered
118-
// with the error is the last token and scanning should stop after this one.
119-
// After ErrFinalToken is received by Scan, scanning stops with no error.
119+
// returned by a Split function to indicate that the scanning should stop
120+
// with no error. If the token being delivered with this error is not nil,
121+
// the token is the last token.
122+
//
120123
// The value is useful to stop processing early or when it is necessary to
121-
// deliver a final empty token. One could achieve the same behavior
122-
// with a custom error value but providing one here is tidier.
124+
// deliver a final empty token (which is different from a nil token).
125+
// One could achieve the same behavior with a custom error value but
126+
// providing one here is tidier.
123127
// See the emptyFinalToken example for a use of this value.
124128
var ErrFinalToken = errors.New("final token")
125129

126130
// Scan advances the [Scanner] to the next token, which will then be
127-
// available through the [Scanner.Bytes] or [Scanner.Text] method. It returns false when the
128-
// scan stops, either by reaching the end of the input or an error.
131+
// available through the [Scanner.Bytes] or [Scanner.Text] method. It returns false when
132+
// there are no more tokens, either by reaching the end of the input or an error.
129133
// After Scan returns false, the [Scanner.Err] method will return any error that
130134
// occurred during scanning, except that if it was [io.EOF], [Scanner.Err]
131135
// will return nil.
@@ -148,7 +152,10 @@ func (s *Scanner) Scan() bool {
148152
if err == ErrFinalToken {
149153
s.token = token
150154
s.done = true
151-
return true
155+
// When token is not nil, it means the scanning stops
156+
// with a trailing token, and thus the return value
157+
// should be true to indicate the existence of the token.
158+
return token != nil
152159
}
153160
s.setErr(err)
154161
return false

src/bytes/bytes.go

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -121,25 +121,7 @@ func LastIndex(s, sep []byte) int {
121121
case n > len(s):
122122
return -1
123123
}
124-
// Rabin-Karp search from the end of the string
125-
hashss, pow := bytealg.HashStrRevBytes(sep)
126-
last := len(s) - n
127-
var h uint32
128-
for i := len(s) - 1; i >= last; i-- {
129-
h = h*bytealg.PrimeRK + uint32(s[i])
130-
}
131-
if h == hashss && Equal(s[last:], sep) {
132-
return last
133-
}
134-
for i := last - 1; i >= 0; i-- {
135-
h *= bytealg.PrimeRK
136-
h += uint32(s[i])
137-
h -= pow * uint32(s[i+n])
138-
if h == hashss && Equal(s[i:i+n], sep) {
139-
return i
140-
}
141-
}
142-
return -1
124+
return bytealg.LastIndexRabinKarp(s, sep)
143125
}
144126

145127
// LastIndexByte returns the index of the last instance of c in s, or -1 if c is not present in s.
@@ -1331,7 +1313,7 @@ func Index(s, sep []byte) int {
13311313
// we should cutover at even larger average skips,
13321314
// because Equal becomes that much more expensive.
13331315
// This code does not take that effect into account.
1334-
j := bytealg.IndexRabinKarpBytes(s[i:], sep)
1316+
j := bytealg.IndexRabinKarp(s[i:], sep)
13351317
if j < 0 {
13361318
return -1
13371319
}

src/cmd/asm/internal/asm/testdata/ppc64.s

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,9 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
179179
ADD $-32768, R6 // 38c68000
180180
ADD $-32768, R6, R5 // 38a68000
181181
// Hex constant 0xFFFFFFFE00000000
182-
ADD $-8589934592, R5 // 3fe0fffe63ff00007bff83e463ff00007cbf2a14 or 0602000038a50000
182+
ADD $-8589934592, R5 // 3fe0fffe600000007bff83e4600000007cbf2a14 or 0602000038a50000
183+
// Hex constant 0xFFFFFFFE00010001
184+
ADD $-8589869055, R5 // 3fe0fffe63ff00017bff83e463ff00017cbf2a14 or 0602000138a50001
183185

184186
//TODO: this compiles to add r5,r6,r0. It should be addi r5,r6,0.
185187
// this is OK since r0 == $0, but the latter is preferred.
@@ -223,6 +225,8 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
223225
OR $-32768, R6, R7 // 3be080007fe73378
224226
OR $1234567, R5 // 641f001263ffd6877fe52b78
225227
OR $1234567, R5, R3 // 641f001263ffd6877fe32b78
228+
OR $2147483648, R5, R3 // 641f8000600000007fe32b78
229+
OR $2147483649, R5, R3 // 641f800063ff00017fe32b78
226230
ORIS $255, R3, R4
227231

228232
XOR $1, R3 // 68630001
@@ -249,7 +253,6 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
249253
CMPB R3,R4,R4 // 7c6423f8
250254
CMPEQB R3,R4,CR6 // 7f0321c0
251255

252-
// TODO: constants for ADDC?
253256
ADD R3, R4 // 7c841a14
254257
ADD R3, R4, R5 // 7ca41a14
255258
ADDC R3, R4 // 7c841814
@@ -262,6 +265,8 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
262265
ADDV R3, R4 // 7c841e14
263266
ADDVCC R3, R4 // 7c841e15
264267
ADDCCC R3, R4, R5 // 7ca41815
268+
ADDCCC $65536, R4, R5 // 641f0001600000007cbf2015
269+
ADDCCC $65537, R4, R5 // 641f000163ff00017cbf2015
265270
ADDME R3, R4 // 7c8301d4
266271
ADDMECC R3, R4 // 7c8301d5
267272
ADDMEV R3, R4 // 7c8305d4
@@ -315,6 +320,8 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
315320
SUBECC R3, R4, R5 // 7ca32111
316321
SUBEV R3, R4, R5 // 7ca32510
317322
SUBEVCC R3, R4, R5 // 7ca32511
323+
SUBC R3, $65536, R4 // 3fe00001600000007c83f810
324+
SUBC R3, $65537, R4 // 3fe0000163ff00017c83f810
318325

319326
MULLW R3, R4 // 7c8419d6
320327
MULLW R3, R4, R5 // 7ca419d6

0 commit comments

Comments
 (0)