2011-08-08 07:56:38 -06:00
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// System calls and other sys.stuff for AMD64, OpenBSD
|
|
|
|
// /usr/src/sys/kern/syscalls.master for syscall numbers.
|
|
|
|
//
|
|
|
|
|
2011-12-19 13:51:13 -07:00
|
|
|
#include "zasm_GOOS_GOARCH.h"
|
2013-08-07 13:20:05 -06:00
|
|
|
#include "../../cmd/ld/textflag.h"
|
2011-08-08 07:56:38 -06:00
|
|
|
|
2012-12-18 09:30:29 -07:00
|
|
|
// int64 tfork(void *param, uintptr psize, M *mp, G *gp, void (*fn)(void));
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·tfork(SB),NOSPLIT,$32
|
2011-08-08 07:56:38 -06:00
|
|
|
|
2012-12-18 09:30:29 -07:00
|
|
|
// Copy mp, gp and fn off parent stack for use by child.
|
2012-04-25 08:08:02 -06:00
|
|
|
MOVQ mm+16(FP), R8
|
|
|
|
MOVQ gg+24(FP), R9
|
|
|
|
MOVQ fn+32(FP), R12
|
2011-08-08 07:56:38 -06:00
|
|
|
|
2012-04-25 08:08:02 -06:00
|
|
|
MOVQ param+0(FP), DI
|
2012-11-21 07:25:53 -07:00
|
|
|
MOVQ psize+8(FP), SI
|
|
|
|
MOVL $8, AX // sys___tfork
|
2011-08-08 07:56:38 -06:00
|
|
|
SYSCALL
|
|
|
|
|
2012-04-25 08:08:02 -06:00
|
|
|
// Return if tfork syscall failed.
|
2011-08-08 07:56:38 -06:00
|
|
|
JCC 3(PC)
|
2013-03-14 21:42:11 -06:00
|
|
|
NEGQ AX
|
2011-08-08 07:56:38 -06:00
|
|
|
RET
|
|
|
|
|
|
|
|
// In parent, return.
|
|
|
|
CMPL AX, $0
|
|
|
|
JEQ 2(PC)
|
|
|
|
RET
|
|
|
|
|
|
|
|
// Set FS to point at m->tls.
|
|
|
|
LEAQ m_tls(R8), DI
|
|
|
|
CALL runtime·settls(SB)
|
|
|
|
|
2012-04-25 08:08:02 -06:00
|
|
|
// In child, set up new stack.
|
2011-08-08 07:56:38 -06:00
|
|
|
get_tls(CX)
|
|
|
|
MOVQ R8, m(CX)
|
|
|
|
MOVQ R9, g(CX)
|
|
|
|
CALL runtime·stackcheck(SB)
|
|
|
|
|
|
|
|
// Call fn
|
|
|
|
CALL R12
|
|
|
|
|
|
|
|
// It shouldn't return. If it does, exit
|
2012-04-11 06:02:08 -06:00
|
|
|
MOVQ $0, DI // arg 1 - notdead
|
|
|
|
MOVL $302, AX // sys___threxit
|
2011-08-08 07:56:38 -06:00
|
|
|
SYSCALL
|
2011-08-29 07:35:13 -06:00
|
|
|
JMP -3(PC) // keep exiting
|
2011-08-08 07:56:38 -06:00
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·osyield(SB),NOSPLIT,$0
|
2012-11-21 07:25:53 -07:00
|
|
|
MOVL $298, AX // sys_sched_yield
|
2011-08-08 07:56:38 -06:00
|
|
|
SYSCALL
|
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·thrsleep(SB),NOSPLIT,$0
|
2011-10-08 07:56:13 -06:00
|
|
|
MOVQ 8(SP), DI // arg 1 - ident
|
|
|
|
MOVL 16(SP), SI // arg 2 - clock_id
|
|
|
|
MOVQ 24(SP), DX // arg 3 - tp
|
|
|
|
MOVQ 32(SP), R10 // arg 4 - lock
|
2012-04-11 06:02:08 -06:00
|
|
|
MOVQ 40(SP), R8 // arg 5 - abort
|
2014-01-11 01:00:32 -07:00
|
|
|
MOVL $94, AX // sys___thrsleep
|
2011-08-08 07:56:38 -06:00
|
|
|
SYSCALL
|
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·thrwakeup(SB),NOSPLIT,$0
|
2011-10-08 07:56:13 -06:00
|
|
|
MOVQ 8(SP), DI // arg 1 - ident
|
|
|
|
MOVL 16(SP), SI // arg 2 - n
|
2012-04-11 06:02:08 -06:00
|
|
|
MOVL $301, AX // sys___thrwakeup
|
2011-08-08 07:56:38 -06:00
|
|
|
SYSCALL
|
|
|
|
RET
|
|
|
|
|
|
|
|
// Exit the entire program (like C exit)
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·exit(SB),NOSPLIT,$-8
|
2011-08-08 07:56:38 -06:00
|
|
|
MOVL 8(SP), DI // arg 1 - exit status
|
|
|
|
MOVL $1, AX // sys_exit
|
|
|
|
SYSCALL
|
2012-04-11 06:02:08 -06:00
|
|
|
MOVL $0xf1, 0xf1 // crash
|
2011-08-08 07:56:38 -06:00
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·exit1(SB),NOSPLIT,$-8
|
2012-04-11 06:02:08 -06:00
|
|
|
MOVQ $0, DI // arg 1 - notdead
|
|
|
|
MOVL $302, AX // sys___threxit
|
2011-08-08 07:56:38 -06:00
|
|
|
SYSCALL
|
2012-04-11 06:02:08 -06:00
|
|
|
MOVL $0xf1, 0xf1 // crash
|
2011-08-08 07:56:38 -06:00
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·open(SB),NOSPLIT,$-8
|
2013-03-12 11:47:44 -06:00
|
|
|
MOVQ 8(SP), DI // arg 1 pathname
|
|
|
|
MOVL 16(SP), SI // arg 2 flags
|
|
|
|
MOVL 20(SP), DX // arg 3 mode
|
|
|
|
MOVL $5, AX
|
|
|
|
SYSCALL
|
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·close(SB),NOSPLIT,$-8
|
2013-03-12 11:47:44 -06:00
|
|
|
MOVL 8(SP), DI // arg 1 fd
|
|
|
|
MOVL $6, AX
|
|
|
|
SYSCALL
|
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·read(SB),NOSPLIT,$-8
|
2013-03-12 11:47:44 -06:00
|
|
|
MOVL 8(SP), DI // arg 1 fd
|
|
|
|
MOVQ 16(SP), SI // arg 2 buf
|
|
|
|
MOVL 24(SP), DX // arg 3 count
|
|
|
|
MOVL $3, AX
|
|
|
|
SYSCALL
|
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·write(SB),NOSPLIT,$-8
|
2011-08-08 07:56:38 -06:00
|
|
|
MOVL 8(SP), DI // arg 1 - fd
|
|
|
|
MOVQ 16(SP), SI // arg 2 - buf
|
|
|
|
MOVL 24(SP), DX // arg 3 - nbyte
|
|
|
|
MOVL $4, AX // sys_write
|
|
|
|
SYSCALL
|
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·usleep(SB),NOSPLIT,$16
|
2011-10-01 12:58:36 -06:00
|
|
|
MOVL $0, DX
|
|
|
|
MOVL usec+0(FP), AX
|
|
|
|
MOVL $1000000, CX
|
|
|
|
DIVL CX
|
|
|
|
MOVQ AX, 0(SP) // tv_sec
|
|
|
|
MOVL $1000, AX
|
|
|
|
MULL DX
|
|
|
|
MOVQ AX, 8(SP) // tv_nsec
|
|
|
|
|
|
|
|
MOVQ SP, DI // arg 1 - rqtp
|
|
|
|
MOVQ $0, SI // arg 2 - rmtp
|
2014-01-11 01:00:32 -07:00
|
|
|
MOVL $91, AX // sys_nanosleep
|
2011-10-01 12:58:36 -06:00
|
|
|
SYSCALL
|
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·raise(SB),NOSPLIT,$16
|
2011-08-08 07:56:38 -06:00
|
|
|
MOVL $299, AX // sys_getthrid
|
|
|
|
SYSCALL
|
|
|
|
MOVQ AX, DI // arg 1 - pid
|
2014-01-11 01:00:32 -07:00
|
|
|
MOVL sig+0(FP), SI // arg 2 - signum
|
2011-08-08 07:56:38 -06:00
|
|
|
MOVL $37, AX // sys_kill
|
|
|
|
SYSCALL
|
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·setitimer(SB),NOSPLIT,$-8
|
2011-08-08 07:56:38 -06:00
|
|
|
MOVL 8(SP), DI // arg 1 - which
|
|
|
|
MOVQ 16(SP), SI // arg 2 - itv
|
|
|
|
MOVQ 24(SP), DX // arg 3 - oitv
|
2014-01-11 01:00:32 -07:00
|
|
|
MOVL $69, AX // sys_setitimer
|
2011-08-08 07:56:38 -06:00
|
|
|
SYSCALL
|
|
|
|
RET
|
|
|
|
|
2011-11-30 09:59:44 -07:00
|
|
|
// func now() (sec int64, nsec int32)
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT time·now(SB), NOSPLIT, $32
|
runtime: use clock_gettime to get ns resolution for time.now & runtime.nanotime
For Linux/{386,arm}, FreeBSD/{386,amd64,arm}, NetBSD/{386,amd64}, OpenBSD/{386,amd64}.
Note: our Darwin implementation already has ns resolution.
Linux/386 (Core i7-2600 @ 3.40GHz, kernel 3.5.2-gentoo)
benchmark old ns/op new ns/op delta
BenchmarkNow 110 118 +7.27%
Linux/ARM (ARM Cortex-A8 @ 800MHz, kernel 2.6.32.28 android)
benchmark old ns/op new ns/op delta
BenchmarkNow 625 542 -13.28%
Linux/ARM (ARM Cortex-A9 @ 1GHz, Pandaboard)
benchmark old ns/op new ns/op delta
BenchmarkNow 992 909 -8.37%
FreeBSD 9-REL-p1/amd64 (Dell R610 Server with Xeon X5650 @ 2.67GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 699 695 -0.57%
FreeBSD 9-REL-p1/amd64 (Atom D525 @ 1.80GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 1553 1658 +6.76%
OpenBSD/amd64 (Dell E6410 with i5 CPU M 540 @ 2.53GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 1262 1236 -2.06%
OpenBSD/i386 (Asus eeePC 701 with Intel Celeron M 900MHz - locked to 631MHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 5089 5043 -0.90%
NetBSD/i386 (VMware VM with Core i5 CPU @ 2.7GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 277 278 +0.36%
NetBSD/amd64 (VMware VM with Core i5 CPU @ 2.7Ghz)
benchmark old ns/op new ns/op delta
BenchmarkNow 103 105 +1.94%
Thanks Maxim Khitrov, Joel Sing, and Dave Cheney for providing benchmark data.
R=jsing, dave, rsc
CC=golang-dev
https://golang.org/cl/6820120
2012-12-18 07:57:25 -07:00
|
|
|
MOVQ $0, DI // arg 1 - clock_id
|
|
|
|
LEAQ 8(SP), SI // arg 2 - tp
|
2014-01-11 01:00:32 -07:00
|
|
|
MOVL $87, AX // sys_clock_gettime
|
2011-11-30 09:59:44 -07:00
|
|
|
SYSCALL
|
2014-01-11 01:00:32 -07:00
|
|
|
MOVQ 8(SP), AX // sec
|
runtime: use clock_gettime to get ns resolution for time.now & runtime.nanotime
For Linux/{386,arm}, FreeBSD/{386,amd64,arm}, NetBSD/{386,amd64}, OpenBSD/{386,amd64}.
Note: our Darwin implementation already has ns resolution.
Linux/386 (Core i7-2600 @ 3.40GHz, kernel 3.5.2-gentoo)
benchmark old ns/op new ns/op delta
BenchmarkNow 110 118 +7.27%
Linux/ARM (ARM Cortex-A8 @ 800MHz, kernel 2.6.32.28 android)
benchmark old ns/op new ns/op delta
BenchmarkNow 625 542 -13.28%
Linux/ARM (ARM Cortex-A9 @ 1GHz, Pandaboard)
benchmark old ns/op new ns/op delta
BenchmarkNow 992 909 -8.37%
FreeBSD 9-REL-p1/amd64 (Dell R610 Server with Xeon X5650 @ 2.67GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 699 695 -0.57%
FreeBSD 9-REL-p1/amd64 (Atom D525 @ 1.80GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 1553 1658 +6.76%
OpenBSD/amd64 (Dell E6410 with i5 CPU M 540 @ 2.53GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 1262 1236 -2.06%
OpenBSD/i386 (Asus eeePC 701 with Intel Celeron M 900MHz - locked to 631MHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 5089 5043 -0.90%
NetBSD/i386 (VMware VM with Core i5 CPU @ 2.7GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 277 278 +0.36%
NetBSD/amd64 (VMware VM with Core i5 CPU @ 2.7Ghz)
benchmark old ns/op new ns/op delta
BenchmarkNow 103 105 +1.94%
Thanks Maxim Khitrov, Joel Sing, and Dave Cheney for providing benchmark data.
R=jsing, dave, rsc
CC=golang-dev
https://golang.org/cl/6820120
2012-12-18 07:57:25 -07:00
|
|
|
MOVQ 16(SP), DX // nsec
|
2011-11-30 09:59:44 -07:00
|
|
|
|
runtime: use clock_gettime to get ns resolution for time.now & runtime.nanotime
For Linux/{386,arm}, FreeBSD/{386,amd64,arm}, NetBSD/{386,amd64}, OpenBSD/{386,amd64}.
Note: our Darwin implementation already has ns resolution.
Linux/386 (Core i7-2600 @ 3.40GHz, kernel 3.5.2-gentoo)
benchmark old ns/op new ns/op delta
BenchmarkNow 110 118 +7.27%
Linux/ARM (ARM Cortex-A8 @ 800MHz, kernel 2.6.32.28 android)
benchmark old ns/op new ns/op delta
BenchmarkNow 625 542 -13.28%
Linux/ARM (ARM Cortex-A9 @ 1GHz, Pandaboard)
benchmark old ns/op new ns/op delta
BenchmarkNow 992 909 -8.37%
FreeBSD 9-REL-p1/amd64 (Dell R610 Server with Xeon X5650 @ 2.67GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 699 695 -0.57%
FreeBSD 9-REL-p1/amd64 (Atom D525 @ 1.80GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 1553 1658 +6.76%
OpenBSD/amd64 (Dell E6410 with i5 CPU M 540 @ 2.53GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 1262 1236 -2.06%
OpenBSD/i386 (Asus eeePC 701 with Intel Celeron M 900MHz - locked to 631MHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 5089 5043 -0.90%
NetBSD/i386 (VMware VM with Core i5 CPU @ 2.7GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 277 278 +0.36%
NetBSD/amd64 (VMware VM with Core i5 CPU @ 2.7Ghz)
benchmark old ns/op new ns/op delta
BenchmarkNow 103 105 +1.94%
Thanks Maxim Khitrov, Joel Sing, and Dave Cheney for providing benchmark data.
R=jsing, dave, rsc
CC=golang-dev
https://golang.org/cl/6820120
2012-12-18 07:57:25 -07:00
|
|
|
// sec is in AX, nsec in DX
|
2011-11-30 09:59:44 -07:00
|
|
|
MOVQ AX, sec+0(FP)
|
|
|
|
MOVL DX, nsec+8(FP)
|
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·nanotime(SB),NOSPLIT,$24
|
runtime: use clock_gettime to get ns resolution for time.now & runtime.nanotime
For Linux/{386,arm}, FreeBSD/{386,amd64,arm}, NetBSD/{386,amd64}, OpenBSD/{386,amd64}.
Note: our Darwin implementation already has ns resolution.
Linux/386 (Core i7-2600 @ 3.40GHz, kernel 3.5.2-gentoo)
benchmark old ns/op new ns/op delta
BenchmarkNow 110 118 +7.27%
Linux/ARM (ARM Cortex-A8 @ 800MHz, kernel 2.6.32.28 android)
benchmark old ns/op new ns/op delta
BenchmarkNow 625 542 -13.28%
Linux/ARM (ARM Cortex-A9 @ 1GHz, Pandaboard)
benchmark old ns/op new ns/op delta
BenchmarkNow 992 909 -8.37%
FreeBSD 9-REL-p1/amd64 (Dell R610 Server with Xeon X5650 @ 2.67GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 699 695 -0.57%
FreeBSD 9-REL-p1/amd64 (Atom D525 @ 1.80GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 1553 1658 +6.76%
OpenBSD/amd64 (Dell E6410 with i5 CPU M 540 @ 2.53GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 1262 1236 -2.06%
OpenBSD/i386 (Asus eeePC 701 with Intel Celeron M 900MHz - locked to 631MHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 5089 5043 -0.90%
NetBSD/i386 (VMware VM with Core i5 CPU @ 2.7GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 277 278 +0.36%
NetBSD/amd64 (VMware VM with Core i5 CPU @ 2.7Ghz)
benchmark old ns/op new ns/op delta
BenchmarkNow 103 105 +1.94%
Thanks Maxim Khitrov, Joel Sing, and Dave Cheney for providing benchmark data.
R=jsing, dave, rsc
CC=golang-dev
https://golang.org/cl/6820120
2012-12-18 07:57:25 -07:00
|
|
|
MOVQ $0, DI // arg 1 - clock_id
|
|
|
|
LEAQ 8(SP), SI // arg 2 - tp
|
2014-01-11 01:00:32 -07:00
|
|
|
MOVL $87, AX // sys_clock_gettime
|
2011-08-08 07:56:38 -06:00
|
|
|
SYSCALL
|
2014-01-11 01:00:32 -07:00
|
|
|
MOVQ 8(SP), AX // sec
|
runtime: use clock_gettime to get ns resolution for time.now & runtime.nanotime
For Linux/{386,arm}, FreeBSD/{386,amd64,arm}, NetBSD/{386,amd64}, OpenBSD/{386,amd64}.
Note: our Darwin implementation already has ns resolution.
Linux/386 (Core i7-2600 @ 3.40GHz, kernel 3.5.2-gentoo)
benchmark old ns/op new ns/op delta
BenchmarkNow 110 118 +7.27%
Linux/ARM (ARM Cortex-A8 @ 800MHz, kernel 2.6.32.28 android)
benchmark old ns/op new ns/op delta
BenchmarkNow 625 542 -13.28%
Linux/ARM (ARM Cortex-A9 @ 1GHz, Pandaboard)
benchmark old ns/op new ns/op delta
BenchmarkNow 992 909 -8.37%
FreeBSD 9-REL-p1/amd64 (Dell R610 Server with Xeon X5650 @ 2.67GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 699 695 -0.57%
FreeBSD 9-REL-p1/amd64 (Atom D525 @ 1.80GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 1553 1658 +6.76%
OpenBSD/amd64 (Dell E6410 with i5 CPU M 540 @ 2.53GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 1262 1236 -2.06%
OpenBSD/i386 (Asus eeePC 701 with Intel Celeron M 900MHz - locked to 631MHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 5089 5043 -0.90%
NetBSD/i386 (VMware VM with Core i5 CPU @ 2.7GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 277 278 +0.36%
NetBSD/amd64 (VMware VM with Core i5 CPU @ 2.7Ghz)
benchmark old ns/op new ns/op delta
BenchmarkNow 103 105 +1.94%
Thanks Maxim Khitrov, Joel Sing, and Dave Cheney for providing benchmark data.
R=jsing, dave, rsc
CC=golang-dev
https://golang.org/cl/6820120
2012-12-18 07:57:25 -07:00
|
|
|
MOVQ 16(SP), DX // nsec
|
2011-11-03 15:35:28 -06:00
|
|
|
|
runtime: use clock_gettime to get ns resolution for time.now & runtime.nanotime
For Linux/{386,arm}, FreeBSD/{386,amd64,arm}, NetBSD/{386,amd64}, OpenBSD/{386,amd64}.
Note: our Darwin implementation already has ns resolution.
Linux/386 (Core i7-2600 @ 3.40GHz, kernel 3.5.2-gentoo)
benchmark old ns/op new ns/op delta
BenchmarkNow 110 118 +7.27%
Linux/ARM (ARM Cortex-A8 @ 800MHz, kernel 2.6.32.28 android)
benchmark old ns/op new ns/op delta
BenchmarkNow 625 542 -13.28%
Linux/ARM (ARM Cortex-A9 @ 1GHz, Pandaboard)
benchmark old ns/op new ns/op delta
BenchmarkNow 992 909 -8.37%
FreeBSD 9-REL-p1/amd64 (Dell R610 Server with Xeon X5650 @ 2.67GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 699 695 -0.57%
FreeBSD 9-REL-p1/amd64 (Atom D525 @ 1.80GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 1553 1658 +6.76%
OpenBSD/amd64 (Dell E6410 with i5 CPU M 540 @ 2.53GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 1262 1236 -2.06%
OpenBSD/i386 (Asus eeePC 701 with Intel Celeron M 900MHz - locked to 631MHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 5089 5043 -0.90%
NetBSD/i386 (VMware VM with Core i5 CPU @ 2.7GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 277 278 +0.36%
NetBSD/amd64 (VMware VM with Core i5 CPU @ 2.7Ghz)
benchmark old ns/op new ns/op delta
BenchmarkNow 103 105 +1.94%
Thanks Maxim Khitrov, Joel Sing, and Dave Cheney for providing benchmark data.
R=jsing, dave, rsc
CC=golang-dev
https://golang.org/cl/6820120
2012-12-18 07:57:25 -07:00
|
|
|
// sec is in AX, nsec in DX
|
2011-11-03 15:35:28 -06:00
|
|
|
// return nsec in AX
|
|
|
|
IMULQ $1000000000, AX
|
|
|
|
ADDQ DX, AX
|
2011-08-08 07:56:38 -06:00
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·sigaction(SB),NOSPLIT,$-8
|
2011-08-08 07:56:38 -06:00
|
|
|
MOVL 8(SP), DI // arg 1 - signum
|
|
|
|
MOVQ 16(SP), SI // arg 2 - nsa
|
|
|
|
MOVQ 24(SP), DX // arg 3 - osa
|
|
|
|
MOVL $46, AX
|
|
|
|
SYSCALL
|
|
|
|
JCC 2(PC)
|
2012-04-11 06:02:08 -06:00
|
|
|
MOVL $0xf1, 0xf1 // crash
|
2011-08-08 07:56:38 -06:00
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·sigprocmask(SB),NOSPLIT,$0
|
2012-04-10 05:57:05 -06:00
|
|
|
MOVL 8(SP), DI // arg 1 - how
|
|
|
|
MOVL 12(SP), SI // arg 2 - set
|
|
|
|
MOVL $48, AX // sys_sigprocmask
|
|
|
|
SYSCALL
|
|
|
|
JCC 2(PC)
|
2012-04-11 06:02:08 -06:00
|
|
|
MOVL $0xf1, 0xf1 // crash
|
2012-04-10 05:57:05 -06:00
|
|
|
MOVL AX, oset+0(FP) // Return oset
|
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·sigtramp(SB),NOSPLIT,$64
|
2011-08-08 07:56:38 -06:00
|
|
|
get_tls(BX)
|
|
|
|
|
2012-03-12 13:55:18 -06:00
|
|
|
// check that m exists
|
|
|
|
MOVQ m(BX), BP
|
|
|
|
CMPQ BP, $0
|
2013-07-11 14:39:39 -06:00
|
|
|
JNE 5(PC)
|
2012-09-04 12:40:49 -06:00
|
|
|
MOVQ DI, 0(SP)
|
2013-07-11 14:39:39 -06:00
|
|
|
MOVQ $runtime·badsignal(SB), AX
|
|
|
|
CALL AX
|
2012-09-04 12:40:49 -06:00
|
|
|
RET
|
2012-03-12 13:55:18 -06:00
|
|
|
|
2011-08-08 07:56:38 -06:00
|
|
|
// save g
|
|
|
|
MOVQ g(BX), R10
|
|
|
|
MOVQ R10, 40(SP)
|
|
|
|
|
|
|
|
// g = m->signal
|
|
|
|
MOVQ m_gsignal(BP), BP
|
|
|
|
MOVQ BP, g(BX)
|
|
|
|
|
|
|
|
MOVQ DI, 0(SP)
|
|
|
|
MOVQ SI, 8(SP)
|
|
|
|
MOVQ DX, 16(SP)
|
|
|
|
MOVQ R10, 24(SP)
|
|
|
|
|
|
|
|
CALL runtime·sighandler(SB)
|
|
|
|
|
|
|
|
// restore g
|
|
|
|
get_tls(BX)
|
|
|
|
MOVQ 40(SP), R10
|
|
|
|
MOVQ R10, g(BX)
|
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·mmap(SB),NOSPLIT,$0
|
2011-08-08 07:56:38 -06:00
|
|
|
MOVQ 8(SP), DI // arg 1 - addr
|
|
|
|
MOVQ 16(SP), SI // arg 2 - len
|
|
|
|
MOVL 24(SP), DX // arg 3 - prot
|
|
|
|
MOVL 28(SP), R10 // arg 4 - flags
|
|
|
|
MOVL 32(SP), R8 // arg 5 - fd
|
|
|
|
MOVQ 36(SP), R9
|
|
|
|
SUBQ $16, SP
|
|
|
|
MOVQ R9, 8(SP) // arg 7 - offset (passed on stack)
|
|
|
|
MOVQ $0, R9 // arg 6 - pad
|
|
|
|
MOVL $197, AX
|
|
|
|
SYSCALL
|
|
|
|
ADDQ $16, SP
|
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·munmap(SB),NOSPLIT,$0
|
2011-08-08 07:56:38 -06:00
|
|
|
MOVQ 8(SP), DI // arg 1 - addr
|
|
|
|
MOVQ 16(SP), SI // arg 2 - len
|
|
|
|
MOVL $73, AX // sys_munmap
|
|
|
|
SYSCALL
|
|
|
|
JCC 2(PC)
|
2012-04-11 06:02:08 -06:00
|
|
|
MOVL $0xf1, 0xf1 // crash
|
2011-08-08 07:56:38 -06:00
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·madvise(SB),NOSPLIT,$0
|
2012-11-26 04:32:59 -07:00
|
|
|
MOVQ addr+0(FP), DI // arg 1 - addr
|
|
|
|
MOVQ len+8(FP), SI // arg 2 - len
|
|
|
|
MOVQ behav+16(FP), DX // arg 3 - behav
|
|
|
|
MOVQ $75, AX // sys_madvise
|
|
|
|
SYSCALL
|
2012-12-22 13:06:28 -07:00
|
|
|
// ignore failure - maybe pages are locked
|
2012-11-26 04:32:59 -07:00
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·sigaltstack(SB),NOSPLIT,$-8
|
2011-08-08 07:56:38 -06:00
|
|
|
MOVQ new+8(SP), DI // arg 1 - nss
|
|
|
|
MOVQ old+16(SP), SI // arg 2 - oss
|
|
|
|
MOVQ $288, AX // sys_sigaltstack
|
|
|
|
SYSCALL
|
|
|
|
JCC 2(PC)
|
2012-04-11 06:02:08 -06:00
|
|
|
MOVL $0xf1, 0xf1 // crash
|
2011-08-08 07:56:38 -06:00
|
|
|
RET
|
|
|
|
|
|
|
|
// set tls base to DI
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·settls(SB),NOSPLIT,$0
|
2011-08-08 07:56:38 -06:00
|
|
|
// adjust for ELF: wants to use -16(FS) and -8(FS) for g and m
|
|
|
|
ADDQ $16, DI
|
2012-11-21 07:25:53 -07:00
|
|
|
MOVQ $329, AX // sys___settcb
|
2011-08-08 07:56:38 -06:00
|
|
|
SYSCALL
|
|
|
|
JCC 2(PC)
|
2012-04-11 06:02:08 -06:00
|
|
|
MOVL $0xf1, 0xf1 // crash
|
2011-08-08 07:56:38 -06:00
|
|
|
RET
|
2011-10-05 11:16:43 -06:00
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·sysctl(SB),NOSPLIT,$0
|
2011-10-05 11:16:43 -06:00
|
|
|
MOVQ 8(SP), DI // arg 1 - name
|
|
|
|
MOVL 16(SP), SI // arg 2 - namelen
|
|
|
|
MOVQ 24(SP), DX // arg 3 - oldp
|
|
|
|
MOVQ 32(SP), R10 // arg 4 - oldlenp
|
|
|
|
MOVQ 40(SP), R8 // arg 5 - newp
|
|
|
|
MOVQ 48(SP), R9 // arg 6 - newlen
|
|
|
|
MOVQ $202, AX // sys___sysctl
|
|
|
|
SYSCALL
|
2012-04-11 06:02:08 -06:00
|
|
|
JCC 3(PC)
|
2013-03-14 21:42:11 -06:00
|
|
|
NEGQ AX
|
2011-10-05 11:16:43 -06:00
|
|
|
RET
|
|
|
|
MOVL $0, AX
|
|
|
|
RET
|
|
|
|
|
2013-05-20 04:25:32 -06:00
|
|
|
// int32 runtime·kqueue(void);
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·kqueue(SB),NOSPLIT,$0
|
2013-05-20 04:25:32 -06:00
|
|
|
MOVQ $0, DI
|
|
|
|
MOVQ $0, SI
|
|
|
|
MOVQ $0, DX
|
|
|
|
MOVL $269, AX
|
|
|
|
SYSCALL
|
|
|
|
JCC 2(PC)
|
|
|
|
NEGQ AX
|
|
|
|
RET
|
|
|
|
|
|
|
|
// int32 runtime·kevent(int kq, Kevent *changelist, int nchanges, Kevent *eventlist, int nevents, Timespec *timeout);
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·kevent(SB),NOSPLIT,$0
|
2013-05-20 04:25:32 -06:00
|
|
|
MOVL 8(SP), DI
|
|
|
|
MOVQ 16(SP), SI
|
|
|
|
MOVL 24(SP), DX
|
|
|
|
MOVQ 32(SP), R10
|
|
|
|
MOVL 40(SP), R8
|
|
|
|
MOVQ 48(SP), R9
|
2014-01-11 01:00:32 -07:00
|
|
|
MOVL $72, AX
|
2013-05-20 04:25:32 -06:00
|
|
|
SYSCALL
|
|
|
|
JCC 2(PC)
|
|
|
|
NEGQ AX
|
|
|
|
RET
|
|
|
|
|
|
|
|
// void runtime·closeonexec(int32 fd);
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·closeonexec(SB),NOSPLIT,$0
|
2013-05-20 04:25:32 -06:00
|
|
|
MOVL 8(SP), DI // fd
|
|
|
|
MOVQ $2, SI // F_SETFD
|
|
|
|
MOVQ $1, DX // FD_CLOEXEC
|
|
|
|
MOVL $92, AX // fcntl
|
|
|
|
SYSCALL
|
|
|
|
RET
|