2009-03-31 16:45:12 -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 386, Darwin
|
2018-06-13 15:39:36 -06:00
|
|
|
// System calls are implemented in libSystem, this file contains
|
|
|
|
// trampolines that convert from Go to C calling convention.
|
2009-03-31 16:45:12 -06: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
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"
|
2009-06-17 16:15:55 -06:00
|
|
|
|
2009-03-31 16:45:12 -06:00
|
|
|
// Exit the entire program (like C exit)
|
2018-05-03 11:30:31 -06:00
|
|
|
TEXT runtime·exit_trampoline(SB),NOSPLIT,$0
|
2018-04-30 08:50:10 -06:00
|
|
|
PUSHL BP
|
|
|
|
MOVL SP, BP
|
2018-05-03 11:30:31 -06:00
|
|
|
SUBL $8, SP // allocate space for callee args (must be 8 mod 16)
|
|
|
|
MOVL 16(SP), CX // arg ptr
|
|
|
|
MOVL 0(CX), AX // arg 1 exit status
|
2018-04-30 08:50:10 -06:00
|
|
|
MOVL AX, 0(SP)
|
|
|
|
CALL libc_exit(SB)
|
2012-03-08 12:03:56 -07:00
|
|
|
MOVL $0xf1, 0xf1 // crash
|
2018-04-30 08:50:10 -06:00
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
2009-03-31 16:45:12 -06:00
|
|
|
RET
|
|
|
|
|
2018-05-03 11:30:31 -06:00
|
|
|
TEXT runtime·open_trampoline(SB),NOSPLIT,$0
|
2018-04-30 20:55:41 -06:00
|
|
|
PUSHL BP
|
|
|
|
MOVL SP, BP
|
2018-05-03 11:30:31 -06:00
|
|
|
SUBL $24, SP
|
|
|
|
MOVL 32(SP), CX
|
|
|
|
MOVL 0(CX), AX // arg 1 name
|
2018-04-30 20:55:41 -06:00
|
|
|
MOVL AX, 0(SP)
|
2018-05-03 11:30:31 -06:00
|
|
|
MOVL 4(CX), AX // arg 2 mode
|
|
|
|
MOVL AX, 4(SP)
|
|
|
|
MOVL 8(CX), AX // arg 3 perm
|
|
|
|
MOVL AX, 8(SP)
|
2018-04-30 20:55:41 -06:00
|
|
|
CALL libc_open(SB)
|
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
2013-03-12 11:47:44 -06:00
|
|
|
RET
|
|
|
|
|
2018-05-03 11:30:31 -06:00
|
|
|
TEXT runtime·close_trampoline(SB),NOSPLIT,$0
|
2018-04-30 20:55:41 -06:00
|
|
|
PUSHL BP
|
|
|
|
MOVL SP, BP
|
2018-05-03 11:30:31 -06:00
|
|
|
SUBL $8, SP
|
|
|
|
MOVL 16(SP), CX
|
|
|
|
MOVL 0(CX), AX // arg 1 fd
|
2018-04-30 20:55:41 -06:00
|
|
|
MOVL AX, 0(SP)
|
|
|
|
CALL libc_close(SB)
|
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
2013-03-12 11:47:44 -06:00
|
|
|
RET
|
|
|
|
|
2018-05-03 11:30:31 -06:00
|
|
|
TEXT runtime·read_trampoline(SB),NOSPLIT,$0
|
2018-04-30 20:55:41 -06:00
|
|
|
PUSHL BP
|
|
|
|
MOVL SP, BP
|
2018-05-03 11:30:31 -06:00
|
|
|
SUBL $24, SP
|
|
|
|
MOVL 32(SP), CX
|
|
|
|
MOVL 0(CX), AX // arg 1 fd
|
2018-04-30 20:55:41 -06:00
|
|
|
MOVL AX, 0(SP)
|
2018-05-03 11:30:31 -06:00
|
|
|
MOVL 4(CX), AX // arg 2 buf
|
|
|
|
MOVL AX, 4(SP)
|
|
|
|
MOVL 8(CX), AX // arg 3 count
|
|
|
|
MOVL AX, 8(SP)
|
2018-04-30 20:55:41 -06:00
|
|
|
CALL libc_read(SB)
|
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
2013-03-12 11:47:44 -06:00
|
|
|
RET
|
|
|
|
|
2018-05-03 11:30:31 -06:00
|
|
|
TEXT runtime·write_trampoline(SB),NOSPLIT,$0
|
2018-04-30 20:55:41 -06:00
|
|
|
PUSHL BP
|
|
|
|
MOVL SP, BP
|
2018-05-03 11:30:31 -06:00
|
|
|
SUBL $24, SP
|
|
|
|
MOVL 32(SP), CX
|
|
|
|
MOVL 0(CX), AX // arg 1 fd
|
2018-04-30 20:55:41 -06:00
|
|
|
MOVL AX, 0(SP)
|
2018-05-03 11:30:31 -06:00
|
|
|
MOVL 4(CX), AX // arg 2 buf
|
|
|
|
MOVL AX, 4(SP)
|
|
|
|
MOVL 8(CX), AX // arg 3 count
|
|
|
|
MOVL AX, 8(SP)
|
2018-04-30 20:55:41 -06:00
|
|
|
CALL libc_write(SB)
|
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
2009-03-31 16:45:12 -06:00
|
|
|
RET
|
|
|
|
|
2018-05-03 11:30:31 -06:00
|
|
|
TEXT runtime·mmap_trampoline(SB),NOSPLIT,$0
|
2018-04-30 20:25:46 -06:00
|
|
|
PUSHL BP
|
|
|
|
MOVL SP, BP
|
|
|
|
SUBL $24, SP
|
2018-05-03 11:30:31 -06:00
|
|
|
MOVL 32(SP), CX
|
|
|
|
MOVL 0(CX), AX // arg 1 addr
|
2018-04-30 20:25:46 -06:00
|
|
|
MOVL AX, 0(SP)
|
2018-05-03 11:30:31 -06:00
|
|
|
MOVL 4(CX), AX // arg 2 len
|
|
|
|
MOVL AX, 4(SP)
|
|
|
|
MOVL 8(CX), AX // arg 3 prot
|
|
|
|
MOVL AX, 8(SP)
|
|
|
|
MOVL 12(CX), AX // arg 4 flags
|
|
|
|
MOVL AX, 12(SP)
|
|
|
|
MOVL 16(CX), AX // arg 5 fid
|
|
|
|
MOVL AX, 16(SP)
|
|
|
|
MOVL 20(CX), AX // arg 6 offset
|
|
|
|
MOVL AX, 20(SP)
|
2018-04-30 20:25:46 -06:00
|
|
|
CALL libc_mmap(SB)
|
|
|
|
XORL DX, DX
|
|
|
|
CMPL AX, $-1
|
|
|
|
JNE ok
|
|
|
|
CALL libc_error(SB)
|
|
|
|
MOVL (AX), DX // errno
|
|
|
|
XORL AX, AX
|
2017-10-16 18:28:29 -06:00
|
|
|
ok:
|
2018-05-03 11:30:31 -06:00
|
|
|
MOVL 32(SP), CX
|
|
|
|
MOVL AX, 24(CX) // result pointer
|
|
|
|
MOVL DX, 28(CX) // errno
|
2018-04-30 20:25:46 -06:00
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
2009-03-31 16:45:12 -06:00
|
|
|
RET
|
|
|
|
|
2018-05-03 11:30:31 -06:00
|
|
|
TEXT runtime·madvise_trampoline(SB),NOSPLIT,$0
|
2018-04-30 20:25:46 -06:00
|
|
|
PUSHL BP
|
|
|
|
MOVL SP, BP
|
2018-05-03 11:30:31 -06:00
|
|
|
SUBL $24, SP
|
|
|
|
MOVL 32(SP), CX
|
|
|
|
MOVL 0(CX), AX // arg 1 addr
|
2018-04-30 20:25:46 -06:00
|
|
|
MOVL AX, 0(SP)
|
2018-05-03 11:30:31 -06:00
|
|
|
MOVL 4(CX), AX // arg 2 len
|
|
|
|
MOVL AX, 4(SP)
|
|
|
|
MOVL 8(CX), AX // arg 3 advice
|
|
|
|
MOVL AX, 8(SP)
|
2018-04-30 20:25:46 -06:00
|
|
|
CALL libc_madvise(SB)
|
2012-12-22 13:06:28 -07:00
|
|
|
// ignore failure - maybe pages are locked
|
2018-04-30 20:25:46 -06:00
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
2012-01-19 13:51:29 -07:00
|
|
|
RET
|
|
|
|
|
2018-05-03 11:30:31 -06:00
|
|
|
TEXT runtime·munmap_trampoline(SB),NOSPLIT,$0
|
2018-04-30 20:25:46 -06:00
|
|
|
PUSHL BP
|
|
|
|
MOVL SP, BP
|
|
|
|
SUBL $8, SP
|
2018-05-03 11:30:31 -06:00
|
|
|
MOVL 16(SP), CX
|
|
|
|
MOVL 0(CX), AX // arg 1 addr
|
2018-04-30 20:25:46 -06:00
|
|
|
MOVL AX, 0(SP)
|
2018-05-03 11:30:31 -06:00
|
|
|
MOVL 4(CX), AX // arg 2 len
|
|
|
|
MOVL AX, 4(SP)
|
2018-04-30 20:25:46 -06:00
|
|
|
CALL libc_munmap(SB)
|
|
|
|
TESTL AX, AX
|
|
|
|
JEQ 2(PC)
|
2012-03-08 12:03:56 -07:00
|
|
|
MOVL $0xf1, 0xf1 // crash
|
2018-04-30 20:25:46 -06:00
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
2010-09-07 07:57:22 -06:00
|
|
|
RET
|
|
|
|
|
2018-06-13 09:20:23 -06:00
|
|
|
TEXT runtime·setitimer_trampoline(SB),NOSPLIT,$0
|
|
|
|
PUSHL BP
|
|
|
|
MOVL SP, BP
|
|
|
|
SUBL $24, SP
|
|
|
|
MOVL 32(SP), CX
|
|
|
|
MOVL 0(CX), AX // arg 1 mode
|
|
|
|
MOVL AX, 0(SP)
|
|
|
|
MOVL 4(CX), AX // arg 2 new
|
|
|
|
MOVL AX, 4(SP)
|
|
|
|
MOVL 8(CX), AX // arg 3 old
|
|
|
|
MOVL AX, 8(SP)
|
|
|
|
CALL libc_setitimer(SB)
|
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
2011-03-23 09:31:42 -06:00
|
|
|
RET
|
|
|
|
|
2018-05-26 10:58:26 -06:00
|
|
|
TEXT runtime·walltime_trampoline(SB),NOSPLIT,$0
|
|
|
|
PUSHL BP
|
|
|
|
MOVL SP, BP
|
|
|
|
SUBL $8, SP
|
2016-08-01 22:54:40 -06:00
|
|
|
MOVL 16(SP), AX
|
2018-05-26 10:58:26 -06:00
|
|
|
MOVL AX, 0(SP) // *timeval
|
|
|
|
MOVL $0, 4(SP) // no timezone needed
|
|
|
|
CALL libc_gettimeofday(SB)
|
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
2012-06-05 14:23:30 -06:00
|
|
|
RET
|
2012-02-28 14:18:24 -07:00
|
|
|
|
2018-05-01 10:42:04 -06:00
|
|
|
GLOBL timebase<>(SB),NOPTR,$(machTimebaseInfo__size)
|
|
|
|
|
|
|
|
TEXT runtime·nanotime_trampoline(SB),NOSPLIT,$0
|
|
|
|
PUSHL BP
|
|
|
|
MOVL SP, BP
|
|
|
|
SUBL $8+(machTimebaseInfo__size+15)/16*16, SP
|
|
|
|
CALL libc_mach_absolute_time(SB)
|
|
|
|
MOVL 16+(machTimebaseInfo__size+15)/16*16(SP), CX
|
|
|
|
MOVL AX, 0(CX)
|
|
|
|
MOVL DX, 4(CX)
|
|
|
|
MOVL timebase<>+machTimebaseInfo_denom(SB), DI // atomic read
|
|
|
|
MOVL timebase<>+machTimebaseInfo_numer(SB), SI
|
|
|
|
TESTL DI, DI
|
|
|
|
JNE initialized
|
|
|
|
|
|
|
|
LEAL 4(SP), AX
|
|
|
|
MOVL AX, 0(SP)
|
|
|
|
CALL libc_mach_timebase_info(SB)
|
|
|
|
MOVL 4+machTimebaseInfo_numer(SP), SI
|
|
|
|
MOVL 4+machTimebaseInfo_denom(SP), DI
|
|
|
|
|
|
|
|
MOVL SI, timebase<>+machTimebaseInfo_numer(SB)
|
|
|
|
MOVL DI, AX
|
|
|
|
XCHGL AX, timebase<>+machTimebaseInfo_denom(SB) // atomic write
|
|
|
|
MOVL 16+(machTimebaseInfo__size+15)/16*16(SP), CX
|
|
|
|
|
|
|
|
initialized:
|
|
|
|
MOVL SI, 8(CX)
|
|
|
|
MOVL DI, 12(CX)
|
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
2010-02-08 15:32:22 -07:00
|
|
|
RET
|
|
|
|
|
2018-05-20 09:57:53 -06:00
|
|
|
TEXT runtime·sigaction_trampoline(SB),NOSPLIT,$0
|
|
|
|
PUSHL BP
|
|
|
|
MOVL SP, BP
|
|
|
|
SUBL $24, SP
|
|
|
|
MOVL 32(SP), CX
|
|
|
|
MOVL 0(CX), AX // arg 1 sig
|
|
|
|
MOVL AX, 0(SP)
|
|
|
|
MOVL 4(CX), AX // arg 2 new
|
|
|
|
MOVL AX, 4(SP)
|
|
|
|
MOVL 8(CX), AX // arg 3 old
|
|
|
|
MOVL AX, 8(SP)
|
|
|
|
CALL libc_sigaction(SB)
|
|
|
|
TESTL AX, AX
|
|
|
|
JEQ 2(PC)
|
2012-03-08 12:03:56 -07:00
|
|
|
MOVL $0xf1, 0xf1 // crash
|
2018-05-20 09:57:53 -06:00
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
2012-02-23 12:44:06 -07:00
|
|
|
RET
|
|
|
|
|
2018-05-20 09:57:53 -06:00
|
|
|
TEXT runtime·sigprocmask_trampoline(SB),NOSPLIT,$0
|
|
|
|
PUSHL BP
|
|
|
|
MOVL SP, BP
|
|
|
|
SUBL $24, SP
|
|
|
|
MOVL 32(SP), CX
|
|
|
|
MOVL 0(CX), AX // arg 1 how
|
|
|
|
MOVL AX, 0(SP)
|
|
|
|
MOVL 4(CX), AX // arg 2 new
|
|
|
|
MOVL AX, 4(SP)
|
|
|
|
MOVL 8(CX), AX // arg 3 old
|
|
|
|
MOVL AX, 8(SP)
|
|
|
|
CALL libc_pthread_sigmask(SB)
|
|
|
|
TESTL AX, AX
|
|
|
|
JEQ 2(PC)
|
|
|
|
MOVL $0xf1, 0xf1 // crash
|
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
|
|
|
RET
|
|
|
|
|
|
|
|
TEXT runtime·sigaltstack_trampoline(SB),NOSPLIT,$0
|
|
|
|
PUSHL BP
|
|
|
|
MOVL SP, BP
|
|
|
|
SUBL $8, SP
|
|
|
|
MOVL 16(SP), CX
|
|
|
|
MOVL 0(CX), AX // arg 1 new
|
|
|
|
MOVL AX, 0(SP)
|
|
|
|
MOVL 4(CX), AX // arg 2 old
|
|
|
|
MOVL AX, 4(SP)
|
|
|
|
CALL libc_sigaltstack(SB)
|
|
|
|
TESTL AX, AX
|
|
|
|
JEQ 2(PC)
|
2012-03-08 12:03:56 -07:00
|
|
|
MOVL $0xf1, 0xf1 // crash
|
2018-05-20 09:57:53 -06:00
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
|
|
|
RET
|
|
|
|
|
|
|
|
TEXT runtime·raiseproc_trampoline(SB),NOSPLIT,$0
|
|
|
|
PUSHL BP
|
|
|
|
MOVL SP, BP
|
|
|
|
SUBL $8, SP
|
|
|
|
CALL libc_getpid(SB)
|
|
|
|
MOVL AX, 0(SP) // arg 1 pid
|
|
|
|
MOVL 16(SP), CX
|
|
|
|
MOVL 0(CX), AX
|
|
|
|
MOVL AX, 4(SP) // arg 2 signal
|
|
|
|
CALL libc_kill(SB)
|
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
2009-03-31 16:45:12 -06:00
|
|
|
RET
|
|
|
|
|
2016-01-27 23:00:59 -07:00
|
|
|
TEXT runtime·sigfwd(SB),NOSPLIT,$0-16
|
2015-12-21 23:27:01 -07:00
|
|
|
MOVL fn+0(FP), AX
|
2016-01-27 23:00:59 -07:00
|
|
|
MOVL sig+4(FP), BX
|
|
|
|
MOVL info+8(FP), CX
|
|
|
|
MOVL ctx+12(FP), DX
|
|
|
|
MOVL SP, SI
|
2016-10-27 15:36:39 -06:00
|
|
|
SUBL $32, SP
|
|
|
|
ANDL $~15, SP // align stack: handler might be a C function
|
2016-01-27 23:00:59 -07:00
|
|
|
MOVL BX, 0(SP)
|
|
|
|
MOVL CX, 4(SP)
|
|
|
|
MOVL DX, 8(SP)
|
2016-10-27 15:36:39 -06:00
|
|
|
MOVL SI, 12(SP) // save SI: handler might be a Go function
|
2013-07-11 14:39:39 -06:00
|
|
|
CALL AX
|
2016-01-27 23:00:59 -07:00
|
|
|
MOVL 12(SP), AX
|
|
|
|
MOVL AX, SP
|
2015-12-21 23:27:01 -07:00
|
|
|
RET
|
runtime: parallelize garbage collector mark + sweep
Running test/garbage/parser.out.
On a 4-core Lenovo X201s (Linux):
31.12u 0.60s 31.74r 1 cpu, no atomics
32.27u 0.58s 32.86r 1 cpu, atomic instructions
33.04u 0.83s 27.47r 2 cpu
On a 16-core Xeon (Linux):
33.08u 0.65s 33.80r 1 cpu, no atomics
34.87u 1.12s 29.60r 2 cpu
36.00u 1.87s 28.43r 3 cpu
36.46u 2.34s 27.10r 4 cpu
38.28u 3.85s 26.92r 5 cpu
37.72u 5.25s 26.73r 6 cpu
39.63u 7.11s 26.95r 7 cpu
39.67u 8.10s 26.68r 8 cpu
On a 2-core MacBook Pro Core 2 Duo 2.26 (circa 2009, MacBookPro5,5):
39.43u 1.45s 41.27r 1 cpu, no atomics
43.98u 2.95s 38.69r 2 cpu
On a 2-core Mac Mini Core 2 Duo 1.83 (circa 2008; Macmini2,1):
48.81u 2.12s 51.76r 1 cpu, no atomics
57.15u 4.72s 51.54r 2 cpu
The handoff algorithm is really only good for two cores.
Beyond that we will need to so something more sophisticated,
like have each core hand off to the next one, around a circle.
Even so, the code is a good checkpoint; for now we'll limit the
number of gc procs to at most 2.
R=dvyukov
CC=golang-dev
https://golang.org/cl/4641082
2011-09-30 07:40:01 -06:00
|
|
|
|
2015-12-21 23:27:01 -07:00
|
|
|
// Sigtramp's job is to call the actual signal handler.
|
2018-05-20 09:57:53 -06:00
|
|
|
// It is called with the C calling convention, and calls out
|
|
|
|
// to sigtrampgo with the Go calling convention.
|
|
|
|
TEXT runtime·sigtramp(SB),NOSPLIT,$0
|
|
|
|
SUBL $28, SP
|
|
|
|
|
|
|
|
// Save callee-save registers.
|
|
|
|
MOVL BP, 12(SP)
|
|
|
|
MOVL BX, 16(SP)
|
|
|
|
MOVL SI, 20(SP)
|
|
|
|
MOVL DI, 24(SP)
|
|
|
|
|
|
|
|
MOVL 32(SP), AX
|
|
|
|
MOVL AX, 0(SP) // arg 1 signal number
|
|
|
|
MOVL 36(SP), AX
|
|
|
|
MOVL AX, 4(SP) // arg 2 siginfo
|
|
|
|
MOVL 40(SP), AX
|
|
|
|
MOVL AX, 8(SP) // arg 3 ctxt
|
2015-12-21 23:27:01 -07:00
|
|
|
CALL runtime·sigtrampgo(SB)
|
2009-11-16 18:51:47 -07:00
|
|
|
|
2018-05-20 09:57:53 -06:00
|
|
|
// Restore callee-save registers.
|
|
|
|
MOVL 12(SP), BP
|
|
|
|
MOVL 16(SP), BX
|
|
|
|
MOVL 20(SP), SI
|
|
|
|
MOVL 24(SP), DI
|
2009-03-31 16:45:12 -06:00
|
|
|
|
2018-05-20 09:57:53 -06:00
|
|
|
ADDL $28, SP
|
2009-03-31 16:45:12 -06:00
|
|
|
RET
|
|
|
|
|
2018-03-24 16:51:01 -06:00
|
|
|
TEXT runtime·cgoSigtramp(SB),NOSPLIT,$0
|
|
|
|
JMP runtime·sigtramp(SB)
|
|
|
|
|
2018-05-03 11:30:31 -06:00
|
|
|
TEXT runtime·usleep_trampoline(SB),NOSPLIT,$0
|
2018-04-30 20:25:46 -06:00
|
|
|
PUSHL BP
|
|
|
|
MOVL SP, BP
|
2018-05-03 11:30:31 -06:00
|
|
|
SUBL $8, SP
|
|
|
|
MOVL 16(SP), CX
|
|
|
|
MOVL 0(CX), AX // arg 1 usec
|
2018-04-30 20:25:46 -06:00
|
|
|
MOVL AX, 0(SP)
|
|
|
|
CALL libc_usleep(SB)
|
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
runtime: parallelize garbage collector mark + sweep
Running test/garbage/parser.out.
On a 4-core Lenovo X201s (Linux):
31.12u 0.60s 31.74r 1 cpu, no atomics
32.27u 0.58s 32.86r 1 cpu, atomic instructions
33.04u 0.83s 27.47r 2 cpu
On a 16-core Xeon (Linux):
33.08u 0.65s 33.80r 1 cpu, no atomics
34.87u 1.12s 29.60r 2 cpu
36.00u 1.87s 28.43r 3 cpu
36.46u 2.34s 27.10r 4 cpu
38.28u 3.85s 26.92r 5 cpu
37.72u 5.25s 26.73r 6 cpu
39.63u 7.11s 26.95r 7 cpu
39.67u 8.10s 26.68r 8 cpu
On a 2-core MacBook Pro Core 2 Duo 2.26 (circa 2009, MacBookPro5,5):
39.43u 1.45s 41.27r 1 cpu, no atomics
43.98u 2.95s 38.69r 2 cpu
On a 2-core Mac Mini Core 2 Duo 1.83 (circa 2008; Macmini2,1):
48.81u 2.12s 51.76r 1 cpu, no atomics
57.15u 4.72s 51.54r 2 cpu
The handoff algorithm is really only good for two cores.
Beyond that we will need to so something more sophisticated,
like have each core hand off to the next one, around a circle.
Even so, the code is a good checkpoint; for now we'll limit the
number of gc procs to at most 2.
R=dvyukov
CC=golang-dev
https://golang.org/cl/4641082
2011-09-30 07:40:01 -06:00
|
|
|
RET
|
|
|
|
|
2015-01-23 18:56:47 -07:00
|
|
|
// func setldt(entry int, address int, limit int)
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·setldt(SB),NOSPLIT,$32
|
2018-04-30 08:50:10 -06:00
|
|
|
// Nothing to do on Darwin, pthread already set thread-local storage up.
|
2009-03-31 16:45:12 -06:00
|
|
|
RET
|
runtime: parallelize garbage collector mark + sweep
Running test/garbage/parser.out.
On a 4-core Lenovo X201s (Linux):
31.12u 0.60s 31.74r 1 cpu, no atomics
32.27u 0.58s 32.86r 1 cpu, atomic instructions
33.04u 0.83s 27.47r 2 cpu
On a 16-core Xeon (Linux):
33.08u 0.65s 33.80r 1 cpu, no atomics
34.87u 1.12s 29.60r 2 cpu
36.00u 1.87s 28.43r 3 cpu
36.46u 2.34s 27.10r 4 cpu
38.28u 3.85s 26.92r 5 cpu
37.72u 5.25s 26.73r 6 cpu
39.63u 7.11s 26.95r 7 cpu
39.67u 8.10s 26.68r 8 cpu
On a 2-core MacBook Pro Core 2 Duo 2.26 (circa 2009, MacBookPro5,5):
39.43u 1.45s 41.27r 1 cpu, no atomics
43.98u 2.95s 38.69r 2 cpu
On a 2-core Mac Mini Core 2 Duo 1.83 (circa 2008; Macmini2,1):
48.81u 2.12s 51.76r 1 cpu, no atomics
57.15u 4.72s 51.54r 2 cpu
The handoff algorithm is really only good for two cores.
Beyond that we will need to so something more sophisticated,
like have each core hand off to the next one, around a circle.
Even so, the code is a good checkpoint; for now we'll limit the
number of gc procs to at most 2.
R=dvyukov
CC=golang-dev
https://golang.org/cl/4641082
2011-09-30 07:40:01 -06:00
|
|
|
|
2018-06-13 09:20:23 -06:00
|
|
|
TEXT runtime·sysctl_trampoline(SB),NOSPLIT,$0
|
|
|
|
PUSHL BP
|
|
|
|
MOVL SP, BP
|
|
|
|
SUBL $24, SP
|
|
|
|
MOVL 32(SP), CX
|
|
|
|
MOVL 0(CX), AX // arg 1 mib
|
|
|
|
MOVL AX, 0(SP)
|
|
|
|
MOVL 4(CX), AX // arg 2 miblen
|
|
|
|
MOVL AX, 4(SP)
|
|
|
|
MOVL 8(CX), AX // arg 3 out
|
|
|
|
MOVL AX, 8(SP)
|
|
|
|
MOVL 12(CX), AX // arg 4 size
|
|
|
|
MOVL AX, 12(SP)
|
|
|
|
MOVL 16(CX), AX // arg 5 dst
|
|
|
|
MOVL AX, 16(SP)
|
|
|
|
MOVL 20(CX), AX // arg 6 ndst
|
|
|
|
MOVL AX, 20(SP)
|
|
|
|
CALL libc_sysctl(SB)
|
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
runtime: parallelize garbage collector mark + sweep
Running test/garbage/parser.out.
On a 4-core Lenovo X201s (Linux):
31.12u 0.60s 31.74r 1 cpu, no atomics
32.27u 0.58s 32.86r 1 cpu, atomic instructions
33.04u 0.83s 27.47r 2 cpu
On a 16-core Xeon (Linux):
33.08u 0.65s 33.80r 1 cpu, no atomics
34.87u 1.12s 29.60r 2 cpu
36.00u 1.87s 28.43r 3 cpu
36.46u 2.34s 27.10r 4 cpu
38.28u 3.85s 26.92r 5 cpu
37.72u 5.25s 26.73r 6 cpu
39.63u 7.11s 26.95r 7 cpu
39.67u 8.10s 26.68r 8 cpu
On a 2-core MacBook Pro Core 2 Duo 2.26 (circa 2009, MacBookPro5,5):
39.43u 1.45s 41.27r 1 cpu, no atomics
43.98u 2.95s 38.69r 2 cpu
On a 2-core Mac Mini Core 2 Duo 1.83 (circa 2008; Macmini2,1):
48.81u 2.12s 51.76r 1 cpu, no atomics
57.15u 4.72s 51.54r 2 cpu
The handoff algorithm is really only good for two cores.
Beyond that we will need to so something more sophisticated,
like have each core hand off to the next one, around a circle.
Even so, the code is a good checkpoint; for now we'll limit the
number of gc procs to at most 2.
R=dvyukov
CC=golang-dev
https://golang.org/cl/4641082
2011-09-30 07:40:01 -06:00
|
|
|
RET
|
2013-03-14 00:38:37 -06:00
|
|
|
|
2018-06-13 09:20:23 -06:00
|
|
|
TEXT runtime·kqueue_trampoline(SB),NOSPLIT,$0
|
|
|
|
PUSHL BP
|
|
|
|
MOVL SP, BP
|
|
|
|
SUBL $8, SP
|
|
|
|
CALL libc_kqueue(SB)
|
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
2013-03-14 00:38:37 -06:00
|
|
|
RET
|
|
|
|
|
2018-06-13 09:20:23 -06:00
|
|
|
TEXT runtime·kevent_trampoline(SB),NOSPLIT,$0
|
|
|
|
PUSHL BP
|
|
|
|
MOVL SP, BP
|
|
|
|
SUBL $24, SP
|
|
|
|
MOVL 32(SP), CX
|
|
|
|
MOVL 0(CX), AX // arg 1 kq
|
|
|
|
MOVL AX, 0(SP)
|
|
|
|
MOVL 4(CX), AX // arg 2 ch
|
|
|
|
MOVL AX, 4(SP)
|
|
|
|
MOVL 8(CX), AX // arg 3 nch
|
|
|
|
MOVL AX, 8(SP)
|
|
|
|
MOVL 12(CX), AX // arg 4 ev
|
|
|
|
MOVL AX, 12(SP)
|
|
|
|
MOVL 16(CX), AX // arg 5 nev
|
|
|
|
MOVL AX, 16(SP)
|
|
|
|
MOVL 20(CX), AX // arg 6 ts
|
|
|
|
MOVL AX, 20(SP)
|
|
|
|
CALL libc_kevent(SB)
|
|
|
|
CMPL AX, $-1
|
|
|
|
JNE ok
|
|
|
|
CALL libc_error(SB)
|
|
|
|
MOVL (AX), AX // errno
|
|
|
|
NEGL AX // caller wants it as a negative error code
|
|
|
|
ok:
|
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
2013-03-14 00:38:37 -06:00
|
|
|
RET
|
|
|
|
|
2018-06-13 09:20:23 -06:00
|
|
|
TEXT runtime·fcntl_trampoline(SB),NOSPLIT,$0
|
|
|
|
PUSHL BP
|
|
|
|
MOVL SP, BP
|
|
|
|
SUBL $24, SP
|
|
|
|
MOVL 32(SP), CX
|
|
|
|
MOVL 0(CX), AX // arg 1 fd
|
|
|
|
MOVL AX, 0(SP)
|
|
|
|
MOVL 4(CX), AX // arg 2 cmd
|
|
|
|
MOVL AX, 4(SP)
|
|
|
|
MOVL 8(CX), AX // arg 3 arg
|
|
|
|
MOVL AX, 8(SP)
|
|
|
|
CALL libc_fcntl(SB)
|
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
2013-03-14 00:38:37 -06:00
|
|
|
RET
|
2018-04-23 08:30:32 -06:00
|
|
|
|
|
|
|
// mstart_stub is the first function executed on a new thread started by pthread_create.
|
|
|
|
// It just does some low-level setup and then calls mstart.
|
|
|
|
// Note: called with the C calling convention.
|
|
|
|
TEXT runtime·mstart_stub(SB),NOSPLIT,$0
|
|
|
|
// The value at SP+4 points to the m.
|
|
|
|
// We are already on m's g0 stack.
|
|
|
|
|
2018-05-20 09:57:53 -06:00
|
|
|
// Save callee-save registers.
|
|
|
|
SUBL $16, SP
|
|
|
|
MOVL BP, 0(SP)
|
|
|
|
MOVL BX, 4(SP)
|
|
|
|
MOVL SI, 8(SP)
|
|
|
|
MOVL DI, 12(SP)
|
|
|
|
|
2018-04-23 08:30:32 -06:00
|
|
|
MOVL SP, AX // hide argument read from vet (vet thinks this function is using the Go calling convention)
|
2018-05-20 09:57:53 -06:00
|
|
|
MOVL 20(AX), DI // m
|
2018-04-23 08:30:32 -06:00
|
|
|
MOVL m_g0(DI), DX // g
|
|
|
|
|
|
|
|
// Initialize TLS entry.
|
|
|
|
// See cmd/link/internal/ld/sym.go:computeTLSOffset.
|
|
|
|
MOVL DX, 0x18(GS)
|
|
|
|
|
|
|
|
// Someday the convention will be D is always cleared.
|
|
|
|
CLD
|
|
|
|
|
|
|
|
CALL runtime·mstart(SB)
|
|
|
|
|
2018-05-20 09:57:53 -06:00
|
|
|
// Restore callee-save registers.
|
|
|
|
MOVL 0(SP), BP
|
|
|
|
MOVL 4(SP), BX
|
|
|
|
MOVL 8(SP), SI
|
|
|
|
MOVL 12(SP), DI
|
|
|
|
|
2018-04-30 08:50:10 -06:00
|
|
|
// Go is all done with this OS thread.
|
|
|
|
// Tell pthread everything is ok (we never join with this thread, so
|
|
|
|
// the value here doesn't really matter).
|
2018-04-23 08:30:32 -06:00
|
|
|
XORL AX, AX
|
2018-05-20 09:57:53 -06:00
|
|
|
|
|
|
|
ADDL $16, SP
|
2018-04-23 08:30:32 -06:00
|
|
|
RET
|
|
|
|
|
2018-05-03 11:30:31 -06:00
|
|
|
TEXT runtime·pthread_attr_init_trampoline(SB),NOSPLIT,$0
|
2018-04-23 08:30:32 -06:00
|
|
|
PUSHL BP
|
|
|
|
MOVL SP, BP
|
2018-05-03 11:30:31 -06:00
|
|
|
SUBL $8, SP
|
|
|
|
MOVL 16(SP), CX
|
|
|
|
MOVL 0(CX), AX // arg 1 attr
|
2018-04-23 08:30:32 -06:00
|
|
|
MOVL AX, 0(SP)
|
|
|
|
CALL libc_pthread_attr_init(SB)
|
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
|
|
|
RET
|
|
|
|
|
2018-05-03 11:30:31 -06:00
|
|
|
TEXT runtime·pthread_attr_setstacksize_trampoline(SB),NOSPLIT,$0
|
2018-04-23 08:30:32 -06:00
|
|
|
PUSHL BP
|
|
|
|
MOVL SP, BP
|
2018-04-30 08:50:10 -06:00
|
|
|
SUBL $8, SP
|
2018-05-03 11:30:31 -06:00
|
|
|
MOVL 16(SP), CX
|
|
|
|
MOVL 0(CX), AX // arg 1 attr
|
2018-04-23 08:30:32 -06:00
|
|
|
MOVL AX, 0(SP)
|
2018-05-03 11:30:31 -06:00
|
|
|
MOVL 4(CX), AX // arg 2 size
|
|
|
|
MOVL AX, 4(SP)
|
2018-04-30 08:50:10 -06:00
|
|
|
CALL libc_pthread_attr_setstacksize(SB)
|
2018-04-23 08:30:32 -06:00
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
|
|
|
RET
|
|
|
|
|
2018-05-03 11:30:31 -06:00
|
|
|
TEXT runtime·pthread_attr_setdetachstate_trampoline(SB),NOSPLIT,$0
|
2018-04-23 08:30:32 -06:00
|
|
|
PUSHL BP
|
|
|
|
MOVL SP, BP
|
|
|
|
SUBL $8, SP
|
2018-05-03 11:30:31 -06:00
|
|
|
MOVL 16(SP), CX
|
|
|
|
MOVL 0(CX), AX // arg 1 attr
|
2018-04-23 08:30:32 -06:00
|
|
|
MOVL AX, 0(SP)
|
2018-05-03 11:30:31 -06:00
|
|
|
MOVL 4(CX), AX // arg 2 state
|
|
|
|
MOVL AX, 4(SP)
|
2018-04-23 08:30:32 -06:00
|
|
|
CALL libc_pthread_attr_setdetachstate(SB)
|
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
|
|
|
RET
|
|
|
|
|
2018-05-03 11:30:31 -06:00
|
|
|
TEXT runtime·pthread_create_trampoline(SB),NOSPLIT,$0
|
2018-04-23 08:30:32 -06:00
|
|
|
PUSHL BP
|
|
|
|
MOVL SP, BP
|
2018-05-03 11:30:31 -06:00
|
|
|
SUBL $24, SP
|
|
|
|
MOVL 32(SP), CX
|
|
|
|
LEAL 16(SP), AX // arg "0" &threadid (which we throw away)
|
2018-04-23 08:30:32 -06:00
|
|
|
MOVL AX, 0(SP)
|
2018-05-03 11:30:31 -06:00
|
|
|
MOVL 0(CX), AX // arg 1 attr
|
|
|
|
MOVL AX, 4(SP)
|
|
|
|
MOVL 4(CX), AX // arg 2 start
|
|
|
|
MOVL AX, 8(SP)
|
|
|
|
MOVL 8(CX), AX // arg 3 arg
|
|
|
|
MOVL AX, 12(SP)
|
2018-04-23 08:30:32 -06:00
|
|
|
CALL libc_pthread_create(SB)
|
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
|
|
|
RET
|
2018-04-30 17:21:02 -06:00
|
|
|
|
2018-05-21 07:33:20 -06:00
|
|
|
TEXT runtime·raise_trampoline(SB),NOSPLIT,$0
|
2018-04-30 17:21:02 -06:00
|
|
|
PUSHL BP
|
|
|
|
MOVL SP, BP
|
2018-05-03 11:30:31 -06:00
|
|
|
SUBL $8, SP
|
|
|
|
MOVL 16(SP), CX
|
2018-05-21 07:33:20 -06:00
|
|
|
MOVL 0(CX), AX // arg 1 sig
|
2018-04-30 17:21:02 -06:00
|
|
|
MOVL AX, 0(SP)
|
2018-05-21 07:33:20 -06:00
|
|
|
CALL libc_raise(SB)
|
2018-04-30 17:21:02 -06:00
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
|
|
|
RET
|
2018-06-13 15:39:36 -06:00
|
|
|
|
|
|
|
TEXT runtime·pthread_mutex_init_trampoline(SB),NOSPLIT,$0
|
|
|
|
PUSHL BP
|
|
|
|
MOVL SP, BP
|
|
|
|
SUBL $8, SP
|
|
|
|
MOVL 16(SP), CX
|
|
|
|
MOVL 0(CX), AX // arg 1 mutex
|
|
|
|
MOVL AX, 0(SP)
|
|
|
|
MOVL 4(CX), AX // arg 2 attr
|
|
|
|
MOVL AX, 4(SP)
|
|
|
|
CALL libc_pthread_mutex_init(SB)
|
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
|
|
|
RET
|
|
|
|
|
|
|
|
TEXT runtime·pthread_mutex_lock_trampoline(SB),NOSPLIT,$0
|
|
|
|
PUSHL BP
|
|
|
|
MOVL SP, BP
|
|
|
|
SUBL $8, SP
|
|
|
|
MOVL 16(SP), CX
|
|
|
|
MOVL 0(CX), AX // arg 1 mutex
|
|
|
|
MOVL AX, 0(SP)
|
|
|
|
CALL libc_pthread_mutex_lock(SB)
|
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
|
|
|
RET
|
|
|
|
|
|
|
|
TEXT runtime·pthread_mutex_unlock_trampoline(SB),NOSPLIT,$0
|
|
|
|
PUSHL BP
|
|
|
|
MOVL SP, BP
|
|
|
|
SUBL $8, SP
|
|
|
|
MOVL 16(SP), CX
|
|
|
|
MOVL 0(CX), AX // arg 1 mutex
|
|
|
|
MOVL AX, 0(SP)
|
|
|
|
CALL libc_pthread_mutex_unlock(SB)
|
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
|
|
|
RET
|
|
|
|
|
|
|
|
TEXT runtime·pthread_cond_init_trampoline(SB),NOSPLIT,$0
|
|
|
|
PUSHL BP
|
|
|
|
MOVL SP, BP
|
|
|
|
SUBL $8, SP
|
|
|
|
MOVL 16(SP), CX
|
|
|
|
MOVL 0(CX), AX // arg 1 cond
|
|
|
|
MOVL AX, 0(SP)
|
|
|
|
MOVL 4(CX), AX // arg 2 attr
|
|
|
|
MOVL AX, 4(SP)
|
|
|
|
CALL libc_pthread_cond_init(SB)
|
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
|
|
|
RET
|
|
|
|
|
|
|
|
TEXT runtime·pthread_cond_wait_trampoline(SB),NOSPLIT,$0
|
|
|
|
PUSHL BP
|
|
|
|
MOVL SP, BP
|
|
|
|
SUBL $8, SP
|
|
|
|
MOVL 16(SP), CX
|
|
|
|
MOVL 0(CX), AX // arg 1 cond
|
|
|
|
MOVL AX, 0(SP)
|
|
|
|
MOVL 4(CX), AX // arg 2 mutex
|
|
|
|
MOVL AX, 4(SP)
|
|
|
|
CALL libc_pthread_cond_wait(SB)
|
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
|
|
|
RET
|
|
|
|
|
2018-06-22 23:15:19 -06:00
|
|
|
TEXT runtime·pthread_cond_timedwait_relative_np_trampoline(SB),NOSPLIT,$0
|
2018-06-13 15:39:36 -06:00
|
|
|
PUSHL BP
|
|
|
|
MOVL SP, BP
|
|
|
|
SUBL $24, SP
|
|
|
|
MOVL 32(SP), CX
|
|
|
|
MOVL 0(CX), AX // arg 1 cond
|
|
|
|
MOVL AX, 0(SP)
|
|
|
|
MOVL 4(CX), AX // arg 2 mutex
|
|
|
|
MOVL AX, 4(SP)
|
|
|
|
MOVL 8(CX), AX // arg 3 timeout
|
|
|
|
MOVL AX, 8(SP)
|
2018-06-22 23:15:19 -06:00
|
|
|
CALL libc_pthread_cond_timedwait_relative_np(SB)
|
2018-06-13 15:39:36 -06:00
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
|
|
|
RET
|
|
|
|
|
|
|
|
TEXT runtime·pthread_cond_signal_trampoline(SB),NOSPLIT,$0
|
|
|
|
PUSHL BP
|
|
|
|
MOVL SP, BP
|
|
|
|
SUBL $8, SP
|
|
|
|
MOVL 16(SP), CX
|
|
|
|
MOVL 0(CX), AX // arg 1 cond
|
|
|
|
MOVL AX, 0(SP)
|
|
|
|
CALL libc_pthread_cond_signal(SB)
|
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
|
|
|
RET
|