Skip to content

Instantly share code, notes, and snippets.

@mmcloughlin
Last active December 19, 2018 10:14
Show Gist options
  • Save mmcloughlin/598774c255f40605e613ffb3361e240c to your computer and use it in GitHub Desktop.
Save mmcloughlin/598774c255f40605e613ffb3361e240c to your computer and use it in GitHub Desktop.
package argsize
func Index3(a [7]byte) byte
func Expect(a [7]byte) byte { return a[3] }
TEXT ·Index3(SB),0,$0-16
MOVB a_3+3(FP), AL
MOVB AL, ret+8(FP)
RET
package argsize
import (
"testing"
"testing/quick"
)
func TestIndex3(t *testing.T) {
if err := quick.CheckEqual(Index3, Expect, nil); err != nil {
t.Fatal(err)
}
}
+ go=go1.12beta1
+ go1.12beta1 test -v
=== RUN TestIndex3
--- PASS: TestIndex3 (0.00s)
PASS
ok _/tmp/argsize 0.006s
+ go1.12beta1 tool compile -S argsize.go
+ grep -A5 'Expect STEXT'
"".Expect STEXT nosplit size=10 args=0x10 locals=0x0
0x0000 00000 (argsize.go:6) TEXT "".Expect(SB), NOSPLIT|ABIInternal, $0-16
0x0000 00000 (argsize.go:6) FUNCDATA $0, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
0x0000 00000 (argsize.go:6) FUNCDATA $1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
0x0000 00000 (argsize.go:6) FUNCDATA $3, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
0x0000 00000 (argsize.go:6) PCDATA $2, $0
+ go1.12beta1 vet
# _/tmp/argsize
./argsize.s:1:1: [amd64] Index3: wrong argument size 16; expected $...-9
#!/bin/bash -x
go=go1.12beta1
$go test -v
$go tool compile -S argsize.go | grep -A5 'Expect STEXT'
$go vet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment