1
0
mirror of https://github.com/golang/go synced 2024-11-12 00:20:22 -07:00

[dev.cc] runtime: convert assembly files for C to Go transition

The main change is that #include "zasm_GOOS_GOARCH.h"
is now #include "go_asm.h" and/or #include "go_tls.h".

Also, because C StackGuard is now Go _StackGuard,
the assembly name changes from const_StackGuard to
const__StackGuard.

In asm_$GOARCH.s, add new function getg, formerly
implemented in C.

The renamed atomics now have Go wrappers, to get
escape analysis annotations right. Those wrappers
are in CL 174860043.

LGTM=r, aram
R=r, aram
CC=austin, dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/168510043
This commit is contained in:
Russ Cox 2014-11-11 17:06:22 -05:00
parent 2d917c0c26
commit 15ced2d008
35 changed files with 124 additions and 49 deletions

View File

@ -12,3 +12,8 @@ DATA runtime·no_pointers_stackmap+0x00(SB)/4, $2
DATA runtime·no_pointers_stackmap+0x04(SB)/4, $0
GLOBL runtime·no_pointers_stackmap(SB),RODATA, $8
TEXT runtime·nop(SB),NOSPLIT,$0-0
RET
GLOBL runtime·mheap_(SB), NOPTR, $0
GLOBL runtime·memstats(SB), NOPTR, $0

View File

@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "funcdata.h"
#include "textflag.h"
@ -49,7 +50,7 @@ nocpuinfo:
// update stackguard after _cgo_init
MOVL $runtime·g0(SB), CX
MOVL (g_stack+stack_lo)(CX), AX
ADDL $const_StackGuard, AX
ADDL $const__StackGuard, AX
MOVL AX, g_stackguard0(CX)
MOVL AX, g_stackguard1(CX)
@ -502,7 +503,7 @@ cas64_fail:
// return 1;
// }else
// return 0;
TEXT runtime·casp(SB), NOSPLIT, $0-13
TEXT runtime·casp1(SB), NOSPLIT, $0-13
MOVL ptr+0(FP), BX
MOVL old+4(FP), AX
MOVL new+8(FP), CX
@ -537,7 +538,7 @@ TEXT runtime·xchg(SB), NOSPLIT, $0-12
MOVL AX, ret+8(FP)
RET
TEXT runtime·xchgp(SB), NOSPLIT, $0-12
TEXT runtime·xchgp1(SB), NOSPLIT, $0-12
MOVL ptr+0(FP), BX
MOVL new+4(FP), AX
XCHGL AX, 0(BX)
@ -555,7 +556,7 @@ again:
JNZ again
RET
TEXT runtime·atomicstorep(SB), NOSPLIT, $0-8
TEXT runtime·atomicstorep1(SB), NOSPLIT, $0-8
MOVL ptr+0(FP), BX
MOVL val+4(FP), AX
XCHGL AX, 0(BX)
@ -2290,3 +2291,10 @@ TEXT _cgo_topofstack(SB),NOSPLIT,$0
TEXT runtime·goexit(SB),NOSPLIT,$0-0
BYTE $0x90 // NOP
CALL runtime·goexit1(SB) // does not return
TEXT runtime·getg(SB),NOSPLIT,$0-4
get_tls(CX)
MOVL g(CX), AX
MOVL AX, ret+0(FP)
RET

View File

@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "funcdata.h"
#include "textflag.h"
@ -47,7 +48,7 @@ nocpuinfo:
// update stackguard after _cgo_init
MOVQ $runtime·g0(SB), CX
MOVQ (g_stack+stack_lo)(CX), AX
ADDQ $const_StackGuard, AX
ADDQ $const__StackGuard, AX
MOVQ AX, g_stackguard0(CX)
MOVQ AX, g_stackguard1(CX)
@ -489,7 +490,7 @@ TEXT runtime·atomicstoreuintptr(SB), NOSPLIT, $0-16
// return 1;
// } else
// return 0;
TEXT runtime·casp(SB), NOSPLIT, $0-25
TEXT runtime·casp1(SB), NOSPLIT, $0-25
MOVQ ptr+0(FP), BX
MOVQ old+8(FP), AX
MOVQ new+16(FP), CX
@ -541,7 +542,7 @@ TEXT runtime·xchg64(SB), NOSPLIT, $0-24
MOVQ AX, ret+16(FP)
RET
TEXT runtime·xchgp(SB), NOSPLIT, $0-24
TEXT runtime·xchgp1(SB), NOSPLIT, $0-24
MOVQ ptr+0(FP), BX
MOVQ new+8(FP), AX
XCHGQ AX, 0(BX)
@ -559,7 +560,7 @@ again:
JNZ again
RET
TEXT runtime·atomicstorep(SB), NOSPLIT, $0-16
TEXT runtime·atomicstorep1(SB), NOSPLIT, $0-16
MOVQ ptr+0(FP), BX
MOVQ val+8(FP), AX
XCHGQ AX, 0(BX)
@ -2235,3 +2236,9 @@ TEXT _cgo_topofstack(SB),NOSPLIT,$0
TEXT runtime·goexit(SB),NOSPLIT,$0-0
BYTE $0x90 // NOP
CALL runtime·goexit1(SB) // does not return
TEXT runtime·getg(SB),NOSPLIT,$0-8
get_tls(CX)
MOVQ g(CX), AX
MOVQ AX, ret+0(FP)
RET

View File

@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "funcdata.h"
#include "textflag.h"
@ -460,7 +461,7 @@ cas64_fail:
// return 1;
// } else
// return 0;
TEXT runtime·casp(SB), NOSPLIT, $0-17
TEXT runtime·casp1(SB), NOSPLIT, $0-17
MOVL ptr+0(FP), BX
MOVL old+4(FP), AX
MOVL new+8(FP), CX
@ -512,7 +513,7 @@ TEXT runtime·xchg64(SB), NOSPLIT, $0-24
MOVQ AX, ret+16(FP)
RET
TEXT runtime·xchgp(SB), NOSPLIT, $0-12
TEXT runtime·xchgp1(SB), NOSPLIT, $0-12
MOVL ptr+0(FP), BX
MOVL new+4(FP), AX
XCHGL AX, 0(BX)
@ -530,7 +531,7 @@ again:
JNZ again
RET
TEXT runtime·atomicstorep(SB), NOSPLIT, $0-8
TEXT runtime·atomicstorep1(SB), NOSPLIT, $0-8
MOVL ptr+0(FP), BX
MOVL val+4(FP), AX
XCHGL AX, 0(BX)
@ -1085,3 +1086,9 @@ TEXT runtime·return0(SB), NOSPLIT, $0
TEXT runtime·goexit(SB),NOSPLIT,$0-0
BYTE $0x90 // NOP
CALL runtime·goexit1(SB) // does not return
TEXT runtime·getg(SB),NOSPLIT,$0-4
get_tls(CX)
MOVL g(CX), AX
MOVL AX, ret+0(FP)
RET

View File

@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "funcdata.h"
#include "textflag.h"
@ -1326,3 +1327,7 @@ TEXT _cgo_topofstack(SB),NOSPLIT,$8
TEXT runtime·goexit(SB),NOSPLIT,$-4-0
MOVW R0, R0 // NOP
BL runtime·goexit1(SB) // does not return
TEXT runtime·getg(SB),NOSPLIT,$-4-4
MOVW g, ret+0(FP)
RET

View File

@ -4,7 +4,8 @@
// +build race
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "funcdata.h"
#include "textflag.h"

View File

@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "textflag.h"
TEXT _rt0_amd64_windows(SB),NOSPLIT,$-8

View File

@ -6,7 +6,8 @@
// See http://fxr.watson.org/fxr/source/bsd/kern/syscalls.c?v=xnu-1228
// or /usr/include/sys/syscall.h (on a Mac) for system call numbers.
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "textflag.h"
// Exit the entire program (like C exit)

View File

@ -11,7 +11,8 @@
// The high 8 bits specify the kind of system call: 1=Mach, 2=BSD, 3=Machine-Dependent.
//
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "textflag.h"
// Exit the entire program (like C exit)

View File

@ -6,7 +6,8 @@
// /usr/src/sys/kern/syscalls.master for syscall numbers.
//
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "textflag.h"
TEXT runtime·sys_umtx_sleep(SB),NOSPLIT,$-4

View File

@ -6,7 +6,8 @@
// /usr/src/sys/kern/syscalls.master for syscall numbers.
//
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "textflag.h"
TEXT runtime·sys_umtx_sleep(SB),NOSPLIT,$0

View File

@ -6,7 +6,8 @@
// /usr/src/sys/kern/syscalls.master for syscall numbers.
//
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "textflag.h"
TEXT runtime·sys_umtx_op(SB),NOSPLIT,$-4

View File

@ -6,7 +6,8 @@
// /usr/src/sys/kern/syscalls.master for syscall numbers.
//
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "textflag.h"
// FreeBSD 8, FreeBSD 9, and older versions that I have checked

View File

@ -6,7 +6,8 @@
// /usr/src/sys/kern/syscalls.master for syscall numbers.
//
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "textflag.h"
// for EABI, as we don't support OABI
@ -362,7 +363,7 @@ TEXT runtime·closeonexec(SB),NOSPLIT,$0
SWI $0
RET
TEXT runtime·casp(SB),NOSPLIT,$0
TEXT runtime·casp1(SB),NOSPLIT,$0
B runtime·cas(SB)
// TODO(minux): this is only valid for ARMv6+

View File

@ -6,7 +6,8 @@
// System calls and other sys.stuff for 386, Linux
//
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "textflag.h"
TEXT runtime·exit(SB),NOSPLIT,$0

View File

@ -6,7 +6,8 @@
// System calls and other sys.stuff for AMD64, Linux
//
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "textflag.h"
TEXT runtime·exit(SB),NOSPLIT,$0-4

View File

@ -6,7 +6,8 @@
// System calls and other sys.stuff for arm, Linux
//
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "textflag.h"
// for EABI, as we don't support OABI
@ -391,7 +392,7 @@ cascheck:
MOVB R0, ret+12(FP)
RET
TEXT runtime·casp(SB),NOSPLIT,$0
TEXT runtime·casp1(SB),NOSPLIT,$0
B runtime·cas(SB)
TEXT runtime·osyield(SB),NOSPLIT,$0

View File

@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "textflag.h"
#include "syscall_nacl.h"

View File

@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "textflag.h"
#include "syscall_nacl.h"

View File

@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "textflag.h"
#include "syscall_nacl.h"
@ -301,7 +302,7 @@ nog:
TEXT runtime·nacl_sysinfo(SB),NOSPLIT,$16
RET
TEXT runtime·casp(SB),NOSPLIT,$0
TEXT runtime·casp1(SB),NOSPLIT,$0
B runtime·cas(SB)
// This is only valid for ARMv6+, however, NaCl/ARM is only defined

View File

@ -6,7 +6,8 @@
// /usr/src/sys/kern/syscalls.master for syscall numbers.
//
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "textflag.h"
// Exit the entire program (like C exit)

View File

@ -6,7 +6,8 @@
// /usr/src/sys/kern/syscalls.master for syscall numbers.
//
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "textflag.h"
// int32 lwp_create(void *context, uintptr flags, void *lwpid)

View File

@ -6,7 +6,8 @@
// /usr/src/sys/kern/syscalls.master for syscall numbers.
//
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "textflag.h"
// Exit the entire program (like C exit)
@ -330,7 +331,7 @@ TEXT runtime·closeonexec(SB),NOSPLIT,$0
SWI $0xa0005c // sys_fcntl
RET
TEXT runtime·casp(SB),NOSPLIT,$0
TEXT runtime·casp1(SB),NOSPLIT,$0
B runtime·cas(SB)
// TODO(minux): this is only valid for ARMv6+

View File

@ -6,7 +6,8 @@
// /usr/src/sys/kern/syscalls.master for syscall numbers.
//
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "textflag.h"
#define CLOCK_MONOTONIC $3

View File

@ -6,7 +6,8 @@
// /usr/src/sys/kern/syscalls.master for syscall numbers.
//
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "textflag.h"
#define CLOCK_MONOTONIC $3

View File

@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "textflag.h"
// setldt(int entry, int address, int limit)

View File

@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "textflag.h"
// setldt(int entry, int address, int limit)

View File

@ -6,7 +6,8 @@
// /usr/include/sys/syscall.h for syscall numbers.
//
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "textflag.h"
// This is needed by asm_amd64.s

View File

@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "textflag.h"
// void runtime·asmstdcall(void *c);

View File

@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "textflag.h"
// maxargs should be divisible by 2, as Windows stack

View File

@ -4,7 +4,6 @@
// This file exposes various internal runtime functions to other packages in std lib.
#include "zasm_GOOS_GOARCH.h"
#include "textflag.h"
#ifdef GOARCH_arm
@ -181,3 +180,18 @@ TEXT syscall·runtime_envs(SB),NOSPLIT,$0-0
TEXT os·runtime_args(SB),NOSPLIT,$0-0
JMP runtime·runtime_args(SB)
TEXT sync·runtime_procUnpin(SB),NOSPLIT,$0-0
JMP runtime·sync_procUnpin(SB)
TEXT sync·runtime_procPin(SB),NOSPLIT,$0-0
JMP runtime·sync_procPin(SB)
TEXT syscall·runtime_BeforeFork(SB),NOSPLIT,$0-0
JMP runtime·syscall_BeforeFork(SB)
TEXT syscall·runtime_AfterFork(SB),NOSPLIT,$0-0
JMP runtime·syscall_AfterFork(SB)
TEXT reflect·typelinks(SB),NOSPLIT,$0-0
JMP runtime·typelinks(SB)

View File

@ -4,7 +4,8 @@
// This file exposes various external library functions to Go code in the runtime.
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "textflag.h"
TEXT runtime·libc_chdir(SB),NOSPLIT,$0

View File

@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "textflag.h"
TEXT syscall·Syscall(SB),NOSPLIT,$0-0

View File

@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "funcdata.h"
#include "textflag.h"

View File

@ -23,7 +23,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#include "zasm_GOOS_GOARCH.h"
#include "go_asm.h"
#include "go_tls.h"
#include "textflag.h"
arg=0