From 3879ea54ed1f5c266657ffe593e2a8e1b63401ec Mon Sep 17 00:00:00 2001 From: Iskander Sharipov Date: Mon, 6 Aug 2018 14:16:43 +0300 Subject: [PATCH] runtime: fix Go prototypes in amd64 asm code Also adds some missing asmdecl comments for funcs with Go proto. Change-Id: Iabc68e8c0ad936e06ed719e0f030bfc5f6f6e168 Reviewed-on: https://go-review.googlesource.com/127760 Run-TryBot: Iskander Sharipov TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- src/runtime/asm_amd64.s | 22 +++++++++++++++------- src/runtime/stubs.go | 2 +- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/runtime/asm_amd64.s b/src/runtime/asm_amd64.s index 6902ce2c22..6c65674b3b 100644 --- a/src/runtime/asm_amd64.s +++ b/src/runtime/asm_amd64.s @@ -228,7 +228,7 @@ TEXT runtime·asminit(SB),NOSPLIT,$0-0 * go-routine */ -// void gosave(Gobuf*) +// func gosave(buf *gobuf) // save state in Gobuf; setjmp TEXT runtime·gosave(SB), NOSPLIT, $0-8 MOVQ buf+0(FP), AX // gobuf @@ -248,7 +248,7 @@ TEXT runtime·gosave(SB), NOSPLIT, $0-8 MOVQ BX, gobuf_g(AX) RET -// void gogo(Gobuf*) +// func gogo(buf *gobuf) // restore state from Gobuf; longjmp TEXT runtime·gogo(SB), NOSPLIT, $16-8 MOVQ buf+0(FP), BX // gobuf @@ -560,7 +560,8 @@ TEXT ·publicationBarrier(SB),NOSPLIT,$0-0 // compile barrier. RET -// void jmpdefer(fn, sp); +// func jmpdefer(fv *funcval, argp uintptr) +// argp is a caller SP. // called from deferreturn. // 1. pop the caller // 2. sub 5 bytes from the callers return @@ -670,7 +671,7 @@ nosave: MOVL AX, ret+16(FP) RET -// cgocallback(void (*fn)(void*), void *frame, uintptr framesize, uintptr ctxt) +// func cgocallback(fn, frame unsafe.Pointer, framesize, ctxt uintptr) // Turn the fn into a Go func (by taking its address) and call // cgocallback_gofunc. TEXT runtime·cgocallback(SB),NOSPLIT,$32-32 @@ -686,7 +687,7 @@ TEXT runtime·cgocallback(SB),NOSPLIT,$32-32 CALL AX RET -// cgocallback_gofunc(FuncVal*, void *frame, uintptr framesize, uintptr ctxt) +// func cgocallback_gofunc(fn, frame, framesize, ctxt uintptr) // See cgocall.go for more details. TEXT ·cgocallback_gofunc(SB),NOSPLIT,$16-32 NO_LOCAL_POINTERS @@ -811,7 +812,8 @@ havem: // Done! RET -// void setg(G*); set g. for use by needm. +// func setg(gg *g) +// set g. for use by needm. TEXT runtime·setg(SB), NOSPLIT, $0-8 MOVQ gg+0(FP), BX #ifdef GOOS_windows @@ -866,6 +868,7 @@ done: MOVQ AX, ret+0(FP) RET +// func aeshash(p unsafe.Pointer, h, s uintptr) uintptr // hash function using AES hardware instructions TEXT runtime·aeshash(SB),NOSPLIT,$0-32 MOVQ p+0(FP), AX // ptr to data @@ -873,6 +876,7 @@ TEXT runtime·aeshash(SB),NOSPLIT,$0-32 LEAQ ret+24(FP), DX JMP runtime·aeshashbody(SB) +// func aeshashstr(p unsafe.Pointer, h uintptr) uintptr TEXT runtime·aeshashstr(SB),NOSPLIT,$0-24 MOVQ p+0(FP), AX // ptr to string struct MOVQ 8(AX), CX // length of string @@ -1210,7 +1214,8 @@ aesloop: PXOR X9, X8 MOVQ X8, (DX) RET - + +// func aeshash32(p unsafe.Pointer, h uintptr) uintptr TEXT runtime·aeshash32(SB),NOSPLIT,$0-24 MOVQ p+0(FP), AX // ptr to data MOVQ h+8(FP), X0 // seed @@ -1221,6 +1226,7 @@ TEXT runtime·aeshash32(SB),NOSPLIT,$0-24 MOVQ X0, ret+16(FP) RET +// func aeshash64(p unsafe.Pointer, h uintptr) uintptr TEXT runtime·aeshash64(SB),NOSPLIT,$0-24 MOVQ p+0(FP), AX // ptr to data MOVQ h+8(FP), X0 // seed @@ -1266,6 +1272,7 @@ DATA masks<>+0xf0(SB)/8, $0xffffffffffffffff DATA masks<>+0xf8(SB)/8, $0x00ffffffffffffff GLOBL masks<>(SB),RODATA,$256 +// func checkASM() bool TEXT ·checkASM(SB),NOSPLIT,$0-1 // check that masks<>(SB) and shifts<>(SB) are aligned to 16-byte MOVQ $masks<>(SB), AX @@ -1616,6 +1623,7 @@ DEBUG_CALL_FN(debugCall16384<>, 16384) DEBUG_CALL_FN(debugCall32768<>, 32768) DEBUG_CALL_FN(debugCall65536<>, 65536) +// func debugCallPanicked(val interface{}) TEXT runtime·debugCallPanicked(SB),NOSPLIT,$16-16 // Copy the panic value to the top of stack. MOVQ val_type+0(FP), AX diff --git a/src/runtime/stubs.go b/src/runtime/stubs.go index 74b385d596..632b1e2293 100644 --- a/src/runtime/stubs.go +++ b/src/runtime/stubs.go @@ -178,7 +178,7 @@ func goexit(neverCallThisFunction) // cgocallback_gofunc is not called from go, only from cgocallback, // so the arguments will be found via cgocallback's pointer-declared arguments. // See the assembly implementations for more details. -func cgocallback_gofunc(fv uintptr, frame uintptr, framesize, ctxt uintptr) +func cgocallback_gofunc(fv, frame, framesize, ctxt uintptr) // publicationBarrier performs a store/store barrier (a "publication" // or "export" barrier). Some form of synchronization is required -- 2.50.0