2013-02-12 10:00:04 -07:00
|
|
|
// Copyright 2013 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.
|
|
|
|
//
|
|
|
|
// System calls and other sys.stuff for ARM, NetBSD
|
|
|
|
// /usr/src/sys/kern/syscalls.master for syscall numbers.
|
|
|
|
//
|
|
|
|
|
[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
2014-11-11 15:06:22 -07:00
|
|
|
#include "go_asm.h"
|
|
|
|
#include "go_tls.h"
|
2014-09-04 21:05:18 -06:00
|
|
|
#include "textflag.h"
|
2013-02-12 10:00:04 -07:00
|
|
|
|
|
|
|
// Exit the entire program (like C exit)
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·exit(SB),NOSPLIT,$-4
|
2015-02-23 08:56:10 -07:00
|
|
|
MOVW code+0(FP), R0 // arg 1 exit status
|
2013-02-12 10:00:04 -07:00
|
|
|
SWI $0xa00001
|
2013-05-28 06:13:02 -06:00
|
|
|
MOVW.CS $0, R8 // crash on syscall failure
|
|
|
|
MOVW.CS R8, (R8)
|
2013-02-12 10:00:04 -07:00
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·exit1(SB),NOSPLIT,$-4
|
2013-02-12 10:00:04 -07:00
|
|
|
SWI $0xa00136 // sys__lwp_exit
|
2013-05-28 06:13:02 -06:00
|
|
|
MOVW $1, R8 // crash
|
|
|
|
MOVW R8, (R8)
|
2013-02-12 10:00:04 -07:00
|
|
|
RET
|
2013-03-18 12:47:04 -06:00
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·open(SB),NOSPLIT,$-8
|
2015-02-23 08:56:10 -07:00
|
|
|
MOVW name+0(FP), R0
|
|
|
|
MOVW mode+4(FP), R1
|
|
|
|
MOVW perm+8(FP), R2
|
2013-03-18 12:47:04 -06:00
|
|
|
SWI $0xa00005
|
2015-03-02 21:16:48 -07:00
|
|
|
MOVW.CS $-1, R0
|
cmd/cc, runtime: convert C compilers to use Go calling convention
To date, the C compilers and Go compilers differed only in how
values were returned from functions. This made it difficult to call
Go from C or C from Go if return values were involved. It also made
assembly called from Go and assembly called from C different.
This CL changes the C compiler to use the Go conventions, passing
results on the stack, after the arguments.
[Exception: this does not apply to C ... functions, because you can't
know where on the stack the arguments end.]
By doing this, the CL makes it possible to rewrite C functions into Go
one at a time, without worrying about which languages call that
function or which languages it calls.
This CL also updates all the assembly files in package runtime to use
the new conventions. Argument references of the form 40(SP) have
been rewritten to the form name+10(FP) instead, and there are now
Go func prototypes for every assembly function called from C or Go.
This means that 'go vet runtime' checks effectively every assembly
function, and go vet's output was used to automate the bulk of the
conversion.
Some functions, like seek and nsec on Plan 9, needed to be rewritten.
Many assembly routines called from C were reading arguments
incorrectly, using MOVL instead of MOVQ or vice versa, especially on
the less used systems like openbsd.
These were found by go vet and have been corrected too.
If we're lucky, this may reduce flakiness on those systems.
Tested on:
darwin/386
darwin/amd64
linux/arm
linux/386
linux/amd64
If this breaks another system, the bug is almost certainly in the
sys_$GOOS_$GOARCH.s file, since the rest of the CL is tested
by the combination of the above systems.
LGTM=dvyukov, iant
R=golang-codereviews, 0intro, dave, alex.brainman, dvyukov, iant
CC=golang-codereviews, josharian, r
https://golang.org/cl/135830043
2014-08-27 09:32:17 -06:00
|
|
|
MOVW R0, ret+12(FP)
|
2013-03-18 12:47:04 -06:00
|
|
|
RET
|
|
|
|
|
2015-04-13 17:37:04 -06:00
|
|
|
TEXT runtime·closefd(SB),NOSPLIT,$-8
|
2015-02-23 08:56:10 -07:00
|
|
|
MOVW fd+0(FP), R0
|
2013-03-18 12:47:04 -06:00
|
|
|
SWI $0xa00006
|
2015-03-02 21:16:48 -07:00
|
|
|
MOVW.CS $-1, R0
|
cmd/cc, runtime: convert C compilers to use Go calling convention
To date, the C compilers and Go compilers differed only in how
values were returned from functions. This made it difficult to call
Go from C or C from Go if return values were involved. It also made
assembly called from Go and assembly called from C different.
This CL changes the C compiler to use the Go conventions, passing
results on the stack, after the arguments.
[Exception: this does not apply to C ... functions, because you can't
know where on the stack the arguments end.]
By doing this, the CL makes it possible to rewrite C functions into Go
one at a time, without worrying about which languages call that
function or which languages it calls.
This CL also updates all the assembly files in package runtime to use
the new conventions. Argument references of the form 40(SP) have
been rewritten to the form name+10(FP) instead, and there are now
Go func prototypes for every assembly function called from C or Go.
This means that 'go vet runtime' checks effectively every assembly
function, and go vet's output was used to automate the bulk of the
conversion.
Some functions, like seek and nsec on Plan 9, needed to be rewritten.
Many assembly routines called from C were reading arguments
incorrectly, using MOVL instead of MOVQ or vice versa, especially on
the less used systems like openbsd.
These were found by go vet and have been corrected too.
If we're lucky, this may reduce flakiness on those systems.
Tested on:
darwin/386
darwin/amd64
linux/arm
linux/386
linux/amd64
If this breaks another system, the bug is almost certainly in the
sys_$GOOS_$GOARCH.s file, since the rest of the CL is tested
by the combination of the above systems.
LGTM=dvyukov, iant
R=golang-codereviews, 0intro, dave, alex.brainman, dvyukov, iant
CC=golang-codereviews, josharian, r
https://golang.org/cl/135830043
2014-08-27 09:32:17 -06:00
|
|
|
MOVW R0, ret+4(FP)
|
2013-03-18 12:47:04 -06:00
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·read(SB),NOSPLIT,$-8
|
2015-02-23 08:56:10 -07:00
|
|
|
MOVW fd+0(FP), R0
|
|
|
|
MOVW p+4(FP), R1
|
|
|
|
MOVW n+8(FP), R2
|
2013-03-18 12:47:04 -06:00
|
|
|
SWI $0xa00003
|
2015-03-02 21:16:48 -07:00
|
|
|
MOVW.CS $-1, R0
|
cmd/cc, runtime: convert C compilers to use Go calling convention
To date, the C compilers and Go compilers differed only in how
values were returned from functions. This made it difficult to call
Go from C or C from Go if return values were involved. It also made
assembly called from Go and assembly called from C different.
This CL changes the C compiler to use the Go conventions, passing
results on the stack, after the arguments.
[Exception: this does not apply to C ... functions, because you can't
know where on the stack the arguments end.]
By doing this, the CL makes it possible to rewrite C functions into Go
one at a time, without worrying about which languages call that
function or which languages it calls.
This CL also updates all the assembly files in package runtime to use
the new conventions. Argument references of the form 40(SP) have
been rewritten to the form name+10(FP) instead, and there are now
Go func prototypes for every assembly function called from C or Go.
This means that 'go vet runtime' checks effectively every assembly
function, and go vet's output was used to automate the bulk of the
conversion.
Some functions, like seek and nsec on Plan 9, needed to be rewritten.
Many assembly routines called from C were reading arguments
incorrectly, using MOVL instead of MOVQ or vice versa, especially on
the less used systems like openbsd.
These were found by go vet and have been corrected too.
If we're lucky, this may reduce flakiness on those systems.
Tested on:
darwin/386
darwin/amd64
linux/arm
linux/386
linux/amd64
If this breaks another system, the bug is almost certainly in the
sys_$GOOS_$GOARCH.s file, since the rest of the CL is tested
by the combination of the above systems.
LGTM=dvyukov, iant
R=golang-codereviews, 0intro, dave, alex.brainman, dvyukov, iant
CC=golang-codereviews, josharian, r
https://golang.org/cl/135830043
2014-08-27 09:32:17 -06:00
|
|
|
MOVW R0, ret+12(FP)
|
2013-03-18 12:47:04 -06:00
|
|
|
RET
|
2013-02-12 10:00:04 -07:00
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·write(SB),NOSPLIT,$-4
|
2015-02-23 08:56:10 -07:00
|
|
|
MOVW fd+0(FP), R0 // arg 1 - fd
|
|
|
|
MOVW p+4(FP), R1 // arg 2 - buf
|
|
|
|
MOVW n+8(FP), R2 // arg 3 - nbyte
|
2013-02-12 10:00:04 -07:00
|
|
|
SWI $0xa00004 // sys_write
|
2015-03-02 21:16:48 -07:00
|
|
|
MOVW.CS $-1, R0
|
cmd/cc, runtime: convert C compilers to use Go calling convention
To date, the C compilers and Go compilers differed only in how
values were returned from functions. This made it difficult to call
Go from C or C from Go if return values were involved. It also made
assembly called from Go and assembly called from C different.
This CL changes the C compiler to use the Go conventions, passing
results on the stack, after the arguments.
[Exception: this does not apply to C ... functions, because you can't
know where on the stack the arguments end.]
By doing this, the CL makes it possible to rewrite C functions into Go
one at a time, without worrying about which languages call that
function or which languages it calls.
This CL also updates all the assembly files in package runtime to use
the new conventions. Argument references of the form 40(SP) have
been rewritten to the form name+10(FP) instead, and there are now
Go func prototypes for every assembly function called from C or Go.
This means that 'go vet runtime' checks effectively every assembly
function, and go vet's output was used to automate the bulk of the
conversion.
Some functions, like seek and nsec on Plan 9, needed to be rewritten.
Many assembly routines called from C were reading arguments
incorrectly, using MOVL instead of MOVQ or vice versa, especially on
the less used systems like openbsd.
These were found by go vet and have been corrected too.
If we're lucky, this may reduce flakiness on those systems.
Tested on:
darwin/386
darwin/amd64
linux/arm
linux/386
linux/amd64
If this breaks another system, the bug is almost certainly in the
sys_$GOOS_$GOARCH.s file, since the rest of the CL is tested
by the combination of the above systems.
LGTM=dvyukov, iant
R=golang-codereviews, 0intro, dave, alex.brainman, dvyukov, iant
CC=golang-codereviews, josharian, r
https://golang.org/cl/135830043
2014-08-27 09:32:17 -06:00
|
|
|
MOVW R0, ret+12(FP)
|
2013-02-12 10:00:04 -07:00
|
|
|
RET
|
|
|
|
|
|
|
|
// int32 lwp_create(void *context, uintptr flags, void *lwpid)
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·lwp_create(SB),NOSPLIT,$0
|
cmd/cc, runtime: convert C compilers to use Go calling convention
To date, the C compilers and Go compilers differed only in how
values were returned from functions. This made it difficult to call
Go from C or C from Go if return values were involved. It also made
assembly called from Go and assembly called from C different.
This CL changes the C compiler to use the Go conventions, passing
results on the stack, after the arguments.
[Exception: this does not apply to C ... functions, because you can't
know where on the stack the arguments end.]
By doing this, the CL makes it possible to rewrite C functions into Go
one at a time, without worrying about which languages call that
function or which languages it calls.
This CL also updates all the assembly files in package runtime to use
the new conventions. Argument references of the form 40(SP) have
been rewritten to the form name+10(FP) instead, and there are now
Go func prototypes for every assembly function called from C or Go.
This means that 'go vet runtime' checks effectively every assembly
function, and go vet's output was used to automate the bulk of the
conversion.
Some functions, like seek and nsec on Plan 9, needed to be rewritten.
Many assembly routines called from C were reading arguments
incorrectly, using MOVL instead of MOVQ or vice versa, especially on
the less used systems like openbsd.
These were found by go vet and have been corrected too.
If we're lucky, this may reduce flakiness on those systems.
Tested on:
darwin/386
darwin/amd64
linux/arm
linux/386
linux/amd64
If this breaks another system, the bug is almost certainly in the
sys_$GOOS_$GOARCH.s file, since the rest of the CL is tested
by the combination of the above systems.
LGTM=dvyukov, iant
R=golang-codereviews, 0intro, dave, alex.brainman, dvyukov, iant
CC=golang-codereviews, josharian, r
https://golang.org/cl/135830043
2014-08-27 09:32:17 -06:00
|
|
|
MOVW ctxt+0(FP), R0
|
2013-02-12 10:00:04 -07:00
|
|
|
MOVW flags+4(FP), R1
|
|
|
|
MOVW lwpid+8(FP), R2
|
|
|
|
SWI $0xa00135 // sys__lwp_create
|
cmd/cc, runtime: convert C compilers to use Go calling convention
To date, the C compilers and Go compilers differed only in how
values were returned from functions. This made it difficult to call
Go from C or C from Go if return values were involved. It also made
assembly called from Go and assembly called from C different.
This CL changes the C compiler to use the Go conventions, passing
results on the stack, after the arguments.
[Exception: this does not apply to C ... functions, because you can't
know where on the stack the arguments end.]
By doing this, the CL makes it possible to rewrite C functions into Go
one at a time, without worrying about which languages call that
function or which languages it calls.
This CL also updates all the assembly files in package runtime to use
the new conventions. Argument references of the form 40(SP) have
been rewritten to the form name+10(FP) instead, and there are now
Go func prototypes for every assembly function called from C or Go.
This means that 'go vet runtime' checks effectively every assembly
function, and go vet's output was used to automate the bulk of the
conversion.
Some functions, like seek and nsec on Plan 9, needed to be rewritten.
Many assembly routines called from C were reading arguments
incorrectly, using MOVL instead of MOVQ or vice versa, especially on
the less used systems like openbsd.
These were found by go vet and have been corrected too.
If we're lucky, this may reduce flakiness on those systems.
Tested on:
darwin/386
darwin/amd64
linux/arm
linux/386
linux/amd64
If this breaks another system, the bug is almost certainly in the
sys_$GOOS_$GOARCH.s file, since the rest of the CL is tested
by the combination of the above systems.
LGTM=dvyukov, iant
R=golang-codereviews, 0intro, dave, alex.brainman, dvyukov, iant
CC=golang-codereviews, josharian, r
https://golang.org/cl/135830043
2014-08-27 09:32:17 -06:00
|
|
|
MOVW R0, ret+12(FP)
|
2013-02-12 10:00:04 -07:00
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·osyield(SB),NOSPLIT,$0
|
2013-02-12 10:00:04 -07:00
|
|
|
SWI $0xa0015e // sys_sched_yield
|
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·lwp_park(SB),NOSPLIT,$0
|
2015-02-23 08:56:10 -07:00
|
|
|
MOVW abstime+0(FP), R0 // arg 1 - abstime
|
|
|
|
MOVW unpark+4(FP), R1 // arg 2 - unpark
|
|
|
|
MOVW hint+8(FP), R2 // arg 3 - hint
|
|
|
|
MOVW unparkhint+12(FP), R3 // arg 4 - unparkhint
|
2013-02-12 10:00:04 -07:00
|
|
|
SWI $0xa001b2 // sys__lwp_park
|
cmd/cc, runtime: convert C compilers to use Go calling convention
To date, the C compilers and Go compilers differed only in how
values were returned from functions. This made it difficult to call
Go from C or C from Go if return values were involved. It also made
assembly called from Go and assembly called from C different.
This CL changes the C compiler to use the Go conventions, passing
results on the stack, after the arguments.
[Exception: this does not apply to C ... functions, because you can't
know where on the stack the arguments end.]
By doing this, the CL makes it possible to rewrite C functions into Go
one at a time, without worrying about which languages call that
function or which languages it calls.
This CL also updates all the assembly files in package runtime to use
the new conventions. Argument references of the form 40(SP) have
been rewritten to the form name+10(FP) instead, and there are now
Go func prototypes for every assembly function called from C or Go.
This means that 'go vet runtime' checks effectively every assembly
function, and go vet's output was used to automate the bulk of the
conversion.
Some functions, like seek and nsec on Plan 9, needed to be rewritten.
Many assembly routines called from C were reading arguments
incorrectly, using MOVL instead of MOVQ or vice versa, especially on
the less used systems like openbsd.
These were found by go vet and have been corrected too.
If we're lucky, this may reduce flakiness on those systems.
Tested on:
darwin/386
darwin/amd64
linux/arm
linux/386
linux/amd64
If this breaks another system, the bug is almost certainly in the
sys_$GOOS_$GOARCH.s file, since the rest of the CL is tested
by the combination of the above systems.
LGTM=dvyukov, iant
R=golang-codereviews, 0intro, dave, alex.brainman, dvyukov, iant
CC=golang-codereviews, josharian, r
https://golang.org/cl/135830043
2014-08-27 09:32:17 -06:00
|
|
|
MOVW R0, ret+16(FP)
|
2013-02-12 10:00:04 -07:00
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·lwp_unpark(SB),NOSPLIT,$0
|
2015-02-23 08:56:10 -07:00
|
|
|
MOVW lwp+0(FP), R0 // arg 1 - lwp
|
|
|
|
MOVW hint+4(FP), R1 // arg 2 - hint
|
2013-02-12 10:00:04 -07:00
|
|
|
SWI $0xa00141 // sys__lwp_unpark
|
cmd/cc, runtime: convert C compilers to use Go calling convention
To date, the C compilers and Go compilers differed only in how
values were returned from functions. This made it difficult to call
Go from C or C from Go if return values were involved. It also made
assembly called from Go and assembly called from C different.
This CL changes the C compiler to use the Go conventions, passing
results on the stack, after the arguments.
[Exception: this does not apply to C ... functions, because you can't
know where on the stack the arguments end.]
By doing this, the CL makes it possible to rewrite C functions into Go
one at a time, without worrying about which languages call that
function or which languages it calls.
This CL also updates all the assembly files in package runtime to use
the new conventions. Argument references of the form 40(SP) have
been rewritten to the form name+10(FP) instead, and there are now
Go func prototypes for every assembly function called from C or Go.
This means that 'go vet runtime' checks effectively every assembly
function, and go vet's output was used to automate the bulk of the
conversion.
Some functions, like seek and nsec on Plan 9, needed to be rewritten.
Many assembly routines called from C were reading arguments
incorrectly, using MOVL instead of MOVQ or vice versa, especially on
the less used systems like openbsd.
These were found by go vet and have been corrected too.
If we're lucky, this may reduce flakiness on those systems.
Tested on:
darwin/386
darwin/amd64
linux/arm
linux/386
linux/amd64
If this breaks another system, the bug is almost certainly in the
sys_$GOOS_$GOARCH.s file, since the rest of the CL is tested
by the combination of the above systems.
LGTM=dvyukov, iant
R=golang-codereviews, 0intro, dave, alex.brainman, dvyukov, iant
CC=golang-codereviews, josharian, r
https://golang.org/cl/135830043
2014-08-27 09:32:17 -06:00
|
|
|
MOVW R0, ret+8(FP)
|
2013-02-12 10:00:04 -07:00
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·lwp_self(SB),NOSPLIT,$0
|
2013-02-12 10:00:04 -07:00
|
|
|
SWI $0xa00137 // sys__lwp_self
|
cmd/cc, runtime: convert C compilers to use Go calling convention
To date, the C compilers and Go compilers differed only in how
values were returned from functions. This made it difficult to call
Go from C or C from Go if return values were involved. It also made
assembly called from Go and assembly called from C different.
This CL changes the C compiler to use the Go conventions, passing
results on the stack, after the arguments.
[Exception: this does not apply to C ... functions, because you can't
know where on the stack the arguments end.]
By doing this, the CL makes it possible to rewrite C functions into Go
one at a time, without worrying about which languages call that
function or which languages it calls.
This CL also updates all the assembly files in package runtime to use
the new conventions. Argument references of the form 40(SP) have
been rewritten to the form name+10(FP) instead, and there are now
Go func prototypes for every assembly function called from C or Go.
This means that 'go vet runtime' checks effectively every assembly
function, and go vet's output was used to automate the bulk of the
conversion.
Some functions, like seek and nsec on Plan 9, needed to be rewritten.
Many assembly routines called from C were reading arguments
incorrectly, using MOVL instead of MOVQ or vice versa, especially on
the less used systems like openbsd.
These were found by go vet and have been corrected too.
If we're lucky, this may reduce flakiness on those systems.
Tested on:
darwin/386
darwin/amd64
linux/arm
linux/386
linux/amd64
If this breaks another system, the bug is almost certainly in the
sys_$GOOS_$GOARCH.s file, since the rest of the CL is tested
by the combination of the above systems.
LGTM=dvyukov, iant
R=golang-codereviews, 0intro, dave, alex.brainman, dvyukov, iant
CC=golang-codereviews, josharian, r
https://golang.org/cl/135830043
2014-08-27 09:32:17 -06:00
|
|
|
MOVW R0, ret+0(FP)
|
2013-02-12 10:00:04 -07:00
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·lwp_tramp(SB),NOSPLIT,$0
|
all: remove 'extern register M *m' from runtime
The runtime has historically held two dedicated values g (current goroutine)
and m (current thread) in 'extern register' slots (TLS on x86, real registers
backed by TLS on ARM).
This CL removes the extern register m; code now uses g->m.
On ARM, this frees up the register that formerly held m (R9).
This is important for NaCl, because NaCl ARM code cannot use R9 at all.
The Go 1 macrobenchmarks (those with per-op times >= 10 µs) are unaffected:
BenchmarkBinaryTree17 5491374955 5471024381 -0.37%
BenchmarkFannkuch11 4357101311 4275174828 -1.88%
BenchmarkGobDecode 11029957 11364184 +3.03%
BenchmarkGobEncode 6852205 6784822 -0.98%
BenchmarkGzip 650795967 650152275 -0.10%
BenchmarkGunzip 140962363 141041670 +0.06%
BenchmarkHTTPClientServer 71581 73081 +2.10%
BenchmarkJSONEncode 31928079 31913356 -0.05%
BenchmarkJSONDecode 117470065 113689916 -3.22%
BenchmarkMandelbrot200 6008923 5998712 -0.17%
BenchmarkGoParse 6310917 6327487 +0.26%
BenchmarkRegexpMatchMedium_1K 114568 114763 +0.17%
BenchmarkRegexpMatchHard_1K 168977 169244 +0.16%
BenchmarkRevcomp 935294971 914060918 -2.27%
BenchmarkTemplate 145917123 148186096 +1.55%
Minux previous reported larger variations, but these were caused by
run-to-run noise, not repeatable slowdowns.
Actual code changes by Minux.
I only did the docs and the benchmarking.
LGTM=dvyukov, iant, minux
R=minux, josharian, iant, dave, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/109050043
2014-06-26 09:54:39 -06:00
|
|
|
MOVW R0, g_m(R1)
|
2013-05-28 06:13:02 -06:00
|
|
|
MOVW R1, g
|
2013-02-12 10:00:04 -07:00
|
|
|
|
|
|
|
BL runtime·emptyfunc(SB) // fault if stack check is wrong
|
|
|
|
BL (R2)
|
2013-05-28 06:13:02 -06:00
|
|
|
MOVW $2, R8 // crash (not reached)
|
|
|
|
MOVW R8, (R8)
|
2013-02-12 10:00:04 -07:00
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·usleep(SB),NOSPLIT,$16
|
2013-02-12 10:00:04 -07:00
|
|
|
MOVW usec+0(FP), R0
|
|
|
|
MOVW R0, R2
|
|
|
|
MOVW $1000000, R1
|
|
|
|
DIV R1, R0
|
|
|
|
// 0(R13) is the saved LR, don't use it
|
|
|
|
MOVW R0, 4(R13) // tv_sec.low
|
|
|
|
MOVW $0, R0
|
|
|
|
MOVW R0, 8(R13) // tv_sec.high
|
|
|
|
MOD R1, R2
|
|
|
|
MOVW $1000, R1
|
|
|
|
MUL R1, R2
|
|
|
|
MOVW R2, 12(R13) // tv_nsec
|
|
|
|
|
|
|
|
MOVW $4(R13), R0 // arg 1 - rqtp
|
|
|
|
MOVW $0, R1 // arg 2 - rmtp
|
|
|
|
SWI $0xa001ae // sys_nanosleep
|
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·raise(SB),NOSPLIT,$16
|
2013-02-12 10:00:04 -07:00
|
|
|
SWI $0xa00137 // sys__lwp_self, the returned R0 is arg 1
|
2013-03-14 23:11:03 -06:00
|
|
|
MOVW sig+0(FP), R1 // arg 2 - signal
|
2013-02-12 10:00:04 -07:00
|
|
|
SWI $0xa0013e // sys__lwp_kill
|
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·setitimer(SB),NOSPLIT,$-4
|
2015-02-23 08:56:10 -07:00
|
|
|
MOVW mode+0(FP), R0 // arg 1 - which
|
|
|
|
MOVW new+4(FP), R1 // arg 2 - itv
|
|
|
|
MOVW old+8(FP), R2 // arg 3 - oitv
|
2013-02-12 10:00:04 -07:00
|
|
|
SWI $0xa001a9 // sys_setitimer
|
|
|
|
RET
|
|
|
|
|
|
|
|
// func now() (sec int64, nsec int32)
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT time·now(SB), NOSPLIT, $32
|
2013-02-12 10:00:04 -07:00
|
|
|
MOVW $0, R0 // CLOCK_REALTIME
|
|
|
|
MOVW $8(R13), R1
|
|
|
|
SWI $0xa001ab // clock_gettime
|
|
|
|
|
|
|
|
MOVW 8(R13), R0 // sec.low
|
|
|
|
MOVW 12(R13), R1 // sec.high
|
|
|
|
MOVW 16(R13), R2 // nsec
|
|
|
|
|
2015-02-23 08:56:10 -07:00
|
|
|
MOVW R0, sec_lo+0(FP)
|
|
|
|
MOVW R1, sec_hi+4(FP)
|
|
|
|
MOVW R2, nsec+8(FP)
|
2013-02-12 10:00:04 -07:00
|
|
|
RET
|
|
|
|
|
|
|
|
// int64 nanotime(void) so really
|
|
|
|
// void nanotime(int64 *nsec)
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·nanotime(SB), NOSPLIT, $32
|
2013-02-12 10:00:04 -07:00
|
|
|
MOVW $0, R0 // CLOCK_REALTIME
|
|
|
|
MOVW $8(R13), R1
|
|
|
|
SWI $0xa001ab // clock_gettime
|
|
|
|
|
|
|
|
MOVW 8(R13), R0 // sec.low
|
|
|
|
MOVW 12(R13), R4 // sec.high
|
|
|
|
MOVW 16(R13), R2 // nsec
|
|
|
|
|
|
|
|
MOVW $1000000000, R3
|
|
|
|
MULLU R0, R3, (R1, R0)
|
|
|
|
MUL R3, R4
|
|
|
|
ADD.S R2, R0
|
|
|
|
ADC R4, R1
|
|
|
|
|
cmd/cc, runtime: convert C compilers to use Go calling convention
To date, the C compilers and Go compilers differed only in how
values were returned from functions. This made it difficult to call
Go from C or C from Go if return values were involved. It also made
assembly called from Go and assembly called from C different.
This CL changes the C compiler to use the Go conventions, passing
results on the stack, after the arguments.
[Exception: this does not apply to C ... functions, because you can't
know where on the stack the arguments end.]
By doing this, the CL makes it possible to rewrite C functions into Go
one at a time, without worrying about which languages call that
function or which languages it calls.
This CL also updates all the assembly files in package runtime to use
the new conventions. Argument references of the form 40(SP) have
been rewritten to the form name+10(FP) instead, and there are now
Go func prototypes for every assembly function called from C or Go.
This means that 'go vet runtime' checks effectively every assembly
function, and go vet's output was used to automate the bulk of the
conversion.
Some functions, like seek and nsec on Plan 9, needed to be rewritten.
Many assembly routines called from C were reading arguments
incorrectly, using MOVL instead of MOVQ or vice versa, especially on
the less used systems like openbsd.
These were found by go vet and have been corrected too.
If we're lucky, this may reduce flakiness on those systems.
Tested on:
darwin/386
darwin/amd64
linux/arm
linux/386
linux/amd64
If this breaks another system, the bug is almost certainly in the
sys_$GOOS_$GOARCH.s file, since the rest of the CL is tested
by the combination of the above systems.
LGTM=dvyukov, iant
R=golang-codereviews, 0intro, dave, alex.brainman, dvyukov, iant
CC=golang-codereviews, josharian, r
https://golang.org/cl/135830043
2014-08-27 09:32:17 -06:00
|
|
|
MOVW R0, ret_lo+0(FP)
|
|
|
|
MOVW R1, ret_hi+4(FP)
|
2013-02-12 10:00:04 -07:00
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·getcontext(SB),NOSPLIT,$-4
|
2015-02-23 08:56:10 -07:00
|
|
|
MOVW ctxt+0(FP), R0 // arg 1 - context
|
2013-02-12 10:00:04 -07:00
|
|
|
SWI $0xa00133 // sys_getcontext
|
2013-05-28 06:13:02 -06:00
|
|
|
MOVW.CS $0, R8 // crash on syscall failure
|
|
|
|
MOVW.CS R8, (R8)
|
2013-02-12 10:00:04 -07:00
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·sigprocmask(SB),NOSPLIT,$0
|
2015-02-23 08:56:10 -07:00
|
|
|
MOVW mode+0(FP), R0 // arg 1 - how
|
|
|
|
MOVW new+4(FP), R1 // arg 2 - set
|
|
|
|
MOVW old+8(FP), R2 // arg 3 - oset
|
2013-02-12 10:00:04 -07:00
|
|
|
SWI $0xa00125 // sys_sigprocmask
|
2013-05-28 06:13:02 -06:00
|
|
|
MOVW.CS $0, R8 // crash on syscall failure
|
|
|
|
MOVW.CS R8, (R8)
|
2013-02-12 10:00:04 -07:00
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·sigreturn_tramp(SB),NOSPLIT,$-4
|
2013-07-02 10:33:38 -06:00
|
|
|
// on entry, SP points to siginfo, we add sizeof(ucontext)
|
|
|
|
// to SP to get a pointer to ucontext.
|
|
|
|
ADD $0x80, R13, R0 // 0x80 == sizeof(UcontextT)
|
2013-02-12 10:00:04 -07:00
|
|
|
SWI $0xa00134 // sys_setcontext
|
|
|
|
// something failed, we have to exit
|
|
|
|
MOVW $0x4242, R0 // magic return number
|
|
|
|
SWI $0xa00001 // sys_exit
|
|
|
|
B -2(PC) // continue exit
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·sigaction(SB),NOSPLIT,$4
|
2015-02-23 08:56:10 -07:00
|
|
|
MOVW sig+0(FP), R0 // arg 1 - signum
|
|
|
|
MOVW new+4(FP), R1 // arg 2 - nsa
|
|
|
|
MOVW old+8(FP), R2 // arg 3 - osa
|
2013-02-12 10:00:04 -07:00
|
|
|
MOVW $runtime·sigreturn_tramp(SB), R3 // arg 4 - tramp
|
|
|
|
MOVW $2, R4 // arg 5 - vers
|
|
|
|
MOVW R4, 4(R13)
|
|
|
|
ADD $4, R13 // pass arg 5 on stack
|
|
|
|
SWI $0xa00154 // sys___sigaction_sigtramp
|
|
|
|
SUB $4, R13
|
2013-05-28 06:13:02 -06:00
|
|
|
MOVW.CS $3, R8 // crash on syscall failure
|
|
|
|
MOVW.CS R8, (R8)
|
2013-02-12 10:00:04 -07:00
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·sigtramp(SB),NOSPLIT,$24
|
2013-02-12 10:00:04 -07:00
|
|
|
// this might be called in external code context,
|
all: remove 'extern register M *m' from runtime
The runtime has historically held two dedicated values g (current goroutine)
and m (current thread) in 'extern register' slots (TLS on x86, real registers
backed by TLS on ARM).
This CL removes the extern register m; code now uses g->m.
On ARM, this frees up the register that formerly held m (R9).
This is important for NaCl, because NaCl ARM code cannot use R9 at all.
The Go 1 macrobenchmarks (those with per-op times >= 10 µs) are unaffected:
BenchmarkBinaryTree17 5491374955 5471024381 -0.37%
BenchmarkFannkuch11 4357101311 4275174828 -1.88%
BenchmarkGobDecode 11029957 11364184 +3.03%
BenchmarkGobEncode 6852205 6784822 -0.98%
BenchmarkGzip 650795967 650152275 -0.10%
BenchmarkGunzip 140962363 141041670 +0.06%
BenchmarkHTTPClientServer 71581 73081 +2.10%
BenchmarkJSONEncode 31928079 31913356 -0.05%
BenchmarkJSONDecode 117470065 113689916 -3.22%
BenchmarkMandelbrot200 6008923 5998712 -0.17%
BenchmarkGoParse 6310917 6327487 +0.26%
BenchmarkRegexpMatchMedium_1K 114568 114763 +0.17%
BenchmarkRegexpMatchHard_1K 168977 169244 +0.16%
BenchmarkRevcomp 935294971 914060918 -2.27%
BenchmarkTemplate 145917123 148186096 +1.55%
Minux previous reported larger variations, but these were caused by
run-to-run noise, not repeatable slowdowns.
Actual code changes by Minux.
I only did the docs and the benchmarking.
LGTM=dvyukov, iant, minux
R=minux, josharian, iant, dave, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/109050043
2014-06-26 09:54:39 -06:00
|
|
|
// where g is not set.
|
|
|
|
// first save R0, because runtime·load_g will clobber it
|
2013-02-12 10:00:04 -07:00
|
|
|
MOVW R0, 4(R13) // signum
|
2013-08-14 11:18:32 -06:00
|
|
|
MOVB runtime·iscgo(SB), R0
|
2013-02-12 10:00:04 -07:00
|
|
|
CMP $0, R0
|
all: remove 'extern register M *m' from runtime
The runtime has historically held two dedicated values g (current goroutine)
and m (current thread) in 'extern register' slots (TLS on x86, real registers
backed by TLS on ARM).
This CL removes the extern register m; code now uses g->m.
On ARM, this frees up the register that formerly held m (R9).
This is important for NaCl, because NaCl ARM code cannot use R9 at all.
The Go 1 macrobenchmarks (those with per-op times >= 10 µs) are unaffected:
BenchmarkBinaryTree17 5491374955 5471024381 -0.37%
BenchmarkFannkuch11 4357101311 4275174828 -1.88%
BenchmarkGobDecode 11029957 11364184 +3.03%
BenchmarkGobEncode 6852205 6784822 -0.98%
BenchmarkGzip 650795967 650152275 -0.10%
BenchmarkGunzip 140962363 141041670 +0.06%
BenchmarkHTTPClientServer 71581 73081 +2.10%
BenchmarkJSONEncode 31928079 31913356 -0.05%
BenchmarkJSONDecode 117470065 113689916 -3.22%
BenchmarkMandelbrot200 6008923 5998712 -0.17%
BenchmarkGoParse 6310917 6327487 +0.26%
BenchmarkRegexpMatchMedium_1K 114568 114763 +0.17%
BenchmarkRegexpMatchHard_1K 168977 169244 +0.16%
BenchmarkRevcomp 935294971 914060918 -2.27%
BenchmarkTemplate 145917123 148186096 +1.55%
Minux previous reported larger variations, but these were caused by
run-to-run noise, not repeatable slowdowns.
Actual code changes by Minux.
I only did the docs and the benchmarking.
LGTM=dvyukov, iant, minux
R=minux, josharian, iant, dave, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/109050043
2014-06-26 09:54:39 -06:00
|
|
|
BL.NE runtime·load_g(SB)
|
2013-02-12 10:00:04 -07:00
|
|
|
|
all: remove 'extern register M *m' from runtime
The runtime has historically held two dedicated values g (current goroutine)
and m (current thread) in 'extern register' slots (TLS on x86, real registers
backed by TLS on ARM).
This CL removes the extern register m; code now uses g->m.
On ARM, this frees up the register that formerly held m (R9).
This is important for NaCl, because NaCl ARM code cannot use R9 at all.
The Go 1 macrobenchmarks (those with per-op times >= 10 µs) are unaffected:
BenchmarkBinaryTree17 5491374955 5471024381 -0.37%
BenchmarkFannkuch11 4357101311 4275174828 -1.88%
BenchmarkGobDecode 11029957 11364184 +3.03%
BenchmarkGobEncode 6852205 6784822 -0.98%
BenchmarkGzip 650795967 650152275 -0.10%
BenchmarkGunzip 140962363 141041670 +0.06%
BenchmarkHTTPClientServer 71581 73081 +2.10%
BenchmarkJSONEncode 31928079 31913356 -0.05%
BenchmarkJSONDecode 117470065 113689916 -3.22%
BenchmarkMandelbrot200 6008923 5998712 -0.17%
BenchmarkGoParse 6310917 6327487 +0.26%
BenchmarkRegexpMatchMedium_1K 114568 114763 +0.17%
BenchmarkRegexpMatchHard_1K 168977 169244 +0.16%
BenchmarkRevcomp 935294971 914060918 -2.27%
BenchmarkTemplate 145917123 148186096 +1.55%
Minux previous reported larger variations, but these were caused by
run-to-run noise, not repeatable slowdowns.
Actual code changes by Minux.
I only did the docs and the benchmarking.
LGTM=dvyukov, iant, minux
R=minux, josharian, iant, dave, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/109050043
2014-06-26 09:54:39 -06:00
|
|
|
CMP $0, g
|
2013-07-11 14:39:39 -06:00
|
|
|
BNE 4(PC)
|
2013-05-27 06:46:53 -06:00
|
|
|
// signal number is already prepared in 4(R13)
|
2013-07-11 14:39:39 -06:00
|
|
|
MOVW $runtime·badsignal(SB), R11
|
|
|
|
BL (R11)
|
2013-05-27 06:46:53 -06:00
|
|
|
RET
|
|
|
|
|
2013-02-12 10:00:04 -07:00
|
|
|
// save g
|
2013-05-28 06:13:02 -06:00
|
|
|
MOVW g, R4
|
|
|
|
MOVW g, 20(R13)
|
2013-02-12 10:00:04 -07:00
|
|
|
|
|
|
|
// g = m->signal
|
all: remove 'extern register M *m' from runtime
The runtime has historically held two dedicated values g (current goroutine)
and m (current thread) in 'extern register' slots (TLS on x86, real registers
backed by TLS on ARM).
This CL removes the extern register m; code now uses g->m.
On ARM, this frees up the register that formerly held m (R9).
This is important for NaCl, because NaCl ARM code cannot use R9 at all.
The Go 1 macrobenchmarks (those with per-op times >= 10 µs) are unaffected:
BenchmarkBinaryTree17 5491374955 5471024381 -0.37%
BenchmarkFannkuch11 4357101311 4275174828 -1.88%
BenchmarkGobDecode 11029957 11364184 +3.03%
BenchmarkGobEncode 6852205 6784822 -0.98%
BenchmarkGzip 650795967 650152275 -0.10%
BenchmarkGunzip 140962363 141041670 +0.06%
BenchmarkHTTPClientServer 71581 73081 +2.10%
BenchmarkJSONEncode 31928079 31913356 -0.05%
BenchmarkJSONDecode 117470065 113689916 -3.22%
BenchmarkMandelbrot200 6008923 5998712 -0.17%
BenchmarkGoParse 6310917 6327487 +0.26%
BenchmarkRegexpMatchMedium_1K 114568 114763 +0.17%
BenchmarkRegexpMatchHard_1K 168977 169244 +0.16%
BenchmarkRevcomp 935294971 914060918 -2.27%
BenchmarkTemplate 145917123 148186096 +1.55%
Minux previous reported larger variations, but these were caused by
run-to-run noise, not repeatable slowdowns.
Actual code changes by Minux.
I only did the docs and the benchmarking.
LGTM=dvyukov, iant, minux
R=minux, josharian, iant, dave, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/109050043
2014-06-26 09:54:39 -06:00
|
|
|
MOVW g_m(g), R8
|
|
|
|
MOVW m_gsignal(R8), g
|
2013-02-12 10:00:04 -07:00
|
|
|
|
|
|
|
// R0 is already saved
|
|
|
|
MOVW R1, 8(R13) // info
|
|
|
|
MOVW R2, 12(R13) // context
|
|
|
|
MOVW R4, 16(R13) // gp
|
|
|
|
|
|
|
|
BL runtime·sighandler(SB)
|
|
|
|
|
|
|
|
// restore g
|
2013-05-28 06:13:02 -06:00
|
|
|
MOVW 20(R13), g
|
2013-02-12 10:00:04 -07:00
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·mmap(SB),NOSPLIT,$12
|
2015-02-23 08:56:10 -07:00
|
|
|
MOVW addr+0(FP), R0 // arg 1 - addr
|
|
|
|
MOVW n+4(FP), R1 // arg 2 - len
|
|
|
|
MOVW prot+8(FP), R2 // arg 3 - prot
|
|
|
|
MOVW flags+12(FP), R3 // arg 4 - flags
|
2013-02-12 10:00:04 -07:00
|
|
|
// arg 5 (fid) and arg6 (offset_lo, offset_hi) are passed on stack
|
|
|
|
// note the C runtime only passes the 32-bit offset_lo to us
|
2015-02-23 08:56:10 -07:00
|
|
|
MOVW fd+16(FP), R4 // arg 5
|
2013-02-12 10:00:04 -07:00
|
|
|
MOVW R4, 4(R13)
|
2015-02-23 08:56:10 -07:00
|
|
|
MOVW off+20(FP), R5 // arg 6 lower 32-bit
|
2013-02-12 10:00:04 -07:00
|
|
|
MOVW R5, 8(R13)
|
|
|
|
MOVW $0, R6 // higher 32-bit for arg 6
|
|
|
|
MOVW R6, 12(R13)
|
|
|
|
ADD $4, R13 // pass arg 5 and arg 6 on stack
|
|
|
|
SWI $0xa000c5 // sys_mmap
|
|
|
|
SUB $4, R13
|
cmd/cc, runtime: convert C compilers to use Go calling convention
To date, the C compilers and Go compilers differed only in how
values were returned from functions. This made it difficult to call
Go from C or C from Go if return values were involved. It also made
assembly called from Go and assembly called from C different.
This CL changes the C compiler to use the Go conventions, passing
results on the stack, after the arguments.
[Exception: this does not apply to C ... functions, because you can't
know where on the stack the arguments end.]
By doing this, the CL makes it possible to rewrite C functions into Go
one at a time, without worrying about which languages call that
function or which languages it calls.
This CL also updates all the assembly files in package runtime to use
the new conventions. Argument references of the form 40(SP) have
been rewritten to the form name+10(FP) instead, and there are now
Go func prototypes for every assembly function called from C or Go.
This means that 'go vet runtime' checks effectively every assembly
function, and go vet's output was used to automate the bulk of the
conversion.
Some functions, like seek and nsec on Plan 9, needed to be rewritten.
Many assembly routines called from C were reading arguments
incorrectly, using MOVL instead of MOVQ or vice versa, especially on
the less used systems like openbsd.
These were found by go vet and have been corrected too.
If we're lucky, this may reduce flakiness on those systems.
Tested on:
darwin/386
darwin/amd64
linux/arm
linux/386
linux/amd64
If this breaks another system, the bug is almost certainly in the
sys_$GOOS_$GOARCH.s file, since the rest of the CL is tested
by the combination of the above systems.
LGTM=dvyukov, iant
R=golang-codereviews, 0intro, dave, alex.brainman, dvyukov, iant
CC=golang-codereviews, josharian, r
https://golang.org/cl/135830043
2014-08-27 09:32:17 -06:00
|
|
|
MOVW R0, ret+24(FP)
|
2013-02-12 10:00:04 -07:00
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·munmap(SB),NOSPLIT,$0
|
2015-02-23 08:56:10 -07:00
|
|
|
MOVW addr+0(FP), R0 // arg 1 - addr
|
|
|
|
MOVW n+4(FP), R1 // arg 2 - len
|
2013-02-12 10:00:04 -07:00
|
|
|
SWI $0xa00049 // sys_munmap
|
2013-05-28 06:13:02 -06:00
|
|
|
MOVW.CS $0, R8 // crash on syscall failure
|
|
|
|
MOVW.CS R8, (R8)
|
2013-02-12 10:00:04 -07:00
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·madvise(SB),NOSPLIT,$0
|
2015-02-23 08:56:10 -07:00
|
|
|
MOVW addr+0(FP), R0 // arg 1 - addr
|
|
|
|
MOVW n+4(FP), R1 // arg 2 - len
|
|
|
|
MOVW flags+8(FP), R2 // arg 3 - behav
|
2013-02-12 10:00:04 -07:00
|
|
|
SWI $0xa0004b // sys_madvise
|
|
|
|
// ignore failure - maybe pages are locked
|
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·sigaltstack(SB),NOSPLIT,$-4
|
2015-02-23 08:56:10 -07:00
|
|
|
MOVW new+0(FP), R0 // arg 1 - nss
|
|
|
|
MOVW old+4(FP), R1 // arg 2 - oss
|
2013-02-12 10:00:04 -07:00
|
|
|
SWI $0xa00119 // sys___sigaltstack14
|
2013-05-28 06:13:02 -06:00
|
|
|
MOVW.CS $0, R8 // crash on syscall failure
|
|
|
|
MOVW.CS R8, (R8)
|
2013-02-12 10:00:04 -07:00
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·sysctl(SB),NOSPLIT,$8
|
2015-02-23 08:56:10 -07:00
|
|
|
MOVW mib+0(FP), R0 // arg 1 - name
|
|
|
|
MOVW miblen+4(FP), R1 // arg 2 - namelen
|
|
|
|
MOVW out+8(FP), R2 // arg 3 - oldp
|
|
|
|
MOVW size+12(FP), R3 // arg 4 - oldlenp
|
|
|
|
MOVW dst+16(FP), R4 // arg 5 - newp
|
2013-02-12 10:00:04 -07:00
|
|
|
MOVW R4, 4(R13)
|
2015-02-23 08:56:10 -07:00
|
|
|
MOVW ndst+20(FP), R4 // arg 6 - newlen
|
2013-02-12 10:00:04 -07:00
|
|
|
MOVW R4, 8(R13)
|
|
|
|
ADD $4, R13 // pass arg 5 and 6 on stack
|
|
|
|
SWI $0xa000ca // sys___sysctl
|
|
|
|
SUB $4, R13
|
cmd/cc, runtime: convert C compilers to use Go calling convention
To date, the C compilers and Go compilers differed only in how
values were returned from functions. This made it difficult to call
Go from C or C from Go if return values were involved. It also made
assembly called from Go and assembly called from C different.
This CL changes the C compiler to use the Go conventions, passing
results on the stack, after the arguments.
[Exception: this does not apply to C ... functions, because you can't
know where on the stack the arguments end.]
By doing this, the CL makes it possible to rewrite C functions into Go
one at a time, without worrying about which languages call that
function or which languages it calls.
This CL also updates all the assembly files in package runtime to use
the new conventions. Argument references of the form 40(SP) have
been rewritten to the form name+10(FP) instead, and there are now
Go func prototypes for every assembly function called from C or Go.
This means that 'go vet runtime' checks effectively every assembly
function, and go vet's output was used to automate the bulk of the
conversion.
Some functions, like seek and nsec on Plan 9, needed to be rewritten.
Many assembly routines called from C were reading arguments
incorrectly, using MOVL instead of MOVQ or vice versa, especially on
the less used systems like openbsd.
These were found by go vet and have been corrected too.
If we're lucky, this may reduce flakiness on those systems.
Tested on:
darwin/386
darwin/amd64
linux/arm
linux/386
linux/amd64
If this breaks another system, the bug is almost certainly in the
sys_$GOOS_$GOARCH.s file, since the rest of the CL is tested
by the combination of the above systems.
LGTM=dvyukov, iant
R=golang-codereviews, 0intro, dave, alex.brainman, dvyukov, iant
CC=golang-codereviews, josharian, r
https://golang.org/cl/135830043
2014-08-27 09:32:17 -06:00
|
|
|
MOVW R0, ret+24(FP)
|
2013-02-12 10:00:04 -07:00
|
|
|
RET
|
|
|
|
|
2013-08-16 21:11:29 -06:00
|
|
|
// int32 runtime·kqueue(void)
|
|
|
|
TEXT runtime·kqueue(SB),NOSPLIT,$0
|
|
|
|
SWI $0xa00158 // sys_kqueue
|
|
|
|
RSB.CS $0, R0
|
cmd/cc, runtime: convert C compilers to use Go calling convention
To date, the C compilers and Go compilers differed only in how
values were returned from functions. This made it difficult to call
Go from C or C from Go if return values were involved. It also made
assembly called from Go and assembly called from C different.
This CL changes the C compiler to use the Go conventions, passing
results on the stack, after the arguments.
[Exception: this does not apply to C ... functions, because you can't
know where on the stack the arguments end.]
By doing this, the CL makes it possible to rewrite C functions into Go
one at a time, without worrying about which languages call that
function or which languages it calls.
This CL also updates all the assembly files in package runtime to use
the new conventions. Argument references of the form 40(SP) have
been rewritten to the form name+10(FP) instead, and there are now
Go func prototypes for every assembly function called from C or Go.
This means that 'go vet runtime' checks effectively every assembly
function, and go vet's output was used to automate the bulk of the
conversion.
Some functions, like seek and nsec on Plan 9, needed to be rewritten.
Many assembly routines called from C were reading arguments
incorrectly, using MOVL instead of MOVQ or vice versa, especially on
the less used systems like openbsd.
These were found by go vet and have been corrected too.
If we're lucky, this may reduce flakiness on those systems.
Tested on:
darwin/386
darwin/amd64
linux/arm
linux/386
linux/amd64
If this breaks another system, the bug is almost certainly in the
sys_$GOOS_$GOARCH.s file, since the rest of the CL is tested
by the combination of the above systems.
LGTM=dvyukov, iant
R=golang-codereviews, 0intro, dave, alex.brainman, dvyukov, iant
CC=golang-codereviews, josharian, r
https://golang.org/cl/135830043
2014-08-27 09:32:17 -06:00
|
|
|
MOVW R0, ret+0(FP)
|
2013-08-16 21:11:29 -06:00
|
|
|
RET
|
|
|
|
|
|
|
|
// int32 runtime·kevent(int kq, Kevent *changelist, int nchanges, Kevent *eventlist, int nevents, Timespec *timeout)
|
|
|
|
TEXT runtime·kevent(SB),NOSPLIT,$8
|
2015-02-23 08:56:10 -07:00
|
|
|
MOVW kq+0(FP), R0 // kq
|
|
|
|
MOVW ch+4(FP), R1 // changelist
|
|
|
|
MOVW nch+8(FP), R2 // nchanges
|
|
|
|
MOVW ev+12(FP), R3 // eventlist
|
|
|
|
MOVW nev+16(FP), R4 // nevents
|
2013-08-16 21:11:29 -06:00
|
|
|
MOVW R4, 4(R13)
|
2015-02-23 08:56:10 -07:00
|
|
|
MOVW ts+20(FP), R4 // timeout
|
2013-08-16 21:11:29 -06:00
|
|
|
MOVW R4, 8(R13)
|
|
|
|
ADD $4, R13 // pass arg 5 and 6 on stack
|
|
|
|
SWI $0xa001b3 // sys___kevent50
|
|
|
|
RSB.CS $0, R0
|
|
|
|
SUB $4, R13
|
cmd/cc, runtime: convert C compilers to use Go calling convention
To date, the C compilers and Go compilers differed only in how
values were returned from functions. This made it difficult to call
Go from C or C from Go if return values were involved. It also made
assembly called from Go and assembly called from C different.
This CL changes the C compiler to use the Go conventions, passing
results on the stack, after the arguments.
[Exception: this does not apply to C ... functions, because you can't
know where on the stack the arguments end.]
By doing this, the CL makes it possible to rewrite C functions into Go
one at a time, without worrying about which languages call that
function or which languages it calls.
This CL also updates all the assembly files in package runtime to use
the new conventions. Argument references of the form 40(SP) have
been rewritten to the form name+10(FP) instead, and there are now
Go func prototypes for every assembly function called from C or Go.
This means that 'go vet runtime' checks effectively every assembly
function, and go vet's output was used to automate the bulk of the
conversion.
Some functions, like seek and nsec on Plan 9, needed to be rewritten.
Many assembly routines called from C were reading arguments
incorrectly, using MOVL instead of MOVQ or vice versa, especially on
the less used systems like openbsd.
These were found by go vet and have been corrected too.
If we're lucky, this may reduce flakiness on those systems.
Tested on:
darwin/386
darwin/amd64
linux/arm
linux/386
linux/amd64
If this breaks another system, the bug is almost certainly in the
sys_$GOOS_$GOARCH.s file, since the rest of the CL is tested
by the combination of the above systems.
LGTM=dvyukov, iant
R=golang-codereviews, 0intro, dave, alex.brainman, dvyukov, iant
CC=golang-codereviews, josharian, r
https://golang.org/cl/135830043
2014-08-27 09:32:17 -06:00
|
|
|
MOVW R0, ret+24(FP)
|
2013-08-16 21:11:29 -06:00
|
|
|
RET
|
|
|
|
|
|
|
|
// void runtime·closeonexec(int32 fd)
|
|
|
|
TEXT runtime·closeonexec(SB),NOSPLIT,$0
|
2015-02-23 08:56:10 -07:00
|
|
|
MOVW fd+0(FP), R0 // fd
|
2013-08-16 21:11:29 -06:00
|
|
|
MOVW $2, R1 // F_SETFD
|
|
|
|
MOVW $1, R2 // FD_CLOEXEC
|
|
|
|
SWI $0xa0005c // sys_fcntl
|
|
|
|
RET
|
|
|
|
|
[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
2014-11-11 15:06:22 -07:00
|
|
|
TEXT runtime·casp1(SB),NOSPLIT,$0
|
2013-02-12 10:00:04 -07:00
|
|
|
B runtime·cas(SB)
|
|
|
|
|
|
|
|
// TODO(minux): this is only valid for ARMv6+
|
|
|
|
// bool armcas(int32 *val, int32 old, int32 new)
|
|
|
|
// Atomically:
|
|
|
|
// if(*val == old){
|
|
|
|
// *val = new;
|
|
|
|
// return 1;
|
|
|
|
// }else
|
|
|
|
// return 0;
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·cas(SB),NOSPLIT,$0
|
2013-02-12 10:00:04 -07:00
|
|
|
B runtime·armcas(SB)
|
runtime.cmd/ld: Add ARM external linking and implement -shared in terms of external linking
This CL is an aggregate of 10271047, 10499043, 9733044. Descriptions of each follow:
10499043
runtime,cmd/ld: Merge TLS symbols and teach 5l about ARM TLS
This CL prepares for external linking support to ARM.
The pseudo-symbols runtime.g and runtime.m are merged into a single
runtime.tlsgm symbol. When external linking, the offset of a thread local
variable is stored at a memory location instead of being embedded into a offset
of a ldr instruction. With a single runtime.tlsgm symbol for both g and m, only
one such offset is needed.
The larger part of this CL moves TLS code from gcc compiled to internally
compiled. The TLS code now uses the modern MRC instruction, and 5l is taught
about TLS fallbacks in case the instruction is not available or appropriate.
10271047
This CL adds support for -linkmode external to 5l.
For 5l itself, use addrel to allow for D_CALL relocations to be handled by the
host linker. Of the cases listed in rsc's comment in issue 4069, only case 5 and
63 needed an update. One of the TODO: addrel cases was since replaced, and the
rest of the cases are either covered by indirection through addpool (cases with
LTO or LFROM flags) or stubs (case 74). The addpool cases are covered because
addpool emits AWORD instructions, which in turn are handled by case 11.
In the runtime, change the argv argument in the rt0* functions slightly to be a
pointer to the argv list, instead of relying on a particular location of argv.
9733044
The -shared flag to 6l outputs a shared library, implemented in Go
and callable from non-Go programs such as C.
The main part of this CL change the thread local storage model.
Go uses the fastest and least general mode, local exec. TLS data in shared
libraries normally requires at least the local dynamic mode, however, this CL
instead opts for using the initial exec mode. Initial exec mode is faster than
local dynamic mode and can be used in linux since the linker has reserved a
limited amount of TLS space for performance sensitive TLS code.
Initial exec mode requires an extra load from the GOT table to determine the
TLS offset. This penalty will not be paid if ld is not in -shared mode, since
TLS accesses will be reduced to local exec.
The elf sections .init_array and .rela.init_array are added to register the Go
runtime entry with cgo at library load time.
The "hidden" attribute is added to Cgo functions called from Go, since Go
does not generate call through the GOT table, and adding non-GOT relocations for
a global function is not supported by gcc. Cgo symbols don't need to be global
and avoiding the GOT table is also faster.
The changes to 8l are only removes code relevant to the old -shared mode where
internal linking was used.
This CL only address the low level linker work. It can be submitted by itself,
but to be useful, the runtime changes in CL 9738047 is also needed.
Design discussion at
https://groups.google.com/forum/?fromgroups#!topic/golang-nuts/zmjXkGrEx6Q
Fixes #5590.
R=rsc
CC=golang-dev
https://golang.org/cl/12871044
2013-08-14 09:38:54 -06:00
|
|
|
|
2015-06-15 10:30:23 -06:00
|
|
|
// TODO: this is only valid for ARMv7+
|
|
|
|
TEXT ·publicationBarrier(SB),NOSPLIT,$-4-0
|
|
|
|
B runtime·armPublicationBarrier(SB)
|
|
|
|
|
runtime.cmd/ld: Add ARM external linking and implement -shared in terms of external linking
This CL is an aggregate of 10271047, 10499043, 9733044. Descriptions of each follow:
10499043
runtime,cmd/ld: Merge TLS symbols and teach 5l about ARM TLS
This CL prepares for external linking support to ARM.
The pseudo-symbols runtime.g and runtime.m are merged into a single
runtime.tlsgm symbol. When external linking, the offset of a thread local
variable is stored at a memory location instead of being embedded into a offset
of a ldr instruction. With a single runtime.tlsgm symbol for both g and m, only
one such offset is needed.
The larger part of this CL moves TLS code from gcc compiled to internally
compiled. The TLS code now uses the modern MRC instruction, and 5l is taught
about TLS fallbacks in case the instruction is not available or appropriate.
10271047
This CL adds support for -linkmode external to 5l.
For 5l itself, use addrel to allow for D_CALL relocations to be handled by the
host linker. Of the cases listed in rsc's comment in issue 4069, only case 5 and
63 needed an update. One of the TODO: addrel cases was since replaced, and the
rest of the cases are either covered by indirection through addpool (cases with
LTO or LFROM flags) or stubs (case 74). The addpool cases are covered because
addpool emits AWORD instructions, which in turn are handled by case 11.
In the runtime, change the argv argument in the rt0* functions slightly to be a
pointer to the argv list, instead of relying on a particular location of argv.
9733044
The -shared flag to 6l outputs a shared library, implemented in Go
and callable from non-Go programs such as C.
The main part of this CL change the thread local storage model.
Go uses the fastest and least general mode, local exec. TLS data in shared
libraries normally requires at least the local dynamic mode, however, this CL
instead opts for using the initial exec mode. Initial exec mode is faster than
local dynamic mode and can be used in linux since the linker has reserved a
limited amount of TLS space for performance sensitive TLS code.
Initial exec mode requires an extra load from the GOT table to determine the
TLS offset. This penalty will not be paid if ld is not in -shared mode, since
TLS accesses will be reduced to local exec.
The elf sections .init_array and .rela.init_array are added to register the Go
runtime entry with cgo at library load time.
The "hidden" attribute is added to Cgo functions called from Go, since Go
does not generate call through the GOT table, and adding non-GOT relocations for
a global function is not supported by gcc. Cgo symbols don't need to be global
and avoiding the GOT table is also faster.
The changes to 8l are only removes code relevant to the old -shared mode where
internal linking was used.
This CL only address the low level linker work. It can be submitted by itself,
but to be useful, the runtime changes in CL 9738047 is also needed.
Design discussion at
https://groups.google.com/forum/?fromgroups#!topic/golang-nuts/zmjXkGrEx6Q
Fixes #5590.
R=rsc
CC=golang-dev
https://golang.org/cl/12871044
2013-08-14 09:38:54 -06:00
|
|
|
TEXT runtime·read_tls_fallback(SB),NOSPLIT,$-4
|
|
|
|
MOVM.WP [R1, R2, R3, R12], (R13)
|
|
|
|
SWI $0x00a0013c // _lwp_getprivate
|
|
|
|
MOVM.IAW (R13), [R1, R2, R3, R12]
|
|
|
|
RET
|