mirror of
https://github.com/golang/go
synced 2024-09-28 18:14:29 -06:00
[dev.boringcrypto] all: merge master into dev.boringcrypto
Conflicts due to randutil.MaybeReadByte (kept at the top for patch maintainability and consistency): src/crypto/ecdsa/ecdsa.go src/crypto/rsa/pkcs1v15.go src/crypto/rsa/rsa.go Change-Id: I03a2de541e68a1bbdc48590ad7c01fbffbbf4a2b
This commit is contained in:
commit
a4b7722ffa
@ -19,14 +19,14 @@ BSD-style license found in the LICENSE file.
|
||||
Official binary distributions are available at https://golang.org/dl/.
|
||||
|
||||
After downloading a binary release, visit https://golang.org/doc/install
|
||||
or load doc/install.html in your web browser for installation
|
||||
or load [doc/install.html](./doc/install.html) in your web browser for installation
|
||||
instructions.
|
||||
|
||||
#### Install From Source
|
||||
|
||||
If a binary distribution is not available for your combination of
|
||||
operating system and architecture, visit
|
||||
https://golang.org/doc/install/source or load doc/install-source.html
|
||||
https://golang.org/doc/install/source or load [doc/install-source.html](./doc/install-source.html)
|
||||
in your web browser for source installation instructions.
|
||||
|
||||
### Contributing
|
||||
|
@ -48,6 +48,15 @@ See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.10.2">Go
|
||||
1.10.2 milestone</a> on our issue tracker for details.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
go1.10.3 (released 2018/06/05) includes fixes to the go command, and the
|
||||
<code>crypto/tls</code>, <code>crypto/x509</code>, and <code>strings</code> packages.
|
||||
In particular, it adds <a href="https://go.googlesource.com/go/+/d4e21288e444d3ffd30d1a0737f15ea3fc3b8ad9">
|
||||
minimal support to the go command for the vgo transition</a>.
|
||||
See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.10.3">Go
|
||||
1.10.3 milestone</a> on our issue tracker for details.
|
||||
</p>
|
||||
|
||||
<h2 id="go1.9">go1.9 (released 2017/08/24)</h2>
|
||||
|
||||
<p>
|
||||
@ -101,6 +110,15 @@ See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.9.6">Go
|
||||
1.9.6 milestone</a> on our issue tracker for details.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
go1.9.7 (released 2018/06/05) includes fixes to the go command, and the
|
||||
<code>crypto/x509</code>, and <code>strings</code> packages.
|
||||
In particular, it adds <a href="https://go.googlesource.com/go/+/d4e21288e444d3ffd30d1a0737f15ea3fc3b8ad9">
|
||||
minimal support to the go command for the vgo transition</a>.
|
||||
See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.9.7">Go
|
||||
1.9.7 milestone</a> on our issue tracker for details.
|
||||
</p>
|
||||
|
||||
|
||||
<h2 id="go1.8">go1.8 (released 2017/02/16)</h2>
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// cmpout -tags=use_go_run
|
||||
// run -tags=use_go_run
|
||||
|
||||
// Copyright 2010 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
|
@ -1,4 +1,4 @@
|
||||
// cmpout -tags=use_go_run
|
||||
// run -tags=use_go_run
|
||||
|
||||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
|
@ -1,4 +1,4 @@
|
||||
// cmpout -tags=use_go_run
|
||||
// run -tags=use_go_run
|
||||
|
||||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
|
@ -1,4 +1,4 @@
|
||||
// cmpout -tags=use_go_run
|
||||
// run -tags=use_go_run
|
||||
|
||||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
|
@ -51,7 +51,7 @@
|
||||
|
||||
global.Go = class {
|
||||
constructor() {
|
||||
this.argv = [];
|
||||
this.argv = ["js"];
|
||||
this.env = {};
|
||||
this.exit = (code) => {
|
||||
if (code !== 0) {
|
||||
@ -143,6 +143,11 @@
|
||||
mem().setInt32(sp + 16, (msec % 1000) * 1000000, true);
|
||||
},
|
||||
|
||||
// func getRandomData(r []byte)
|
||||
"runtime.getRandomData": (sp) => {
|
||||
crypto.getRandomValues(loadSlice(sp + 8));
|
||||
},
|
||||
|
||||
// func boolVal(value bool) Value
|
||||
"syscall/js.boolVal": (sp) => {
|
||||
storeValue(sp + 16, mem().getUint8(sp + 8) !== 0);
|
||||
|
@ -94,7 +94,7 @@ const (
|
||||
// application can only parse GNU formatted archives.
|
||||
//
|
||||
// Reference:
|
||||
// http://www.gnu.org/software/tar/manual/html_node/Standard.html
|
||||
// https://www.gnu.org/software/tar/manual/html_node/Standard.html
|
||||
FormatGNU
|
||||
|
||||
// Schily's tar format, which is incompatible with USTAR.
|
||||
|
@ -202,7 +202,7 @@ func timeZone(offset time.Duration) *time.Location {
|
||||
|
||||
// msDosTimeToTime converts an MS-DOS date and time into a time.Time.
|
||||
// The resolution is 2s.
|
||||
// See: http://msdn.microsoft.com/en-us/library/ms724247(v=VS.85).aspx
|
||||
// See: https://msdn.microsoft.com/en-us/library/ms724247(v=VS.85).aspx
|
||||
func msDosTimeToTime(dosDate, dosTime uint16) time.Time {
|
||||
return time.Date(
|
||||
// date bits 0-4: day of month; 5-8: month; 9-15: years since 1980
|
||||
@ -222,7 +222,7 @@ func msDosTimeToTime(dosDate, dosTime uint16) time.Time {
|
||||
|
||||
// timeToMsDosTime converts a time.Time to an MS-DOS date and time.
|
||||
// The resolution is 2s.
|
||||
// See: http://msdn.microsoft.com/en-us/library/ms724274(v=VS.85).aspx
|
||||
// See: https://msdn.microsoft.com/en-us/library/ms724274(v=VS.85).aspx
|
||||
func timeToMsDosTime(t time.Time) (fDate uint16, fTime uint16) {
|
||||
fDate = uint16(t.Day() + int(t.Month())<<5 + (t.Year()-1980)<<9)
|
||||
fTime = uint16(t.Second()/2 + t.Minute()<<5 + t.Hour()<<11)
|
||||
|
@ -72,7 +72,7 @@ func (w *Writer) SetComment(comment string) error {
|
||||
}
|
||||
|
||||
// Close finishes writing the zip file by writing the central directory.
|
||||
// It does not (and cannot) close the underlying writer.
|
||||
// It does not close the underlying writer.
|
||||
func (w *Writer) Close() error {
|
||||
if w.last != nil && !w.last.closed {
|
||||
if err := w.last.close(); err != nil {
|
||||
|
@ -202,6 +202,7 @@ func (b *Buffer) ReadFrom(r io.Reader) (n int64, err error) {
|
||||
b.lastRead = opInvalid
|
||||
for {
|
||||
i := b.grow(MinRead)
|
||||
b.buf = b.buf[:i]
|
||||
m, e := r.Read(b.buf[i:cap(b.buf)])
|
||||
if m < 0 {
|
||||
panic(errNegativeRead)
|
||||
|
@ -269,6 +269,39 @@ func TestReadFrom(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
type panicReader struct{ panic bool }
|
||||
|
||||
func (r panicReader) Read(p []byte) (int, error) {
|
||||
if r.panic {
|
||||
panic(nil)
|
||||
}
|
||||
return 0, io.EOF
|
||||
}
|
||||
|
||||
// Make sure that an empty Buffer remains empty when
|
||||
// it is "grown" before a Read that panics
|
||||
func TestReadFromPanicReader(t *testing.T) {
|
||||
|
||||
// First verify non-panic behaviour
|
||||
var buf Buffer
|
||||
i, err := buf.ReadFrom(panicReader{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if i != 0 {
|
||||
t.Fatalf("unexpected return from bytes.ReadFrom (1): got: %d, want %d", i, 0)
|
||||
}
|
||||
check(t, "TestReadFromPanicReader (1)", &buf, "")
|
||||
|
||||
// Confirm that when Reader panics, the emtpy buffer remains empty
|
||||
var buf2 Buffer
|
||||
defer func() {
|
||||
recover()
|
||||
check(t, "TestReadFromPanicReader (2)", &buf2, "")
|
||||
}()
|
||||
buf2.ReadFrom(panicReader{panic: true})
|
||||
}
|
||||
|
||||
func TestReadFromNegativeReader(t *testing.T) {
|
||||
var b Buffer
|
||||
defer func() {
|
||||
|
678
src/cmd/asm/internal/asm/testdata/amd64enc_extra.s
vendored
678
src/cmd/asm/internal/asm/testdata/amd64enc_extra.s
vendored
@ -371,5 +371,683 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
|
||||
VPEXTRB $-1, X1, AX // c4e37914c8ff
|
||||
VPEXTRD $-1, X1, AX // c4e37916c8ff
|
||||
VPEXTRQ $-1, X1, AX // c4e3f916c8ff
|
||||
// EVEX: High-16 X registers.
|
||||
VADDPD X30, X1, X0 // 6291f50858c6
|
||||
VADDPD X2, X29, X0 // 62f1950058c2
|
||||
VADDPD X30, X29, X0 // 6291950058c6
|
||||
VADDPD X2, X1, X28 // 6261f50858e2
|
||||
VADDPD X30, X1, X28 // 6201f50858e6
|
||||
VADDPD X2, X29, X28 // 6261950058e2
|
||||
VADDPD X30, X29, X28 // 6201950058e6
|
||||
VADDPD X30, X11, X10 // 6211a50858d6
|
||||
VADDPD X12, X29, X10 // 6251950058d4
|
||||
VADDPD X30, X29, X10 // 6211950058d6
|
||||
VADDPD X12, X11, X28 // 6241a50858e4
|
||||
VADDPD X30, X11, X28 // 6201a50858e6
|
||||
VADDPD X12, X29, X28 // 6241950058e4
|
||||
VADDPD X30, X29, X28 // 6201950058e6
|
||||
VADDPD (AX), X29, X0 // 62f195005800
|
||||
VADDPD (AX), X1, X28 // 6261f5085820
|
||||
VADDPD (AX), X29, X28 // 626195005820
|
||||
VADDPD (AX), X29, X10 // 627195005810
|
||||
VADDPD (AX), X10, X28 // 6261ad085820
|
||||
VADDPD (CX)(AX*1), X29, X0 // 62f19500580401
|
||||
VADDPD (CX)(AX*1), X1, X28 // 6261f508582401
|
||||
VADDPD (CX)(AX*1), X29, X28 // 62619500582401
|
||||
VADDPD (CX)(AX*1), X29, X10 // 62719500581401
|
||||
VADDPD (CX)(AX*1), X10, X28 // 6261ad08582401
|
||||
VADDPD (CX)(AX*2), X29, X0 // 62f19500580441
|
||||
VADDPD (CX)(AX*2), X1, X28 // 6261f508582441
|
||||
VADDPD (CX)(AX*2), X29, X28 // 62619500582441
|
||||
VADDPD (CX)(AX*2), X29, X10 // 62719500581441
|
||||
VADDPD (CX)(AX*2), X10, X28 // 6261ad08582441
|
||||
// EVEX: displacement without Disp8.
|
||||
VADDPD 15(AX), X29, X0 // 62f1950058800f000000
|
||||
VADDPD 15(AX), X1, X28 // 6261f50858a00f000000
|
||||
VADDPD 15(AX), X29, X28 // 6261950058a00f000000
|
||||
VADDPD 15(AX), X29, X10 // 6271950058900f000000
|
||||
VADDPD 15(AX), X10, X28 // 6261ad0858a00f000000
|
||||
VADDPD 15(CX)(AX*1), X29, X0 // 62f195005884010f000000
|
||||
VADDPD 15(CX)(AX*1), X1, X28 // 6261f50858a4010f000000
|
||||
VADDPD 15(CX)(AX*1), X29, X28 // 6261950058a4010f000000
|
||||
VADDPD 15(CX)(AX*1), X29, X10 // 627195005894010f000000
|
||||
VADDPD 15(CX)(AX*1), X10, X28 // 6261ad0858a4010f000000
|
||||
VADDPD 15(CX)(AX*2), X29, X0 // 62f195005884410f000000
|
||||
VADDPD 15(CX)(AX*2), X1, X28 // 6261f50858a4410f000000
|
||||
VADDPD 15(CX)(AX*2), X29, X28 // 6261950058a4410f000000
|
||||
VADDPD 15(CX)(AX*2), X29, X10 // 627195005894410f000000
|
||||
VADDPD 15(CX)(AX*2), X10, X28 // 6261ad0858a4410f000000
|
||||
// EVEX: compressed displacement (Disp8).
|
||||
VADDPD 2032(DX), X29, X0 // 62f1950058427f
|
||||
VADDPD 2032(DX), X1, X29 // 6261f508586a7f
|
||||
VADDPD 2032(DX), X29, X28 // 6261950058627f
|
||||
VADDPD 2032(DX)(AX*2), X29, X0 // 62f195005844427f
|
||||
VADDPD 2032(DX)(AX*2), X1, X29 // 6261f508586c427f
|
||||
VADDPD 2032(DX)(AX*2), X29, X28 // 626195005864427f
|
||||
VADDPD 4064(DX), Y0, Y29 // 6261fd28586a7f
|
||||
VADDPD 4064(DX), Y29, Y1 // 62f19520584a7f
|
||||
VADDPD 4064(DX), Y28, Y29 // 62619d20586a7f
|
||||
VADDPD 4064(DX)(AX*2), Y0, Y29 // 6261fd28586c427f
|
||||
VADDPD 4064(DX)(AX*2), Y29, Y1 // 62f19520584c427f
|
||||
VADDPD 8128(DX), Z0, Z29 // 6261fd48586a7f
|
||||
VADDPD 8128(DX), Z29, Z1 // 62f19540584a7f
|
||||
VADDPD 8128(DX), Z28, Z29 // 62619d40586a7f
|
||||
VADDPD 8128(DX)(AX*2), Z0, Z29 // 6261fd48586c427f
|
||||
VADDPD 8128(DX)(AX*2), Z29, Z1 // 62f19540584c427f
|
||||
// EVEX: compressed displacement that does not fit into 8bits.
|
||||
VADDPD 2048(DX), X29, X0 // 62f19500588200080000
|
||||
VADDPD 2048(DX), X1, X29 // 6261f50858aa00080000
|
||||
VADDPD 2048(DX), X29, X28 // 6261950058a200080000
|
||||
VADDPD 2048(DX)(AX*2), X29, X0 // 62f1950058844200080000
|
||||
VADDPD 2048(DX)(AX*2), X1, X29 // 6261f50858ac4200080000
|
||||
VADDPD 2048(DX)(AX*2), X29, X28 // 6261950058a44200080000
|
||||
VADDPD 4096(DX), Y0, Y29 // 6261fd2858aa00100000
|
||||
VADDPD 4096(DX), Y29, Y1 // 62f19520588a00100000
|
||||
VADDPD 4096(DX), Y28, Y29 // 62619d2058aa00100000
|
||||
VADDPD 4096(DX)(AX*2), Y0, Y29 // 6261fd2858ac4200100000
|
||||
VADDPD 4096(DX)(AX*2), Y29, Y1 // 62f19520588c4200100000
|
||||
VADDPD 8192(DX), Z0, Z29 // 6261fd4858aa00200000
|
||||
VADDPD 8192(DX), Z29, Z1 // 62f19540588a00200000
|
||||
VADDPD 8192(DX), Z28, Z29 // 62619d4058aa00200000
|
||||
VADDPD 8192(DX)(AX*2), Z0, Z29 // 6261fd4858ac4200200000
|
||||
VADDPD 8192(DX)(AX*2), Z29, Z1 // 62f19540588c4200200000
|
||||
// EVEX: Y registers; VL=256.
|
||||
VADDPD Y30, Y1, Y0 // 6291f52858c6
|
||||
VADDPD Y0, Y29, Y2 // 62f1952058d0
|
||||
VADDPD Y0, Y29, Y30 // 6261952058f0
|
||||
VADDPD Y28, Y1, Y2 // 6291f52858d4
|
||||
VADDPD Y28, Y1, Y30 // 6201f52858f4
|
||||
VADDPD Y28, Y29, Y2 // 6291952058d4
|
||||
VADDPD Y28, Y29, Y30 // 6201952058f4
|
||||
VADDPD Y10, Y11, Y30 // 6241a52858f2
|
||||
VADDPD Y10, Y29, Y12 // 6251952058e2
|
||||
VADDPD Y10, Y29, Y30 // 6241952058f2
|
||||
VADDPD Y28, Y11, Y12 // 6211a52858e4
|
||||
VADDPD Y28, Y11, Y30 // 6201a52858f4
|
||||
VADDPD Y28, Y29, Y12 // 6211952058e4
|
||||
VADDPD Y28, Y29, Y30 // 6201952058f4
|
||||
VADDPD (AX), Y29, Y0 // 62f195205800
|
||||
VADDPD (AX), Y1, Y28 // 6261f5285820
|
||||
VADDPD (AX), Y29, Y28 // 626195205820
|
||||
VADDPD (AX), Y29, Y10 // 627195205810
|
||||
VADDPD (AX), Y10, Y28 // 6261ad285820
|
||||
VADDPD (CX)(AX*1), Y29, Y0 // 62f19520580401
|
||||
VADDPD (CX)(AX*1), Y1, Y28 // 6261f528582401
|
||||
VADDPD (CX)(AX*1), Y29, Y28 // 62619520582401
|
||||
VADDPD (CX)(AX*1), Y29, Y10 // 62719520581401
|
||||
VADDPD (CX)(AX*1), Y10, Y28 // 6261ad28582401
|
||||
VADDPD (CX)(AX*2), Y29, Y0 // 62f19520580441
|
||||
VADDPD (CX)(AX*2), Y1, Y28 // 6261f528582441
|
||||
VADDPD (CX)(AX*2), Y29, Y28 // 62619520582441
|
||||
VADDPD (CX)(AX*2), Y29, Y10 // 62719520581441
|
||||
VADDPD (CX)(AX*2), Y10, Y28 // 6261ad28582441
|
||||
VADDPD 15(AX), Y0, Y29 // 6261fd2858a80f000000
|
||||
VADDPD 15(AX), Y28, Y1 // 62f19d2058880f000000
|
||||
VADDPD 15(AX), Y28, Y29 // 62619d2058a80f000000
|
||||
VADDPD 15(AX), Y10, Y29 // 6261ad2858a80f000000
|
||||
VADDPD 15(AX), Y28, Y10 // 62719d2058900f000000
|
||||
VADDPD 15(CX)(AX*1), Y0, Y29 // 6261fd2858ac010f000000
|
||||
VADDPD 15(CX)(AX*1), Y28, Y1 // 62f19d20588c010f000000
|
||||
VADDPD 15(CX)(AX*1), Y28, Y29 // 62619d2058ac010f000000
|
||||
VADDPD 15(CX)(AX*1), Y10, Y29 // 6261ad2858ac010f000000
|
||||
VADDPD 15(CX)(AX*1), Y28, Y10 // 62719d205894010f000000
|
||||
VADDPD 15(CX)(AX*2), Y0, Y29 // 6261fd2858ac410f000000
|
||||
VADDPD 15(CX)(AX*2), Y28, Y1 // 62f19d20588c410f000000
|
||||
VADDPD 15(CX)(AX*2), Y28, Y29 // 62619d2058ac410f000000
|
||||
VADDPD 15(CX)(AX*2), Y10, Y29 // 6261ad2858ac410f000000
|
||||
VADDPD 15(CX)(AX*2), Y28, Y10 // 62719d205894410f000000
|
||||
VADDPD 2048(DX), Y0, Y29 // 6261fd28586a40
|
||||
VADDPD 2048(DX), Y29, Y1 // 62f19520584a40
|
||||
VADDPD 2048(DX), Y28, Y29 // 62619d20586a40
|
||||
VADDPD 2048(DX)(AX*2), Y0, Y29 // 6261fd28586c4240
|
||||
VADDPD 2048(DX)(AX*2), Y29, Y1 // 62f19520584c4240
|
||||
VADDPD 2048(DX)(AX*2), Y28, Y29 // 62619d20586c4240
|
||||
// EVEX: Z registers; VL=512.
|
||||
VADDPD Z30, Z0, Z1 // 6291fd4858ce
|
||||
VADDPD Z0, Z2, Z29 // 6261ed4858e8
|
||||
VADDPD Z0, Z30, Z29 // 62618d4058e8
|
||||
VADDPD Z28, Z2, Z1 // 6291ed4858cc
|
||||
VADDPD Z28, Z30, Z1 // 62918d4058cc
|
||||
VADDPD Z28, Z2, Z29 // 6201ed4858ec
|
||||
VADDPD Z28, Z30, Z29 // 62018d4058ec
|
||||
VADDPD Z10, Z30, Z11 // 62518d4058da
|
||||
VADDPD Z10, Z12, Z29 // 62419d4858ea
|
||||
VADDPD Z10, Z30, Z29 // 62418d4058ea
|
||||
VADDPD Z28, Z12, Z11 // 62119d4858dc
|
||||
VADDPD Z28, Z30, Z11 // 62118d4058dc
|
||||
VADDPD Z28, Z12, Z29 // 62019d4858ec
|
||||
VADDPD Z28, Z30, Z29 // 62018d4058ec
|
||||
VADDPD (AX), Z0, Z29 // 6261fd485828
|
||||
VADDPD (AX), Z28, Z1 // 62f19d405808
|
||||
VADDPD (AX), Z28, Z29 // 62619d405828
|
||||
VADDPD (AX), Z10, Z29 // 6261ad485828
|
||||
VADDPD (AX), Z28, Z10 // 62719d405810
|
||||
VADDPD (CX)(AX*1), Z0, Z29 // 6261fd48582c01
|
||||
VADDPD (CX)(AX*1), Z28, Z1 // 62f19d40580c01
|
||||
VADDPD (CX)(AX*1), Z28, Z29 // 62619d40582c01
|
||||
VADDPD (CX)(AX*1), Z10, Z29 // 6261ad48582c01
|
||||
VADDPD (CX)(AX*1), Z28, Z10 // 62719d40581401
|
||||
VADDPD (CX)(AX*2), Z0, Z29 // 6261fd48582c41
|
||||
VADDPD (CX)(AX*2), Z28, Z1 // 62f19d40580c41
|
||||
VADDPD (CX)(AX*2), Z28, Z29 // 62619d40582c41
|
||||
VADDPD (CX)(AX*2), Z10, Z29 // 6261ad48582c41
|
||||
VADDPD (CX)(AX*2), Z28, Z10 // 62719d40581441
|
||||
VADDPD 15(AX), Z29, Z0 // 62f1954058800f000000
|
||||
VADDPD 15(AX), Z1, Z28 // 6261f54858a00f000000
|
||||
VADDPD 15(AX), Z29, Z28 // 6261954058a00f000000
|
||||
VADDPD 15(AX), Z29, Z10 // 6271954058900f000000
|
||||
VADDPD 15(AX), Z10, Z28 // 6261ad4858a00f000000
|
||||
VADDPD 15(CX)(AX*1), Z29, Z0 // 62f195405884010f000000
|
||||
VADDPD 15(CX)(AX*1), Z1, Z28 // 6261f54858a4010f000000
|
||||
VADDPD 15(CX)(AX*1), Z29, Z28 // 6261954058a4010f000000
|
||||
VADDPD 15(CX)(AX*1), Z29, Z10 // 627195405894010f000000
|
||||
VADDPD 15(CX)(AX*1), Z10, Z28 // 6261ad4858a4010f000000
|
||||
VADDPD 15(CX)(AX*2), Z29, Z0 // 62f195405884410f000000
|
||||
VADDPD 15(CX)(AX*2), Z1, Z28 // 6261f54858a4410f000000
|
||||
VADDPD 15(CX)(AX*2), Z29, Z28 // 6261954058a4410f000000
|
||||
VADDPD 15(CX)(AX*2), Z29, Z10 // 627195405894410f000000
|
||||
VADDPD 15(CX)(AX*2), Z10, Z28 // 6261ad4858a4410f000000
|
||||
VADDPD 2048(DX), Z29, Z0 // 62f19540584220
|
||||
VADDPD 2048(DX), Z1, Z29 // 6261f548586a20
|
||||
VADDPD 2048(DX), Z29, Z28 // 62619540586220
|
||||
VADDPD 2048(DX)(AX*2), Z29, Z0 // 62f1954058444220
|
||||
VADDPD 2048(DX)(AX*2), Z1, Z29 // 6261f548586c4220
|
||||
VADDPD 2048(DX)(AX*2), Z29, Z28 // 6261954058644220
|
||||
// EVEX: KOP (opmask) instructions.
|
||||
KMOVB K0, K0 // c5f990c0
|
||||
KMOVB K7, K7 // c5f990ff
|
||||
KMOVB K5, K1 // c5f990cd
|
||||
KMOVB K1, K5 // c5f990e9
|
||||
KMOVB (AX), K1 // c5f99008
|
||||
KMOVB K0, (AX) // c5f99100
|
||||
KMOVB K7, (R10) // c4c179913a
|
||||
KMOVB K5, AX // c5f993c5
|
||||
KMOVB K7, R10 // c57993d7
|
||||
KMOVB AX, K5 // c5f992e8
|
||||
KMOVB R10, K7 // c4c17992fa
|
||||
KMOVW K0, K0 // c5f890c0
|
||||
KMOVW K7, K7 // c5f890ff
|
||||
KMOVW K5, K1 // c5f890cd
|
||||
KMOVW K1, K5 // c5f890e9
|
||||
KMOVW (AX), K1 // c5f89008
|
||||
KMOVW K0, (AX) // c5f89100
|
||||
KMOVW K7, (R10) // c4c178913a
|
||||
KMOVW K5, AX // c5f893c5
|
||||
KMOVW K7, R10 // c57893d7
|
||||
KMOVW AX, K5 // c5f892e8
|
||||
KMOVW R10, K7 // c4c17892fa
|
||||
KMOVD K0, K0 // c4e1f990c0
|
||||
KMOVD K7, K7 // c4e1f990ff
|
||||
KMOVD K5, K1 // c4e1f990cd
|
||||
KMOVD K1, K5 // c4e1f990e9
|
||||
KMOVD (AX), K1 // c4e1f99008
|
||||
KMOVD AX, K5 // c5fb92e8
|
||||
KMOVD R10, K7 // c4c17b92fa
|
||||
KMOVD K0, (AX) // c4e1f99100
|
||||
KMOVD K7, (R10) // c4c1f9913a
|
||||
KMOVD K5, AX // c5fb93c5
|
||||
KMOVD K7, R10 // c57b93d7
|
||||
KMOVQ K0, K0 // c4e1f890c0
|
||||
KMOVQ K7, K7 // c4e1f890ff
|
||||
KMOVQ K5, K1 // c4e1f890cd
|
||||
KMOVQ K1, K5 // c4e1f890e9
|
||||
KMOVQ (AX), K1 // c4e1f89008
|
||||
KMOVQ AX, K5 // c4e1fb92e8
|
||||
KMOVQ R10, K7 // c4c1fb92fa
|
||||
KMOVQ K0, (AX) // c4e1f89100
|
||||
KMOVQ K7, (R10) // c4c1f8913a
|
||||
KMOVQ K5, AX // c4e1fb93c5
|
||||
KMOVQ K7, R10 // c461fb93d7
|
||||
KNOTB K7, K0 // c5f944c7
|
||||
KNOTB K1, K5 // c5f944e9
|
||||
KNOTW K7, K0 // c5f844c7
|
||||
KNOTW K1, K5 // c5f844e9
|
||||
KNOTD K7, K0 // c4e1f944c7
|
||||
KNOTD K1, K5 // c4e1f944e9
|
||||
KNOTQ K7, K0 // c4e1f844c7
|
||||
KNOTQ K1, K5 // c4e1f844e9
|
||||
KORB K7, K5, K0 // c5d545c7
|
||||
KORB K0, K7, K5 // c5c545e8
|
||||
KORW K7, K5, K0 // c5d445c7
|
||||
KORW K0, K7, K5 // c5c445e8
|
||||
KORD K7, K5, K0 // c4e1d545c7
|
||||
KORD K0, K7, K5 // c4e1c545e8
|
||||
KORQ K7, K5, K0 // c4e1d445c7
|
||||
KORQ K0, K7, K5 // c4e1c445e8
|
||||
KSHIFTLB $0, K7, K0 // c4e37932c700
|
||||
KSHIFTLB $196, K1, K5 // c4e37932e9c4
|
||||
KSHIFTLW $0, K7, K0 // c4e3f932c700
|
||||
KSHIFTLW $196, K1, K5 // c4e3f932e9c4
|
||||
KSHIFTLD $0, K7, K0 // c4e37933c700
|
||||
KSHIFTLD $196, K1, K5 // c4e37933e9c4
|
||||
KSHIFTLQ $0, K7, K0 // c4e3f933c700
|
||||
KSHIFTLQ $196, K1, K5 // c4e3f933e9c4
|
||||
// EVEX: masking with K1-K7.
|
||||
VADDPD X2, X1, K1, X0 // 62f1f50958c2
|
||||
VADDPD X12, X1, K4, X10 // 6251f50c58d4
|
||||
VADDPD X22, X1, K7, X20 // 62a1f50f58e6
|
||||
VADDPD (AX), X1, K1, X1 // 62f1f5095808
|
||||
VADDPD 8(R10), X10, K4, X10 // 6251ad0c589208000000
|
||||
VADDPD (R10)(AX*4), X20, K7, X20 // 62c1dd07582482
|
||||
VADDPD Y2, Y1, K1, Y0 // 62f1f52958c2
|
||||
VADDPD Y12, Y1, K4, Y10 // 6251f52c58d4
|
||||
VADDPD Y22, Y1, K7, Y20 // 62a1f52f58e6
|
||||
VADDPD (AX), Y1, K1, Y1 // 62f1f5295808
|
||||
VADDPD 8(R10), Y10, K4, Y10 // 6251ad2c589208000000
|
||||
VADDPD (R10)(AX*4), Y20, K7, Y20 // 62c1dd27582482
|
||||
VADDPD Z2, Z1, K1, Z0 // 62f1f54958c2
|
||||
VADDPD Z12, Z1, K4, Z10 // 6251f54c58d4
|
||||
VADDPD Z22, Z1, K7, Z20 // 62a1f54f58e6
|
||||
VADDPD (AX), Z1, K1, Z1 // 62f1f5495808
|
||||
VADDPD 8(R10), Z10, K4, Z10 // 6251ad4c589208000000
|
||||
VADDPD (R10)(AX*4), Z20, K7, Z20 // 62c1dd47582482
|
||||
// EVEX gather (also tests Z as VSIB index).
|
||||
VPGATHERDD 360(AX)(X2*4), K1, X1 // 62f27d09904c905a
|
||||
VPGATHERDD 640(BP)(X15*8), K3, X14 // 62327d0b90b4fd80020000
|
||||
VPGATHERDD 960(R10)(X25*2), K7, X24 // 62027d0790844ac0030000
|
||||
VPGATHERDD 1280(R10)(X1*4), K4, X0 // 62d27d0c90848a00050000
|
||||
VPGATHERDD 360(AX)(Y2*4), K1, Y1 // 62f27d29904c905a
|
||||
VPGATHERDD 640(BP)(Y15*8), K3, Y14 // 62327d2b90b4fd80020000
|
||||
VPGATHERDD 960(R10)(Y25*2), K7, Y24 // 62027d2790844ac0030000
|
||||
VPGATHERDD 1280(R10)(Y1*4), K4, Y0 // 62d27d2c90848a00050000
|
||||
VPGATHERDD 360(AX)(Z2*4), K1, Z1 // 62f27d49904c905a
|
||||
VPGATHERDD 640(BP)(Z15*8), K3, Z14 // 62327d4b90b4fd80020000
|
||||
VPGATHERDD 960(R10)(Z25*2), K7, Z24 // 62027d4790844ac0030000
|
||||
VPGATHERDD 1280(R10)(Z1*4), K4, Z0 // 62d27d4c90848a00050000
|
||||
VPGATHERDQ 360(AX)(X2*4), K1, X1 // 62f2fd09904c902d
|
||||
VPGATHERDQ 640(BP)(X15*8), K3, X14 // 6232fd0b9074fd50
|
||||
VPGATHERDQ 960(R10)(X25*2), K7, X24 // 6202fd0790444a78
|
||||
VPGATHERDQ 1280(R10)(X1*4), K4, X0 // 62d2fd0c90848a00050000
|
||||
VPGATHERDQ 360(AX)(X2*4), K1, Y1 // 62f2fd29904c902d
|
||||
VPGATHERDQ 640(BP)(X15*8), K3, Y14 // 6232fd2b9074fd50
|
||||
VPGATHERDQ 960(R10)(X25*2), K7, Y24 // 6202fd2790444a78
|
||||
VPGATHERDQ 1280(R10)(X1*4), K4, Y0 // 62d2fd2c90848a00050000
|
||||
VPGATHERDQ 360(AX)(Y2*4), K1, Z1 // 62f2fd49904c902d
|
||||
VPGATHERDQ 640(BP)(Y15*8), K3, Z14 // 6232fd4b9074fd50
|
||||
VPGATHERDQ 960(R10)(Y25*2), K7, Z24 // 6202fd4790444a78
|
||||
VPGATHERDQ 1280(R10)(Y1*4), K4, Z0 // 62d2fd4c90848a00050000
|
||||
VGATHERDPD 360(R15)(X30*2), K6, X20 // 6282fd069264772d
|
||||
VGATHERDPD 640(R15)(X20*2), K6, X10 // 6252fd0692546750
|
||||
VGATHERDPD 960(R15)(X10*2), K6, X20 // 6282fd0e92645778
|
||||
VGATHERDPD 1280(R15)(X0*2), K6, X10 // 6252fd0e92944700050000
|
||||
VGATHERDPD 360(R15)(X30*2), K6, Y20 // 6282fd269264772d
|
||||
VGATHERDPD 640(R15)(X20*2), K6, Y10 // 6252fd2692546750
|
||||
VGATHERDPD 960(R15)(X10*2), K6, Y20 // 6282fd2e92645778
|
||||
VGATHERDPD 1280(R15)(X0*2), K6, Y10 // 6252fd2e92944700050000
|
||||
VGATHERDPD 360(R15)(Y30*2), K6, Z20 // 6282fd469264772d
|
||||
VGATHERDPD 640(R15)(Y20*2), K6, Z10 // 6252fd4692546750
|
||||
VGATHERDPD 960(R15)(Y10*2), K6, Z20 // 6282fd4e92645778
|
||||
VGATHERDPD 1280(R15)(Y0*2), K6, Z10 // 6252fd4e92944700050000
|
||||
VGATHERDPS 360(R15)(X30*2), K6, X20 // 62827d069264775a
|
||||
VGATHERDPS 640(R15)(X20*2), K6, X10 // 62527d0692946780020000
|
||||
VGATHERDPS 960(R15)(X10*2), K6, X20 // 62827d0e92a457c0030000
|
||||
VGATHERDPS 1280(R15)(X0*2), K6, X10 // 62527d0e92944700050000
|
||||
VGATHERDPS 360(R15)(Y30*2), K6, Y20 // 62827d269264775a
|
||||
VGATHERDPS 640(R15)(Y20*2), K6, Y10 // 62527d2692946780020000
|
||||
VGATHERDPS 960(R15)(Y10*2), K6, Y20 // 62827d2e92a457c0030000
|
||||
VGATHERDPS 1280(R15)(Y0*2), K6, Y10 // 62527d2e92944700050000
|
||||
VGATHERDPS 360(R15)(Z30*2), K6, Z20 // 62827d469264775a
|
||||
VGATHERDPS 640(R15)(Z20*2), K6, Z10 // 62527d4692946780020000
|
||||
VGATHERDPS 960(R15)(Z10*2), K6, Z20 // 62827d4e92a457c0030000
|
||||
VGATHERDPS 1280(R15)(Z0*2), K6, Z10 // 62527d4e92944700050000
|
||||
VGATHERQPS 360(R15)(X30*2), K6, X20 // 62827d069364775a
|
||||
VGATHERQPS 640(R15)(X20*2), K6, X10 // 62527d0693946780020000
|
||||
VGATHERQPS 960(R15)(X10*2), K6, X20 // 62827d0e93a457c0030000
|
||||
VGATHERQPS 1280(R15)(X0*2), K6, X10 // 62527d0e93944700050000
|
||||
VGATHERQPS 360(R15)(Y30*2), K6, X20 // 62827d269364775a
|
||||
VGATHERQPS 640(R15)(Y20*2), K6, X10 // 62527d2693946780020000
|
||||
VGATHERQPS 960(R15)(Y10*2), K6, X20 // 62827d2e93a457c0030000
|
||||
VGATHERQPS 1280(R15)(Y0*2), K6, X10 // 62527d2e93944700050000
|
||||
VGATHERQPS 360(R15)(Z30*2), K6, Y20 // 62827d469364775a
|
||||
VGATHERQPS 640(R15)(Z20*2), K6, Y10 // 62527d4693946780020000
|
||||
VGATHERQPS 960(R15)(Z10*2), K6, Y20 // 62827d4e93a457c0030000
|
||||
VGATHERQPS 1280(R15)(Z0*2), K6, Y10 // 62527d4e93944700050000
|
||||
VPGATHERQD 360(R15)(X30*2), K6, X20 // 62827d069164775a
|
||||
VPGATHERQD 640(R15)(X20*2), K6, X10 // 62527d0691946780020000
|
||||
VPGATHERQD 960(R15)(X10*2), K6, X20 // 62827d0e91a457c0030000
|
||||
VPGATHERQD 1280(R15)(X0*2), K6, X10 // 62527d0e91944700050000
|
||||
VPGATHERQD 360(R15)(Y30*2), K6, X20 // 62827d269164775a
|
||||
VPGATHERQD 640(R15)(Y20*2), K6, X10 // 62527d2691946780020000
|
||||
VPGATHERQD 960(R15)(Y10*2), K6, X20 // 62827d2e91a457c0030000
|
||||
VPGATHERQD 1280(R15)(Y0*2), K6, X10 // 62527d2e91944700050000
|
||||
VPGATHERQD 360(R15)(Z30*2), K6, Y20 // 62827d469164775a
|
||||
VPGATHERQD 640(R15)(Z20*2), K6, Y10 // 62527d4691946780020000
|
||||
VPGATHERQD 960(R15)(Z10*2), K6, Y20 // 62827d4e91a457c0030000
|
||||
VPGATHERQD 1280(R15)(Z0*2), K6, Y10 // 62527d4e91944700050000
|
||||
VPGATHERQQ 360(R15)(X30*2), K6, X20 // 6282fd069164772d
|
||||
VPGATHERQQ 640(R15)(X20*2), K6, X10 // 6252fd0691546750
|
||||
VPGATHERQQ 960(R15)(X10*2), K6, X20 // 6282fd0e91645778
|
||||
VPGATHERQQ 1280(R15)(X0*2), K6, X10 // 6252fd0e91944700050000
|
||||
VPGATHERQQ 360(R15)(Y30*2), K6, Y20 // 6282fd269164772d
|
||||
VPGATHERQQ 640(R15)(Y20*2), K6, Y10 // 6252fd2691546750
|
||||
VPGATHERQQ 960(R15)(Y10*2), K6, Y20 // 6282fd2e91645778
|
||||
VPGATHERQQ 1280(R15)(Y0*2), K6, Y10 // 6252fd2e91944700050000
|
||||
VPGATHERQQ 360(R15)(Z30*2), K6, Z20 // 6282fd469164772d
|
||||
VPGATHERQQ 640(R15)(Z20*2), K6, Z10 // 6252fd4691546750
|
||||
VPGATHERQQ 960(R15)(Z10*2), K6, Z20 // 6282fd4e91645778
|
||||
VPGATHERQQ 1280(R15)(Z0*2), K6, Z10 // 6252fd4e91944700050000
|
||||
VGATHERQPD 360(R15)(X30*2), K6, X20 // 6282fd069364772d
|
||||
VGATHERQPD 640(R15)(X20*2), K6, X10 // 6252fd0693546750
|
||||
VGATHERQPD 960(R15)(X10*2), K6, X20 // 6282fd0e93645778
|
||||
VGATHERQPD 1280(R15)(X0*2), K6, X10 // 6252fd0e93944700050000
|
||||
VGATHERQPD 360(R15)(Y30*2), K6, Y20 // 6282fd269364772d
|
||||
VGATHERQPD 640(R15)(Y20*2), K6, Y10 // 6252fd2693546750
|
||||
VGATHERQPD 960(R15)(Y10*2), K6, Y20 // 6282fd2e93645778
|
||||
VGATHERQPD 1280(R15)(Y0*2), K6, Y10 // 6252fd2e93944700050000
|
||||
VGATHERQPD 360(R15)(Z30*2), K6, Z20 // 6282fd469364772d
|
||||
VGATHERQPD 640(R15)(Z20*2), K6, Z10 // 6252fd4693546750
|
||||
VGATHERQPD 960(R15)(Z10*2), K6, Z20 // 6282fd4e93645778
|
||||
VGATHERQPD 1280(R15)(Z0*2), K6, Z10 // 6252fd4e93944700050000
|
||||
// EVEX: corner cases for High-16 registers.
|
||||
VADDPD X31, X16, X15 // 6211fd0058ff
|
||||
VADDPD X23, X15, X16 // 62a1850858c7
|
||||
VADDPD Y31, Y16, Y15 // 6211fd2058ff
|
||||
VADDPD Y23, Y15, Y16 // 62a1852858c7
|
||||
VADDPD Z31, Z16, Z15 // 6211fd4058ff
|
||||
VADDPD Z23, Z15, Z16 // 62a1854858c7
|
||||
VGATHERQPD (DX)(X16*1),K1,X31 // 6262fd01933c02
|
||||
VGATHERQPD (DX)(X31*1),K1,X16 // 62a2fd0193043a
|
||||
VGATHERQPD (DX)(X15*1),K1,X23 // 62a2fd09933c3a
|
||||
VGATHERQPD (DX)(X23*1),K1,X15 // 6272fd01933c3a
|
||||
VGATHERQPD (DX)(Y16*1),K1,Y31 // 6262fd21933c02
|
||||
VGATHERQPD (DX)(Y31*1),K1,Y16 // 62a2fd2193043a
|
||||
VGATHERQPD (DX)(Y15*1),K1,Y23 // 62a2fd29933c3a
|
||||
VGATHERQPD (DX)(Y23*1),K1,Y15 // 6272fd21933c3a
|
||||
VGATHERQPD (DX)(Z16*1),K1,Z31 // 6262fd41933c02
|
||||
VGATHERQPD (DX)(Z31*1),K1,Z16 // 62a2fd4193043a
|
||||
VGATHERQPD (DX)(Z15*1),K1,Z23 // 62a2fd49933c3a
|
||||
VGATHERQPD (DX)(Z23*1),K1,Z15 // 6272fd41933c3a
|
||||
// EVEX: VCVTPD2DQ with Y suffix (VL=2).
|
||||
VCVTPD2DQY (BX), X20 // 62e1ff28e623
|
||||
VCVTPD2DQY (R11), X30 // 6241ff28e633
|
||||
// XED encoder uses EVEX.X=0 for these; most x86 tools use EVEX.X=1.
|
||||
// Either way is OK.
|
||||
VMOVQ SP, X20 // 62e1fd086ee4 or 62a1fd086ee4
|
||||
VMOVQ BP, X20 // 62e1fd086ee5 or 62a1fd086ee5
|
||||
VMOVQ R14, X20 // 62c1fd086ee6 or 6281fd086ee6
|
||||
// "VMOVQ r/m64, xmm1"/6E vs "VMOVQ xmm2/m64, xmm1"/7E with mem operand.
|
||||
VMOVQ (AX), X20 // 62e1fd086e20 or 62e1fe087e20
|
||||
VMOVQ 7(DX), X20 // 62e1fd086ea207000000 or 62e1fe087ea207000000
|
||||
VMOVQ -15(R11)(CX*1), X20 // 62c1fd086ea40bf1ffffff or 62c1fe087ea40bf1ffffff
|
||||
VMOVQ (SP)(AX*2), X20 // 62e1fd086e2444 or 62e1fe087e2444
|
||||
// "VMOVQ xmm1, r/m64"/7E vs "VMOVQ xmm1, xmm2/m64"/D6 with mem operand.
|
||||
VMOVQ X20, (AX) // 62e1fd087e20 or 62e1fd08d620
|
||||
VMOVQ X20, 7(DX) // 62e1fd087ea207000000 or 62e1fd08d6a207000000
|
||||
VMOVQ X20, -15(R11)(CX*1) // 62c1fd087ea40bf1ffffff or 62c1fd08d6a40bf1ffffff
|
||||
VMOVQ X20, (SP)(AX*2) // 62e1fd087e2444 or 62e1fd08d62444
|
||||
// VMOVHPD: overlapping VEX and EVEX variants.
|
||||
VMOVHPD (AX), X5, X5 // c5d11628 or c4e1d11628 or 62f1d5281628 or 62f1d5481628
|
||||
VMOVHPD 7(DX), X5, X5 // c5d1166a07 or 62f1d52816aa07000000 or 62f1d54816aa07000000
|
||||
VMOVHPD -15(R11)(CX*1), X5, X5 // c4c151166c0bf1 or 62d1d52816ac0bf1ffffff or 62d1d54816ac0bf1ffffff
|
||||
VMOVHPD (SP)(AX*2), X5, X5 // c5d1162c44 or c4e1d1162c44 or 62f1d528162c44 or 62f1d548162c44
|
||||
VMOVHPD (AX), X8, X5 // c5b91628 or c4e1b91628 or 62f1bd281628 or 62f1bd481628
|
||||
VMOVHPD 7(DX), X8, X5 // c5b9166a07 or 62f1bd2816aa07000000 or 62f1bd4816aa07000000
|
||||
VMOVHPD -15(R11)(CX*1), X8, X5 // c4c139166c0bf1 or 62d1bd4816ac0bf1ffffff
|
||||
VMOVHPD (SP)(AX*2), X8, X5 // c5b9162c44 or c4e1b9162c44 or 62f1bd28162c44 or 62f1bd48162c44
|
||||
VMOVHPD (AX), X20, X5 // 62f1dd001628 or 62f1dd201628 or 62f1dd401628
|
||||
VMOVHPD 7(DX), X20, X5 // 62f1dd0016aa07000000 or 62f1dd2016aa07000000 or 62f1dd4016aa07000000
|
||||
VMOVHPD -15(R11)(CX*1), X20, X5 // 62d1dd0016ac0bf1ffffff or 62d1dd2016ac0bf1ffffff or 62d1dd4016ac0bf1ffffff
|
||||
VMOVHPD (SP)(AX*2), X20, X5 // 62f1dd00162c44 or 62f1dd20162c44 or 62f1dd40162c44
|
||||
VMOVHPD (AX), X5, X8 // c5511600 or c461d11600 or 6271d5281600 or 6271d5481600
|
||||
VMOVHPD 7(DX), X5, X8 // c551164207 or 6271d528168207000000 or 6271d548168207000000
|
||||
VMOVHPD -15(R11)(CX*1), X5, X8 // c4415116440bf1 or 6251d52816840bf1ffffff or 6251d54816840bf1ffffff
|
||||
VMOVHPD (SP)(AX*2), X5, X8 // c551160444 or 6271d528160444 or 6271d548160444
|
||||
VMOVHPD (AX), X8, X8 // c5391600 or 6271bd281600 or 6271bd481600
|
||||
VMOVHPD 7(DX), X8, X8 // c539164207 or 6271bd28168207000000 or 6271bd48168207000000
|
||||
VMOVHPD -15(R11)(CX*1), X8, X8 // c4413916440bf1 or 6251bd2816840bf1ffffff or 6251bd4816840bf1ffffff
|
||||
VMOVHPD (SP)(AX*2), X8, X8 // c539160444 or 6271bd28160444 or 6271bd48160444
|
||||
VMOVHPD (AX), X20, X8 // 6271dd001600 or 6271dd201600 or 6271dd401600
|
||||
VMOVHPD 7(DX), X20, X8 // 6271dd00168207000000 or 6271dd20168207000000 or 6271dd40168207000000
|
||||
VMOVHPD -15(R11)(CX*1), X20, X8 // 6251dd0016840bf1ffffff or 6251dd2016840bf1ffffff or 6251dd4016840bf1ffffff
|
||||
VMOVHPD (SP)(AX*2), X20, X8 // 6271dd00160444 or 6271dd20160444 or 6271dd40160444
|
||||
VMOVHPD (AX), X5, X20 // 62e1d5081620 or 62e1d5281620 or 62e1d5481620
|
||||
VMOVHPD 7(DX), X5, X20 // 62e1d50816a207000000 or 62e1d52816a207000000 or 62e1d54816a207000000
|
||||
VMOVHPD -15(R11)(CX*1), X5, X20 // 62c1d50816a40bf1ffffff or 62c1d52816a40bf1ffffff or 62c1d54816a40bf1ffffff
|
||||
VMOVHPD (SP)(AX*2), X5, X20 // 62e1d508162444 or 62e1d528162444 or 62e1d548162444
|
||||
VMOVHPD (AX), X8, X20 // 62e1bd081620 or 62e1bd281620 or 62e1bd481620
|
||||
VMOVHPD 7(DX), X8, X20 // 62e1bd0816a207000000 or 62e1bd2816a207000000 or 62e1bd4816a207000000
|
||||
VMOVHPD -15(R11)(CX*1), X8, X20 // 62c1bd0816a40bf1ffffff or 62c1bd2816a40bf1ffffff or 62c1bd4816a40bf1ffffff
|
||||
VMOVHPD (SP)(AX*2), X8, X20 // 62e1bd08162444 or 62e1bd28162444 or 62e1bd48162444
|
||||
VMOVHPD (AX), X20, X20 // 62e1dd001620 or 62e1dd201620 or 62e1dd401620
|
||||
VMOVHPD 7(DX), X20, X20 // 62e1dd0016a207000000 or 62e1dd2016a207000000 or 62e1dd4016a207000000
|
||||
VMOVHPD -15(R11)(CX*1), X20, X20 // 62c1dd0016a40bf1ffffff or 62c1dd2016a40bf1ffffff or 62c1dd4016a40bf1ffffff
|
||||
VMOVHPD (SP)(AX*2), X20, X20 // 62e1dd00162444 or 62e1dd20162444 or 62e1dd40162444
|
||||
VMOVHPD X5, (AX) // c5f91728 or 62f1fd281728 or 62f1fd481728
|
||||
VMOVHPD X8, (AX) // c5791700 or 6271fd281700 or 6271fd481700
|
||||
VMOVHPD X20, (AX) // 62e1fd081720 or 62e1fd281720 or 62e1fd481720
|
||||
VMOVHPD X5, 7(DX) // c5f9176a07 or 62f1fd2817aa07000000 or 62f1fd4817aa07000000
|
||||
VMOVHPD X8, 7(DX) // c579174207 or 6271fd28178207000000 or 6271fd48178207000000
|
||||
VMOVHPD X20, 7(DX) // 62e1fd0817a207000000 or 62e1fd2817a207000000 or 62e1fd4817a207000000
|
||||
VMOVHPD X5, -15(R11)(CX*1) // c4c179176c0bf1 or 62d1fd2817ac0bf1ffffff or 62d1fd4817ac0bf1ffffff
|
||||
VMOVHPD X8, -15(R11)(CX*1) // c4417917440bf1 or 6251fd2817840bf1ffffff or 6251fd4817840bf1ffffff
|
||||
VMOVHPD X20, -15(R11)(CX*1) // 62c1fd0817a40bf1ffffff or 62c1fd2817a40bf1ffffff or 62c1fd4817a40bf1ffffff
|
||||
VMOVHPD X5, (SP)(AX*2) // c5f9172c44 or 62f1fd28172c44 or 62f1fd48172c44
|
||||
VMOVHPD X8, (SP)(AX*2) // c579170444 or 6271fd28170444 or 6271fd48170444
|
||||
VMOVHPD X20, (SP)(AX*2) // 62e1fd08172444 or 62e1fd28172444 or 62e1fd48172444
|
||||
// VMOVLPD: overlapping VEX and EVEX variants.
|
||||
VMOVLPD (AX), X5, X5 // c5d11228 or 62f1d5281228 or 62f1d5481228
|
||||
VMOVLPD 7(DX), X5, X5 // c5d1126a07 or 62f1d52812aa07000000 or 62f1d54812aa07000000
|
||||
VMOVLPD -15(R11)(CX*1), X5, X5 // c4c151126c0bf1 or 62d1d52812ac0bf1ffffff or 62d1d54812ac0bf1ffffff
|
||||
VMOVLPD (SP)(AX*2), X5, X5 // c5d1122c44 or 62f1d528122c44 or 62f1d548122c44
|
||||
VMOVLPD (AX), X8, X5 // c5b91228 or 62f1bd281228 or 62f1bd481228
|
||||
VMOVLPD 7(DX), X8, X5 // c5b9126a07 or 62f1bd2812aa07000000 or 62f1bd4812aa07000000
|
||||
VMOVLPD -15(R11)(CX*1), X8, X5 // c4c139126c0bf1 or 62d1bd2812ac0bf1ffffff or 62d1bd4812ac0bf1ffffff
|
||||
VMOVLPD (SP)(AX*2), X8, X5 // c5b9122c44 or 62f1bd28122c44 or 62f1bd48122c44
|
||||
VMOVLPD (AX), X20, X5 // 62f1dd001228 or 62f1dd201228 or 62f1dd401228
|
||||
VMOVLPD 7(DX), X20, X5 // 62f1dd0012aa07000000 or 62f1dd2012aa07000000 or 62f1dd4012aa07000000
|
||||
VMOVLPD -15(R11)(CX*1), X20, X5 // 62d1dd0012ac0bf1ffffff or 62d1dd2012ac0bf1ffffff or 62d1dd4012ac0bf1ffffff
|
||||
VMOVLPD (SP)(AX*2), X20, X5 // 62f1dd00122c44 or 62f1dd20122c44 or 62f1dd40122c44
|
||||
VMOVLPD (AX), X5, X8 // c5511200 or 6271d5281200 or 6271d5481200
|
||||
VMOVLPD 7(DX), X5, X8 // c551124207 or 6271d528128207000000 or 6271d548128207000000
|
||||
VMOVLPD -15(R11)(CX*1), X5, X8 // c4415112440bf1 or 6251d52812840bf1ffffff or 6251d54812840bf1ffffff
|
||||
VMOVLPD (SP)(AX*2), X5, X8 // c551120444 or 6271d528120444 or 6271d548120444
|
||||
VMOVLPD (AX), X8, X8 // c5391200 or 6271bd281200 or 6271bd481200
|
||||
VMOVLPD 7(DX), X8, X8 // c539124207 or 6271bd28128207000000 or 6271bd48128207000000
|
||||
VMOVLPD -15(R11)(CX*1), X8, X8 // c4413912440bf1 or 6251bd2812840bf1ffffff or 6251bd4812840bf1ffffff
|
||||
VMOVLPD (SP)(AX*2), X8, X8 // c539120444 or 6271bd28120444 or 6271bd48120444
|
||||
VMOVLPD (AX), X20, X8 // 6271dd001200 or 6271dd201200 or 6271dd401200
|
||||
VMOVLPD 7(DX), X20, X8 // 6271dd00128207000000 or 6271dd20128207000000 or 6271dd40128207000000
|
||||
VMOVLPD -15(R11)(CX*1), X20, X8 // 6251dd0012840bf1ffffff or 6251dd2012840bf1ffffff or 6251dd4012840bf1ffffff
|
||||
VMOVLPD (SP)(AX*2), X20, X8 // 6271dd00120444 or 6271dd20120444 or 6271dd40120444
|
||||
VMOVLPD (AX), X5, X20 // 62e1d5081220 or 62e1d5281220 or 62e1d5481220
|
||||
VMOVLPD 7(DX), X5, X20 // 62e1d50812a207000000 or 62e1d52812a207000000 or 62e1d54812a207000000
|
||||
VMOVLPD -15(R11)(CX*1), X5, X20 // 62c1d50812a40bf1ffffff or 62c1d52812a40bf1ffffff or 62c1d54812a40bf1ffffff
|
||||
VMOVLPD (SP)(AX*2), X5, X20 // 62e1d508122444 or 62e1d528122444 or 62e1d548122444
|
||||
VMOVLPD (AX), X8, X20 // 62e1bd081220 or 62e1bd281220 or 62e1bd481220
|
||||
VMOVLPD 7(DX), X8, X20 // 62e1bd0812a207000000 or 62e1bd2812a207000000 or 62e1bd4812a207000000
|
||||
VMOVLPD -15(R11)(CX*1), X8, X20 // 62c1bd0812a40bf1ffffff or 62c1bd2812a40bf1ffffff or 62c1bd4812a40bf1ffffff
|
||||
VMOVLPD (SP)(AX*2), X8, X20 // 62e1bd08122444 or 62e1bd28122444 or 62e1bd48122444
|
||||
VMOVLPD (AX), X20, X20 // 62e1dd001220 or 62e1dd201220 or 62e1dd401220
|
||||
VMOVLPD 7(DX), X20, X20 // 62e1dd0012a207000000 or 62e1dd2012a207000000 or 62e1dd4012a207000000
|
||||
VMOVLPD -15(R11)(CX*1), X20, X20 // 62c1dd0012a40bf1ffffff or 62c1dd2012a40bf1ffffff or 62c1dd4012a40bf1ffffff
|
||||
VMOVLPD (SP)(AX*2), X20, X20 // 62e1dd00122444 or 62e1dd20122444 or 62e1dd40122444
|
||||
VMOVLPD X5, (AX) // c5f91328 or 62f1fd281328 or 62f1fd481328
|
||||
VMOVLPD X8, (AX) // c5791300 or 6271fd281300 or 6271fd481300
|
||||
VMOVLPD X20, (AX) // 62e1fd081320 or 62e1fd281320 or 62e1fd481320
|
||||
VMOVLPD X5, 7(DX) // c5f9136a07 or 62f1fd2813aa07000000 or 62f1fd4813aa07000000
|
||||
VMOVLPD X8, 7(DX) // c579134207 or 6271fd28138207000000 or 6271fd48138207000000
|
||||
VMOVLPD X20, 7(DX) // 62e1fd0813a207000000 or 62e1fd2813a207000000 or 62e1fd4813a207000000
|
||||
VMOVLPD X5, -15(R11)(CX*1) // c4c179136c0bf1 or 62d1fd2813ac0bf1ffffff or 62d1fd4813ac0bf1ffffff
|
||||
VMOVLPD X8, -15(R11)(CX*1) // c4417913440bf1 or 6251fd2813840bf1ffffff or 6251fd4813840bf1ffffff
|
||||
VMOVLPD X20, -15(R11)(CX*1) // 62c1fd0813a40bf1ffffff or 62c1fd2813a40bf1ffffff or 62c1fd4813a40bf1ffffff
|
||||
VMOVLPD X5, (SP)(AX*2) // c5f9132c44 or 62f1fd28132c44 or 62f1fd48132c44
|
||||
VMOVLPD X8, (SP)(AX*2) // c579130444 or 6271fd28130444 or 6271fd48130444
|
||||
VMOVLPD X20, (SP)(AX*2) // 62e1fd08132444 or 62e1fd28132444 or 62e1fd48132444
|
||||
// "VPEXTRW imm8u, xmm1, r32/m16"/15 vs "VPEXTRW imm8u, xmm2, r32"/C5.
|
||||
VPEXTRW $17, X20, AX // 62b17d08c5c411 or 62e37d0815e011 or 62e3fd0815e011
|
||||
VPEXTRW $127, X20, AX // 62b17d08c5c47f or 62e37d0815e07f or 62e3fd0815e07f
|
||||
VPEXTRW $17, X20, SP // 62b17d08c5e411 or 62e37d0815e411 or 62e3fd0815e411
|
||||
VPEXTRW $127, X20, SP // 62b17d08c5e47f or 62e37d0815e47f or 62e3fd0815e47f
|
||||
VPEXTRW $17, X20, BP // 62b17d08c5ec11 or 62e37d0815e511 or 62e3fd0815e511
|
||||
VPEXTRW $127, X20, BP // 62b17d08c5ec7f or 62e37d0815e57f or 62e3fd0815e57f
|
||||
VPEXTRW $17, X20, R14 // 62317d08c5f411 or 62c37d0815e611 or 62c3fd0815e611
|
||||
VPEXTRW $127, X20, R14 // 62317d08c5f47f or 62c37d0815e67f or 62c3fd0815e67f
|
||||
VPEXTRW $17, X20, (AX) // 62e37d08152011 or 62e3fd08152011
|
||||
VPEXTRW $127, X20, (AX) // 62e37d0815207f or 62e3fd0815207f
|
||||
VPEXTRW $17, X20, 7(DX) // 62e37d0815a20700000011 or 62e3fd0815a20700000011
|
||||
VPEXTRW $127, X20, 7(DX) // 62e37d0815a2070000007f or 62e3fd0815a2070000007f
|
||||
VPEXTRW $17, X20, -15(R11)(CX*1) // 62c37d0815a40bf1ffffff11 or 62c3fd0815a40bf1ffffff11
|
||||
VPEXTRW $127, X20, -15(R11)(CX*1) // 62c37d0815a40bf1ffffff7f or 62c3fd0815a40bf1ffffff7f
|
||||
VPEXTRW $17, X20, (SP)(AX*2) // 62e37d0815244411 or 62e3fd0815244411
|
||||
VPEXTRW $127, X20, (SP)(AX*2) // 62e37d081524447f or 62e3fd081524447f
|
||||
// EVEX: embedded zeroing.
|
||||
VADDPD.Z X30, X1, X0 // 6291f58858c6
|
||||
VMAXPD.Z (AX), Z2, K1, Z1 // 62f1edc95f08
|
||||
// EVEX: embedded rounding.
|
||||
VADDPD.RU_SAE Z3, Z2, K1, Z1 // 62f1ed5958cb
|
||||
VADDPD.RD_SAE Z3, Z2, K1, Z1 // 62f1ed3958cb
|
||||
VADDPD.RZ_SAE Z3, Z2, K1, Z1 // 62f1ed7958cb
|
||||
VADDPD.RN_SAE Z3, Z2, K1, Z1 // 62f1ed1958cb
|
||||
VADDPD.RU_SAE.Z Z3, Z2, K1, Z1 // 62f1edd958cb
|
||||
VADDPD.RD_SAE.Z Z3, Z2, K1, Z1 // 62f1edb958cb
|
||||
VADDPD.RZ_SAE.Z Z3, Z2, K1, Z1 // 62f1edf958cb
|
||||
VADDPD.RN_SAE.Z Z3, Z2, K1, Z1 // 62f1ed9958cb
|
||||
// EVEX: embedded broadcasting.
|
||||
VADDPD.BCST (AX), X2, K1, X1 // 62f1ed195808
|
||||
VADDPD.BCST.Z (AX), X2, K1, X1 // 62f1ed995808
|
||||
VADDPD.BCST (AX), Y2, K1, Y1 // 62f1ed395808
|
||||
VADDPD.BCST.Z (AX), Y2, K1, Y1 // 62f1edb95808
|
||||
VADDPD.BCST (AX), Z2, K1, Z1 // 62f1ed595808
|
||||
VADDPD.BCST.Z (AX), Z2, K1, Z1 // 62f1edd95808
|
||||
VMAXPD.BCST (AX), Z2, K1, Z1 // 62f1ed595f08
|
||||
VMAXPD.BCST.Z (AX), Z2, K1, Z1 // 62f1edd95f08
|
||||
// EVEX: surpress all exceptions (SAE).
|
||||
VMAXPD.SAE Z3, Z2, K1, Z1 // 62f1ed595fcb or 62f1ed195fcb
|
||||
VMAXPD.SAE.Z Z3, Z2, K1, Z1 // 62f1edd95fcb or 62f1ed995fcb
|
||||
VMAXPD (AX), Z2, K1, Z1 // 62f1ed495f08
|
||||
VCMPSD.SAE $0, X0, X2, K0 // 62f1ef18c2c000
|
||||
VCMPSD.SAE $0, X0, X2, K1, K0 // 62f1ef19c2c000
|
||||
// EVEX: broadcast-affected compressed displacement (Disp8).
|
||||
VADDPD.BCST 1016(DX), X0, X29 // 6261fd18586a7f
|
||||
VADDPD.BCST 1016(DX), X29, X1 // 62f19510584a7f
|
||||
VADDPD.BCST 1016(DX), X28, X29 // 62619d10586a7f
|
||||
VADDPD.BCST 1016(DX)(AX*2), X0, X29 // 6261fd18586c427f
|
||||
VADDPD.BCST 1016(DX)(AX*2), X29, X1 // 62f19510584c427f
|
||||
VADDPD.BCST 1016(DX), Y0, Y29 // 6261fd38586a7f
|
||||
VADDPD.BCST 1016(DX), Y29, Y1 // 62f19530584a7f
|
||||
VADDPD.BCST 1016(DX), Y28, Y29 // 62619d30586a7f
|
||||
VADDPD.BCST 1016(DX)(AX*2), Y0, Y29 // 6261fd38586c427f
|
||||
VADDPD.BCST 1016(DX)(AX*2), Y29, Y1 // 62f19530584c427f
|
||||
VADDPD.BCST 1016(DX), Z0, Z29 // 6261fd58586a7f
|
||||
VADDPD.BCST 1016(DX), Z29, Z1 // 62f19550584a7f
|
||||
VADDPD.BCST 1016(DX), Z28, Z29 // 62619d50586a7f
|
||||
VADDPD.BCST 1016(DX)(AX*2), Z0, Z29 // 6261fd58586c427f
|
||||
VADDPD.BCST 1016(DX)(AX*2), Z29, Z1 // 62f19550584c427f
|
||||
VADDPS.BCST 508(DX), Z0, Z29 // 62617c58586a7f
|
||||
VADDPS.BCST 508(DX), Z1, Z29 // 62617458586a7f
|
||||
VADDPS.BCST 508(DX), Z28, Z29 // 62611c50586a7f
|
||||
VADDPS.BCST 508(DX)(AX*2), Z0, Z29 // 62617c58586c427f
|
||||
VADDPS.BCST 508(DX)(AX*2), Z1, Z29 // 62617458586c427f
|
||||
// EVEX: broadcast-affected compressed displacement that does not fit into 8bits.
|
||||
VADDPD.BCST 2032(DX), X0, X29 // 6261fd1858aaf0070000
|
||||
VADDPD.BCST 2032(DX), X29, X1 // 62f19510588af0070000
|
||||
VADDPD.BCST 2032(DX), X28, X29 // 62619d1058aaf0070000
|
||||
VADDPD.BCST 2032(DX)(AX*2), X0, X29 // 6261fd1858ac42f0070000
|
||||
VADDPD.BCST 2032(DX)(AX*2), X29, X1 // 62f19510588c42f0070000
|
||||
VADDPD.BCST 2032(DX), Y0, Y29 // 6261fd3858aaf0070000
|
||||
VADDPD.BCST 2032(DX), Y29, Y1 // 62f19530588af0070000
|
||||
VADDPD.BCST 2032(DX), Y28, Y29 // 62619d3058aaf0070000
|
||||
VADDPD.BCST 2032(DX)(AX*2), Y0, Y29 // 6261fd3858ac42f0070000
|
||||
VADDPD.BCST 2032(DX)(AX*2), Y29, Y1 // 62f19530588c42f0070000
|
||||
VADDPD.BCST 2032(DX), Z0, Z29 // 6261fd5858aaf0070000
|
||||
VADDPD.BCST 2032(DX), Z29, Z1 // 62f19550588af0070000
|
||||
VADDPD.BCST 2032(DX), Z28, Z29 // 62619d5058aaf0070000
|
||||
VADDPD.BCST 2032(DX)(AX*2), Z0, Z29 // 6261fd5858ac42f0070000
|
||||
VADDPD.BCST 2032(DX)(AX*2), Z29, Z1 // 62f19550588c42f0070000
|
||||
VADDPS.BCST 2032(DX), Z0, Z29 // 62617c5858aaf0070000
|
||||
VADDPS.BCST 2032(DX), Z1, Z29 // 6261745858aaf0070000
|
||||
VADDPS.BCST 2032(DX), Z28, Z29 // 62611c5058aaf0070000
|
||||
VADDPS.BCST 2032(DX)(AX*2), Z0, Z29 // 62617c5858ac42f0070000
|
||||
VADDPS.BCST 2032(DX)(AX*2), Z1, Z29 // 6261745858ac42f0070000
|
||||
// Forced EVEX encoding due to suffixes.
|
||||
VADDPD.BCST 2032(DX), X0, X0 // 62f1fd185882f0070000
|
||||
VADDPD.BCST 2032(DX), Y0, Y0 // 62f1fd385882f0070000
|
||||
// Test new Z-cases one-by-one.
|
||||
//
|
||||
// Zevex_i_r_k_rm.
|
||||
VCVTPS2PH $1, Z2, K5, Y21 // 62b37d4d1dd501
|
||||
VCVTPS2PH $2, Z21, K4, Y2 // 62e37d4c1dea02
|
||||
// Zevex_i_r_rm.
|
||||
VCVTPS2PH $1, Z2, Y21 // 62b37d481dd501
|
||||
VCVTPS2PH $2, Z21, Y2 // 62e37d481dea02
|
||||
// Zevex_i_rm_k_r.
|
||||
VFPCLASSPDX $1, X2, K5, K3 // 62f3fd0d66da01
|
||||
VFPCLASSPDX $2, X21, K4, K1 // 62b3fd0c66cd02
|
||||
VFPCLASSPDX $1, (AX), K5, K3 // 62f3fd0d661801
|
||||
VFPCLASSPDX $2, (CX), K4, K1 // 62f3fd0c660902
|
||||
// Zevex_i_rm_k_vo.
|
||||
VPROLD $1, X2, K5, X21 // 62f1550572ca01
|
||||
VPROLD $2, Y21, K5, Y2 // 62b16d2d72cd02
|
||||
VPROLD $1, (AX), K5, X21 // 62f15505720801
|
||||
VPROLD $2, (CX), K5, Y2 // 62f16d2d720902
|
||||
// Zevex_i_rm_r.
|
||||
VFPCLASSPDX $1, X2, K3 // 62f3fd0866da01
|
||||
VFPCLASSPDX $2, X21, K1 // 62b3fd0866cd02
|
||||
VFPCLASSPDX $1, (AX), K3 // 62f3fd08661801
|
||||
VFPCLASSPDX $2, (CX), K1 // 62f3fd08660902
|
||||
// Zevex_i_rm_v_k_r.
|
||||
VALIGND $1, X2, X9, K5, X21 // 62e3350d03ea01
|
||||
VALIGND $2, Y21, Y2, K5, Y9 // 62336d2d03cd02
|
||||
VALIGND $3, Z9, Z21, K5, Z2 // 62d3554503d103
|
||||
VALIGND $1, (AX), X9, K5, X21 // 62e3350d032801
|
||||
VALIGND $2, (CX), Y2, K5, Y9 // 62736d2d030902
|
||||
VALIGND $3, (AX), Z21, K5, Z2 // 62f35545031003
|
||||
// Zevex_i_rm_v_r.
|
||||
VALIGND $1, X2, X9, X21 // 62e3350803ea01
|
||||
VALIGND $2, Y21, Y2, Y9 // 62336d2803cd02
|
||||
VALIGND $3, Z9, Z21, Z2 // 62d3554003d103
|
||||
VALIGND $1, (AX), X9, X21 // 62e33508032801
|
||||
VALIGND $2, (CX), Y2, Y9 // 62736d28030902
|
||||
VALIGND $3, (AX), Z21, Z2 // 62f35540031003
|
||||
// Zevex_i_rm_vo.
|
||||
VPROLD $1, X2, X21 // 62f1550072ca01
|
||||
VPROLD $2, Y21, Y2 // 62b16d2872cd02
|
||||
VPROLD $1, (AX), X21 // 62f15500720801
|
||||
VPROLD $2, (CX), Y2 // 62f16d28720902
|
||||
// Zevex_k_rmo.
|
||||
VGATHERPF0DPD K5, (AX)(Y2*2) // 62f2fd4dc60c50
|
||||
VGATHERPF0DPD K3, (CX)(Y21*2) // 62f2fd43c60c69
|
||||
VSCATTERPF1DPD K5, (AX)(Y2*2) // 62f2fd4dc63450
|
||||
VSCATTERPF1DPD K3, (CX)(Y21*2) // 62f2fd43c63469
|
||||
// Zevex_r_k_rm.
|
||||
VPSCATTERDD X2, K5, (AX)(X21*2) // 62f27d05a01468
|
||||
VPSCATTERDD X21, K5, (AX)(X2*2) // 62e27d0da02c50
|
||||
VPSCATTERDD Y2, K5, (AX)(Y21*2) // 62f27d25a01468
|
||||
VPSCATTERDD Y21, K5, (AX)(Y2*2) // 62e27d2da02c50
|
||||
VPSCATTERDD Z2, K5, (AX)(Z21*2) // 62f27d45a01468
|
||||
VPSCATTERDD Z21, K5, (AX)(Z2*2) // 62e27d4da02c50
|
||||
// Zevex_r_v_k_rm.
|
||||
VMOVSD X2, X9, K5, X21 // 62b1b70d11d5 or 62e1b70d10ea
|
||||
VMOVSD X21, X2, K5, X9 // 62c1ef0d11e9 or 6231ef0d10cd
|
||||
VMOVSD X9, X21, K5, X2 // 6271d70511ca or 62d1d70510d1
|
||||
// Zevex_r_v_rm.
|
||||
VMOVSD X2, X9, X21 // 62b1b70811d5 or 62e1b70810ea
|
||||
VMOVSD X21, X2, X9 // 62c1ef0811e9 or 6231ef0810cd
|
||||
VMOVSD X9, X21, X2 // 6271d70011ca or 62d1d70010d1
|
||||
VPMOVDB X2, X21 // 62b27e0831d5
|
||||
VPMOVDB X21, X2 // 62e27e0831ea
|
||||
VPMOVDB X2, (AX) // 62f27e083110
|
||||
VPMOVDB X21, (AX) // 62e27e083128
|
||||
// Zevex_rm_k_r.
|
||||
VMOVDDUP X2, K5, X21 // 62e1ff0d12ea
|
||||
VMOVDDUP X21, K5, X2 // 62b1ff0d12d5
|
||||
VMOVDDUP (AX), K5, X21 // 62e1ff0d1228
|
||||
VMOVDDUP (CX), K5, X2 // 62f1ff0d1211
|
||||
VMOVDDUP Y2, K5, Y21 // 62e1ff2d12ea
|
||||
VMOVDDUP Y21, K5, Y2 // 62b1ff2d12d5
|
||||
VMOVDDUP (AX), K5, Y21 // 62e1ff2d1228
|
||||
VMOVDDUP (CX), K5, Y2 // 62f1ff2d1211
|
||||
VMOVDDUP Z2, K5, Z21 // 62e1ff4d12ea
|
||||
VMOVDDUP Z21, K5, Z2 // 62b1ff4d12d5
|
||||
VMOVDDUP (AX), K5, Z21 // 62e1ff4d1228
|
||||
VMOVDDUP (CX), K5, Z2 // 62f1ff4d1211
|
||||
// Zevex_rm_v_k_r.
|
||||
VADDPD Z2, Z9, K5, Z21 // 62e1b54d58ea
|
||||
VADDPD Z21, Z2, K5, Z9 // 6231ed4d58cd
|
||||
VADDPD Z9, Z21, K5, Z2 // 62d1d54558d1
|
||||
// Zevex_rm_v_r.
|
||||
VADDPD Z2, Z9, Z21 // 62e1b54858ea
|
||||
VADDPD Z21, Z2, Z9 // 6231ed4858cd
|
||||
VADDPD Z9, Z21, Z2 // 62d1d54058d1
|
||||
// End of tests.
|
||||
RET
|
||||
|
21
src/cmd/asm/internal/asm/testdata/arm64.s
vendored
21
src/cmd/asm/internal/asm/testdata/arm64.s
vendored
@ -190,6 +190,15 @@ TEXT foo(SB), DUPOK|NOSPLIT, $-8
|
||||
EOR $(1<<63), R1 // EOR $-9223372036854775808, R1 // 210041d2
|
||||
EOR $(1<<63-1), R1 // EOR $9223372036854775807, R1 // 21f840d2
|
||||
|
||||
AND $0x22220000, R3, R4 // AND $572653568, R3, R4 // 5b44a4d264001b8a
|
||||
ORR $0x22220000, R3, R4 // ORR $572653568, R3, R4 // 5b44a4d264001baa
|
||||
EOR $0x22220000, R3, R4 // EOR $572653568, R3, R4 // 5b44a4d264001bca
|
||||
BIC $0x22220000, R3, R4 // BIC $572653568, R3, R4 // 5b44a4d264003b8a
|
||||
ORN $0x22220000, R3, R4 // ORN $572653568, R3, R4 // 5b44a4d264003baa
|
||||
EON $0x22220000, R3, R4 // EON $572653568, R3, R4 // 5b44a4d264003bca
|
||||
ANDS $0x22220000, R3, R4 // ANDS $572653568, R3, R4 // 5b44a4d264001bea
|
||||
BICS $0x22220000, R3, R4 // BICS $572653568, R3, R4 // 5b44a4d264003bea
|
||||
|
||||
AND $8, R0, RSP // 1f007d92
|
||||
ORR $8, R0, RSP // 1f007db2
|
||||
EOR $8, R0, RSP // 1f007dd2
|
||||
@ -390,6 +399,18 @@ TEXT foo(SB), DUPOK|NOSPLIT, $-8
|
||||
CMP R1>>22, R2
|
||||
CMP R1<<33, R2
|
||||
CMP R22.SXTX, RSP // ffe336eb
|
||||
|
||||
CMP $0x22220000, RSP // CMP $572653568, RSP // 5b44a4d2ff633beb
|
||||
CMPW $0x22220000, RSP // CMPW $572653568, RSP // 5b44a4d2ff633b6b
|
||||
|
||||
// TST
|
||||
TST $15, R2 // 5f0c40f2
|
||||
TST R1, R2 // 5f0001ea
|
||||
TST R1->11, R2 // 5f2c81ea
|
||||
TST R1>>22, R2 // 5f5841ea
|
||||
TST R1<<33, R2 // 5f8401ea
|
||||
TST $0x22220000, R3 // TST $572653568, R3 // 5b44a4d27f001bea
|
||||
|
||||
//
|
||||
// CBZ
|
||||
//
|
||||
|
@ -87,4 +87,6 @@ TEXT errors(SB),$0
|
||||
MADD R1, R2, R3 // ERROR "illegal combination"
|
||||
CINC CS, R2, R3, R4 // ERROR "illegal combination"
|
||||
CSEL LT, R1, R2 // ERROR "illegal combination"
|
||||
AND $0x22220000, R2, RSP // ERROR "illegal combination"
|
||||
ANDS $0x22220000, R2, RSP // ERROR "illegal combination"
|
||||
RET
|
||||
|
@ -19,7 +19,7 @@ import (
|
||||
func (p *Package) godefs(f *File, srcfile string) string {
|
||||
var buf bytes.Buffer
|
||||
|
||||
fmt.Fprintf(&buf, "// Created by cgo -godefs - DO NOT EDIT\n")
|
||||
fmt.Fprintf(&buf, "// Code generated by cmd/cgo -godefs; DO NOT EDIT.\n")
|
||||
fmt.Fprintf(&buf, "// %s %s\n", filepath.Base(os.Args[0]), strings.Join(os.Args[1:], " "))
|
||||
fmt.Fprintf(&buf, "\n")
|
||||
|
||||
|
@ -73,7 +73,7 @@ func (p *Package) writeDefs() {
|
||||
// Write second Go output: definitions of _C_xxx.
|
||||
// In a separate file so that the import of "unsafe" does not
|
||||
// pollute the original file.
|
||||
fmt.Fprintf(fgo2, "// Created by cgo - DO NOT EDIT\n\n")
|
||||
fmt.Fprintf(fgo2, "// Code generated by cmd/cgo; DO NOT EDIT.\n\n")
|
||||
fmt.Fprintf(fgo2, "package %s\n\n", p.PackageName)
|
||||
fmt.Fprintf(fgo2, "import \"unsafe\"\n\n")
|
||||
if !*gccgo && *importRuntimeCgo {
|
||||
@ -536,7 +536,7 @@ func (p *Package) writeOutput(f *File, srcfile string) {
|
||||
p.GccFiles = append(p.GccFiles, base+".cgo2.c")
|
||||
|
||||
// Write Go output: Go input with rewrites of C.xxx to _C_xxx.
|
||||
fmt.Fprintf(fgo1, "// Created by cgo - DO NOT EDIT\n\n")
|
||||
fmt.Fprintf(fgo1, "// Code generated by cmd/cgo; DO NOT EDIT.\n\n")
|
||||
fmt.Fprintf(fgo1, "//line %s:1\n", srcfile)
|
||||
fgo1.Write(f.Edit.Bytes())
|
||||
|
||||
@ -725,7 +725,7 @@ func (p *Package) writeGccgoOutputFunc(fgcc *os.File, n *Name) {
|
||||
// packedAttribute returns host compiler struct attribute that will be
|
||||
// used to match gc's struct layout. For example, on 386 Windows,
|
||||
// gcc wants to 8-align int64s, but gc does not.
|
||||
// Use __gcc_struct__ to work around http://gcc.gnu.org/PR52991 on x86,
|
||||
// Use __gcc_struct__ to work around https://gcc.gnu.org/PR52991 on x86,
|
||||
// and https://golang.org/issue/5603.
|
||||
func (p *Package) packedAttribute() string {
|
||||
s := "__attribute__((__packed__"
|
||||
@ -740,7 +740,7 @@ func (p *Package) packedAttribute() string {
|
||||
func (p *Package) writeExports(fgo2, fm, fgcc, fgcch io.Writer) {
|
||||
p.writeExportHeader(fgcch)
|
||||
|
||||
fmt.Fprintf(fgcc, "/* Created by cgo - DO NOT EDIT. */\n")
|
||||
fmt.Fprintf(fgcc, "/* Code generated by cmd/cgo; DO NOT EDIT. */\n\n")
|
||||
fmt.Fprintf(fgcc, "#include <stdlib.h>\n")
|
||||
fmt.Fprintf(fgcc, "#include \"_cgo_export.h\"\n\n")
|
||||
|
||||
@ -981,7 +981,7 @@ func (p *Package) writeGccgoExports(fgo2, fm, fgcc, fgcch io.Writer) {
|
||||
|
||||
p.writeExportHeader(fgcch)
|
||||
|
||||
fmt.Fprintf(fgcc, "/* Created by cgo - DO NOT EDIT. */\n")
|
||||
fmt.Fprintf(fgcc, "/* Code generated by cmd/cgo; DO NOT EDIT. */\n\n")
|
||||
fmt.Fprintf(fgcc, "#include \"_cgo_export.h\"\n")
|
||||
|
||||
fmt.Fprintf(fgcc, "%s\n", gccgoExportFileProlog)
|
||||
@ -1147,7 +1147,7 @@ func (p *Package) writeGccgoExports(fgo2, fm, fgcc, fgcch io.Writer) {
|
||||
|
||||
// writeExportHeader writes out the start of the _cgo_export.h file.
|
||||
func (p *Package) writeExportHeader(fgcch io.Writer) {
|
||||
fmt.Fprintf(fgcch, "/* Created by \"go tool cgo\" - DO NOT EDIT. */\n\n")
|
||||
fmt.Fprintf(fgcch, "/* Code generated by cmd/cgo; DO NOT EDIT. */\n\n")
|
||||
pkg := *importPath
|
||||
if pkg == "" {
|
||||
pkg = p.PackagePath
|
||||
|
@ -702,32 +702,32 @@ var knownFormats = map[string]string{
|
||||
"interface{} %v": "",
|
||||
"map[*cmd/compile/internal/gc.Node]*cmd/compile/internal/ssa.Value %v": "",
|
||||
"map[cmd/compile/internal/ssa.ID]uint32 %v": "",
|
||||
"reflect.Type %s": "",
|
||||
"rune %#U": "",
|
||||
"rune %c": "",
|
||||
"string %-*s": "",
|
||||
"string %-16s": "",
|
||||
"string %-6s": "",
|
||||
"string %.*s": "",
|
||||
"string %q": "",
|
||||
"string %s": "",
|
||||
"string %v": "",
|
||||
"time.Duration %d": "",
|
||||
"time.Duration %v": "",
|
||||
"uint %04x": "",
|
||||
"uint %5d": "",
|
||||
"uint %d": "",
|
||||
"uint %x": "",
|
||||
"uint16 %d": "",
|
||||
"uint16 %v": "",
|
||||
"uint16 %x": "",
|
||||
"uint32 %d": "",
|
||||
"uint32 %v": "",
|
||||
"uint32 %x": "",
|
||||
"uint64 %08x": "",
|
||||
"uint64 %d": "",
|
||||
"uint64 %x": "",
|
||||
"uint8 %d": "",
|
||||
"uint8 %x": "",
|
||||
"uintptr %d": "",
|
||||
"reflect.Type %s": "",
|
||||
"rune %#U": "",
|
||||
"rune %c": "",
|
||||
"string %-*s": "",
|
||||
"string %-16s": "",
|
||||
"string %-6s": "",
|
||||
"string %.*s": "",
|
||||
"string %q": "",
|
||||
"string %s": "",
|
||||
"string %v": "",
|
||||
"time.Duration %d": "",
|
||||
"time.Duration %v": "",
|
||||
"uint %04x": "",
|
||||
"uint %5d": "",
|
||||
"uint %d": "",
|
||||
"uint %x": "",
|
||||
"uint16 %d": "",
|
||||
"uint16 %v": "",
|
||||
"uint16 %x": "",
|
||||
"uint32 %d": "",
|
||||
"uint32 %v": "",
|
||||
"uint32 %x": "",
|
||||
"uint64 %08x": "",
|
||||
"uint64 %d": "",
|
||||
"uint64 %x": "",
|
||||
"uint8 %d": "",
|
||||
"uint8 %x": "",
|
||||
"uintptr %d": "",
|
||||
}
|
||||
|
@ -778,15 +778,26 @@ func functypefield0(t *types.Type, this *types.Field, in, out []*types.Field) {
|
||||
|
||||
// origSym returns the original symbol written by the user.
|
||||
func origSym(s *types.Sym) *types.Sym {
|
||||
if s != nil && s.Name[0] == '~' {
|
||||
if s == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(s.Name) > 1 && s.Name[0] == '~' {
|
||||
switch s.Name[1] {
|
||||
case 'r': // originally an unnamed result
|
||||
s = nil
|
||||
return nil
|
||||
case 'b': // originally the blank identifier _
|
||||
// TODO(mdempsky): Does s.Pkg matter here?
|
||||
s = nblank.Sym
|
||||
return nblank.Sym
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
if strings.HasPrefix(s.Name, ".anon") {
|
||||
// originally an unnamed or _ name (see subr.go: structargs)
|
||||
return nil
|
||||
}
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
|
@ -1268,7 +1268,7 @@ func (n *Node) exprfmt(s fmt.State, prec int, mode fmtMode) {
|
||||
|
||||
case OTARRAY:
|
||||
if n.Left != nil {
|
||||
mode.Fprintf(s, "[]%v", n.Left)
|
||||
mode.Fprintf(s, "[%v]%v", n.Left, n.Right)
|
||||
return
|
||||
}
|
||||
mode.Fprintf(s, "[]%v", n.Right) // happens before typecheck
|
||||
@ -1599,7 +1599,7 @@ func (n *Node) nodedump(s fmt.State, flag FmtFlag, mode fmtMode) {
|
||||
|
||||
case OTYPE:
|
||||
mode.Fprintf(s, "%v %v%j type=%v", n.Op, n.Sym, n, n.Type)
|
||||
if recur && n.Type == nil && n.Name.Param.Ntype != nil {
|
||||
if recur && n.Type == nil && n.Name != nil && n.Name.Param != nil && n.Name.Param.Ntype != nil {
|
||||
indent(s)
|
||||
mode.Fprintf(s, "%v-ntype%v", n.Op, n.Name.Param.Ntype)
|
||||
}
|
||||
|
@ -352,7 +352,7 @@ func (v *hairyVisitor) visit(n *Node) bool {
|
||||
v.budget -= v.extraCallCost
|
||||
|
||||
case OPANIC:
|
||||
v.budget -= v.extraCallCost
|
||||
v.budget -= inlineExtraPanicCost
|
||||
|
||||
case ORECOVER:
|
||||
// recover matches the argument frame pointer to find
|
||||
|
@ -532,6 +532,10 @@ func Main(archInit func(*Arch)) {
|
||||
checkMapKeys()
|
||||
timings.AddEvent(fcount, "funcs")
|
||||
|
||||
if nsavederrors+nerrors != 0 {
|
||||
errorexit()
|
||||
}
|
||||
|
||||
// Phase 4: Decide how to capture closed variables.
|
||||
// This needs to run before escape analysis,
|
||||
// because variables captured by value do not escape.
|
||||
@ -659,14 +663,6 @@ func Main(archInit func(*Arch)) {
|
||||
Ctxt.DwFixups = nil
|
||||
genDwarfInline = 0
|
||||
}
|
||||
|
||||
// Check whether any of the functions we have compiled have gigantic stack frames.
|
||||
obj.SortSlice(largeStackFrames, func(i, j int) bool {
|
||||
return largeStackFrames[i].Before(largeStackFrames[j])
|
||||
})
|
||||
for _, largePos := range largeStackFrames {
|
||||
yyerrorl(largePos, "stack frame too large (>1GB)")
|
||||
}
|
||||
}
|
||||
|
||||
// Phase 9: Check external declarations.
|
||||
@ -688,6 +684,14 @@ func Main(archInit func(*Arch)) {
|
||||
dumpasmhdr()
|
||||
}
|
||||
|
||||
// Check whether any of the functions we have compiled have gigantic stack frames.
|
||||
obj.SortSlice(largeStackFrames, func(i, j int) bool {
|
||||
return largeStackFrames[i].Before(largeStackFrames[j])
|
||||
})
|
||||
for _, largePos := range largeStackFrames {
|
||||
yyerrorl(largePos, "stack frame too large (>1GB)")
|
||||
}
|
||||
|
||||
if len(compilequeue) != 0 {
|
||||
Fatalf("%d uncompiled functions", len(compilequeue))
|
||||
}
|
||||
|
@ -257,18 +257,32 @@ const maxStackSize = 1 << 30
|
||||
// worker indicates which of the backend workers is doing the processing.
|
||||
func compileSSA(fn *Node, worker int) {
|
||||
f := buildssa(fn, worker)
|
||||
if f.Frontend().(*ssafn).stksize >= maxStackSize {
|
||||
// Note: check arg size to fix issue 25507.
|
||||
if f.Frontend().(*ssafn).stksize >= maxStackSize || fn.Type.ArgWidth() >= maxStackSize {
|
||||
largeStackFramesMu.Lock()
|
||||
largeStackFrames = append(largeStackFrames, fn.Pos)
|
||||
largeStackFramesMu.Unlock()
|
||||
return
|
||||
}
|
||||
pp := newProgs(fn, worker)
|
||||
defer pp.Free()
|
||||
genssa(f, pp)
|
||||
// Check frame size again.
|
||||
// The check above included only the space needed for local variables.
|
||||
// After genssa, the space needed includes local variables and the callee arg region.
|
||||
// We must do this check prior to calling pp.Flush.
|
||||
// If there are any oversized stack frames,
|
||||
// the assembler may emit inscrutable complaints about invalid instructions.
|
||||
if pp.Text.To.Offset >= maxStackSize {
|
||||
largeStackFramesMu.Lock()
|
||||
largeStackFrames = append(largeStackFrames, fn.Pos)
|
||||
largeStackFramesMu.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
pp.Flush() // assemble, fill in boilerplate, etc.
|
||||
// fieldtrack must be called after pp.Flush. See issue 20014.
|
||||
fieldtrack(pp.Text.From.Sym, fn.Func.FieldTrack)
|
||||
pp.Free()
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
@ -14,7 +14,7 @@ import (
|
||||
|
||||
// This file contains the algorithm to place phi nodes in a function.
|
||||
// For small functions, we use Braun, Buchwald, Hack, Leißa, Mallon, and Zwinkau.
|
||||
// http://pp.info.uni-karlsruhe.de/uploads/publikationen/braun13cc.pdf
|
||||
// https://pp.info.uni-karlsruhe.de/uploads/publikationen/braun13cc.pdf
|
||||
// For large functions, we use Sreedhar & Gao: A Linear Time Algorithm for Placing Φ-Nodes.
|
||||
// http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.8.1979&rep=rep1&type=pdf
|
||||
|
||||
|
@ -461,17 +461,6 @@ func (lv *Liveness) regEffects(v *ssa.Value) (uevar, kill liveRegMask) {
|
||||
for _, reg := range regs[:nreg] {
|
||||
if reg.GCNum() == -1 {
|
||||
if ptrOnly {
|
||||
if reg.String() == "g" {
|
||||
// Issue #25504: Sometimes we
|
||||
// spill and reload the g
|
||||
// register, which this sees
|
||||
// as a pointer load into the
|
||||
// g register. The g register
|
||||
// isn't a GP register and
|
||||
// can't appear in register
|
||||
// maps. Ignore it.
|
||||
continue
|
||||
}
|
||||
v.Fatalf("pointer in non-pointer register %v", reg)
|
||||
} else {
|
||||
continue
|
||||
|
@ -4078,7 +4078,7 @@ func canMergeLoads() bool {
|
||||
}
|
||||
|
||||
// isRuneCount reports whether n is of the form len([]rune(string)).
|
||||
// These are optimized into a call to runtime.runecount.
|
||||
// These are optimized into a call to runtime.countrunes.
|
||||
func isRuneCount(n *Node) bool {
|
||||
return Debug['N'] == 0 && !instrumenting && n.Op == OLEN && n.Left.Op == OSTRARRAYRUNE
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
package ssa
|
||||
|
||||
// branchelim tries to elminiate branches by
|
||||
// branchelim tries to eliminate branches by
|
||||
// generating CondSelect instructions.
|
||||
//
|
||||
// Search for basic blocks that look like
|
||||
|
@ -252,6 +252,19 @@ func deadcode(f *Func) {
|
||||
b.Values = b.Values[:i]
|
||||
}
|
||||
|
||||
// Remove dead blocks from WBLoads list.
|
||||
i = 0
|
||||
for _, b := range f.WBLoads {
|
||||
if reachable[b.ID] {
|
||||
f.WBLoads[i] = b
|
||||
i++
|
||||
}
|
||||
}
|
||||
for j := i; j < len(f.WBLoads); j++ {
|
||||
f.WBLoads[j] = nil
|
||||
}
|
||||
f.WBLoads = f.WBLoads[:i]
|
||||
|
||||
// Remove unreachable blocks. Return dead blocks to allocator.
|
||||
i = 0
|
||||
for _, b := range f.Blocks {
|
||||
|
@ -28,6 +28,7 @@ var testCtxts = map[string]*obj.Link{
|
||||
|
||||
func testConfig(tb testing.TB) *Conf { return testConfigArch(tb, "amd64") }
|
||||
func testConfigS390X(tb testing.TB) *Conf { return testConfigArch(tb, "s390x") }
|
||||
func testConfigARM64(tb testing.TB) *Conf { return testConfigArch(tb, "arm64") }
|
||||
|
||||
func testConfigArch(tb testing.TB, arch string) *Conf {
|
||||
ctxt, ok := testCtxts[arch]
|
||||
|
@ -349,10 +349,10 @@ func init() {
|
||||
// result is undefined if the input is zero.
|
||||
// flags are set to "equal" if the input is zero, "not equal" otherwise.
|
||||
// BS{F,R}L returns only the result.
|
||||
{name: "BSFQ", argLength: 1, reg: gp11flags, asm: "BSFQ", typ: "(UInt64,Flags)"}, // # of low-order zeroes in 64-bit arg
|
||||
{name: "BSFL", argLength: 1, reg: gp11, asm: "BSFL", typ: "UInt32"}, // # of low-order zeroes in 32-bit arg
|
||||
{name: "BSRQ", argLength: 1, reg: gp11flags, asm: "BSRQ", typ: "(UInt64,Flags)"}, // # of high-order zeroes in 64-bit arg
|
||||
{name: "BSRL", argLength: 1, reg: gp11, asm: "BSRL", typ: "UInt32"}, // # of high-order zeroes in 32-bit arg
|
||||
{name: "BSFQ", argLength: 1, reg: gp11flags, asm: "BSFQ", typ: "(UInt64,Flags)"}, // # of low-order zeroes in 64-bit arg
|
||||
{name: "BSFL", argLength: 1, reg: gp11, asm: "BSFL", typ: "UInt32", clobberFlags: true}, // # of low-order zeroes in 32-bit arg
|
||||
{name: "BSRQ", argLength: 1, reg: gp11flags, asm: "BSRQ", typ: "(UInt64,Flags)"}, // # of high-order zeroes in 64-bit arg
|
||||
{name: "BSRL", argLength: 1, reg: gp11, asm: "BSRL", typ: "UInt32", clobberFlags: true}, // # of high-order zeroes in 32-bit arg
|
||||
|
||||
// CMOV instructions: 64, 32 and 16-bit sizes.
|
||||
// if arg2 encodes a true result, return arg1, else arg0
|
||||
|
@ -46,8 +46,7 @@
|
||||
(Not x) -> (I64Eqz x)
|
||||
|
||||
// Lowering pointer arithmetic
|
||||
(OffPtr [0] ptr) -> ptr
|
||||
(OffPtr [off] ptr) && off > 0 -> (I64AddConst [off] ptr)
|
||||
(OffPtr [off] ptr) -> (I64AddConst [off] ptr)
|
||||
|
||||
// Lowering extension
|
||||
// It is unnecessary to extend loads
|
||||
@ -388,6 +387,7 @@
|
||||
(I64Ne x (I64Const [0])) -> (I64Eqz (I64Eqz x))
|
||||
|
||||
(I64Add x (I64Const [y])) -> (I64AddConst [y] x)
|
||||
(I64AddConst [0] x) -> x
|
||||
(I64Eqz (I64Eqz (I64Eqz x))) -> (I64Eqz x)
|
||||
|
||||
((I64Load|I64Load32U|I64Load32S|I64Load16U|I64Load16S|I64Load8U|I64Load8S) [off] (I64AddConst [off2] ptr) mem)
|
||||
|
@ -212,7 +212,7 @@
|
||||
// (Mod64u x y) is always between 0 (inclusive) and y (exclusive).
|
||||
(IsInBounds (Mod32u _ y) y) -> (ConstBool [1])
|
||||
(IsInBounds (Mod64u _ y) y) -> (ConstBool [1])
|
||||
// Right shifting a unsigned number limits its value.
|
||||
// Right shifting an unsigned number limits its value.
|
||||
(IsInBounds (ZeroExt8to64 (Rsh8Ux64 _ (Const64 [c]))) (Const64 [d])) && 0 < c && c < 8 && 1<<uint( 8-c)-1 < d -> (ConstBool [1])
|
||||
(IsInBounds (ZeroExt8to32 (Rsh8Ux64 _ (Const64 [c]))) (Const32 [d])) && 0 < c && c < 8 && 1<<uint( 8-c)-1 < d -> (ConstBool [1])
|
||||
(IsInBounds (ZeroExt8to16 (Rsh8Ux64 _ (Const64 [c]))) (Const16 [d])) && 0 < c && c < 8 && 1<<uint( 8-c)-1 < d -> (ConstBool [1])
|
||||
|
@ -7393,9 +7393,10 @@ var opcodeTable = [...]opInfo{
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "BSFL",
|
||||
argLen: 1,
|
||||
asm: x86.ABSFL,
|
||||
name: "BSFL",
|
||||
argLen: 1,
|
||||
clobberFlags: true,
|
||||
asm: x86.ABSFL,
|
||||
reg: regInfo{
|
||||
inputs: []inputInfo{
|
||||
{0, 65519}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R14 R15
|
||||
@ -7420,9 +7421,10 @@ var opcodeTable = [...]opInfo{
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "BSRL",
|
||||
argLen: 1,
|
||||
asm: x86.ABSRL,
|
||||
name: "BSRL",
|
||||
argLen: 1,
|
||||
clobberFlags: true,
|
||||
asm: x86.ABSRL,
|
||||
reg: regInfo{
|
||||
inputs: []inputInfo{
|
||||
{0, 65519}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R14 R15
|
||||
|
@ -532,6 +532,9 @@ func (s *regAllocState) allocValToReg(v *Value, mask regMask, nospill bool, pos
|
||||
}
|
||||
|
||||
s.assignReg(r, v, c)
|
||||
if c.Op == OpLoadReg && s.isGReg(r) {
|
||||
s.f.Fatalf("allocValToReg.OpLoadReg targeting g: " + c.LongString())
|
||||
}
|
||||
if nospill {
|
||||
s.nospill |= regMask(1) << r
|
||||
}
|
||||
@ -809,6 +812,10 @@ func (s *regAllocState) regspec(op Op) regInfo {
|
||||
return opcodeTable[op].reg
|
||||
}
|
||||
|
||||
func (s *regAllocState) isGReg(r register) bool {
|
||||
return s.f.Config.hasGReg && s.GReg == r
|
||||
}
|
||||
|
||||
func (s *regAllocState) regalloc(f *Func) {
|
||||
regValLiveSet := f.newSparseSet(f.NumValues()) // set of values that may be live in register
|
||||
defer f.retSparseSet(regValLiveSet)
|
||||
@ -951,6 +958,7 @@ func (s *regAllocState) regalloc(f *Func) {
|
||||
// Majority vote? Deepest nesting level?
|
||||
phiRegs = phiRegs[:0]
|
||||
var phiUsed regMask
|
||||
|
||||
for _, v := range phis {
|
||||
if !s.values[v.ID].needReg {
|
||||
phiRegs = append(phiRegs, noRegister)
|
||||
@ -1516,6 +1524,9 @@ func (s *regAllocState) regalloc(f *Func) {
|
||||
// predecessor of it, find live values that we use soon after
|
||||
// the merge point and promote them to registers now.
|
||||
if len(b.Succs) == 1 {
|
||||
if s.f.Config.hasGReg && s.regs[s.GReg].v != nil {
|
||||
s.freeReg(s.GReg) // Spill value in G register before any merge.
|
||||
}
|
||||
// For this to be worthwhile, the loop must have no calls in it.
|
||||
top := b.Succs[0].b
|
||||
loop := s.loopnest.b2l[top.ID]
|
||||
@ -1996,6 +2007,9 @@ func (e *edgeState) process() {
|
||||
c = e.p.NewValue1(pos, OpLoadReg, c.Type, c)
|
||||
}
|
||||
e.set(r, vid, c, false, pos)
|
||||
if c.Op == OpLoadReg && e.s.isGReg(register(r.(*Register).num)) {
|
||||
e.s.f.Fatalf("process.OpLoadReg targeting g: " + c.LongString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2110,6 +2124,9 @@ func (e *edgeState) processDest(loc Location, vid ID, splice **Value, pos src.XP
|
||||
}
|
||||
}
|
||||
e.set(loc, vid, x, true, pos)
|
||||
if x.Op == OpLoadReg && e.s.isGReg(register(loc.(*Register).num)) {
|
||||
e.s.f.Fatalf("processDest.OpLoadReg targeting g: " + x.LongString())
|
||||
}
|
||||
if splice != nil {
|
||||
(*splice).Uses--
|
||||
*splice = x
|
||||
|
@ -36,6 +36,55 @@ func TestLiveControlOps(t *testing.T) {
|
||||
checkFunc(f.f)
|
||||
}
|
||||
|
||||
// Test to make sure G register is never reloaded from spill (spill of G is okay)
|
||||
// See #25504
|
||||
func TestNoGetgLoadReg(t *testing.T) {
|
||||
/*
|
||||
Original:
|
||||
func fff3(i int) *g {
|
||||
gee := getg()
|
||||
if i == 0 {
|
||||
fff()
|
||||
}
|
||||
return gee // here
|
||||
}
|
||||
*/
|
||||
c := testConfigARM64(t)
|
||||
f := c.Fun("b1",
|
||||
Bloc("b1",
|
||||
Valu("v1", OpInitMem, types.TypeMem, 0, nil),
|
||||
Valu("v6", OpArg, c.config.Types.Int64, 0, c.Frontend().Auto(src.NoXPos, c.config.Types.Int64)),
|
||||
Valu("v8", OpGetG, c.config.Types.Int64.PtrTo(), 0, nil, "v1"),
|
||||
Valu("v11", OpARM64CMPconst, types.TypeFlags, 0, nil, "v6"),
|
||||
Eq("v11", "b2", "b4"),
|
||||
),
|
||||
Bloc("b4",
|
||||
Goto("b3"),
|
||||
),
|
||||
Bloc("b3",
|
||||
Valu("v14", OpPhi, types.TypeMem, 0, nil, "v1", "v12"),
|
||||
Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil),
|
||||
Valu("v16", OpARM64MOVDstore, types.TypeMem, 0, nil, "v8", "sb", "v14"),
|
||||
Exit("v16"),
|
||||
),
|
||||
Bloc("b2",
|
||||
Valu("v12", OpARM64CALLstatic, types.TypeMem, 0, nil, "v1"),
|
||||
Goto("b3"),
|
||||
),
|
||||
)
|
||||
regalloc(f.f)
|
||||
checkFunc(f.f)
|
||||
// Double-check that we never restore to the G register. Regalloc should catch it, but check again anyway.
|
||||
r := f.f.RegAlloc
|
||||
for _, b := range f.blocks {
|
||||
for _, v := range b.Values {
|
||||
if v.Op == OpLoadReg && r[v.ID].String() == "g" {
|
||||
t.Errorf("Saw OpLoadReg targeting g register: %s", v.LongString())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test to make sure we don't push spills into loops.
|
||||
// See issue #19595.
|
||||
func TestSpillWithLoop(t *testing.T) {
|
||||
|
@ -463,6 +463,8 @@ func rewriteValueWasm(v *Value) bool {
|
||||
return rewriteValueWasm_OpWasmF64Mul_0(v)
|
||||
case OpWasmI64Add:
|
||||
return rewriteValueWasm_OpWasmI64Add_0(v)
|
||||
case OpWasmI64AddConst:
|
||||
return rewriteValueWasm_OpWasmI64AddConst_0(v)
|
||||
case OpWasmI64And:
|
||||
return rewriteValueWasm_OpWasmI64And_0(v)
|
||||
case OpWasmI64Eq:
|
||||
@ -3688,34 +3690,17 @@ func rewriteValueWasm_OpNot_0(v *Value) bool {
|
||||
}
|
||||
}
|
||||
func rewriteValueWasm_OpOffPtr_0(v *Value) bool {
|
||||
// match: (OffPtr [0] ptr)
|
||||
// cond:
|
||||
// result: ptr
|
||||
for {
|
||||
if v.AuxInt != 0 {
|
||||
break
|
||||
}
|
||||
ptr := v.Args[0]
|
||||
v.reset(OpCopy)
|
||||
v.Type = ptr.Type
|
||||
v.AddArg(ptr)
|
||||
return true
|
||||
}
|
||||
// match: (OffPtr [off] ptr)
|
||||
// cond: off > 0
|
||||
// cond:
|
||||
// result: (I64AddConst [off] ptr)
|
||||
for {
|
||||
off := v.AuxInt
|
||||
ptr := v.Args[0]
|
||||
if !(off > 0) {
|
||||
break
|
||||
}
|
||||
v.reset(OpWasmI64AddConst)
|
||||
v.AuxInt = off
|
||||
v.AddArg(ptr)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
func rewriteValueWasm_OpOr16_0(v *Value) bool {
|
||||
// match: (Or16 x y)
|
||||
@ -5211,6 +5196,22 @@ func rewriteValueWasm_OpWasmI64Add_0(v *Value) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
func rewriteValueWasm_OpWasmI64AddConst_0(v *Value) bool {
|
||||
// match: (I64AddConst [0] x)
|
||||
// cond:
|
||||
// result: x
|
||||
for {
|
||||
if v.AuxInt != 0 {
|
||||
break
|
||||
}
|
||||
x := v.Args[0]
|
||||
v.reset(OpCopy)
|
||||
v.Type = x.Type
|
||||
v.AddArg(x)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
func rewriteValueWasm_OpWasmI64And_0(v *Value) bool {
|
||||
b := v.Block
|
||||
_ = b
|
||||
|
@ -6,7 +6,7 @@ package ssa
|
||||
|
||||
import "cmd/internal/src"
|
||||
|
||||
// from http://research.swtch.com/sparse
|
||||
// from https://research.swtch.com/sparse
|
||||
// in turn, from Briggs and Torczon
|
||||
|
||||
type sparseEntry struct {
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
package ssa
|
||||
|
||||
// from http://research.swtch.com/sparse
|
||||
// from https://research.swtch.com/sparse
|
||||
// in turn, from Briggs and Torczon
|
||||
|
||||
type sparseSet struct {
|
||||
|
@ -5,6 +5,7 @@
|
||||
package main_test
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"flag"
|
||||
"fmt"
|
||||
@ -17,6 +18,7 @@ import (
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
@ -36,6 +38,12 @@ var (
|
||||
coverInput = filepath.Join(testdata, "test_line.go")
|
||||
coverOutput = filepath.Join(testdata, "test_cover.go")
|
||||
coverProfile = filepath.Join(testdata, "profile.cov")
|
||||
|
||||
// The HTML test files are in a separate directory
|
||||
// so they are a complete package.
|
||||
htmlProfile = filepath.Join(testdata, "html", "html.cov")
|
||||
htmlHTML = filepath.Join(testdata, "html", "html.html")
|
||||
htmlGolden = filepath.Join(testdata, "html", "html.golden")
|
||||
)
|
||||
|
||||
var debug = flag.Bool("debug", false, "keep rewritten files for debugging")
|
||||
@ -256,6 +264,61 @@ func TestCoverFunc(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Check that cover produces correct HTML.
|
||||
// Issue #25767.
|
||||
func TestCoverHTML(t *testing.T) {
|
||||
if _, err := exec.LookPath("diff"); err != nil {
|
||||
t.Skipf("skip test on %s: diff command is required", runtime.GOOS)
|
||||
}
|
||||
testenv.MustHaveGoBuild(t)
|
||||
if !*debug {
|
||||
defer os.Remove(testcover)
|
||||
defer os.Remove(htmlProfile)
|
||||
defer os.Remove(htmlHTML)
|
||||
}
|
||||
// go build -o testcover
|
||||
cmd := exec.Command(testenv.GoToolPath(t), "build", "-o", testcover)
|
||||
run(cmd, t)
|
||||
// go test -coverprofile testdata/html/html.cov cmd/cover/testdata/html
|
||||
cmd = exec.Command(testenv.GoToolPath(t), "test", "-coverprofile", htmlProfile, "cmd/cover/testdata/html")
|
||||
run(cmd, t)
|
||||
// ./testcover -html testdata/html/html.cov -o testdata/html/html.html
|
||||
cmd = exec.Command(testcover, "-html", htmlProfile, "-o", htmlHTML)
|
||||
run(cmd, t)
|
||||
|
||||
// Extract the parts of the HTML with comment markers,
|
||||
// and compare against a golden file.
|
||||
entireHTML, err := ioutil.ReadFile(htmlHTML)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var out bytes.Buffer
|
||||
scan := bufio.NewScanner(bytes.NewReader(entireHTML))
|
||||
in := false
|
||||
for scan.Scan() {
|
||||
line := scan.Text()
|
||||
if strings.Contains(line, "// START") {
|
||||
in = true
|
||||
}
|
||||
if in {
|
||||
fmt.Fprintln(&out, line)
|
||||
}
|
||||
if strings.Contains(line, "// END") {
|
||||
in = false
|
||||
}
|
||||
}
|
||||
if err := ioutil.WriteFile(htmlHTML, out.Bytes(), 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
diff := "diff"
|
||||
if runtime.GOOS == "plan9" {
|
||||
diff = "/bin/ape/diff"
|
||||
}
|
||||
// diff -uw testdata/html/html.html testdata/html/html.golden
|
||||
cmd = exec.Command(diff, "-u", "-w", htmlHTML, htmlGolden)
|
||||
run(cmd, t)
|
||||
}
|
||||
|
||||
func run(c *exec.Cmd, t *testing.T) {
|
||||
t.Helper()
|
||||
c.Stdout = os.Stdout
|
||||
|
@ -153,6 +153,7 @@ type Boundary struct {
|
||||
Start bool // Is this the start of a block?
|
||||
Count int // Event count from the cover profile.
|
||||
Norm float64 // Count normalized to [0..1].
|
||||
Index int // Order in input file.
|
||||
}
|
||||
|
||||
// Boundaries returns a Profile as a set of Boundary objects within the provided src.
|
||||
@ -168,13 +169,15 @@ func (p *Profile) Boundaries(src []byte) (boundaries []Boundary) {
|
||||
divisor := math.Log(float64(max))
|
||||
|
||||
// boundary returns a Boundary, populating the Norm field with a normalized Count.
|
||||
index := 0
|
||||
boundary := func(offset int, start bool, count int) Boundary {
|
||||
b := Boundary{Offset: offset, Start: start, Count: count}
|
||||
b := Boundary{Offset: offset, Start: start, Count: count, Index: index}
|
||||
index++
|
||||
if !start || count == 0 {
|
||||
return b
|
||||
}
|
||||
if max <= 1 {
|
||||
b.Norm = 0.8 // Profile is in"set" mode; we want a heat map. Use cov8 in the CSS.
|
||||
b.Norm = 0.8 // Profile is in "set" mode; we want a heat map. Use cov8 in the CSS.
|
||||
} else if count > 0 {
|
||||
b.Norm = math.Log(float64(count)) / divisor
|
||||
}
|
||||
@ -209,7 +212,9 @@ func (b boundariesByPos) Len() int { return len(b) }
|
||||
func (b boundariesByPos) Swap(i, j int) { b[i], b[j] = b[j], b[i] }
|
||||
func (b boundariesByPos) Less(i, j int) bool {
|
||||
if b[i].Offset == b[j].Offset {
|
||||
return !b[i].Start && b[j].Start
|
||||
// Boundaries at the same offset should be ordered according to
|
||||
// their original position.
|
||||
return b[i].Index < b[j].Index
|
||||
}
|
||||
return b[i].Offset < b[j].Offset
|
||||
}
|
||||
|
30
src/cmd/cover/testdata/html/html.go
vendored
Normal file
30
src/cmd/cover/testdata/html/html.go
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
package html
|
||||
|
||||
import "fmt"
|
||||
|
||||
// This file is tested by html_test.go.
|
||||
// The comments below are markers for extracting the annotated source
|
||||
// from the HTML output.
|
||||
|
||||
// This is a regression test for incorrect sorting of boundaries
|
||||
// that coincide, specifically for empty select clauses.
|
||||
// START f
|
||||
func f() {
|
||||
ch := make(chan int)
|
||||
select {
|
||||
case <-ch:
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
// END f
|
||||
|
||||
// https://golang.org/issue/25767
|
||||
// START g
|
||||
func g() {
|
||||
if false {
|
||||
fmt.Printf("Hello")
|
||||
}
|
||||
}
|
||||
|
||||
// END g
|
18
src/cmd/cover/testdata/html/html.golden
vendored
Normal file
18
src/cmd/cover/testdata/html/html.golden
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
// START f
|
||||
func f() <span class="cov8" title="1">{
|
||||
ch := make(chan int)
|
||||
select </span>{
|
||||
case <-ch:<span class="cov0" title="0"></span>
|
||||
default:<span class="cov8" title="1"></span>
|
||||
}
|
||||
}
|
||||
|
||||
// END f
|
||||
// START g
|
||||
func g() <span class="cov8" title="1">{
|
||||
if false </span><span class="cov0" title="0">{
|
||||
fmt.Printf("Hello")
|
||||
}</span>
|
||||
}
|
||||
|
||||
// END g
|
8
src/cmd/cover/testdata/html/html_test.go
vendored
Normal file
8
src/cmd/cover/testdata/html/html_test.go
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
package html
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestAll(t *testing.T) {
|
||||
f()
|
||||
g()
|
||||
}
|
2
src/cmd/dist/build.go
vendored
2
src/cmd/dist/build.go
vendored
@ -1438,7 +1438,7 @@ func checkCC() {
|
||||
fatalf("cannot invoke C compiler %q: %v\n\n"+
|
||||
"Go needs a system C compiler for use with cgo.\n"+
|
||||
"To set a C compiler, set CC=the-compiler.\n"+
|
||||
"To disable cgo, set CGO_ENABLED=0.\n%s%s", defaultcc, err, outputHdr, output)
|
||||
"To disable cgo, set CGO_ENABLED=0.\n%s%s", defaultcc[""], err, outputHdr, output)
|
||||
}
|
||||
}
|
||||
|
||||
|
26
src/cmd/dist/main.go
vendored
26
src/cmd/dist/main.go
vendored
@ -9,7 +9,6 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -61,6 +60,8 @@ func main() {
|
||||
// Even on 64-bit platform, darwin uname -m prints i386.
|
||||
// We don't support any of the OS X versions that run on 32-bit-only hardware anymore.
|
||||
gohostarch = "amd64"
|
||||
// macOS 10.9 and later require clang
|
||||
defaultclang = true
|
||||
case "freebsd":
|
||||
// Since FreeBSD 10 gcc is no longer part of the base system.
|
||||
defaultclang = true
|
||||
@ -126,29 +127,6 @@ func main() {
|
||||
}
|
||||
bginit()
|
||||
|
||||
// The OS X 10.6 linker does not support external linking mode.
|
||||
// See golang.org/issue/5130.
|
||||
//
|
||||
// OS X 10.6 does not work with clang either, but OS X 10.9 requires it.
|
||||
// It seems to work with OS X 10.8, so we default to clang for 10.8 and later.
|
||||
// See golang.org/issue/5822.
|
||||
//
|
||||
// Roughly, OS X 10.N shows up as uname release (N+4),
|
||||
// so OS X 10.6 is uname version 10 and OS X 10.8 is uname version 12.
|
||||
if gohostos == "darwin" {
|
||||
rel := run("", CheckExit, "uname", "-r")
|
||||
if i := strings.Index(rel, "."); i >= 0 {
|
||||
rel = rel[:i]
|
||||
}
|
||||
osx, _ := strconv.Atoi(rel)
|
||||
if osx <= 6+4 {
|
||||
goextlinkenabled = "0"
|
||||
}
|
||||
if osx >= 8+4 {
|
||||
defaultclang = true
|
||||
}
|
||||
}
|
||||
|
||||
if len(os.Args) > 1 && os.Args[1] == "-check-goarm" {
|
||||
useVFPv1() // might fail with SIGILL
|
||||
println("VFPv1 OK.")
|
||||
|
2
src/cmd/dist/sys_windows.go
vendored
2
src/cmd/dist/sys_windows.go
vendored
@ -14,7 +14,7 @@ var (
|
||||
procGetSystemInfo = modkernel32.NewProc("GetSystemInfo")
|
||||
)
|
||||
|
||||
// see http://msdn.microsoft.com/en-us/library/windows/desktop/ms724958(v=vs.85).aspx
|
||||
// see https://msdn.microsoft.com/en-us/library/windows/desktop/ms724958(v=vs.85).aspx
|
||||
type systeminfo struct {
|
||||
wProcessorArchitecture uint16
|
||||
wReserved uint16
|
||||
|
11
src/cmd/dist/test.go
vendored
11
src/cmd/dist/test.go
vendored
@ -889,7 +889,7 @@ func (t *tester) extLink() bool {
|
||||
pair := gohostos + "-" + goarch
|
||||
switch pair {
|
||||
case "android-arm",
|
||||
"darwin-arm", "darwin-arm64",
|
||||
"darwin-386", "darwin-amd64", "darwin-arm", "darwin-arm64",
|
||||
"dragonfly-amd64",
|
||||
"freebsd-386", "freebsd-amd64", "freebsd-arm",
|
||||
"linux-386", "linux-amd64", "linux-arm", "linux-arm64", "linux-ppc64le", "linux-mips64", "linux-mips64le", "linux-mips", "linux-mipsle", "linux-s390x",
|
||||
@ -897,15 +897,6 @@ func (t *tester) extLink() bool {
|
||||
"openbsd-386", "openbsd-amd64",
|
||||
"windows-386", "windows-amd64":
|
||||
return true
|
||||
case "darwin-386", "darwin-amd64":
|
||||
// linkmode=external fails on OS X 10.6 and earlier == Darwin
|
||||
// 10.8 and earlier.
|
||||
unameR, err := exec.Command("uname", "-r").Output()
|
||||
if err != nil {
|
||||
log.Fatalf("uname -r: %v", err)
|
||||
}
|
||||
major, _ := strconv.Atoi(string(unameR[:bytes.IndexByte(unameR, '.')]))
|
||||
return major > 10
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
@ -579,7 +579,7 @@
|
||||
//
|
||||
// Usage:
|
||||
//
|
||||
// go list [-deps] [-e] [-f format] [-json] [-test] [build flags] [packages]
|
||||
// go list [-cgo] [-deps] [-e] [-export] [-f format] [-json] [-list] [-test] [build flags] [packages]
|
||||
//
|
||||
// List lists the packages named by the import paths, one per line.
|
||||
//
|
||||
@ -609,6 +609,9 @@
|
||||
// Root string // Go root or Go path dir containing this package
|
||||
// ConflictDir string // this directory shadows Dir in $GOPATH
|
||||
// BinaryOnly bool // binary-only package: cannot be recompiled from sources
|
||||
// ForTest string // package is only for use in named test
|
||||
// DepOnly bool // package is only a dependency, not explicitly listed
|
||||
// Export string // file containing export data (when using -export)
|
||||
//
|
||||
// // Source files
|
||||
// GoFiles []string // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles)
|
||||
@ -683,9 +686,15 @@
|
||||
// The -json flag causes the package data to be printed in JSON format
|
||||
// instead of using the template format.
|
||||
//
|
||||
// The -cgo flag causes list to set CgoFiles not to the original *.go files
|
||||
// importing "C" but instead to the translated files generated by the cgo
|
||||
// command.
|
||||
//
|
||||
// The -deps flag causes list to iterate over not just the named packages
|
||||
// but also all their dependencies. It visits them in a depth-first post-order
|
||||
// traversal, so that a package is listed only after all its dependencies.
|
||||
// Packages not explicitly listed on the command line will have the DepOnly
|
||||
// field set to true.
|
||||
//
|
||||
// The -e flag changes the handling of erroneous packages, those that
|
||||
// cannot be found or are malformed. By default, the list command
|
||||
@ -697,6 +706,9 @@
|
||||
// a non-nil Error field; other information may or may not be missing
|
||||
// (zeroed).
|
||||
//
|
||||
// The -export flag causes list to set the Export field to the name of a
|
||||
// file containing up-to-date export information for the given package.
|
||||
//
|
||||
// The -test flag causes list to report not only the named packages
|
||||
// but also their test binaries (for packages with tests), to convey to
|
||||
// source code analysis tools exactly how test binaries are constructed.
|
||||
@ -707,7 +719,18 @@
|
||||
// package itself). The reported import path of a package recompiled
|
||||
// for a particular test binary is followed by a space and the name of
|
||||
// the test binary in brackets, as in "math/rand [math/rand.test]"
|
||||
// or "regexp [sort.test]".
|
||||
// or "regexp [sort.test]". The ForTest field is also set to the name
|
||||
// of the package being tested ("math/rand" or "sort" in the previous
|
||||
// examples).
|
||||
//
|
||||
// The Dir, Target, Shlib, Root, ConflictDir, and Export file paths
|
||||
// are all absolute paths.
|
||||
//
|
||||
// By default, the lists GoFiles, CgoFiles, and so on hold names of files in Dir
|
||||
// (that is, paths relative to Dir, not absolute paths).
|
||||
// The extra entries added by the -cgo and -test flags are absolute paths
|
||||
// referring to cached copies of generated Go source files.
|
||||
// Although they are Go source files, the paths may not end in ".go".
|
||||
//
|
||||
// For more about build flags, see 'go help build'.
|
||||
//
|
||||
|
@ -1977,6 +1977,55 @@ func TestGoListTest(t *testing.T) {
|
||||
tg.grepStdout(`^runtime/cgo$`, "missing runtime/cgo")
|
||||
}
|
||||
|
||||
func TestGoListCgo(t *testing.T) {
|
||||
tg := testgo(t)
|
||||
defer tg.cleanup()
|
||||
tg.parallel()
|
||||
tg.makeTempdir()
|
||||
tg.setenv("GOCACHE", tg.tempdir)
|
||||
|
||||
tg.run("list", "-f", `{{join .CgoFiles "\n"}}`, "net")
|
||||
if tg.stdout.String() == "" {
|
||||
t.Skip("net does not use cgo")
|
||||
}
|
||||
if strings.Contains(tg.stdout.String(), tg.tempdir) {
|
||||
t.Fatalf(".CgoFiles without -cgo unexpectedly mentioned cache %s", tg.tempdir)
|
||||
}
|
||||
tg.run("list", "-cgo", "-f", `{{join .CgoFiles "\n"}}`, "net")
|
||||
if !strings.Contains(tg.stdout.String(), tg.tempdir) {
|
||||
t.Fatalf(".CgoFiles with -cgo did not mention cache %s", tg.tempdir)
|
||||
}
|
||||
for _, file := range strings.Split(tg.stdout.String(), "\n") {
|
||||
if file == "" {
|
||||
continue
|
||||
}
|
||||
if _, err := os.Stat(file); err != nil {
|
||||
t.Fatalf("cannot find .CgoFiles result %s: %v", file, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGoListExport(t *testing.T) {
|
||||
tg := testgo(t)
|
||||
defer tg.cleanup()
|
||||
tg.parallel()
|
||||
tg.makeTempdir()
|
||||
tg.setenv("GOCACHE", tg.tempdir)
|
||||
|
||||
tg.run("list", "-f", "{{.Export}}", "strings")
|
||||
if tg.stdout.String() != "" {
|
||||
t.Fatalf(".Export without -export unexpectedly set")
|
||||
}
|
||||
tg.run("list", "-export", "-f", "{{.Export}}", "strings")
|
||||
file := strings.TrimSpace(tg.stdout.String())
|
||||
if file == "" {
|
||||
t.Fatalf(".Export with -export was empty")
|
||||
}
|
||||
if _, err := os.Stat(file); err != nil {
|
||||
t.Fatalf("cannot find .Export result %s: %v", file, err)
|
||||
}
|
||||
}
|
||||
|
||||
// Issue 4096. Validate the output of unsuccessful go install foo/quxx.
|
||||
func TestUnsuccessfulGoInstallShouldMentionMissingPackage(t *testing.T) {
|
||||
tg := testgo(t)
|
||||
@ -2925,7 +2974,7 @@ func TestCgoPkgConfig(t *testing.T) {
|
||||
// OpenBSD's pkg-config is strict about whitespace and only
|
||||
// supports backslash-escaped whitespace. It does not support
|
||||
// quotes, which the normal freedesktop.org pkg-config does
|
||||
// support. See http://man.openbsd.org/pkg-config.1
|
||||
// support. See https://man.openbsd.org/pkg-config.1
|
||||
tg.tempFile("foo.pc", `
|
||||
Name: foo
|
||||
Description: The foo library
|
||||
@ -3203,6 +3252,43 @@ func TestGoTestBuildsAnXtestContainingOnlyNonRunnableExamples(t *testing.T) {
|
||||
tg.grepStdout("File with non-runnable example was built.", "file with non-runnable example was not built")
|
||||
}
|
||||
|
||||
// issue 24570
|
||||
func TestGoTestCoverMultiPackage(t *testing.T) {
|
||||
tg := testgo(t)
|
||||
defer tg.cleanup()
|
||||
tg.run("test", "-cover", "./testdata/testcover/...")
|
||||
tg.grepStdout(`\?.*testdata/testcover/pkg1.*\d\.\d\d\ds.*coverage:.*0\.0% of statements \[no test files\]`, "expected [no test files] for pkg1")
|
||||
tg.grepStdout(`ok.*testdata/testcover/pkg2.*\d\.\d\d\ds.*coverage:.*0\.0% of statements \[no tests to run\]`, "expected [no tests to run] for pkg2")
|
||||
tg.grepStdout(`ok.*testdata/testcover/pkg3.*\d\.\d\d\ds.*coverage:.*100\.0% of statements`, "expected 100% coverage for pkg3")
|
||||
}
|
||||
|
||||
// issue 24570
|
||||
func TestGoTestCoverprofileMultiPackage(t *testing.T) {
|
||||
tg := testgo(t)
|
||||
defer tg.cleanup()
|
||||
tg.creatingTemp("testdata/cover.out")
|
||||
tg.run("test", "-coverprofile=testdata/cover.out", "./testdata/testcover/...")
|
||||
tg.grepStdout(`\?.*testdata/testcover/pkg1.*\d\.\d\d\ds.*coverage:.*0\.0% of statements \[no test files\]`, "expected [no test files] for pkg1")
|
||||
tg.grepStdout(`ok.*testdata/testcover/pkg2.*\d\.\d\d\ds.*coverage:.*0\.0% of statements \[no tests to run\]`, "expected [no tests to run] for pkg2")
|
||||
tg.grepStdout(`ok.*testdata/testcover/pkg3.*\d\.\d\d\ds.*coverage:.*100\.0% of statements`, "expected 100% coverage for pkg3")
|
||||
if out, err := ioutil.ReadFile("testdata/cover.out"); err != nil {
|
||||
t.Error(err)
|
||||
} else {
|
||||
if !bytes.Contains(out, []byte("mode: set")) {
|
||||
t.Errorf(`missing "mode: set" in %s`, out)
|
||||
}
|
||||
if !bytes.Contains(out, []byte(`pkg1/a.go:5.10,7.2 1 0`)) && !bytes.Contains(out, []byte(`pkg1\a.go:5.10,7.2 1 0`)) {
|
||||
t.Errorf(`missing "pkg1/a.go:5.10,7.2 1 0" in %s`, out)
|
||||
}
|
||||
if !bytes.Contains(out, []byte(`pkg2/a.go:5.10,7.2 1 0`)) && !bytes.Contains(out, []byte(`pkg2\a.go:5.10,7.2 1 0`)) {
|
||||
t.Errorf(`missing "pkg2/a.go:5.10,7.2 1 0" in %s`, out)
|
||||
}
|
||||
if !bytes.Contains(out, []byte(`pkg3/a.go:5.10,7.2 1 1`)) && !bytes.Contains(out, []byte(`pkg3\a.go:5.10,7.2 1 1`)) {
|
||||
t.Errorf(`missing "pkg3/a.go:5.10,7.2 1 1" in %s`, out)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGoGenerateHandlesSimpleCommand(t *testing.T) {
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("skipping because windows has no echo command")
|
||||
@ -3690,6 +3776,40 @@ func TestGoGetUpdateInsecure(t *testing.T) {
|
||||
tg.run("get", "-d", "-u", "-f", "-insecure", pkg)
|
||||
}
|
||||
|
||||
func TestGoGetUpdateUnknownProtocol(t *testing.T) {
|
||||
testenv.MustHaveExternalNetwork(t)
|
||||
|
||||
tg := testgo(t)
|
||||
defer tg.cleanup()
|
||||
tg.makeTempdir()
|
||||
tg.setenv("GOPATH", tg.path("."))
|
||||
|
||||
const repo = "github.com/golang/example"
|
||||
|
||||
// Clone the repo via HTTPS manually.
|
||||
repoDir := tg.path("src/" + repo)
|
||||
cmd := exec.Command("git", "clone", "-q", "https://"+repo, repoDir)
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("cloning %v repo: %v\n%s", repo, err, out)
|
||||
}
|
||||
|
||||
// Configure the repo to use a protocol unknown to cmd/go
|
||||
// that still actually works.
|
||||
cmd = exec.Command("git", "remote", "set-url", "origin", "xyz://"+repo)
|
||||
cmd.Dir = repoDir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git remote set-url: %v\n%s", err, out)
|
||||
}
|
||||
cmd = exec.Command("git", "config", "--local", "url.https://github.com/.insteadOf", "xyz://github.com/")
|
||||
cmd.Dir = repoDir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git config: %v\n%s", err, out)
|
||||
}
|
||||
|
||||
// We need -f to ignore import comments.
|
||||
tg.run("get", "-d", "-u", "-f", repo+"/hello")
|
||||
}
|
||||
|
||||
func TestGoGetInsecureCustomDomain(t *testing.T) {
|
||||
testenv.MustHaveExternalNetwork(t)
|
||||
|
||||
@ -4900,30 +5020,34 @@ func TestTestRegexps(t *testing.T) {
|
||||
// BenchmarkX/Y is run in full, twice
|
||||
want := `=== RUN TestX
|
||||
=== RUN TestX/Y
|
||||
x_test.go:6: LOG: X running
|
||||
x_test.go:8: LOG: Y running
|
||||
x_test.go:6: LOG: X running
|
||||
x_test.go:8: LOG: Y running
|
||||
=== RUN TestXX
|
||||
z_test.go:10: LOG: XX running
|
||||
z_test.go:10: LOG: XX running
|
||||
=== RUN TestX
|
||||
=== RUN TestX/Y
|
||||
x_test.go:6: LOG: X running
|
||||
x_test.go:8: LOG: Y running
|
||||
x_test.go:6: LOG: X running
|
||||
x_test.go:8: LOG: Y running
|
||||
=== RUN TestXX
|
||||
z_test.go:10: LOG: XX running
|
||||
z_test.go:10: LOG: XX running
|
||||
--- BENCH: BenchmarkX/Y
|
||||
x_test.go:15: LOG: Y running N=1
|
||||
x_test.go:15: LOG: Y running N=100
|
||||
x_test.go:15: LOG: Y running N=10000
|
||||
x_test.go:15: LOG: Y running N=1000000
|
||||
x_test.go:15: LOG: Y running N=100000000
|
||||
x_test.go:15: LOG: Y running N=2000000000
|
||||
x_test.go:15: LOG: Y running N=1
|
||||
x_test.go:15: LOG: Y running N=100
|
||||
x_test.go:15: LOG: Y running N=10000
|
||||
x_test.go:15: LOG: Y running N=1000000
|
||||
x_test.go:15: LOG: Y running N=100000000
|
||||
x_test.go:15: LOG: Y running N=2000000000
|
||||
--- BENCH: BenchmarkX/Y
|
||||
x_test.go:15: LOG: Y running N=1
|
||||
x_test.go:15: LOG: Y running N=2000000000
|
||||
x_test.go:15: LOG: Y running N=1
|
||||
x_test.go:15: LOG: Y running N=100
|
||||
x_test.go:15: LOG: Y running N=10000
|
||||
x_test.go:15: LOG: Y running N=1000000
|
||||
x_test.go:15: LOG: Y running N=100000000
|
||||
x_test.go:15: LOG: Y running N=2000000000
|
||||
--- BENCH: BenchmarkX
|
||||
x_test.go:13: LOG: X running N=1
|
||||
x_test.go:13: LOG: X running N=1
|
||||
--- BENCH: BenchmarkXX
|
||||
z_test.go:18: LOG: XX running N=1
|
||||
z_test.go:18: LOG: XX running N=1
|
||||
`
|
||||
|
||||
have := strings.Join(lines, "")
|
||||
@ -6300,3 +6424,47 @@ func TestLinkerTmpDirIsDeleted(t *testing.T) {
|
||||
t.Fatalf("Stat(%q) returns unexpected error: %v", tmpdir, err)
|
||||
}
|
||||
}
|
||||
|
||||
func testCDAndGOPATHAreDifferent(tg *testgoData, cd, gopath string) {
|
||||
tg.setenv("GOPATH", gopath)
|
||||
|
||||
tg.tempDir("dir")
|
||||
exe := tg.path("dir/a.exe")
|
||||
|
||||
tg.cd(cd)
|
||||
|
||||
tg.run("build", "-o", exe, "-ldflags", "-X=my.pkg.Text=linkXworked")
|
||||
out, err := exec.Command(exe).CombinedOutput()
|
||||
if err != nil {
|
||||
tg.t.Fatal(err)
|
||||
}
|
||||
if string(out) != "linkXworked\n" {
|
||||
tg.t.Errorf(`incorrect output with GOPATH=%q and CD=%q: expected "linkXworked\n", but have %q`, gopath, cd, string(out))
|
||||
}
|
||||
}
|
||||
|
||||
func TestCDAndGOPATHAreDifferent(t *testing.T) {
|
||||
tg := testgo(t)
|
||||
defer tg.cleanup()
|
||||
|
||||
gopath := filepath.Join(tg.pwd(), "testdata")
|
||||
cd := filepath.Join(gopath, "src/my.pkg/main")
|
||||
|
||||
testCDAndGOPATHAreDifferent(tg, cd, gopath)
|
||||
if runtime.GOOS == "windows" {
|
||||
testCDAndGOPATHAreDifferent(tg, cd, strings.Replace(gopath, `\`, `/`, -1))
|
||||
testCDAndGOPATHAreDifferent(tg, cd, strings.ToUpper(gopath))
|
||||
testCDAndGOPATHAreDifferent(tg, cd, strings.ToLower(gopath))
|
||||
}
|
||||
}
|
||||
|
||||
// Issue 25579.
|
||||
func TestGoBuildDashODevNull(t *testing.T) {
|
||||
tg := testgo(t)
|
||||
defer tg.cleanup()
|
||||
tg.parallel()
|
||||
tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata"))
|
||||
tg.run("build", "-o", os.DevNull, filepath.Join(tg.pwd(), "testdata", "src", "hello", "hello.go"))
|
||||
tg.mustNotExist("hello")
|
||||
tg.mustNotExist("hello.exe")
|
||||
}
|
||||
|
@ -55,6 +55,13 @@ func parseMetaGoImports(r io.Reader) (imports []metaImport, err error) {
|
||||
continue
|
||||
}
|
||||
if f := strings.Fields(attrValue(e.Attr, "content")); len(f) == 3 {
|
||||
// Ignore VCS type "mod", which is new Go modules.
|
||||
// This code is for old go get and must ignore the new mod lines.
|
||||
// Otherwise matchGoImport will complain about two
|
||||
// different metaImport lines for the same Prefix.
|
||||
if f[1] == "mod" {
|
||||
continue
|
||||
}
|
||||
imports = append(imports, metaImport{
|
||||
Prefix: f[0],
|
||||
VCS: f[1],
|
||||
|
@ -209,7 +209,7 @@ var downloadRootCache = map[string]bool{}
|
||||
// download runs the download half of the get command
|
||||
// for the package named by the argument.
|
||||
func download(arg string, parent *load.Package, stk *load.ImportStack, mode int) {
|
||||
if mode&load.UseVendor != 0 {
|
||||
if mode&load.ResolveImport != 0 {
|
||||
// Caller is responsible for expanding vendor paths.
|
||||
panic("internal error: download mode has useVendor set")
|
||||
}
|
||||
@ -217,7 +217,7 @@ func download(arg string, parent *load.Package, stk *load.ImportStack, mode int)
|
||||
if parent == nil {
|
||||
return load.LoadPackage(path, stk)
|
||||
}
|
||||
return load.LoadImport(path, parent.Dir, parent, stk, nil, mode)
|
||||
return load.LoadImport(path, parent.Dir, parent, stk, nil, mode|load.ResolveModule)
|
||||
}
|
||||
|
||||
p := load1(arg, mode)
|
||||
@ -346,12 +346,12 @@ func download(arg string, parent *load.Package, stk *load.ImportStack, mode int)
|
||||
base.Errorf("%s", err)
|
||||
continue
|
||||
}
|
||||
// If this is a test import, apply vendor lookup now.
|
||||
// We cannot pass useVendor to download, because
|
||||
// If this is a test import, apply module and vendor lookup now.
|
||||
// We cannot pass ResolveImport to download, because
|
||||
// download does caching based on the value of path,
|
||||
// so it must be the fully qualified path already.
|
||||
if i >= len(p.Imports) {
|
||||
path = load.VendoredImportPath(p, path)
|
||||
path = load.ResolveImportPath(p, path)
|
||||
}
|
||||
download(path, p, stk, 0)
|
||||
}
|
||||
@ -369,6 +369,7 @@ func downloadPackage(p *load.Package) error {
|
||||
vcs *vcsCmd
|
||||
repo, rootPath string
|
||||
err error
|
||||
blindRepo bool // set if the repo has unusual configuration
|
||||
)
|
||||
|
||||
security := web.Secure
|
||||
@ -389,10 +390,12 @@ func downloadPackage(p *load.Package) error {
|
||||
dir := filepath.Join(p.Internal.Build.SrcRoot, filepath.FromSlash(rootPath))
|
||||
remote, err := vcs.remoteRepo(vcs, dir)
|
||||
if err != nil {
|
||||
return err
|
||||
// Proceed anyway. The package is present; we likely just don't understand
|
||||
// the repo configuration (e.g. unusual remote protocol).
|
||||
blindRepo = true
|
||||
}
|
||||
repo = remote
|
||||
if !*getF {
|
||||
if !*getF && err == nil {
|
||||
if rr, err := repoRootForImportPath(p.ImportPath, security); err == nil {
|
||||
repo := rr.repo
|
||||
if rr.vcs.resolveRepo != nil {
|
||||
@ -416,7 +419,7 @@ func downloadPackage(p *load.Package) error {
|
||||
}
|
||||
vcs, repo, rootPath = rr.vcs, rr.repo, rr.root
|
||||
}
|
||||
if !vcs.isSecure(repo) && !*getInsecure {
|
||||
if !blindRepo && !vcs.isSecure(repo) && !*getInsecure {
|
||||
return fmt.Errorf("cannot download, %v uses insecure protocol", repo)
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,20 @@ var parseMetaGoImportsTests = []struct {
|
||||
{"baz/quux", "git", "http://github.com/rsc/baz/quux"},
|
||||
},
|
||||
},
|
||||
{
|
||||
`<meta name="go-import" content="foo/bar git https://github.com/rsc/foo/bar">
|
||||
<meta name="go-import" content="foo/bar mod http://github.com/rsc/baz/quux">`,
|
||||
[]metaImport{
|
||||
{"foo/bar", "git", "https://github.com/rsc/foo/bar"},
|
||||
},
|
||||
},
|
||||
{
|
||||
`<meta name="go-import" content="foo/bar mod http://github.com/rsc/baz/quux">
|
||||
<meta name="go-import" content="foo/bar git https://github.com/rsc/foo/bar">`,
|
||||
[]metaImport{
|
||||
{"foo/bar", "git", "https://github.com/rsc/foo/bar"},
|
||||
},
|
||||
},
|
||||
{
|
||||
`<head>
|
||||
<meta name="go-import" content="foo/bar git https://github.com/rsc/foo/bar">
|
||||
|
@ -23,7 +23,7 @@ import (
|
||||
)
|
||||
|
||||
var CmdList = &base.Command{
|
||||
UsageLine: "list [-deps] [-e] [-f format] [-json] [-test] [build flags] [packages]",
|
||||
UsageLine: "list [-cgo] [-deps] [-e] [-export] [-f format] [-json] [-list] [-test] [build flags] [packages]",
|
||||
Short: "list packages",
|
||||
Long: `
|
||||
List lists the packages named by the import paths, one per line.
|
||||
@ -54,6 +54,9 @@ syntax of package template. The default output is equivalent to -f
|
||||
Root string // Go root or Go path dir containing this package
|
||||
ConflictDir string // this directory shadows Dir in $GOPATH
|
||||
BinaryOnly bool // binary-only package: cannot be recompiled from sources
|
||||
ForTest string // package is only for use in named test
|
||||
DepOnly bool // package is only a dependency, not explicitly listed
|
||||
Export string // file containing export data (when using -export)
|
||||
|
||||
// Source files
|
||||
GoFiles []string // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles)
|
||||
@ -128,9 +131,15 @@ for the go/build package's Context type.
|
||||
The -json flag causes the package data to be printed in JSON format
|
||||
instead of using the template format.
|
||||
|
||||
The -cgo flag causes list to set CgoFiles not to the original *.go files
|
||||
importing "C" but instead to the translated files generated by the cgo
|
||||
command.
|
||||
|
||||
The -deps flag causes list to iterate over not just the named packages
|
||||
but also all their dependencies. It visits them in a depth-first post-order
|
||||
traversal, so that a package is listed only after all its dependencies.
|
||||
Packages not explicitly listed on the command line will have the DepOnly
|
||||
field set to true.
|
||||
|
||||
The -e flag changes the handling of erroneous packages, those that
|
||||
cannot be found or are malformed. By default, the list command
|
||||
@ -142,6 +151,9 @@ printing. Erroneous packages will have a non-empty ImportPath and
|
||||
a non-nil Error field; other information may or may not be missing
|
||||
(zeroed).
|
||||
|
||||
The -export flag causes list to set the Export field to the name of a
|
||||
file containing up-to-date export information for the given package.
|
||||
|
||||
The -test flag causes list to report not only the named packages
|
||||
but also their test binaries (for packages with tests), to convey to
|
||||
source code analysis tools exactly how test binaries are constructed.
|
||||
@ -152,7 +164,18 @@ dependencies specially for that test (most commonly the tested
|
||||
package itself). The reported import path of a package recompiled
|
||||
for a particular test binary is followed by a space and the name of
|
||||
the test binary in brackets, as in "math/rand [math/rand.test]"
|
||||
or "regexp [sort.test]".
|
||||
or "regexp [sort.test]". The ForTest field is also set to the name
|
||||
of the package being tested ("math/rand" or "sort" in the previous
|
||||
examples).
|
||||
|
||||
The Dir, Target, Shlib, Root, ConflictDir, and Export file paths
|
||||
are all absolute paths.
|
||||
|
||||
By default, the lists GoFiles, CgoFiles, and so on hold names of files in Dir
|
||||
(that is, paths relative to Dir, not absolute paths).
|
||||
The extra entries added by the -cgo and -test flags are absolute paths
|
||||
referring to cached copies of generated Go source files.
|
||||
Although they are Go source files, the paths may not end in ".go".
|
||||
|
||||
For more about build flags, see 'go help build'.
|
||||
|
||||
@ -165,8 +188,10 @@ func init() {
|
||||
work.AddBuildFlags(CmdList)
|
||||
}
|
||||
|
||||
var listCgo = CmdList.Flag.Bool("cgo", false, "")
|
||||
var listDeps = CmdList.Flag.Bool("deps", false, "")
|
||||
var listE = CmdList.Flag.Bool("e", false, "")
|
||||
var listExport = CmdList.Flag.Bool("export", false, "")
|
||||
var listFmt = CmdList.Flag.String("f", "{{.ImportPath}}", "")
|
||||
var listJson = CmdList.Flag.Bool("json", false, "")
|
||||
var listTest = CmdList.Flag.Bool("test", false, "")
|
||||
@ -222,11 +247,22 @@ func runList(cmd *base.Command, args []string) {
|
||||
pkgs = load.Packages(args)
|
||||
}
|
||||
|
||||
if *listTest {
|
||||
c := cache.Default()
|
||||
if c == nil {
|
||||
if cache.Default() == nil {
|
||||
// These flags return file names pointing into the build cache,
|
||||
// so the build cache must exist.
|
||||
if *listCgo {
|
||||
base.Fatalf("go list -cgo requires build cache")
|
||||
}
|
||||
if *listExport {
|
||||
base.Fatalf("go list -export requires build cache")
|
||||
}
|
||||
if *listTest {
|
||||
base.Fatalf("go list -test requires build cache")
|
||||
}
|
||||
}
|
||||
|
||||
if *listTest {
|
||||
c := cache.Default()
|
||||
// Add test binaries to packages to be listed.
|
||||
for _, p := range pkgs {
|
||||
if p.Error != nil {
|
||||
@ -279,13 +315,14 @@ func runList(cmd *base.Command, args []string) {
|
||||
pkgs = load.PackageList(pkgs)
|
||||
}
|
||||
|
||||
// Estimate whether staleness information is needed,
|
||||
// since it's a little bit of work to compute.
|
||||
// Do we need to run a build to gather information?
|
||||
needStale := *listJson || strings.Contains(*listFmt, ".Stale")
|
||||
if needStale {
|
||||
if needStale || *listExport || *listCgo {
|
||||
var b work.Builder
|
||||
b.Init()
|
||||
b.ComputeStaleOnly = true
|
||||
b.IsCmdList = true
|
||||
b.NeedExport = *listExport
|
||||
b.NeedCgoFiles = *listCgo
|
||||
a := &work.Action{}
|
||||
// TODO: Use pkgsFilter?
|
||||
for _, p := range pkgs {
|
||||
@ -296,8 +333,8 @@ func runList(cmd *base.Command, args []string) {
|
||||
|
||||
for _, p := range pkgs {
|
||||
// Show vendor-expanded paths in listing
|
||||
p.TestImports = p.Vendored(p.TestImports)
|
||||
p.XTestImports = p.Vendored(p.XTestImports)
|
||||
p.TestImports = p.Resolve(p.TestImports)
|
||||
p.XTestImports = p.Resolve(p.XTestImports)
|
||||
}
|
||||
|
||||
if *listTest {
|
||||
|
@ -6,6 +6,7 @@
|
||||
package load
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"go/build"
|
||||
"go/token"
|
||||
@ -14,6 +15,7 @@ import (
|
||||
pathpkg "path"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
@ -49,6 +51,7 @@ type PackagePublic struct {
|
||||
BinaryOnly bool `json:",omitempty"` // package cannot be recompiled
|
||||
ForTest string `json:",omitempty"` // package is only for use in named test
|
||||
DepOnly bool `json:",omitempty"` // package is only as a dependency, not explicitly listed
|
||||
Export string `json:",omitempty"` // file containing export data (set by go list -export)
|
||||
|
||||
// Stale and StaleReason remain here *only* for the list command.
|
||||
// They are only initialized in preparation for list execution.
|
||||
@ -179,7 +182,7 @@ func (e *NoGoError) Error() string {
|
||||
return "no Go files in " + e.Package.Dir
|
||||
}
|
||||
|
||||
// Vendored returns the vendor-resolved version of imports,
|
||||
// Resolve returns the resolved version of imports,
|
||||
// which should be p.TestImports or p.XTestImports, NOT p.Imports.
|
||||
// The imports in p.TestImports and p.XTestImports are not recursively
|
||||
// loaded during the initial load of p, so they list the imports found in
|
||||
@ -189,14 +192,14 @@ func (e *NoGoError) Error() string {
|
||||
// can produce better error messages if it starts with the original paths.
|
||||
// The initial load of p loads all the non-test imports and rewrites
|
||||
// the vendored paths, so nothing should ever call p.vendored(p.Imports).
|
||||
func (p *Package) Vendored(imports []string) []string {
|
||||
func (p *Package) Resolve(imports []string) []string {
|
||||
if len(imports) > 0 && len(p.Imports) > 0 && &imports[0] == &p.Imports[0] {
|
||||
panic("internal error: p.vendored(p.Imports) called")
|
||||
panic("internal error: p.Resolve(p.Imports) called")
|
||||
}
|
||||
seen := make(map[string]bool)
|
||||
var all []string
|
||||
for _, path := range imports {
|
||||
path = VendoredImportPath(p, path)
|
||||
path = ResolveImportPath(p, path)
|
||||
if !seen[path] {
|
||||
seen[path] = true
|
||||
all = append(all, path)
|
||||
@ -397,16 +400,20 @@ func makeImportValid(r rune) rune {
|
||||
|
||||
// Mode flags for loadImport and download (in get.go).
|
||||
const (
|
||||
// UseVendor means that loadImport should do vendor expansion
|
||||
// (provided the vendoring experiment is enabled).
|
||||
// That is, useVendor means that the import path came from
|
||||
// a source file and has not been vendor-expanded yet.
|
||||
// Every import path should be loaded initially with useVendor,
|
||||
// and then the expanded version (with the /vendor/ in it) gets
|
||||
// recorded as the canonical import path. At that point, future loads
|
||||
// of that package must not pass useVendor, because
|
||||
// ResolveImport means that loadImport should do import path expansion.
|
||||
// That is, ResolveImport means that the import path came from
|
||||
// a source file and has not been expanded yet to account for
|
||||
// vendoring or possible module adjustment.
|
||||
// Every import path should be loaded initially with ResolveImport,
|
||||
// and then the expanded version (for example with the /vendor/ in it)
|
||||
// gets recorded as the canonical import path. At that point, future loads
|
||||
// of that package must not pass ResolveImport, because
|
||||
// disallowVendor will reject direct use of paths containing /vendor/.
|
||||
UseVendor = 1 << iota
|
||||
ResolveImport = 1 << iota
|
||||
|
||||
// ResolveModule is for download (part of "go get") and indicates
|
||||
// that the module adjustment should be done, but not vendor adjustment.
|
||||
ResolveModule
|
||||
|
||||
// GetTestDeps is for download (part of "go get") and indicates
|
||||
// that test dependencies should be fetched too.
|
||||
@ -431,12 +438,15 @@ func LoadImport(path, srcDir string, parent *Package, stk *ImportStack, importPo
|
||||
isLocal := build.IsLocalImport(path)
|
||||
if isLocal {
|
||||
importPath = dirToImportPath(filepath.Join(srcDir, path))
|
||||
} else if mode&UseVendor != 0 {
|
||||
// We do our own vendor resolution, because we want to
|
||||
} else if mode&ResolveImport != 0 {
|
||||
// We do our own path resolution, because we want to
|
||||
// find out the key to use in packageCache without the
|
||||
// overhead of repeated calls to buildContext.Import.
|
||||
// The code is also needed in a few other places anyway.
|
||||
path = VendoredImportPath(parent, path)
|
||||
path = ResolveImportPath(parent, path)
|
||||
importPath = path
|
||||
} else if mode&ResolveModule != 0 {
|
||||
path = ModuleImportPath(parent, path)
|
||||
importPath = path
|
||||
}
|
||||
|
||||
@ -453,7 +463,7 @@ func LoadImport(path, srcDir string, parent *Package, stk *ImportStack, importPo
|
||||
// Import always returns bp != nil, even if an error occurs,
|
||||
// in order to return partial information.
|
||||
buildMode := build.ImportComment
|
||||
if mode&UseVendor == 0 || path != origPath {
|
||||
if mode&ResolveImport == 0 || path != origPath {
|
||||
// Not vendoring, or we already found the vendored path.
|
||||
buildMode |= build.IgnoreVendor
|
||||
}
|
||||
@ -484,7 +494,7 @@ func LoadImport(path, srcDir string, parent *Package, stk *ImportStack, importPo
|
||||
if perr := disallowInternal(srcDir, p, stk); perr != p {
|
||||
return setErrorPos(perr, importPos)
|
||||
}
|
||||
if mode&UseVendor != 0 {
|
||||
if mode&ResolveImport != 0 {
|
||||
if perr := disallowVendor(srcDir, origPath, p, stk); perr != p {
|
||||
return setErrorPos(perr, importPos)
|
||||
}
|
||||
@ -543,7 +553,50 @@ func isDir(path string) bool {
|
||||
return result
|
||||
}
|
||||
|
||||
// VendoredImportPath returns the expansion of path when it appears in parent.
|
||||
// ResolveImportPath returns the true meaning of path when it appears in parent.
|
||||
// There are two different resolutions applied.
|
||||
// First, there is Go 1.5 vendoring (golang.org/s/go15vendor).
|
||||
// If vendor expansion doesn't trigger, then the path is also subject to
|
||||
// Go 1.11 vgo legacy conversion (golang.org/issue/25069).
|
||||
func ResolveImportPath(parent *Package, path string) (found string) {
|
||||
found = VendoredImportPath(parent, path)
|
||||
if found != path {
|
||||
return found
|
||||
}
|
||||
return ModuleImportPath(parent, path)
|
||||
}
|
||||
|
||||
// dirAndRoot returns the source directory and workspace root
|
||||
// for the package p, guaranteeing that root is a path prefix of dir.
|
||||
func dirAndRoot(p *Package) (dir, root string) {
|
||||
dir = filepath.Clean(p.Dir)
|
||||
root = filepath.Join(p.Root, "src")
|
||||
if !str.HasFilePathPrefix(dir, root) || p.ImportPath != "command-line-arguments" && filepath.Join(root, p.ImportPath) != dir {
|
||||
// Look for symlinks before reporting error.
|
||||
dir = expandPath(dir)
|
||||
root = expandPath(root)
|
||||
}
|
||||
|
||||
if !str.HasFilePathPrefix(dir, root) || len(dir) <= len(root) || dir[len(root)] != filepath.Separator || p.ImportPath != "command-line-arguments" && !p.Internal.Local && filepath.Join(root, p.ImportPath) != dir {
|
||||
base.Fatalf("unexpected directory layout:\n"+
|
||||
" import path: %s\n"+
|
||||
" root: %s\n"+
|
||||
" dir: %s\n"+
|
||||
" expand root: %s\n"+
|
||||
" expand dir: %s\n"+
|
||||
" separator: %s",
|
||||
p.ImportPath,
|
||||
filepath.Join(p.Root, "src"),
|
||||
filepath.Clean(p.Dir),
|
||||
root,
|
||||
dir,
|
||||
string(filepath.Separator))
|
||||
}
|
||||
|
||||
return dir, root
|
||||
}
|
||||
|
||||
// VendoredImportPath returns the vendor-expansion of path when it appears in parent.
|
||||
// If parent is x/y/z, then path might expand to x/y/z/vendor/path, x/y/vendor/path,
|
||||
// x/vendor/path, vendor/path, or else stay path if none of those exist.
|
||||
// VendoredImportPath returns the expanded path or, if no expansion is found, the original.
|
||||
@ -552,29 +605,7 @@ func VendoredImportPath(parent *Package, path string) (found string) {
|
||||
return path
|
||||
}
|
||||
|
||||
dir := filepath.Clean(parent.Dir)
|
||||
root := filepath.Join(parent.Root, "src")
|
||||
if !str.HasFilePathPrefix(dir, root) || parent.ImportPath != "command-line-arguments" && filepath.Join(root, parent.ImportPath) != dir {
|
||||
// Look for symlinks before reporting error.
|
||||
dir = expandPath(dir)
|
||||
root = expandPath(root)
|
||||
}
|
||||
|
||||
if !str.HasFilePathPrefix(dir, root) || len(dir) <= len(root) || dir[len(root)] != filepath.Separator || parent.ImportPath != "command-line-arguments" && !parent.Internal.Local && filepath.Join(root, parent.ImportPath) != dir {
|
||||
base.Fatalf("unexpected directory layout:\n"+
|
||||
" import path: %s\n"+
|
||||
" root: %s\n"+
|
||||
" dir: %s\n"+
|
||||
" expand root: %s\n"+
|
||||
" expand dir: %s\n"+
|
||||
" separator: %s",
|
||||
parent.ImportPath,
|
||||
filepath.Join(parent.Root, "src"),
|
||||
filepath.Clean(parent.Dir),
|
||||
root,
|
||||
dir,
|
||||
string(filepath.Separator))
|
||||
}
|
||||
dir, root := dirAndRoot(parent)
|
||||
|
||||
vpath := "vendor/" + path
|
||||
for i := len(dir); i >= len(root); i-- {
|
||||
@ -618,6 +649,164 @@ func VendoredImportPath(parent *Package, path string) (found string) {
|
||||
return path
|
||||
}
|
||||
|
||||
var (
|
||||
modulePrefix = []byte("\nmodule ")
|
||||
goModPathCache = make(map[string]string)
|
||||
)
|
||||
|
||||
// goModPath returns the module path in the go.mod in dir, if any.
|
||||
func goModPath(dir string) (path string) {
|
||||
path, ok := goModPathCache[dir]
|
||||
if ok {
|
||||
return path
|
||||
}
|
||||
defer func() {
|
||||
goModPathCache[dir] = path
|
||||
}()
|
||||
|
||||
data, err := ioutil.ReadFile(filepath.Join(dir, "go.mod"))
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
var i int
|
||||
if bytes.HasPrefix(data, modulePrefix[1:]) {
|
||||
i = 0
|
||||
} else {
|
||||
i = bytes.Index(data, modulePrefix)
|
||||
if i < 0 {
|
||||
return ""
|
||||
}
|
||||
i++
|
||||
}
|
||||
line := data[i:]
|
||||
|
||||
// Cut line at \n, drop trailing \r if present.
|
||||
if j := bytes.IndexByte(line, '\n'); j >= 0 {
|
||||
line = line[:j]
|
||||
}
|
||||
if line[len(line)-1] == '\r' {
|
||||
line = line[:len(line)-1]
|
||||
}
|
||||
line = line[len("module "):]
|
||||
|
||||
// If quoted, unquote.
|
||||
path = strings.TrimSpace(string(line))
|
||||
if path != "" && path[0] == '"' {
|
||||
s, err := strconv.Unquote(path)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
path = s
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
// findVersionElement returns the slice indices of the final version element /vN in path.
|
||||
// If there is no such element, it returns -1, -1.
|
||||
func findVersionElement(path string) (i, j int) {
|
||||
j = len(path)
|
||||
for i = len(path) - 1; i >= 0; i-- {
|
||||
if path[i] == '/' {
|
||||
if isVersionElement(path[i:j]) {
|
||||
return i, j
|
||||
}
|
||||
j = i
|
||||
}
|
||||
}
|
||||
return -1, -1
|
||||
}
|
||||
|
||||
// isVersionElement reports whether s is a well-formed path version element:
|
||||
// v2, v3, v10, etc, but not v0, v05, v1.
|
||||
func isVersionElement(s string) bool {
|
||||
if len(s) < 3 || s[0] != '/' || s[1] != 'v' || s[2] == '0' || s[2] == '1' && len(s) == 3 {
|
||||
return false
|
||||
}
|
||||
for i := 2; i < len(s); i++ {
|
||||
if s[i] < '0' || '9' < s[i] {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// ModuleImportPath translates import paths found in go modules
|
||||
// back down to paths that can be resolved in ordinary builds.
|
||||
//
|
||||
// Define “new” code as code with a go.mod file in the same directory
|
||||
// or a parent directory. If an import in new code says x/y/v2/z but
|
||||
// x/y/v2/z does not exist and x/y/go.mod says “module x/y/v2”,
|
||||
// then go build will read the import as x/y/z instead.
|
||||
// See golang.org/issue/25069.
|
||||
func ModuleImportPath(parent *Package, path string) (found string) {
|
||||
if parent == nil || parent.Root == "" {
|
||||
return path
|
||||
}
|
||||
|
||||
// If there are no vN elements in path, leave it alone.
|
||||
// (The code below would do the same, but only after
|
||||
// some other file system accesses that we can avoid
|
||||
// here by returning early.)
|
||||
if i, _ := findVersionElement(path); i < 0 {
|
||||
return path
|
||||
}
|
||||
|
||||
dir, root := dirAndRoot(parent)
|
||||
|
||||
// Consider dir and parents, up to and including root.
|
||||
for i := len(dir); i >= len(root); i-- {
|
||||
if i < len(dir) && dir[i] != filepath.Separator {
|
||||
continue
|
||||
}
|
||||
if goModPath(dir[:i]) != "" {
|
||||
goto HaveGoMod
|
||||
}
|
||||
}
|
||||
// This code is not in a tree with a go.mod,
|
||||
// so apply no changes to the path.
|
||||
return path
|
||||
|
||||
HaveGoMod:
|
||||
// This import is in a tree with a go.mod.
|
||||
// Allow it to refer to code in GOPATH/src/x/y/z as x/y/v2/z
|
||||
// if GOPATH/src/x/y/go.mod says module "x/y/v2",
|
||||
|
||||
// If x/y/v2/z exists, use it unmodified.
|
||||
if bp, _ := cfg.BuildContext.Import(path, "", build.IgnoreVendor); bp.Dir != "" {
|
||||
return path
|
||||
}
|
||||
|
||||
// Otherwise look for a go.mod supplying a version element.
|
||||
// Some version-like elements may appear in paths but not
|
||||
// be module versions; we skip over those to look for module
|
||||
// versions. For example the module m/v2 might have a
|
||||
// package m/v2/api/v1/foo.
|
||||
limit := len(path)
|
||||
for limit > 0 {
|
||||
i, j := findVersionElement(path[:limit])
|
||||
if i < 0 {
|
||||
return path
|
||||
}
|
||||
if bp, _ := cfg.BuildContext.Import(path[:i], "", build.IgnoreVendor); bp.Dir != "" {
|
||||
if mpath := goModPath(bp.Dir); mpath != "" {
|
||||
// Found a valid go.mod file, so we're stopping the search.
|
||||
// If the path is m/v2/p and we found m/go.mod that says
|
||||
// "module m/v2", then we return "m/p".
|
||||
if mpath == path[:j] {
|
||||
return path[:i] + path[j:]
|
||||
}
|
||||
// Otherwise just return the original path.
|
||||
// We didn't find anything worth rewriting,
|
||||
// and the go.mod indicates that we should
|
||||
// not consider parent directories.
|
||||
return path
|
||||
}
|
||||
}
|
||||
limit = i
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
// hasGoFiles reports whether dir contains any files with names ending in .go.
|
||||
// For a vendor check we must exclude directories that contain no .go files.
|
||||
// Otherwise it is not possible to vendor just a/b/c and still import the
|
||||
@ -1082,7 +1271,7 @@ func (p *Package) load(stk *ImportStack, bp *build.Package, err error) {
|
||||
if path == "C" {
|
||||
continue
|
||||
}
|
||||
p1 := LoadImport(path, p.Dir, p, stk, p.Internal.Build.ImportPos[path], UseVendor)
|
||||
p1 := LoadImport(path, p.Dir, p, stk, p.Internal.Build.ImportPos[path], ResolveImport)
|
||||
if p.Standard && p.Error == nil && !p1.Standard && p1.Error == nil {
|
||||
p.Error = &PackageError{
|
||||
ImportStack: stk.Copy(),
|
||||
|
@ -13,6 +13,7 @@ import (
|
||||
"path"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -282,7 +283,12 @@ func MatchPackage(pattern, cwd string) func(*Package) bool {
|
||||
}
|
||||
dir = filepath.Join(cwd, dir)
|
||||
if pattern == "" {
|
||||
return func(p *Package) bool { return p.Dir == dir }
|
||||
return func(p *Package) bool {
|
||||
if runtime.GOOS != "windows" {
|
||||
return p.Dir == dir
|
||||
}
|
||||
return strings.EqualFold(p.Dir, dir)
|
||||
}
|
||||
}
|
||||
matchPath := matchPattern(pattern)
|
||||
return func(p *Package) bool {
|
||||
|
@ -49,16 +49,13 @@ type TestCover struct {
|
||||
// (for example, if there are no "package p" test files and
|
||||
// package p need not be instrumented for coverage or any other reason),
|
||||
// then the returned ptest == p.
|
||||
//
|
||||
// The caller is expected to have checked that len(p.TestGoFiles)+len(p.XTestGoFiles) > 0,
|
||||
// or else there's no point in any of this.
|
||||
func TestPackagesFor(p *Package, cover *TestCover) (pmain, ptest, pxtest *Package, err error) {
|
||||
var imports, ximports []*Package
|
||||
var stk ImportStack
|
||||
stk.Push(p.ImportPath + " (test)")
|
||||
rawTestImports := str.StringList(p.TestImports)
|
||||
for i, path := range p.TestImports {
|
||||
p1 := LoadImport(path, p.Dir, p, &stk, p.Internal.Build.TestImportPos[path], UseVendor)
|
||||
p1 := LoadImport(path, p.Dir, p, &stk, p.Internal.Build.TestImportPos[path], ResolveImport)
|
||||
if p1.Error != nil {
|
||||
return nil, nil, nil, p1.Error
|
||||
}
|
||||
@ -86,7 +83,7 @@ func TestPackagesFor(p *Package, cover *TestCover) (pmain, ptest, pxtest *Packag
|
||||
pxtestNeedsPtest := false
|
||||
rawXTestImports := str.StringList(p.XTestImports)
|
||||
for i, path := range p.XTestImports {
|
||||
p1 := LoadImport(path, p.Dir, p, &stk, p.Internal.Build.XTestImportPos[path], UseVendor)
|
||||
p1 := LoadImport(path, p.Dir, p, &stk, p.Internal.Build.XTestImportPos[path], ResolveImport)
|
||||
if p1.Error != nil {
|
||||
return nil, nil, nil, p1.Error
|
||||
}
|
||||
|
@ -600,10 +600,10 @@ func runTest(cmd *base.Command, args []string) {
|
||||
for _, path := range p.Imports {
|
||||
deps[path] = true
|
||||
}
|
||||
for _, path := range p.Vendored(p.TestImports) {
|
||||
for _, path := range p.Resolve(p.TestImports) {
|
||||
deps[path] = true
|
||||
}
|
||||
for _, path := range p.Vendored(p.XTestImports) {
|
||||
for _, path := range p.Resolve(p.XTestImports) {
|
||||
deps[path] = true
|
||||
}
|
||||
}
|
||||
@ -781,14 +781,6 @@ var windowsBadWords = []string{
|
||||
}
|
||||
|
||||
func builderTest(b *work.Builder, p *load.Package) (buildAction, runAction, printAction *work.Action, err error) {
|
||||
if len(p.TestGoFiles)+len(p.XTestGoFiles) == 0 {
|
||||
build := b.CompileAction(work.ModeBuild, work.ModeBuild, p)
|
||||
run := &work.Action{Mode: "test run", Package: p, Deps: []*work.Action{build}}
|
||||
addTestVet(b, p, run, nil)
|
||||
print := &work.Action{Mode: "test print", Func: builderNoTest, Package: p, Deps: []*work.Action{run}}
|
||||
return build, run, print, nil
|
||||
}
|
||||
|
||||
// Build Package structs describing:
|
||||
// pmain - pkg.test binary
|
||||
// ptest - package + test files
|
||||
@ -1176,13 +1168,17 @@ func (c *runCache) builderRunTest(b *work.Builder, a *work.Action) error {
|
||||
|
||||
if err == nil {
|
||||
norun := ""
|
||||
res := "ok"
|
||||
if !testShowPass && !testJSON {
|
||||
buf.Reset()
|
||||
}
|
||||
if bytes.HasPrefix(out, noTestsToRun[1:]) || bytes.Contains(out, noTestsToRun) {
|
||||
if len(a.Package.TestGoFiles)+len(a.Package.XTestGoFiles) == 0 {
|
||||
res = "? "
|
||||
norun = " [no test files]"
|
||||
} else if bytes.HasPrefix(out, noTestsToRun[1:]) || bytes.Contains(out, noTestsToRun) {
|
||||
norun = " [no tests to run]"
|
||||
}
|
||||
fmt.Fprintf(cmd.Stdout, "ok \t%s\t%s%s%s\n", a.Package.ImportPath, t, coveragePercentage(out), norun)
|
||||
fmt.Fprintf(cmd.Stdout, "%s \t%s\t%s%s%s\n", res, a.Package.ImportPath, t, coveragePercentage(out), norun)
|
||||
c.saveOutput(a)
|
||||
} else {
|
||||
base.SetExitStatus(1)
|
||||
@ -1596,15 +1592,3 @@ func builderPrintTest(b *work.Builder, a *work.Action) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// builderNoTest is the action for testing a package with no test files.
|
||||
func builderNoTest(b *work.Builder, a *work.Action) error {
|
||||
var stdout io.Writer = os.Stdout
|
||||
if testJSON {
|
||||
json := test2json.NewConverter(lockedStdout{}, a.Package.ImportPath, test2json.Timestamp)
|
||||
defer json.Close()
|
||||
stdout = json
|
||||
}
|
||||
fmt.Fprintf(stdout, "? \t%s\t[no test files]\n", a.Package.ImportPath)
|
||||
return nil
|
||||
}
|
||||
|
@ -36,7 +36,10 @@ type Builder struct {
|
||||
flagCache map[[2]string]bool // a cache of supported compiler flags
|
||||
Print func(args ...interface{}) (int, error)
|
||||
|
||||
ComputeStaleOnly bool // compute staleness for go list; no actual build
|
||||
IsCmdList bool // running as part of go list; set p.Stale and additional fields below
|
||||
NeedError bool // list needs p.Error
|
||||
NeedExport bool // list needs p.Export
|
||||
NeedCgoFiles bool // list needs p.CgoFiles to cgo-generated files, not originals
|
||||
|
||||
objdirSeq int // counter for NewObjdir
|
||||
pkgSeq int
|
||||
|
@ -284,11 +284,6 @@ func runBuild(cmd *base.Command, args []string) {
|
||||
cfg.BuildO += cfg.ExeSuffix
|
||||
}
|
||||
|
||||
// Special case -o /dev/null by not writing at all.
|
||||
if cfg.BuildO == os.DevNull {
|
||||
cfg.BuildO = ""
|
||||
}
|
||||
|
||||
// sanity check some often mis-used options
|
||||
switch cfg.BuildContext.Compiler {
|
||||
case "gccgo":
|
||||
@ -311,6 +306,11 @@ func runBuild(cmd *base.Command, args []string) {
|
||||
|
||||
pkgs = pkgsFilter(load.Packages(args))
|
||||
|
||||
// Special case -o /dev/null by not writing at all.
|
||||
if cfg.BuildO == os.DevNull {
|
||||
cfg.BuildO = ""
|
||||
}
|
||||
|
||||
if cfg.BuildO != "" {
|
||||
if len(pkgs) > 1 {
|
||||
base.Fatalf("go build: cannot use -o with multiple packages")
|
||||
|
@ -414,7 +414,7 @@ func (b *Builder) useCache(a *Action, p *load.Package, actionHash cache.ActionID
|
||||
// already up-to-date, then to avoid a rebuild, report the package
|
||||
// as up-to-date as well. See "Build IDs" comment above.
|
||||
// TODO(rsc): Rewrite this code to use a TryCache func on the link action.
|
||||
if target != "" && !cfg.BuildA && a.Mode == "build" && len(a.triggers) == 1 && a.triggers[0].Mode == "link" {
|
||||
if target != "" && !cfg.BuildA && !b.NeedExport && a.Mode == "build" && len(a.triggers) == 1 && a.triggers[0].Mode == "link" {
|
||||
buildID, err := buildid.ReadFile(target)
|
||||
if err == nil {
|
||||
id := strings.Split(buildID, buildIDSeparator)
|
||||
@ -455,8 +455,8 @@ func (b *Builder) useCache(a *Action, p *load.Package, actionHash cache.ActionID
|
||||
return true
|
||||
}
|
||||
|
||||
if b.ComputeStaleOnly {
|
||||
// Invoked during go list only to compute and record staleness.
|
||||
if b.IsCmdList {
|
||||
// Invoked during go list to compute and record staleness.
|
||||
if p := a.Package; p != nil && !p.Stale {
|
||||
p.Stale = true
|
||||
if cfg.BuildA {
|
||||
@ -521,10 +521,6 @@ func (b *Builder) useCache(a *Action, p *load.Package, actionHash cache.ActionID
|
||||
a.output = []byte{}
|
||||
}
|
||||
|
||||
if b.ComputeStaleOnly {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
@ -609,11 +605,17 @@ func (b *Builder) updateBuildID(a *Action, target string, rewrite bool) error {
|
||||
panic("internal error: a.output not set")
|
||||
}
|
||||
outputID, _, err := c.Put(a.actionID, r)
|
||||
r.Close()
|
||||
if err == nil && cfg.BuildX {
|
||||
b.Showcmd("", "%s # internal", joinUnambiguously(str.StringList("cp", target, c.OutputFile(outputID))))
|
||||
}
|
||||
if b.NeedExport {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.Package.Export = c.OutputFile(outputID)
|
||||
}
|
||||
c.PutBytes(cache.Subkey(a.actionID, "stdout"), a.output)
|
||||
r.Close()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ func actionList(root *Action) []*Action {
|
||||
|
||||
// do runs the action graph rooted at root.
|
||||
func (b *Builder) Do(root *Action) {
|
||||
if c := cache.Default(); c != nil && !b.ComputeStaleOnly {
|
||||
if c := cache.Default(); c != nil && !b.IsCmdList {
|
||||
// If we're doing real work, take time at the end to trim the cache.
|
||||
defer c.Trim()
|
||||
}
|
||||
@ -296,11 +296,11 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID {
|
||||
return h.Sum()
|
||||
}
|
||||
|
||||
// needCgoHeader reports whether the actions triggered by this one
|
||||
// needCgoHdr reports whether the actions triggered by this one
|
||||
// expect to be able to access the cgo-generated header file.
|
||||
func needCgoHeader(a *Action) bool {
|
||||
func (b *Builder) needCgoHdr(a *Action) bool {
|
||||
// If this build triggers a header install, run cgo to get the header.
|
||||
if (a.Package.UsesCgo() || a.Package.UsesSwig()) && (cfg.BuildBuildmode == "c-archive" || cfg.BuildBuildmode == "c-shared") {
|
||||
if !b.IsCmdList && (a.Package.UsesCgo() || a.Package.UsesSwig()) && (cfg.BuildBuildmode == "c-archive" || cfg.BuildBuildmode == "c-shared") {
|
||||
for _, t1 := range a.triggers {
|
||||
if t1.Mode == "install header" {
|
||||
return true
|
||||
@ -317,19 +317,54 @@ func needCgoHeader(a *Action) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
const (
|
||||
needBuild uint32 = 1 << iota
|
||||
needCgoHdr
|
||||
needVet
|
||||
needCgoFiles
|
||||
needStale
|
||||
)
|
||||
|
||||
// build is the action for building a single package.
|
||||
// Note that any new influence on this logic must be reported in b.buildActionID above as well.
|
||||
func (b *Builder) build(a *Action) (err error) {
|
||||
p := a.Package
|
||||
|
||||
bit := func(x uint32, b bool) uint32 {
|
||||
if b {
|
||||
return x
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
cached := false
|
||||
needCgo := needCgoHeader(a)
|
||||
need := bit(needBuild, !b.IsCmdList || b.NeedExport) |
|
||||
bit(needCgoHdr, b.needCgoHdr(a)) |
|
||||
bit(needVet, a.needVet) |
|
||||
bit(needCgoFiles, b.NeedCgoFiles && (p.UsesCgo() || p.UsesSwig()))
|
||||
|
||||
// Save p.CgoFiles now, because we may modify it for go list.
|
||||
cgofiles := append([]string{}, p.CgoFiles...)
|
||||
|
||||
if !p.BinaryOnly {
|
||||
if b.useCache(a, p, b.buildActionID(a), p.Target) {
|
||||
if b.ComputeStaleOnly || !needCgo && !a.needVet {
|
||||
return nil
|
||||
// We found the main output in the cache.
|
||||
// If we don't need any other outputs, we can stop.
|
||||
need &^= needBuild
|
||||
if b.NeedExport {
|
||||
p.Export = a.built
|
||||
}
|
||||
if need&needCgoFiles != 0 && b.loadCachedCgoFiles(a) {
|
||||
need &^= needCgoFiles
|
||||
}
|
||||
// Otherwise, we need to write files to a.Objdir (needVet, needCgoHdr).
|
||||
// Remember that we might have them in cache
|
||||
// and check again after we create a.Objdir.
|
||||
cached = true
|
||||
a.output = []byte{} // start saving output in case we miss any cache results
|
||||
}
|
||||
if need == 0 {
|
||||
return nil
|
||||
}
|
||||
defer b.flushOutput(a)
|
||||
}
|
||||
@ -338,6 +373,9 @@ func (b *Builder) build(a *Action) (err error) {
|
||||
if err != nil && err != errPrintedOutput {
|
||||
err = fmt.Errorf("go build %s: %v", a.Package.ImportPath, err)
|
||||
}
|
||||
if err != nil && b.IsCmdList && b.NeedError && p.Error == nil {
|
||||
p.Error = &load.PackageError{Err: err.Error()}
|
||||
}
|
||||
}()
|
||||
if cfg.BuildN {
|
||||
// In -n mode, print a banner between packages.
|
||||
@ -357,14 +395,17 @@ func (b *Builder) build(a *Action) (err error) {
|
||||
if err == nil {
|
||||
a.built = a.Package.Target
|
||||
a.Target = a.Package.Target
|
||||
if b.NeedExport {
|
||||
a.Package.Export = a.Package.Target
|
||||
}
|
||||
a.buildID = b.fileHash(a.Package.Target)
|
||||
a.Package.Stale = false
|
||||
a.Package.StaleReason = "binary-only package"
|
||||
return nil
|
||||
}
|
||||
if b.ComputeStaleOnly {
|
||||
a.Package.Stale = true
|
||||
a.Package.StaleReason = "missing or invalid binary-only package"
|
||||
a.Package.Stale = true
|
||||
a.Package.StaleReason = "missing or invalid binary-only package"
|
||||
if b.IsCmdList {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("missing or invalid binary-only package")
|
||||
@ -375,8 +416,21 @@ func (b *Builder) build(a *Action) (err error) {
|
||||
}
|
||||
objdir := a.Objdir
|
||||
|
||||
if cached && (!needCgo || b.loadCachedCgo(a)) && (!a.needVet || b.loadCachedVet(a)) {
|
||||
return nil
|
||||
if cached {
|
||||
if need&needCgoHdr != 0 && b.loadCachedCgoHdr(a) {
|
||||
need &^= needCgoHdr
|
||||
}
|
||||
|
||||
// Load cached vet config, but only if that's all we have left
|
||||
// (need == needVet, not testing just the one bit).
|
||||
// If we are going to do a full build anyway,
|
||||
// we're going to regenerate the files below anyway.
|
||||
if need == needVet && b.loadCachedVet(a) {
|
||||
need &^= needVet
|
||||
}
|
||||
if need == 0 {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// make target directory
|
||||
@ -387,9 +441,8 @@ func (b *Builder) build(a *Action) (err error) {
|
||||
}
|
||||
}
|
||||
|
||||
var gofiles, cgofiles, cfiles, sfiles, cxxfiles, objects, cgoObjects, pcCFLAGS, pcLDFLAGS []string
|
||||
var gofiles, cfiles, sfiles, cxxfiles, objects, cgoObjects, pcCFLAGS, pcLDFLAGS []string
|
||||
gofiles = append(gofiles, a.Package.GoFiles...)
|
||||
cgofiles = append(cgofiles, a.Package.CgoFiles...)
|
||||
cfiles = append(cfiles, a.Package.CFiles...)
|
||||
sfiles = append(sfiles, a.Package.SFiles...)
|
||||
cxxfiles = append(cxxfiles, a.Package.CXXFiles...)
|
||||
@ -500,19 +553,27 @@ func (b *Builder) build(a *Action) (err error) {
|
||||
}
|
||||
b.cacheGofiles(a, gofiles)
|
||||
|
||||
// Running cgo generated the cgo header.
|
||||
need &^= needCgoHdr
|
||||
|
||||
// Sanity check only, since Package.load already checked as well.
|
||||
if len(gofiles) == 0 {
|
||||
return &load.NoGoError{Package: a.Package}
|
||||
}
|
||||
|
||||
// Prepare Go vet config if needed.
|
||||
if a.needVet {
|
||||
if need&needVet != 0 {
|
||||
buildVetConfig(a, gofiles)
|
||||
need &^= needVet
|
||||
}
|
||||
if cached {
|
||||
// The cached package file is OK, so we don't need to run the compile.
|
||||
// We've only gone this far in order to prepare the vet configuration
|
||||
// or cgo header, and now we have.
|
||||
if need&needCgoFiles != 0 {
|
||||
if !b.loadCachedCgoFiles(a) {
|
||||
return fmt.Errorf("failed to cache translated CgoFiles")
|
||||
}
|
||||
need &^= needCgoFiles
|
||||
}
|
||||
if need == 0 {
|
||||
// Nothing left to do.
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -656,17 +717,25 @@ func (b *Builder) cacheObjdirFile(a *Action, c *cache.Cache, name string) error
|
||||
return err
|
||||
}
|
||||
|
||||
func (b *Builder) loadCachedObjdirFile(a *Action, c *cache.Cache, name string) error {
|
||||
func (b *Builder) findCachedObjdirFile(a *Action, c *cache.Cache, name string) (string, error) {
|
||||
entry, err := c.Get(cache.Subkey(a.actionID, name))
|
||||
if err != nil {
|
||||
return err
|
||||
return "", err
|
||||
}
|
||||
out := c.OutputFile(entry.OutputID)
|
||||
info, err := os.Stat(out)
|
||||
if err != nil || info.Size() != entry.Size {
|
||||
return fmt.Errorf("not in cache")
|
||||
return "", fmt.Errorf("not in cache")
|
||||
}
|
||||
return b.copyFile(a.Objdir+name, out, 0666, true)
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (b *Builder) loadCachedObjdirFile(a *Action, c *cache.Cache, name string) error {
|
||||
cached, err := b.findCachedObjdirFile(a, c, name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return b.copyFile(a.Objdir+name, cached, 0666, true)
|
||||
}
|
||||
|
||||
func (b *Builder) cacheCgoHdr(a *Action) {
|
||||
@ -677,7 +746,7 @@ func (b *Builder) cacheCgoHdr(a *Action) {
|
||||
b.cacheObjdirFile(a, c, "_cgo_install.h")
|
||||
}
|
||||
|
||||
func (b *Builder) loadCachedCgo(a *Action) bool {
|
||||
func (b *Builder) loadCachedCgoHdr(a *Action) bool {
|
||||
c := cache.Default()
|
||||
if c == nil {
|
||||
return false
|
||||
@ -737,6 +806,33 @@ func (b *Builder) loadCachedVet(a *Action) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (b *Builder) loadCachedCgoFiles(a *Action) bool {
|
||||
c := cache.Default()
|
||||
if c == nil {
|
||||
return false
|
||||
}
|
||||
list, _, err := c.GetBytes(cache.Subkey(a.actionID, "gofiles"))
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
var files []string
|
||||
for _, name := range strings.Split(string(list), "\n") {
|
||||
if name == "" { // end of list
|
||||
continue
|
||||
}
|
||||
if strings.HasPrefix(name, "./") {
|
||||
continue
|
||||
}
|
||||
file, err := b.findCachedObjdirFile(a, c, name)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
files = append(files, file)
|
||||
}
|
||||
a.Package.CgoFiles = files
|
||||
return true
|
||||
}
|
||||
|
||||
type vetConfig struct {
|
||||
Compiler string
|
||||
Dir string
|
||||
@ -939,7 +1035,7 @@ func (b *Builder) printLinkerConfig(h io.Writer, p *load.Package) {
|
||||
// link is the action for linking a single command.
|
||||
// Note that any new influence on this logic must be reported in b.linkActionID above as well.
|
||||
func (b *Builder) link(a *Action) (err error) {
|
||||
if b.useCache(a, a.Package, b.linkActionID(a), a.Package.Target) {
|
||||
if b.useCache(a, a.Package, b.linkActionID(a), a.Package.Target) || b.IsCmdList {
|
||||
return nil
|
||||
}
|
||||
defer b.flushOutput(a)
|
||||
@ -1172,7 +1268,7 @@ func (b *Builder) linkSharedActionID(a *Action) cache.ActionID {
|
||||
}
|
||||
|
||||
func (b *Builder) linkShared(a *Action) (err error) {
|
||||
if b.useCache(a, nil, b.linkSharedActionID(a), a.Target) {
|
||||
if b.useCache(a, nil, b.linkSharedActionID(a), a.Target) || b.IsCmdList {
|
||||
return nil
|
||||
}
|
||||
defer b.flushOutput(a)
|
||||
@ -1236,13 +1332,17 @@ func BuildInstallFunc(b *Builder, a *Action) (err error) {
|
||||
// We want to hide that awful detail as much as possible, so don't
|
||||
// advertise it by touching the mtimes (usually the libraries are up
|
||||
// to date).
|
||||
if !a.buggyInstall && !b.ComputeStaleOnly {
|
||||
if !a.buggyInstall && !b.IsCmdList {
|
||||
now := time.Now()
|
||||
os.Chtimes(a.Target, now, now)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if b.ComputeStaleOnly {
|
||||
|
||||
// If we're building for go list -export,
|
||||
// never install anything; just keep the cache reference.
|
||||
if b.IsCmdList {
|
||||
a.built = a1.built
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -1468,6 +1568,7 @@ var objectMagic = [][]byte{
|
||||
{0x00, 0x00, 0x01, 0xEB}, // Plan 9 i386
|
||||
{0x00, 0x00, 0x8a, 0x97}, // Plan 9 amd64
|
||||
{0x00, 0x00, 0x06, 0x47}, // Plan 9 arm
|
||||
{0x00, 0x61, 0x73, 0x6D}, // WASM
|
||||
}
|
||||
|
||||
func isObject(s string) bool {
|
||||
|
@ -41,43 +41,57 @@ var re = regexp.MustCompile
|
||||
|
||||
var validCompilerFlags = []*regexp.Regexp{
|
||||
re(`-D([A-Za-z_].*)`),
|
||||
re(`-F([^@\-].*)`),
|
||||
re(`-I([^@\-].*)`),
|
||||
re(`-O`),
|
||||
re(`-O([^@\-].*)`),
|
||||
re(`-W`),
|
||||
re(`-W([^@,]+)`), // -Wall but not -Wa,-foo.
|
||||
re(`-Wa,-mbig-obj`),
|
||||
re(`-Wp,-D([A-Za-z_].*)`),
|
||||
re(`-ansi`),
|
||||
re(`-f(no-)?asynchronous-unwind-tables`),
|
||||
re(`-f(no-)?blocks`),
|
||||
re(`-f(no-)builtin-[a-zA-Z0-9_]*`),
|
||||
re(`-f(no-)?common`),
|
||||
re(`-f(no-)?constant-cfstrings`),
|
||||
re(`-fdiagnostics-show-note-include-stack`),
|
||||
re(`-f(no-)?eliminate-unused-debug-types`),
|
||||
re(`-f(no-)?exceptions`),
|
||||
re(`-f(no-)?fast-math`),
|
||||
re(`-f(no-)?inline-functions`),
|
||||
re(`-finput-charset=([^@\-].*)`),
|
||||
re(`-f(no-)?fat-lto-objects`),
|
||||
re(`-f(no-)?keep-inline-dllexport`),
|
||||
re(`-f(no-)?lto`),
|
||||
re(`-fmacro-backtrace-limit=(.+)`),
|
||||
re(`-fmessage-length=(.+)`),
|
||||
re(`-f(no-)?modules`),
|
||||
re(`-f(no-)?objc-arc`),
|
||||
re(`-f(no-)?objc-nonfragile-abi`),
|
||||
re(`-f(no-)?objc-legacy-dispatch`),
|
||||
re(`-f(no-)?omit-frame-pointer`),
|
||||
re(`-f(no-)?openmp(-simd)?`),
|
||||
re(`-f(no-)?permissive`),
|
||||
re(`-f(no-)?(pic|PIC|pie|PIE)`),
|
||||
re(`-f(no-)?plt`),
|
||||
re(`-f(no-)?rtti`),
|
||||
re(`-f(no-)?split-stack`),
|
||||
re(`-f(no-)?stack-(.+)`),
|
||||
re(`-f(no-)?strict-aliasing`),
|
||||
re(`-f(un)signed-char`),
|
||||
re(`-f(no-)?use-linker-plugin`), // safe if -B is not used; we don't permit -B
|
||||
re(`-f(no-)?visibility-inlines-hidden`),
|
||||
re(`-fsanitize=(.+)`),
|
||||
re(`-ftemplate-depth-(.+)`),
|
||||
re(`-fvisibility=(.+)`),
|
||||
re(`-g([^@\-].*)?`),
|
||||
re(`-m32`),
|
||||
re(`-m64`),
|
||||
re(`-m(arch|cpu|fpu|tune)=([^@\-].*)`),
|
||||
re(`-m(abi|arch|cpu|fpu|tune)=([^@\-].*)`),
|
||||
re(`-marm`),
|
||||
re(`-mfloat-abi=([^@\-].*)`),
|
||||
re(`-mfpmath=[0-9a-z,+]*`),
|
||||
re(`-m(no-)?avx[0-9a-z.]*`),
|
||||
re(`-m(no-)?ms-bitfields`),
|
||||
re(`-m(no-)?stack-(.+)`),
|
||||
@ -86,14 +100,19 @@ var validCompilerFlags = []*regexp.Regexp{
|
||||
re(`-miphoneos-version-min=(.+)`),
|
||||
re(`-mnop-fun-dllimport`),
|
||||
re(`-m(no-)?sse[0-9.]*`),
|
||||
re(`-mthumb(-interwork)?`),
|
||||
re(`-mthreads`),
|
||||
re(`-mwindows`),
|
||||
re(`--param=ssp-buffer-size=[0-9]*`),
|
||||
re(`-pedantic(-errors)?`),
|
||||
re(`-pipe`),
|
||||
re(`-pthread`),
|
||||
re(`-?-std=([^@\-].*)`),
|
||||
re(`-?-stdlib=([^@\-].*)`),
|
||||
re(`--sysroot=([^@\-].*)`),
|
||||
re(`-w`),
|
||||
re(`-x([^@\-].*)`),
|
||||
re(`-v`),
|
||||
}
|
||||
|
||||
var validCompilerFlagsWithNextArg = []string{
|
||||
@ -115,18 +134,24 @@ var validLinkerFlags = []*regexp.Regexp{
|
||||
re(`-O`),
|
||||
re(`-O([^@\-].*)`),
|
||||
re(`-f(no-)?(pic|PIC|pie|PIE)`),
|
||||
re(`-f(no-)?openmp(-simd)?`),
|
||||
re(`-fsanitize=([^@\-].*)`),
|
||||
re(`-g([^@\-].*)?`),
|
||||
re(`-m(arch|cpu|fpu|tune)=([^@\-].*)`),
|
||||
re(`-headerpad_max_install_names`),
|
||||
re(`-m(abi|arch|cpu|fpu|tune)=([^@\-].*)`),
|
||||
re(`-mfloat-abi=([^@\-].*)`),
|
||||
re(`-mmacosx-(.+)`),
|
||||
re(`-mios-simulator-version-min=(.+)`),
|
||||
re(`-miphoneos-version-min=(.+)`),
|
||||
re(`-mthreads`),
|
||||
re(`-mwindows`),
|
||||
re(`-(pic|PIC|pie|PIE)`),
|
||||
re(`-pthread`),
|
||||
re(`-rdynamic`),
|
||||
re(`-shared`),
|
||||
re(`-?-static([-a-z0-9+]*)`),
|
||||
re(`-?-stdlib=([^@\-].*)`),
|
||||
re(`-v`),
|
||||
|
||||
// Note that any wildcards in -Wl need to exclude comma,
|
||||
// since -Wl splits its argument at commas and passes
|
||||
@ -134,22 +159,27 @@ var validLinkerFlags = []*regexp.Regexp{
|
||||
// in a wildcard would allow tunnelling arbitrary additional
|
||||
// linker arguments through one of these.
|
||||
re(`-Wl,--(no-)?allow-multiple-definition`),
|
||||
re(`-Wl,--(no-)?allow-shlib-undefined`),
|
||||
re(`-Wl,--(no-)?as-needed`),
|
||||
re(`-Wl,-Bdynamic`),
|
||||
re(`-Wl,-Bstatic`),
|
||||
re(`-WL,-O([^@,\-][^,]*)?`),
|
||||
re(`-Wl,-d[ny]`),
|
||||
re(`-Wl,--disable-new-dtags`),
|
||||
re(`-Wl,-e[=,][a-zA-Z0-9]*`),
|
||||
re(`-Wl,--enable-new-dtags`),
|
||||
re(`-Wl,--end-group`),
|
||||
re(`-Wl,-framework,[^,@\-][^,]+`),
|
||||
re(`-Wl,-headerpad_max_install_names`),
|
||||
re(`-Wl,--no-undefined`),
|
||||
re(`-Wl,-rpath[=,]([^,@\-][^,]+)`),
|
||||
re(`-Wl,-rpath(-link)?[=,]([^,@\-][^,]+)`),
|
||||
re(`-Wl,-s`),
|
||||
re(`-Wl,-search_paths_first`),
|
||||
re(`-Wl,-sectcreate,([^,@\-][^,]+),([^,@\-][^,]+),([^,@\-][^,]+)`),
|
||||
re(`-Wl,--start-group`),
|
||||
re(`-Wl,-?-static`),
|
||||
re(`-Wl,--subsystem,(native|windows|console|posix|xbox)`),
|
||||
re(`-Wl,-?-subsystem,(native|windows|console|posix|xbox)`),
|
||||
re(`-Wl,-syslibroot[=,]([^,@\-][^,]+)`),
|
||||
re(`-Wl,-undefined[=,]([^,@\-][^,]+)`),
|
||||
re(`-Wl,-?-unresolved-symbols=[^,]+`),
|
||||
re(`-Wl,--(no-)?warn-([^,]+)`),
|
||||
@ -157,6 +187,7 @@ var validLinkerFlags = []*regexp.Regexp{
|
||||
re(`-Wl,-z,relro`),
|
||||
|
||||
re(`[a-zA-Z0-9_/].*\.(a|o|obj|dll|dylib|so)`), // direct linker inputs: x.o or libfoo.so (but not -foo.o or @foo.o)
|
||||
re(`\./.*\.(a|o|obj|dll|dylib|so)`),
|
||||
}
|
||||
|
||||
var validLinkerFlagsWithNextArg = []string{
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
var goodCompilerFlags = [][]string{
|
||||
{"-DFOO"},
|
||||
{"-Dfoo=bar"},
|
||||
{"-F/Qt"},
|
||||
{"-I/"},
|
||||
{"-I/etc/passwd"},
|
||||
{"-I."},
|
||||
@ -57,11 +58,14 @@ var goodCompilerFlags = [][]string{
|
||||
{"-I", "世界"},
|
||||
{"-framework", "Chocolate"},
|
||||
{"-x", "c"},
|
||||
{"-v"},
|
||||
}
|
||||
|
||||
var badCompilerFlags = [][]string{
|
||||
{"-D@X"},
|
||||
{"-D-X"},
|
||||
{"-F@dir"},
|
||||
{"-F-dir"},
|
||||
{"-I@dir"},
|
||||
{"-I-dir"},
|
||||
{"-O@1"},
|
||||
@ -125,6 +129,7 @@ var goodLinkerFlags = [][]string{
|
||||
{"-Wl,--no-warn-error"},
|
||||
{"foo.so"},
|
||||
{"_世界.dll"},
|
||||
{"./x.o"},
|
||||
{"libcgosotest.dylib"},
|
||||
{"-F", "framework"},
|
||||
{"-l", "."},
|
||||
@ -132,6 +137,7 @@ var goodLinkerFlags = [][]string{
|
||||
{"-l", "世界"},
|
||||
{"-L", "framework"},
|
||||
{"-framework", "Chocolate"},
|
||||
{"-v"},
|
||||
{"-Wl,-framework", "-Wl,Chocolate"},
|
||||
{"-Wl,-framework,Chocolate"},
|
||||
{"-Wl,-unresolved-symbols=ignore-all"},
|
||||
@ -191,6 +197,7 @@ var badLinkerFlags = [][]string{
|
||||
{"-x", "--c"},
|
||||
{"-x", "@obj"},
|
||||
{"-Wl,-rpath,@foo"},
|
||||
{"../x.o"},
|
||||
}
|
||||
|
||||
func TestCheckLinkerFlags(t *testing.T) {
|
||||
|
1
src/cmd/go/testdata/modlegacy/src/new/go.mod
vendored
Normal file
1
src/cmd/go/testdata/modlegacy/src/new/go.mod
vendored
Normal file
@ -0,0 +1 @@
|
||||
module "new/v2"
|
3
src/cmd/go/testdata/modlegacy/src/new/new.go
vendored
Normal file
3
src/cmd/go/testdata/modlegacy/src/new/new.go
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
package new
|
||||
|
||||
import _ "new/v2/p2"
|
7
src/cmd/go/testdata/modlegacy/src/new/p1/p1.go
vendored
Normal file
7
src/cmd/go/testdata/modlegacy/src/new/p1/p1.go
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
package p1
|
||||
|
||||
import _ "old/p2"
|
||||
import _ "new/v2"
|
||||
import _ "new/v2/p2"
|
||||
import _ "new/sub/v2/x/v1/y" // v2 is module, v1 is directory in module
|
||||
import _ "new/sub/inner/x" // new/sub/inner/go.mod overrides new/sub/go.mod
|
1
src/cmd/go/testdata/modlegacy/src/new/p2/p2.go
vendored
Normal file
1
src/cmd/go/testdata/modlegacy/src/new/p2/p2.go
vendored
Normal file
@ -0,0 +1 @@
|
||||
package p2
|
1
src/cmd/go/testdata/modlegacy/src/new/sub/go.mod
vendored
Normal file
1
src/cmd/go/testdata/modlegacy/src/new/sub/go.mod
vendored
Normal file
@ -0,0 +1 @@
|
||||
module new/sub/v2
|
1
src/cmd/go/testdata/modlegacy/src/new/sub/inner/go.mod
vendored
Normal file
1
src/cmd/go/testdata/modlegacy/src/new/sub/inner/go.mod
vendored
Normal file
@ -0,0 +1 @@
|
||||
module new/sub/inner
|
1
src/cmd/go/testdata/modlegacy/src/new/sub/inner/x/x.go
vendored
Normal file
1
src/cmd/go/testdata/modlegacy/src/new/sub/inner/x/x.go
vendored
Normal file
@ -0,0 +1 @@
|
||||
package x
|
1
src/cmd/go/testdata/modlegacy/src/new/sub/x/v1/y/y.go
vendored
Normal file
1
src/cmd/go/testdata/modlegacy/src/new/sub/x/v1/y/y.go
vendored
Normal file
@ -0,0 +1 @@
|
||||
package y
|
5
src/cmd/go/testdata/modlegacy/src/old/p1/p1.go
vendored
Normal file
5
src/cmd/go/testdata/modlegacy/src/old/p1/p1.go
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
package p1
|
||||
|
||||
import _ "old/p2"
|
||||
import _ "new/p1"
|
||||
import _ "new"
|
1
src/cmd/go/testdata/modlegacy/src/old/p2/p2.go
vendored
Normal file
1
src/cmd/go/testdata/modlegacy/src/old/p2/p2.go
vendored
Normal file
@ -0,0 +1 @@
|
||||
package p2
|
7
src/cmd/go/testdata/testcover/pkg1/a.go
vendored
Normal file
7
src/cmd/go/testdata/testcover/pkg1/a.go
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
package pkg1
|
||||
|
||||
import "fmt"
|
||||
|
||||
func F() {
|
||||
fmt.Println("pkg1")
|
||||
}
|
7
src/cmd/go/testdata/testcover/pkg2/a.go
vendored
Normal file
7
src/cmd/go/testdata/testcover/pkg2/a.go
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
package pkg2
|
||||
|
||||
import "fmt"
|
||||
|
||||
func F() {
|
||||
fmt.Println("pkg2")
|
||||
}
|
1
src/cmd/go/testdata/testcover/pkg2/a_test.go
vendored
Normal file
1
src/cmd/go/testdata/testcover/pkg2/a_test.go
vendored
Normal file
@ -0,0 +1 @@
|
||||
package pkg2
|
7
src/cmd/go/testdata/testcover/pkg3/a.go
vendored
Normal file
7
src/cmd/go/testdata/testcover/pkg3/a.go
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
package pkg3
|
||||
|
||||
import "fmt"
|
||||
|
||||
func F() {
|
||||
fmt.Println("pkg3")
|
||||
}
|
7
src/cmd/go/testdata/testcover/pkg3/a_test.go
vendored
Normal file
7
src/cmd/go/testdata/testcover/pkg3/a_test.go
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
package pkg3
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestF(t *testing.T) {
|
||||
F()
|
||||
}
|
@ -10,6 +10,7 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"internal/testenv"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
@ -328,3 +329,75 @@ func TestVendor12156(t *testing.T) {
|
||||
tg.grepStderrNot("panic", "panicked")
|
||||
tg.grepStderr(`cannot find package "x"`, "wrong error")
|
||||
}
|
||||
|
||||
// Module legacy support does path rewriting very similar to vendoring.
|
||||
|
||||
func TestModLegacy(t *testing.T) {
|
||||
tg := testgo(t)
|
||||
defer tg.cleanup()
|
||||
tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata/modlegacy"))
|
||||
tg.run("list", "-f", "{{.Imports}}", "old/p1")
|
||||
tg.grepStdout("new/p1", "old/p1 should import new/p1")
|
||||
tg.run("list", "-f", "{{.Imports}}", "new/p1")
|
||||
tg.grepStdout("new/p2", "new/p1 should import new/p2 (not new/v2/p2)")
|
||||
tg.grepStdoutNot("new/v2", "new/p1 should NOT import new/v2*")
|
||||
tg.grepStdout("new/sub/x/v1/y", "new/p1 should import new/sub/x/v1/y (not new/sub/v2/x/v1/y)")
|
||||
tg.grepStdoutNot("new/sub/v2", "new/p1 should NOT import new/sub/v2*")
|
||||
tg.grepStdout("new/sub/inner/x", "new/p1 should import new/sub/inner/x (no rewrites)")
|
||||
tg.run("build", "old/p1", "new/p1")
|
||||
}
|
||||
|
||||
func TestModLegacyGet(t *testing.T) {
|
||||
testenv.MustHaveExternalNetwork(t)
|
||||
|
||||
tg := testgo(t)
|
||||
defer tg.cleanup()
|
||||
tg.makeTempdir()
|
||||
tg.setenv("GOPATH", tg.path("d1"))
|
||||
tg.run("get", "vcs-test.golang.org/git/modlegacy1-old.git/p1")
|
||||
tg.run("list", "-f", "{{.Deps}}", "vcs-test.golang.org/git/modlegacy1-old.git/p1")
|
||||
tg.grepStdout("new.git/p2", "old/p1 should depend on new/p2")
|
||||
tg.grepStdoutNot("new.git/v2/p2", "old/p1 should NOT depend on new/v2/p2")
|
||||
tg.run("build", "vcs-test.golang.org/git/modlegacy1-old.git/p1", "vcs-test.golang.org/git/modlegacy1-new.git/p1")
|
||||
|
||||
tg.setenv("GOPATH", tg.path("d2"))
|
||||
|
||||
tg.must(os.RemoveAll(tg.path("d2")))
|
||||
tg.run("get", "github.com/rsc/vgotest5")
|
||||
tg.run("get", "github.com/rsc/vgotest4")
|
||||
tg.run("get", "github.com/myitcv/vgo_example_compat")
|
||||
|
||||
if testing.Short() {
|
||||
return
|
||||
}
|
||||
|
||||
tg.must(os.RemoveAll(tg.path("d2")))
|
||||
tg.run("get", "github.com/rsc/vgotest4")
|
||||
tg.run("get", "github.com/rsc/vgotest5")
|
||||
tg.run("get", "github.com/myitcv/vgo_example_compat")
|
||||
|
||||
tg.must(os.RemoveAll(tg.path("d2")))
|
||||
tg.run("get", "github.com/rsc/vgotest4", "github.com/rsc/vgotest5")
|
||||
tg.run("get", "github.com/myitcv/vgo_example_compat")
|
||||
|
||||
tg.must(os.RemoveAll(tg.path("d2")))
|
||||
tg.run("get", "github.com/rsc/vgotest5", "github.com/rsc/vgotest4")
|
||||
tg.run("get", "github.com/myitcv/vgo_example_compat")
|
||||
|
||||
tg.must(os.RemoveAll(tg.path("d2")))
|
||||
tg.run("get", "github.com/myitcv/vgo_example_compat")
|
||||
tg.run("get", "github.com/rsc/vgotest4", "github.com/rsc/vgotest5")
|
||||
|
||||
pkgs := []string{"github.com/myitcv/vgo_example_compat", "github.com/rsc/vgotest4", "github.com/rsc/vgotest5"}
|
||||
for i := 0; i < 3; i++ {
|
||||
for j := 0; j < 3; j++ {
|
||||
for k := 0; k < 3; k++ {
|
||||
if i == j || i == k || k == j {
|
||||
continue
|
||||
}
|
||||
tg.must(os.RemoveAll(tg.path("d2")))
|
||||
tg.run("get", pkgs[i], pkgs[j], pkgs[k])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -245,12 +245,12 @@ var optab = []Optab{
|
||||
{AANDS, C_BITCON, C_REG, C_NONE, C_REG, 53, 4, 0, 0, 0},
|
||||
{AANDS, C_BITCON, C_NONE, C_NONE, C_REG, 53, 4, 0, 0, 0},
|
||||
{ATST, C_BITCON, C_REG, C_NONE, C_NONE, 53, 4, 0, 0, 0},
|
||||
{AAND, C_MOVCON, C_REG, C_NONE, C_RSP, 62, 8, 0, 0, 0},
|
||||
{AAND, C_MOVCON, C_REG, C_NONE, C_REG, 62, 8, 0, 0, 0},
|
||||
{AAND, C_MOVCON, C_NONE, C_NONE, C_REG, 62, 8, 0, 0, 0},
|
||||
{AANDS, C_MOVCON, C_REG, C_NONE, C_REG, 62, 8, 0, 0, 0},
|
||||
{AANDS, C_MOVCON, C_NONE, C_NONE, C_REG, 62, 8, 0, 0, 0},
|
||||
{ATST, C_MOVCON, C_REG, C_NONE, C_NONE, 62, 8, 0, 0, 0},
|
||||
{AAND, C_VCON, C_REG, C_NONE, C_RSP, 28, 8, 0, LFROM, 0},
|
||||
{AAND, C_VCON, C_REG, C_NONE, C_REG, 28, 8, 0, LFROM, 0},
|
||||
{AAND, C_VCON, C_NONE, C_NONE, C_REG, 28, 8, 0, LFROM, 0},
|
||||
{AANDS, C_VCON, C_REG, C_NONE, C_REG, 28, 8, 0, LFROM, 0},
|
||||
{AANDS, C_VCON, C_NONE, C_NONE, C_REG, 28, 8, 0, LFROM, 0},
|
||||
@ -3548,7 +3548,7 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
|
||||
if r == 0 {
|
||||
r = rt
|
||||
}
|
||||
if p.To.Type != obj.TYPE_NONE && (p.To.Reg == REGSP || r == REGSP) {
|
||||
if p.To.Reg == REGSP || r == REGSP {
|
||||
o2 = c.opxrrr(p, p.As, false)
|
||||
o2 |= REGTMP & 31 << 16
|
||||
o2 |= LSL0_64
|
||||
|
@ -150,7 +150,7 @@ const (
|
||||
)
|
||||
|
||||
// LINUX for zSeries ELF Application Binary Interface Supplement
|
||||
// http://refspecs.linuxfoundation.org/ELF/zSeries/lzsabi0_zSeries/x1472.html
|
||||
// https://refspecs.linuxfoundation.org/ELF/zSeries/lzsabi0_zSeries/x1472.html
|
||||
var S390XDWARFRegisters = map[int16]int16{}
|
||||
|
||||
func init() {
|
||||
|
@ -4,9 +4,9 @@ package objabi
|
||||
|
||||
import "strconv"
|
||||
|
||||
const _RelocType_name = "R_ADDRR_ADDRPOWERR_ADDRARM64R_ADDRMIPSR_ADDROFFR_WEAKADDROFFR_SIZER_CALLR_CALLARMR_CALLARM64R_CALLINDR_CALLPOWERR_CALLMIPSR_CONSTR_PCRELR_TLS_LER_TLS_IER_GOTOFFR_PLT0R_PLT1R_PLT2R_USEFIELDR_USETYPER_METHODOFFR_POWER_TOCR_GOTPCRELR_JMPMIPSR_DWARFSECREFR_DWARFFILEREFR_ARM64_TLS_LER_ARM64_TLS_IER_ARM64_GOTPCRELR_POWER_TLS_LER_POWER_TLS_IER_POWER_TLSR_ADDRPOWER_DSR_ADDRPOWER_GOTR_ADDRPOWER_PCRELR_ADDRPOWER_TOCRELR_ADDRPOWER_TOCREL_DSR_PCRELDBLR_ADDRMIPSUR_ADDRMIPSTLSR_ADDRCUOFF"
|
||||
const _RelocType_name = "R_ADDRR_ADDRPOWERR_ADDRARM64R_ADDRMIPSR_ADDROFFR_WEAKADDROFFR_SIZER_CALLR_CALLARMR_CALLARM64R_CALLINDR_CALLPOWERR_CALLMIPSR_CONSTR_PCRELR_TLS_LER_TLS_IER_GOTOFFR_PLT0R_PLT1R_PLT2R_USEFIELDR_USETYPER_METHODOFFR_POWER_TOCR_GOTPCRELR_JMPMIPSR_DWARFSECREFR_DWARFFILEREFR_ARM64_TLS_LER_ARM64_TLS_IER_ARM64_GOTPCRELR_POWER_TLS_LER_POWER_TLS_IER_POWER_TLSR_ADDRPOWER_DSR_ADDRPOWER_GOTR_ADDRPOWER_PCRELR_ADDRPOWER_TOCRELR_ADDRPOWER_TOCREL_DSR_PCRELDBLR_ADDRMIPSUR_ADDRMIPSTLSR_ADDRCUOFFR_WASMIMPORT"
|
||||
|
||||
var _RelocType_index = [...]uint16{0, 6, 17, 28, 38, 47, 60, 66, 72, 81, 92, 101, 112, 122, 129, 136, 144, 152, 160, 166, 172, 178, 188, 197, 208, 219, 229, 238, 251, 265, 279, 293, 309, 323, 337, 348, 362, 377, 394, 412, 433, 443, 454, 467, 478}
|
||||
var _RelocType_index = [...]uint16{0, 6, 17, 28, 38, 47, 60, 66, 72, 81, 92, 101, 112, 122, 129, 136, 144, 152, 160, 166, 172, 178, 188, 197, 208, 219, 229, 238, 251, 265, 279, 293, 309, 323, 337, 348, 362, 377, 394, 412, 433, 443, 454, 467, 478, 490}
|
||||
|
||||
func (i RelocType) String() string {
|
||||
i -= 1
|
||||
|
@ -147,7 +147,7 @@ var (
|
||||
fourSpace = []byte(" ")
|
||||
|
||||
skipLinePrefix = []byte("? \t")
|
||||
skipLineSuffix = []byte("\t[no test files]\n")
|
||||
skipLineSuffix = []byte(" [no test files]\n")
|
||||
)
|
||||
|
||||
// handleInputLine handles a single whole test output line.
|
||||
@ -166,7 +166,7 @@ func (c *converter) handleInputLine(line []byte) {
|
||||
return
|
||||
}
|
||||
|
||||
// Special case for entirely skipped test binary: "? \tpkgname\t[no test files]\n" is only line.
|
||||
// Special case for entirely skipped test binary: "? \tpkgname\t0.001s [no test files]\n" is only line.
|
||||
// Report it as plain output but remember to say skip in the final summary.
|
||||
if bytes.HasPrefix(line, skipLinePrefix) && bytes.HasSuffix(line, skipLineSuffix) && len(c.report) == 0 {
|
||||
c.result = "skip"
|
||||
|
@ -617,7 +617,7 @@ func addpltsym(ctxt *ld.Link, s *sym.Symbol) {
|
||||
// so for now we'll just use non-lazy pointers,
|
||||
// which don't need to be told which library to use.
|
||||
//
|
||||
// http://networkpx.blogspot.com/2009/09/about-lcdyldinfoonly-command.html
|
||||
// https://networkpx.blogspot.com/2009/09/about-lcdyldinfoonly-command.html
|
||||
// has details about what we're avoiding.
|
||||
|
||||
addgotsym(ctxt, s)
|
||||
|
@ -95,7 +95,7 @@ func trampoline(ctxt *Link, s *sym.Symbol) {
|
||||
if Symaddr(r.Sym) == 0 && r.Sym.Type != sym.SDYNIMPORT {
|
||||
if r.Sym.File != s.File {
|
||||
if !isRuntimeDepPkg(s.File) || !isRuntimeDepPkg(r.Sym.File) {
|
||||
Errorf(s, "unresolved inter-package jump to %s(%s)", r.Sym, r.Sym.File)
|
||||
ctxt.ErrorUnresolved(s, r)
|
||||
}
|
||||
// runtime and its dependent packages may call to each other.
|
||||
// they are fine, as they will be laid down together.
|
||||
@ -128,7 +128,7 @@ func relocsym(ctxt *Link, s *sym.Symbol) {
|
||||
continue
|
||||
}
|
||||
|
||||
if r.Sym != nil && ((r.Sym.Type == 0 && !r.Sym.Attr.VisibilityHidden()) || r.Sym.Type == sym.SXREF) {
|
||||
if r.Sym != nil && ((r.Sym.Type == sym.Sxxx && !r.Sym.Attr.VisibilityHidden()) || r.Sym.Type == sym.SXREF) {
|
||||
// When putting the runtime but not main into a shared library
|
||||
// these symbols are undefined and that's OK.
|
||||
if ctxt.BuildMode == BuildModeShared {
|
||||
@ -140,7 +140,7 @@ func relocsym(ctxt *Link, s *sym.Symbol) {
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
Errorf(s, "relocation target %s not defined", r.Sym.Name)
|
||||
ctxt.ErrorUnresolved(s, r)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
70
src/cmd/link/internal/ld/ld_test.go
Normal file
70
src/cmd/link/internal/ld/ld_test.go
Normal file
@ -0,0 +1,70 @@
|
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package ld
|
||||
|
||||
import (
|
||||
"internal/testenv"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestUndefinedRelocErrors(t *testing.T) {
|
||||
testenv.MustHaveGoBuild(t)
|
||||
dir, err := ioutil.TempDir("", "go-build")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
out, err := exec.Command(testenv.GoToolPath(t), "build", "./testdata/issue10978").CombinedOutput()
|
||||
if err == nil {
|
||||
t.Fatal("expected build to fail")
|
||||
}
|
||||
|
||||
wantErrors := map[string]int{
|
||||
// Main function has dedicated error message.
|
||||
"function main is undeclared in the main package": 1,
|
||||
|
||||
// Single error reporting per each symbol.
|
||||
// This way, duplicated messages are not reported for
|
||||
// multiple relocations with a same name.
|
||||
"main.defined1: relocation target main.undefined not defined": 1,
|
||||
"main.defined2: relocation target main.undefined not defined": 1,
|
||||
}
|
||||
unexpectedErrors := map[string]int{}
|
||||
|
||||
for _, l := range strings.Split(string(out), "\n") {
|
||||
if strings.HasPrefix(l, "#") || l == "" {
|
||||
continue
|
||||
}
|
||||
matched := ""
|
||||
for want := range wantErrors {
|
||||
if strings.Contains(l, want) {
|
||||
matched = want
|
||||
break
|
||||
}
|
||||
}
|
||||
if matched != "" {
|
||||
wantErrors[matched]--
|
||||
} else {
|
||||
unexpectedErrors[l]++
|
||||
}
|
||||
}
|
||||
|
||||
for want, n := range wantErrors {
|
||||
switch {
|
||||
case n > 0:
|
||||
t.Errorf("unmatched error: %s (x%d)", want, n)
|
||||
case n < 0:
|
||||
t.Errorf("extra errors: %s (x%d)", want, -n)
|
||||
}
|
||||
}
|
||||
for unexpected, n := range unexpectedErrors {
|
||||
t.Errorf("unexpected error: %s (x%d)", unexpected, n)
|
||||
}
|
||||
}
|
@ -1963,7 +1963,7 @@ func usage() {
|
||||
type SymbolType int8
|
||||
|
||||
const (
|
||||
// see also http://9p.io/magic/man2html/1/nm
|
||||
// see also https://9p.io/magic/man2html/1/nm
|
||||
TextSym SymbolType = 'T'
|
||||
DataSym SymbolType = 'D'
|
||||
BSSSym SymbolType = 'B'
|
||||
@ -2200,6 +2200,18 @@ func undefsym(ctxt *Link, s *sym.Symbol) {
|
||||
}
|
||||
|
||||
func (ctxt *Link) undef() {
|
||||
// undefsym performs checks (almost) identical to checks
|
||||
// that report undefined relocations in relocsym.
|
||||
// Both undefsym and relocsym can report same symbol as undefined,
|
||||
// which results in error message duplication (see #10978).
|
||||
//
|
||||
// The undef is run after Arch.Asmb and could detect some
|
||||
// programming errors there, but if object being linked is already
|
||||
// failed with errors, it is better to avoid duplicated errors.
|
||||
if nerrors > 0 {
|
||||
return
|
||||
}
|
||||
|
||||
for _, s := range ctxt.Textp {
|
||||
undefsym(ctxt, s)
|
||||
}
|
||||
|
@ -81,6 +81,33 @@ type Link struct {
|
||||
PackageShlib map[string]string
|
||||
|
||||
tramps []*sym.Symbol // trampolines
|
||||
|
||||
// unresolvedSymSet is a set of erroneous unresolved references.
|
||||
// Used to avoid duplicated error messages.
|
||||
unresolvedSymSet map[unresolvedSymKey]bool
|
||||
}
|
||||
|
||||
type unresolvedSymKey struct {
|
||||
from *sym.Symbol // Symbol that referenced unresolved "to"
|
||||
to *sym.Symbol // Unresolved symbol referenced by "from"
|
||||
}
|
||||
|
||||
// ErrorUnresolved prints unresolved symbol error for r.Sym that is referenced from s.
|
||||
func (ctxt *Link) ErrorUnresolved(s *sym.Symbol, r *sym.Reloc) {
|
||||
if ctxt.unresolvedSymSet == nil {
|
||||
ctxt.unresolvedSymSet = make(map[unresolvedSymKey]bool)
|
||||
}
|
||||
|
||||
k := unresolvedSymKey{from: s, to: r.Sym}
|
||||
if !ctxt.unresolvedSymSet[k] {
|
||||
ctxt.unresolvedSymSet[k] = true
|
||||
// Give a special error message for main symbol (see #24809).
|
||||
if r.Sym.Name == "main.main" {
|
||||
Errorf(s, "function main is undeclared in the main package")
|
||||
} else {
|
||||
Errorf(s, "relocation target %s not defined", r.Sym.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The smallest possible offset from the hardware stack pointer to a local
|
||||
|
@ -142,12 +142,8 @@ const (
|
||||
S_ATTR_SOME_INSTRUCTIONS = 0x00000400
|
||||
)
|
||||
|
||||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Mach-O file writing
|
||||
// http://developer.apple.com/mac/library/DOCUMENTATION/DeveloperTools/Conceptual/MachORuntime/Reference/reference.html
|
||||
// https://developer.apple.com/mac/library/DOCUMENTATION/DeveloperTools/Conceptual/MachORuntime/Reference/reference.html
|
||||
|
||||
var machohdr MachoHdr
|
||||
|
||||
|
@ -116,7 +116,7 @@ const (
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// PE (Portable Executable) file writing
|
||||
// http://www.microsoft.com/whdc/system/platform/firmware/PECOFF.mspx
|
||||
// https://www.microsoft.com/whdc/system/platform/firmware/PECOFF.mspx
|
||||
|
||||
// DOS stub that prints out
|
||||
// "This program cannot be run in DOS mode."
|
||||
|
27
src/cmd/link/internal/ld/testdata/issue10978/main.go
vendored
Normal file
27
src/cmd/link/internal/ld/testdata/issue10978/main.go
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package main
|
||||
|
||||
func undefined()
|
||||
|
||||
func defined1() int {
|
||||
// To check multiple errors for a single symbol,
|
||||
// reference undefined more than once.
|
||||
undefined()
|
||||
undefined()
|
||||
return 0
|
||||
}
|
||||
|
||||
func defined2() {
|
||||
undefined()
|
||||
undefined()
|
||||
}
|
||||
|
||||
func init() {
|
||||
_ = defined1()
|
||||
defined2()
|
||||
}
|
||||
|
||||
// The "main" function remains undeclared.
|
1
src/cmd/link/internal/ld/testdata/issue10978/main.s
vendored
Normal file
1
src/cmd/link/internal/ld/testdata/issue10978/main.s
vendored
Normal file
@ -0,0 +1 @@
|
||||
// This file is needed to make "go build" work for package with external functions.
|
@ -1048,7 +1048,7 @@ func readelfsym(arch *sys.Arch, syms *sym.Symbols, elfobj *ElfObj, i int, elfsym
|
||||
// __i686.get_pc_thunk.bx is allowed to be duplicated, to
|
||||
// workaround that we set dupok.
|
||||
// TODO(minux): correctly handle __i686.get_pc_thunk.bx without
|
||||
// set dupok generally. See http://codereview.appspot.com/5823055/
|
||||
// set dupok generally. See https://golang.org/cl/5823055
|
||||
// comment #5 for details.
|
||||
if s != nil && elfsym.other == 2 {
|
||||
s.Attr |= sym.AttrDuplicateOK | sym.AttrVisibilityHidden
|
||||
|
@ -88,7 +88,7 @@ func assignAddress(ctxt *ld.Link, sect *sym.Section, n int, s *sym.Symbol, va ui
|
||||
}
|
||||
|
||||
// asmb writes the final WebAssembly module binary.
|
||||
// Spec: http://webassembly.github.io/spec/core/binary/modules.html
|
||||
// Spec: https://webassembly.github.io/spec/core/binary/modules.html
|
||||
func asmb(ctxt *ld.Link) {
|
||||
if ctxt.Debugvlog != 0 {
|
||||
ctxt.Logf("%5.2f asmb\n", ld.Cputime())
|
||||
|
@ -86,7 +86,7 @@ func (r *readlineUI) print(withColor bool, args ...interface{}) {
|
||||
if withColor {
|
||||
text = colorize(text)
|
||||
}
|
||||
fmt.Fprintf(r.term, text)
|
||||
fmt.Fprint(r.term, text)
|
||||
}
|
||||
|
||||
// colorize prints the msg in red using ANSI color escapes.
|
||||
|
49
src/cmd/vendor/github.com/google/pprof/internal/driver/cli.go
generated
vendored
49
src/cmd/vendor/github.com/google/pprof/internal/driver/cli.go
generated
vendored
@ -15,6 +15,7 @@
|
||||
package driver
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
@ -28,6 +29,7 @@ type source struct {
|
||||
ExecName string
|
||||
BuildID string
|
||||
Base []string
|
||||
DiffBase bool
|
||||
Normalize bool
|
||||
|
||||
Seconds int
|
||||
@ -43,7 +45,8 @@ type source struct {
|
||||
func parseFlags(o *plugin.Options) (*source, []string, error) {
|
||||
flag := o.Flagset
|
||||
// Comparisons.
|
||||
flagBase := flag.StringList("base", "", "Source for base profile for comparison")
|
||||
flagBase := flag.StringList("base", "", "Source for base profile for profile subtraction")
|
||||
flagDiffBase := flag.StringList("diff_base", "", "Source for diff base profile for comparison")
|
||||
// Source options.
|
||||
flagSymbolize := flag.String("symbolize", "", "Options for profile symbolization")
|
||||
flagBuildID := flag.String("buildid", "", "Override build id for first mapping")
|
||||
@ -85,7 +88,7 @@ func parseFlags(o *plugin.Options) (*source, []string, error) {
|
||||
usageMsgVars)
|
||||
})
|
||||
if len(args) == 0 {
|
||||
return nil, nil, fmt.Errorf("no profile source specified")
|
||||
return nil, nil, errors.New("no profile source specified")
|
||||
}
|
||||
|
||||
var execName string
|
||||
@ -112,7 +115,7 @@ func parseFlags(o *plugin.Options) (*source, []string, error) {
|
||||
return nil, nil, err
|
||||
}
|
||||
if cmd != nil && *flagHTTP != "" {
|
||||
return nil, nil, fmt.Errorf("-http is not compatible with an output format on the command line")
|
||||
return nil, nil, errors.New("-http is not compatible with an output format on the command line")
|
||||
}
|
||||
|
||||
si := pprofVariables["sample_index"].value
|
||||
@ -140,15 +143,13 @@ func parseFlags(o *plugin.Options) (*source, []string, error) {
|
||||
Comment: *flagAddComment,
|
||||
}
|
||||
|
||||
for _, s := range *flagBase {
|
||||
if *s != "" {
|
||||
source.Base = append(source.Base, *s)
|
||||
}
|
||||
if err := source.addBaseProfiles(*flagBase, *flagDiffBase); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
normalize := pprofVariables["normalize"].boolValue()
|
||||
if normalize && len(source.Base) == 0 {
|
||||
return nil, nil, fmt.Errorf("Must have base profile to normalize by")
|
||||
return nil, nil, errors.New("must have base profile to normalize by")
|
||||
}
|
||||
source.Normalize = normalize
|
||||
|
||||
@ -158,6 +159,34 @@ func parseFlags(o *plugin.Options) (*source, []string, error) {
|
||||
return source, cmd, nil
|
||||
}
|
||||
|
||||
// addBaseProfiles adds the list of base profiles or diff base profiles to
|
||||
// the source. This function will return an error if both base and diff base
|
||||
// profiles are specified.
|
||||
func (source *source) addBaseProfiles(flagBase, flagDiffBase []*string) error {
|
||||
base, diffBase := dropEmpty(flagBase), dropEmpty(flagDiffBase)
|
||||
if len(base) > 0 && len(diffBase) > 0 {
|
||||
return errors.New("-base and -diff_base flags cannot both be specified")
|
||||
}
|
||||
|
||||
source.Base = base
|
||||
if len(diffBase) > 0 {
|
||||
source.Base, source.DiffBase = diffBase, true
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// dropEmpty list takes a slice of string pointers, and outputs a slice of
|
||||
// non-empty strings associated with the flag.
|
||||
func dropEmpty(list []*string) []string {
|
||||
var l []string
|
||||
for _, s := range list {
|
||||
if *s != "" {
|
||||
l = append(l, *s)
|
||||
}
|
||||
}
|
||||
return l
|
||||
}
|
||||
|
||||
// installFlags creates command line flags for pprof variables.
|
||||
func installFlags(flag plugin.FlagSet) flagsInstalled {
|
||||
f := flagsInstalled{
|
||||
@ -240,7 +269,7 @@ func outputFormat(bcmd map[string]*bool, acmd map[string]*string) (cmd []string,
|
||||
for n, b := range bcmd {
|
||||
if *b {
|
||||
if cmd != nil {
|
||||
return nil, fmt.Errorf("must set at most one output format")
|
||||
return nil, errors.New("must set at most one output format")
|
||||
}
|
||||
cmd = []string{n}
|
||||
}
|
||||
@ -248,7 +277,7 @@ func outputFormat(bcmd map[string]*bool, acmd map[string]*string) (cmd []string,
|
||||
for n, s := range acmd {
|
||||
if *s != "" {
|
||||
if cmd != nil {
|
||||
return nil, fmt.Errorf("must set at most one output format")
|
||||
return nil, errors.New("must set at most one output format")
|
||||
}
|
||||
cmd = []string{n, *s}
|
||||
}
|
||||
|
27
src/cmd/vendor/github.com/google/pprof/internal/driver/driver.go
generated
vendored
27
src/cmd/vendor/github.com/google/pprof/internal/driver/driver.go
generated
vendored
@ -65,7 +65,13 @@ func generateRawReport(p *profile.Profile, cmd []string, vars variables, o *plug
|
||||
// Identify units of numeric tags in profile.
|
||||
numLabelUnits := identifyNumLabelUnits(p, o.UI)
|
||||
|
||||
vars = applyCommandOverrides(cmd, vars)
|
||||
// Get report output format
|
||||
c := pprofCommands[cmd[0]]
|
||||
if c == nil {
|
||||
panic("unexpected nil command")
|
||||
}
|
||||
|
||||
vars = applyCommandOverrides(cmd[0], c.format, vars)
|
||||
|
||||
// Delay focus after configuring report to get percentages on all samples.
|
||||
relative := vars["relative_percentages"].boolValue()
|
||||
@ -78,10 +84,6 @@ func generateRawReport(p *profile.Profile, cmd []string, vars variables, o *plug
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
c := pprofCommands[cmd[0]]
|
||||
if c == nil {
|
||||
panic("unexpected nil command")
|
||||
}
|
||||
ropt.OutputFormat = c.format
|
||||
if len(cmd) == 2 {
|
||||
s, err := regexp.Compile(cmd[1])
|
||||
@ -149,13 +151,10 @@ func generateReport(p *profile.Profile, cmd []string, vars variables, o *plugin.
|
||||
return out.Close()
|
||||
}
|
||||
|
||||
func applyCommandOverrides(cmd []string, v variables) variables {
|
||||
func applyCommandOverrides(cmd string, outputFormat int, v variables) variables {
|
||||
trim, tagfilter, filter := v["trim"].boolValue(), true, true
|
||||
|
||||
switch cmd[0] {
|
||||
case "proto", "raw":
|
||||
trim, tagfilter, filter = false, false, false
|
||||
v.set("addresses", "t")
|
||||
switch cmd {
|
||||
case "callgrind", "kcachegrind":
|
||||
trim = false
|
||||
v.set("addresses", "t")
|
||||
@ -163,7 +162,7 @@ func applyCommandOverrides(cmd []string, v variables) variables {
|
||||
trim = false
|
||||
v.set("addressnoinlines", "t")
|
||||
case "peek":
|
||||
trim, filter = false, false
|
||||
trim, tagfilter, filter = false, false, false
|
||||
case "list":
|
||||
v.set("nodecount", "0")
|
||||
v.set("lines", "t")
|
||||
@ -176,6 +175,12 @@ func applyCommandOverrides(cmd []string, v variables) variables {
|
||||
v.set("nodecount", "80")
|
||||
}
|
||||
}
|
||||
|
||||
if outputFormat == report.Proto || outputFormat == report.Raw {
|
||||
trim, tagfilter, filter = false, false, false
|
||||
v.set("addresses", "t")
|
||||
}
|
||||
|
||||
if !trim {
|
||||
v.set("nodecount", "0")
|
||||
v.set("nodefraction", "0")
|
||||
|
9
src/cmd/vendor/github.com/google/pprof/internal/driver/driver_test.go
generated
vendored
9
src/cmd/vendor/github.com/google/pprof/internal/driver/driver_test.go
generated
vendored
@ -288,7 +288,7 @@ type testFlags struct {
|
||||
floats map[string]float64
|
||||
strings map[string]string
|
||||
args []string
|
||||
stringLists map[string][]*string
|
||||
stringLists map[string][]string
|
||||
}
|
||||
|
||||
func (testFlags) ExtraUsage() string { return "" }
|
||||
@ -355,7 +355,12 @@ func (f testFlags) StringVar(p *string, s, d, c string) {
|
||||
|
||||
func (f testFlags) StringList(s, d, c string) *[]*string {
|
||||
if t, ok := f.stringLists[s]; ok {
|
||||
return &t
|
||||
// convert slice of strings to slice of string pointers before returning.
|
||||
tp := make([]*string, len(t))
|
||||
for i, v := range t {
|
||||
tp[i] = &v
|
||||
}
|
||||
return &tp
|
||||
}
|
||||
return &[]*string{}
|
||||
}
|
||||
|
3
src/cmd/vendor/github.com/google/pprof/internal/driver/fetch.go
generated
vendored
3
src/cmd/vendor/github.com/google/pprof/internal/driver/fetch.go
generated
vendored
@ -63,6 +63,9 @@ func fetchProfiles(s *source, o *plugin.Options) (*profile.Profile, error) {
|
||||
}
|
||||
|
||||
if pbase != nil {
|
||||
if s.DiffBase {
|
||||
pbase.SetLabel("pprof::base", []string{"true"})
|
||||
}
|
||||
if s.Normalize {
|
||||
err := p.Normalize(pbase)
|
||||
if err != nil {
|
||||
|
240
src/cmd/vendor/github.com/google/pprof/internal/driver/fetch_test.go
generated
vendored
240
src/cmd/vendor/github.com/google/pprof/internal/driver/fetch_test.go
generated
vendored
@ -210,13 +210,20 @@ func TestFetchWithBase(t *testing.T) {
|
||||
baseVars := pprofVariables
|
||||
defer func() { pprofVariables = baseVars }()
|
||||
|
||||
type WantSample struct {
|
||||
values []int64
|
||||
labels map[string][]string
|
||||
}
|
||||
|
||||
const path = "testdata/"
|
||||
type testcase struct {
|
||||
desc string
|
||||
sources []string
|
||||
bases []string
|
||||
normalize bool
|
||||
expectedSamples [][]int64
|
||||
desc string
|
||||
sources []string
|
||||
bases []string
|
||||
diffBases []string
|
||||
normalize bool
|
||||
wantSamples []WantSample
|
||||
wantErrorMsg string
|
||||
}
|
||||
|
||||
testcases := []testcase{
|
||||
@ -224,58 +231,216 @@ func TestFetchWithBase(t *testing.T) {
|
||||
"not normalized base is same as source",
|
||||
[]string{path + "cppbench.contention"},
|
||||
[]string{path + "cppbench.contention"},
|
||||
nil,
|
||||
false,
|
||||
[][]int64{},
|
||||
nil,
|
||||
"",
|
||||
},
|
||||
{
|
||||
"not normalized base is same as source",
|
||||
[]string{path + "cppbench.contention"},
|
||||
[]string{path + "cppbench.contention"},
|
||||
nil,
|
||||
false,
|
||||
nil,
|
||||
"",
|
||||
},
|
||||
{
|
||||
"not normalized single source, multiple base (all profiles same)",
|
||||
[]string{path + "cppbench.contention"},
|
||||
[]string{path + "cppbench.contention", path + "cppbench.contention"},
|
||||
nil,
|
||||
false,
|
||||
[][]int64{{-2700, -608881724}, {-100, -23992}, {-200, -179943}, {-100, -17778444}, {-100, -75976}, {-300, -63568134}},
|
||||
[]WantSample{
|
||||
{
|
||||
values: []int64{-2700, -608881724},
|
||||
labels: map[string][]string{},
|
||||
},
|
||||
{
|
||||
values: []int64{-100, -23992},
|
||||
labels: map[string][]string{},
|
||||
},
|
||||
{
|
||||
values: []int64{-200, -179943},
|
||||
labels: map[string][]string{},
|
||||
},
|
||||
{
|
||||
values: []int64{-100, -17778444},
|
||||
labels: map[string][]string{},
|
||||
},
|
||||
{
|
||||
values: []int64{-100, -75976},
|
||||
labels: map[string][]string{},
|
||||
},
|
||||
{
|
||||
values: []int64{-300, -63568134},
|
||||
labels: map[string][]string{},
|
||||
},
|
||||
},
|
||||
"",
|
||||
},
|
||||
{
|
||||
"not normalized, different base and source",
|
||||
[]string{path + "cppbench.contention"},
|
||||
[]string{path + "cppbench.small.contention"},
|
||||
nil,
|
||||
false,
|
||||
[][]int64{{1700, 608878600}, {100, 23992}, {200, 179943}, {100, 17778444}, {100, 75976}, {300, 63568134}},
|
||||
[]WantSample{
|
||||
{
|
||||
values: []int64{1700, 608878600},
|
||||
labels: map[string][]string{},
|
||||
},
|
||||
{
|
||||
values: []int64{100, 23992},
|
||||
labels: map[string][]string{},
|
||||
},
|
||||
{
|
||||
values: []int64{200, 179943},
|
||||
labels: map[string][]string{},
|
||||
},
|
||||
{
|
||||
values: []int64{100, 17778444},
|
||||
labels: map[string][]string{},
|
||||
},
|
||||
{
|
||||
values: []int64{100, 75976},
|
||||
labels: map[string][]string{},
|
||||
},
|
||||
{
|
||||
values: []int64{300, 63568134},
|
||||
labels: map[string][]string{},
|
||||
},
|
||||
},
|
||||
"",
|
||||
},
|
||||
{
|
||||
"normalized base is same as source",
|
||||
[]string{path + "cppbench.contention"},
|
||||
[]string{path + "cppbench.contention"},
|
||||
nil,
|
||||
true,
|
||||
[][]int64{},
|
||||
nil,
|
||||
"",
|
||||
},
|
||||
{
|
||||
"normalized single source, multiple base (all profiles same)",
|
||||
[]string{path + "cppbench.contention"},
|
||||
[]string{path + "cppbench.contention", path + "cppbench.contention"},
|
||||
nil,
|
||||
true,
|
||||
[][]int64{},
|
||||
nil,
|
||||
"",
|
||||
},
|
||||
{
|
||||
"normalized different base and source",
|
||||
[]string{path + "cppbench.contention"},
|
||||
[]string{path + "cppbench.small.contention"},
|
||||
nil,
|
||||
true,
|
||||
[][]int64{{-229, -370}, {28, 0}, {57, 0}, {28, 80}, {28, 0}, {85, 287}},
|
||||
[]WantSample{
|
||||
{
|
||||
values: []int64{-229, -370},
|
||||
labels: map[string][]string{},
|
||||
},
|
||||
{
|
||||
values: []int64{28, 0},
|
||||
labels: map[string][]string{},
|
||||
},
|
||||
{
|
||||
values: []int64{57, 0},
|
||||
labels: map[string][]string{},
|
||||
},
|
||||
{
|
||||
values: []int64{28, 80},
|
||||
labels: map[string][]string{},
|
||||
},
|
||||
{
|
||||
values: []int64{28, 0},
|
||||
labels: map[string][]string{},
|
||||
},
|
||||
{
|
||||
values: []int64{85, 287},
|
||||
labels: map[string][]string{},
|
||||
},
|
||||
},
|
||||
"",
|
||||
},
|
||||
{
|
||||
"not normalized diff base is same as source",
|
||||
[]string{path + "cppbench.contention"},
|
||||
nil,
|
||||
[]string{path + "cppbench.contention"},
|
||||
false,
|
||||
[]WantSample{
|
||||
{
|
||||
values: []int64{2700, 608881724},
|
||||
labels: map[string][]string{},
|
||||
},
|
||||
{
|
||||
values: []int64{100, 23992},
|
||||
labels: map[string][]string{},
|
||||
},
|
||||
{
|
||||
values: []int64{200, 179943},
|
||||
labels: map[string][]string{},
|
||||
},
|
||||
{
|
||||
values: []int64{100, 17778444},
|
||||
labels: map[string][]string{},
|
||||
},
|
||||
{
|
||||
values: []int64{100, 75976},
|
||||
labels: map[string][]string{},
|
||||
},
|
||||
{
|
||||
values: []int64{300, 63568134},
|
||||
labels: map[string][]string{},
|
||||
},
|
||||
{
|
||||
values: []int64{-2700, -608881724},
|
||||
labels: map[string][]string{"pprof::base": {"true"}},
|
||||
},
|
||||
{
|
||||
values: []int64{-100, -23992},
|
||||
labels: map[string][]string{"pprof::base": {"true"}},
|
||||
},
|
||||
{
|
||||
values: []int64{-200, -179943},
|
||||
labels: map[string][]string{"pprof::base": {"true"}},
|
||||
},
|
||||
{
|
||||
values: []int64{-100, -17778444},
|
||||
labels: map[string][]string{"pprof::base": {"true"}},
|
||||
},
|
||||
{
|
||||
values: []int64{-100, -75976},
|
||||
labels: map[string][]string{"pprof::base": {"true"}},
|
||||
},
|
||||
{
|
||||
values: []int64{-300, -63568134},
|
||||
labels: map[string][]string{"pprof::base": {"true"}},
|
||||
},
|
||||
},
|
||||
"",
|
||||
},
|
||||
{
|
||||
"diff_base and base both specified",
|
||||
[]string{path + "cppbench.contention"},
|
||||
[]string{path + "cppbench.contention"},
|
||||
[]string{path + "cppbench.contention"},
|
||||
false,
|
||||
nil,
|
||||
"-base and -diff_base flags cannot both be specified",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testcases {
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
pprofVariables = baseVars.makeCopy()
|
||||
|
||||
base := make([]*string, len(tc.bases))
|
||||
for i, s := range tc.bases {
|
||||
base[i] = &s
|
||||
}
|
||||
|
||||
f := testFlags{
|
||||
stringLists: map[string][]*string{
|
||||
"base": base,
|
||||
stringLists: map[string][]string{
|
||||
"base": tc.bases,
|
||||
"diff_base": tc.diffBases,
|
||||
},
|
||||
bools: map[string]bool{
|
||||
"normalize": tc.normalize,
|
||||
@ -289,30 +454,37 @@ func TestFetchWithBase(t *testing.T) {
|
||||
})
|
||||
src, _, err := parseFlags(o)
|
||||
|
||||
if tc.wantErrorMsg != "" {
|
||||
if err == nil {
|
||||
t.Fatalf("got nil, want error %q", tc.wantErrorMsg)
|
||||
}
|
||||
|
||||
if gotErrMsg := err.Error(); gotErrMsg != tc.wantErrorMsg {
|
||||
t.Fatalf("got error %q, want error %q", gotErrMsg, tc.wantErrorMsg)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("%s: %v", tc.desc, err)
|
||||
t.Fatalf("got error %q, want no error", err)
|
||||
}
|
||||
|
||||
p, err := fetchProfiles(src, o)
|
||||
pprofVariables = baseVars
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
t.Fatalf("got error %q, want no error", err)
|
||||
}
|
||||
|
||||
if want, got := len(tc.expectedSamples), len(p.Sample); want != got {
|
||||
t.Fatalf("want %d samples got %d", want, got)
|
||||
if got, want := len(p.Sample), len(tc.wantSamples); got != want {
|
||||
t.Fatalf("got %d samples want %d", got, want)
|
||||
}
|
||||
|
||||
if len(p.Sample) > 0 {
|
||||
for i, sample := range p.Sample {
|
||||
if want, got := len(tc.expectedSamples[i]), len(sample.Value); want != got {
|
||||
t.Errorf("want %d values for sample %d, got %d", want, i, got)
|
||||
}
|
||||
for j, value := range sample.Value {
|
||||
if want, got := tc.expectedSamples[i][j], value; want != got {
|
||||
t.Errorf("want value of %d for value %d of sample %d, got %d", want, j, i, got)
|
||||
}
|
||||
}
|
||||
for i, sample := range p.Sample {
|
||||
if !reflect.DeepEqual(tc.wantSamples[i].values, sample.Value) {
|
||||
t.Errorf("for sample %d got values %v, want %v", i, sample.Value, tc.wantSamples[i])
|
||||
}
|
||||
if !reflect.DeepEqual(tc.wantSamples[i].labels, sample.Label) {
|
||||
t.Errorf("for sample %d got labels %v, want %v", i, sample.Label, tc.wantSamples[i].labels)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user