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
|
|
|
|
// See http://fxr.watson.org/fxr/source/bsd/kern/syscalls.c?v=xnu-1228
|
|
|
|
// or /usr/include/sys/syscall.h (on a Mac) for system call numbers.
|
|
|
|
|
[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
|
|
|
|
|
2015-01-14 09:18:24 -07:00
|
|
|
TEXT runtime·raiseproc(SB),NOSPLIT,$16
|
2013-03-14 23:11:03 -06:00
|
|
|
MOVL $20, AX // getpid
|
|
|
|
INT $0x80
|
|
|
|
MOVL AX, 4(SP) // pid
|
|
|
|
MOVL sig+0(FP), AX
|
|
|
|
MOVL AX, 8(SP) // signal
|
|
|
|
MOVL $1, 12(SP) // posix
|
|
|
|
MOVL $37, AX // kill
|
2011-04-25 14:58:00 -06:00
|
|
|
INT $0x80
|
|
|
|
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
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·setitimer(SB),NOSPLIT,$0
|
2011-03-23 09:31:42 -06:00
|
|
|
MOVL $83, AX
|
|
|
|
INT $0x80
|
|
|
|
RET
|
|
|
|
|
2012-06-05 14:23:30 -06:00
|
|
|
// OS X comm page time offsets
|
|
|
|
// http://www.opensource.apple.com/source/xnu/xnu-1699.26.8/osfmk/i386/cpu_capabilities.h
|
|
|
|
#define cpu_capabilities 0x20
|
|
|
|
#define nt_tsc_base 0x50
|
|
|
|
#define nt_scale 0x58
|
|
|
|
#define nt_shift 0x5c
|
|
|
|
#define nt_ns_base 0x60
|
|
|
|
#define nt_generation 0x68
|
|
|
|
#define gtod_generation 0x6c
|
|
|
|
#define gtod_ns_base 0x70
|
|
|
|
#define gtod_sec_base 0x78
|
|
|
|
|
|
|
|
// called from assembly
|
|
|
|
// 64-bit unix nanoseconds returned in DX:AX.
|
|
|
|
// I'd much rather write this in C but we need
|
|
|
|
// assembly for the 96-bit multiply and RDTSC.
|
2017-02-03 17:26:13 -07:00
|
|
|
//
|
|
|
|
// Note that we could arrange to return monotonic time here
|
|
|
|
// as well, but we don't bother, for two reasons:
|
|
|
|
// 1. macOS only supports 64-bit systems, so no one should
|
|
|
|
// be using the 32-bit code in production.
|
|
|
|
// This code is only maintained to make it easier for developers
|
|
|
|
// using Macs to test the 32-bit compiler.
|
|
|
|
// 2. On some (probably now unsupported) CPUs,
|
|
|
|
// the code falls back to the system call always,
|
|
|
|
// so it can't even use the comm page at all.
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·now(SB),NOSPLIT,$40
|
2012-06-05 14:23:30 -06:00
|
|
|
MOVL $0xffff0000, BP /* comm page base */
|
|
|
|
|
|
|
|
// Test for slow CPU. If so, the math is completely
|
|
|
|
// different, and unimplemented here, so use the
|
|
|
|
// system call.
|
|
|
|
MOVL cpu_capabilities(BP), AX
|
|
|
|
TESTL $0x4000, AX
|
|
|
|
JNZ systime
|
|
|
|
|
|
|
|
// Loop trying to take a consistent snapshot
|
|
|
|
// of the time parameters.
|
|
|
|
timeloop:
|
|
|
|
MOVL gtod_generation(BP), BX
|
|
|
|
TESTL BX, BX
|
|
|
|
JZ systime
|
|
|
|
MOVL nt_generation(BP), CX
|
|
|
|
TESTL CX, CX
|
|
|
|
JZ timeloop
|
|
|
|
RDTSC
|
|
|
|
MOVL nt_tsc_base(BP), SI
|
|
|
|
MOVL (nt_tsc_base+4)(BP), DI
|
|
|
|
MOVL SI, 0(SP)
|
|
|
|
MOVL DI, 4(SP)
|
|
|
|
MOVL nt_scale(BP), SI
|
|
|
|
MOVL SI, 8(SP)
|
|
|
|
MOVL nt_ns_base(BP), SI
|
|
|
|
MOVL (nt_ns_base+4)(BP), DI
|
|
|
|
MOVL SI, 12(SP)
|
|
|
|
MOVL DI, 16(SP)
|
|
|
|
CMPL nt_generation(BP), CX
|
|
|
|
JNE timeloop
|
|
|
|
MOVL gtod_ns_base(BP), SI
|
|
|
|
MOVL (gtod_ns_base+4)(BP), DI
|
|
|
|
MOVL SI, 20(SP)
|
|
|
|
MOVL DI, 24(SP)
|
|
|
|
MOVL gtod_sec_base(BP), SI
|
|
|
|
MOVL (gtod_sec_base+4)(BP), DI
|
|
|
|
MOVL SI, 28(SP)
|
|
|
|
MOVL DI, 32(SP)
|
|
|
|
CMPL gtod_generation(BP), BX
|
|
|
|
JNE timeloop
|
|
|
|
|
|
|
|
// Gathered all the data we need. Compute time.
|
|
|
|
// ((tsc - nt_tsc_base) * nt_scale) >> 32 + nt_ns_base - gtod_ns_base + gtod_sec_base*1e9
|
|
|
|
// The multiply and shift extracts the top 64 bits of the 96-bit product.
|
|
|
|
SUBL 0(SP), AX // DX:AX = (tsc - nt_tsc_base)
|
|
|
|
SBBL 4(SP), DX
|
|
|
|
|
|
|
|
// We have x = tsc - nt_tsc_base - DX:AX to be
|
|
|
|
// multiplied by y = nt_scale = 8(SP), keeping the top 64 bits of the 96-bit product.
|
|
|
|
// x*y = (x&0xffffffff)*y + (x&0xffffffff00000000)*y
|
|
|
|
// (x*y)>>32 = ((x&0xffffffff)*y)>>32 + (x>>32)*y
|
|
|
|
MOVL DX, CX // SI = (x&0xffffffff)*y >> 32
|
|
|
|
MOVL $0, DX
|
|
|
|
MULL 8(SP)
|
|
|
|
MOVL DX, SI
|
|
|
|
|
|
|
|
MOVL CX, AX // DX:AX = (x>>32)*y
|
|
|
|
MOVL $0, DX
|
|
|
|
MULL 8(SP)
|
|
|
|
|
|
|
|
ADDL SI, AX // DX:AX += (x&0xffffffff)*y >> 32
|
|
|
|
ADCL $0, DX
|
|
|
|
|
|
|
|
// DX:AX is now ((tsc - nt_tsc_base) * nt_scale) >> 32.
|
|
|
|
ADDL 12(SP), AX // DX:AX += nt_ns_base
|
|
|
|
ADCL 16(SP), DX
|
|
|
|
SUBL 20(SP), AX // DX:AX -= gtod_ns_base
|
|
|
|
SBBL 24(SP), DX
|
|
|
|
MOVL AX, SI // DI:SI = DX:AX
|
|
|
|
MOVL DX, DI
|
|
|
|
MOVL 28(SP), AX // DX:AX = gtod_sec_base*1e9
|
|
|
|
MOVL 32(SP), DX
|
|
|
|
MOVL $1000000000, CX
|
|
|
|
MULL CX
|
|
|
|
ADDL SI, AX // DX:AX += DI:SI
|
|
|
|
ADCL DI, DX
|
2011-11-30 09:59:44 -07:00
|
|
|
RET
|
|
|
|
|
2012-06-05 14:23:30 -06:00
|
|
|
systime:
|
|
|
|
// Fall back to system call (usually first call in this thread)
|
2016-08-01 22:54:40 -06:00
|
|
|
LEAL 16(SP), AX // must be non-nil, unused
|
2010-02-08 15:32:22 -07:00
|
|
|
MOVL AX, 4(SP)
|
|
|
|
MOVL $0, 8(SP) // time zone pointer
|
2016-08-01 22:54:40 -06:00
|
|
|
MOVL $0, 12(SP) // required as of Sierra; Issue 16570
|
2016-10-27 07:22:43 -06:00
|
|
|
MOVL $116, AX // SYS_GETTIMEOFDAY
|
2010-02-08 15:32:22 -07:00
|
|
|
INT $0x80
|
2016-07-07 17:41:29 -06:00
|
|
|
CMPL AX, $0
|
|
|
|
JNE inreg
|
2016-08-01 22:54:40 -06:00
|
|
|
MOVL 16(SP), AX
|
|
|
|
MOVL 20(SP), DX
|
2016-07-07 17:41:29 -06:00
|
|
|
inreg:
|
2012-06-05 14:23:30 -06:00
|
|
|
// sec is in AX, usec in DX
|
2011-11-03 15:35:28 -06:00
|
|
|
// convert to DX:AX nsec
|
2012-06-05 14:23:30 -06:00
|
|
|
MOVL DX, BX
|
2011-11-03 15:35:28 -06:00
|
|
|
MOVL $1000000000, CX
|
|
|
|
MULL CX
|
|
|
|
IMULL $1000, BX
|
|
|
|
ADDL BX, AX
|
|
|
|
ADCL $0, DX
|
2012-06-05 14:23:30 -06:00
|
|
|
RET
|
|
|
|
|
2017-02-03 17:26:13 -07:00
|
|
|
// func now() (sec int64, nsec int32, mono uint64)
|
|
|
|
TEXT time·now(SB),NOSPLIT,$0-20
|
2012-06-05 14:23:30 -06:00
|
|
|
CALL runtime·now(SB)
|
2017-02-03 17:26:13 -07:00
|
|
|
MOVL AX, BX
|
|
|
|
MOVL DX, BP
|
|
|
|
SUBL runtime·startNano(SB), BX
|
|
|
|
SBBL runtime·startNano+4(SB), BP
|
|
|
|
MOVL BX, mono+12(FP)
|
|
|
|
MOVL BP, mono+16(FP)
|
2012-06-05 14:23:30 -06:00
|
|
|
MOVL $1000000000, CX
|
|
|
|
DIVL CX
|
|
|
|
MOVL AX, sec+0(FP)
|
|
|
|
MOVL $0, sec+4(FP)
|
|
|
|
MOVL DX, nsec+8(FP)
|
|
|
|
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
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·sigprocmask(SB),NOSPLIT,$0
|
2012-02-28 14:18:24 -07:00
|
|
|
MOVL $329, AX // pthread_sigmask (on OS X, sigprocmask==entire process)
|
2012-02-23 12:44:06 -07:00
|
|
|
INT $0x80
|
|
|
|
JAE 2(PC)
|
2012-03-08 12:03:56 -07:00
|
|
|
MOVL $0xf1, 0xf1 // crash
|
2012-02-23 12:44:06 -07:00
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·sigaction(SB),NOSPLIT,$0
|
2009-03-31 16:45:12 -06:00
|
|
|
MOVL $46, AX
|
|
|
|
INT $0x80
|
|
|
|
JAE 2(PC)
|
2012-03-08 12:03:56 -07:00
|
|
|
MOVL $0xf1, 0xf1 // crash
|
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.
|
|
|
|
// It is called with the following arguments on the stack:
|
|
|
|
// 0(SP) "return address" - ignored
|
|
|
|
// 4(SP) actual handler
|
2016-07-11 17:05:57 -06:00
|
|
|
// 8(SP) siginfo style
|
|
|
|
// 12(SP) signal number
|
2015-12-21 23:27:01 -07:00
|
|
|
// 16(SP) siginfo
|
|
|
|
// 20(SP) context
|
|
|
|
TEXT runtime·sigtramp(SB),NOSPLIT,$20
|
|
|
|
MOVL sig+8(FP), BX
|
2016-09-25 22:33:27 -06:00
|
|
|
MOVL BX, 0(SP)
|
2015-12-21 23:27:01 -07:00
|
|
|
MOVL info+12(FP), BX
|
2016-09-25 22:33:27 -06:00
|
|
|
MOVL BX, 4(SP)
|
2016-07-11 17:05:57 -06:00
|
|
|
MOVL ctx+16(FP), BX
|
2016-09-25 22:33:27 -06:00
|
|
|
MOVL BX, 8(SP)
|
2015-12-21 23:27:01 -07:00
|
|
|
CALL runtime·sigtrampgo(SB)
|
2009-11-16 18:51:47 -07:00
|
|
|
|
2011-02-23 12:47:42 -07:00
|
|
|
// call sigreturn
|
2016-07-11 17:05:57 -06:00
|
|
|
MOVL ctx+16(FP), CX
|
|
|
|
MOVL infostyle+4(FP), BX
|
2009-03-31 16:45:12 -06:00
|
|
|
MOVL $0, 0(SP) // "caller PC" - ignored
|
|
|
|
MOVL CX, 4(SP)
|
|
|
|
MOVL BX, 8(SP)
|
|
|
|
MOVL $184, AX // sigreturn(ucontext, infostyle)
|
|
|
|
INT $0x80
|
2012-03-08 12:03:56 -07:00
|
|
|
MOVL $0xf1, 0xf1 // crash
|
2009-03-31 16:45:12 -06:00
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·sigaltstack(SB),NOSPLIT,$0
|
2009-03-31 16:45:12 -06:00
|
|
|
MOVL $53, AX
|
|
|
|
INT $0x80
|
|
|
|
JAE 2(PC)
|
2012-03-08 12:03:56 -07:00
|
|
|
MOVL $0xf1, 0xf1 // crash
|
2009-03-31 16:45:12 -06:00
|
|
|
RET
|
|
|
|
|
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
|
|
|
|
|
2009-03-31 16:45:12 -06:00
|
|
|
// Invoke Mach system call.
|
|
|
|
// Assumes system call number in AX,
|
|
|
|
// caller PC on stack, caller's caller PC next,
|
|
|
|
// and then the system call arguments.
|
|
|
|
//
|
|
|
|
// Can be used for BSD too, but we don't,
|
|
|
|
// because if you use this interface the BSD
|
|
|
|
// system call numbers need an extra field
|
|
|
|
// in the high 16 bits that seems to be the
|
|
|
|
// argument count in bytes but is not always.
|
|
|
|
// INT $0x80 works fine for those.
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·sysenter(SB),NOSPLIT,$0
|
2009-03-31 16:45:12 -06:00
|
|
|
POPL DX
|
|
|
|
MOVL SP, CX
|
2018-03-19 14:07:18 -06:00
|
|
|
SYSENTER
|
2009-03-31 16:45:12 -06:00
|
|
|
// returns to DX with SP set to CX
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·mach_msg_trap(SB),NOSPLIT,$0
|
2009-03-31 16:45:12 -06:00
|
|
|
MOVL $-31, AX
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
CALL runtime·sysenter(SB)
|
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
|
|
|
MOVL AX, ret+28(FP)
|
2009-03-31 16:45:12 -06:00
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·mach_reply_port(SB),NOSPLIT,$0
|
2009-03-31 16:45:12 -06:00
|
|
|
MOVL $-26, AX
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
CALL runtime·sysenter(SB)
|
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
|
|
|
MOVL AX, ret+0(FP)
|
2009-03-31 16:45:12 -06:00
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·mach_task_self(SB),NOSPLIT,$0
|
2009-03-31 16:45:12 -06:00
|
|
|
MOVL $-28, AX
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
CALL runtime·sysenter(SB)
|
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
|
|
|
MOVL AX, ret+0(FP)
|
2009-03-31 16:45:12 -06:00
|
|
|
RET
|
|
|
|
|
|
|
|
// Mach provides trap versions of the semaphore ops,
|
|
|
|
// instead of requiring the use of RPC.
|
|
|
|
|
2015-01-23 18:56:47 -07:00
|
|
|
// func mach_semaphore_wait(sema uint32) int32
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·mach_semaphore_wait(SB),NOSPLIT,$0
|
2009-03-31 16:45:12 -06:00
|
|
|
MOVL $-36, AX
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
CALL runtime·sysenter(SB)
|
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
|
|
|
MOVL AX, ret+4(FP)
|
2009-03-31 16:45:12 -06:00
|
|
|
RET
|
|
|
|
|
2015-01-23 18:56:47 -07:00
|
|
|
// func mach_semaphore_timedwait(sema, sec, nsec uint32) int32
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·mach_semaphore_timedwait(SB),NOSPLIT,$0
|
2009-03-31 16:45:12 -06:00
|
|
|
MOVL $-38, AX
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
CALL runtime·sysenter(SB)
|
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
|
|
|
MOVL AX, ret+12(FP)
|
2009-03-31 16:45:12 -06:00
|
|
|
RET
|
|
|
|
|
2015-01-23 18:56:47 -07:00
|
|
|
// func mach_semaphore_signal(sema uint32) int32
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·mach_semaphore_signal(SB),NOSPLIT,$0
|
2009-03-31 16:45:12 -06:00
|
|
|
MOVL $-33, AX
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
CALL runtime·sysenter(SB)
|
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
|
|
|
MOVL AX, ret+4(FP)
|
2009-03-31 16:45:12 -06:00
|
|
|
RET
|
|
|
|
|
2015-01-23 18:56:47 -07:00
|
|
|
// func mach_semaphore_signal_all(sema uint32) int32
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·mach_semaphore_signal_all(SB),NOSPLIT,$0
|
2009-03-31 16:45:12 -06:00
|
|
|
MOVL $-34, AX
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
CALL runtime·sysenter(SB)
|
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
|
|
|
MOVL AX, ret+4(FP)
|
2009-03-31 16:45:12 -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
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·sysctl(SB),NOSPLIT,$0
|
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
|
|
|
MOVL $202, AX
|
|
|
|
INT $0x80
|
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
|
|
|
JAE 4(PC)
|
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
|
|
|
NEGL AX
|
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
|
|
|
MOVL AX, ret+24(FP)
|
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
|
|
|
|
MOVL $0, AX
|
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
|
|
|
MOVL AX, ret+24(FP)
|
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
|
|
|
|
2015-01-23 18:56:47 -07:00
|
|
|
// func kqueue() int32
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·kqueue(SB),NOSPLIT,$0
|
2013-03-14 00:38:37 -06:00
|
|
|
MOVL $362, AX
|
|
|
|
INT $0x80
|
|
|
|
JAE 2(PC)
|
|
|
|
NEGL AX
|
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
|
|
|
MOVL AX, ret+0(FP)
|
2013-03-14 00:38:37 -06:00
|
|
|
RET
|
|
|
|
|
2015-01-23 18:56:47 -07:00
|
|
|
// func kevent(kq int32, ch *keventt, nch int32, ev *keventt, nev int32, ts *timespec) int32
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·kevent(SB),NOSPLIT,$0
|
2013-03-14 00:38:37 -06:00
|
|
|
MOVL $363, AX
|
|
|
|
INT $0x80
|
|
|
|
JAE 2(PC)
|
|
|
|
NEGL AX
|
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
|
|
|
MOVL AX, ret+24(FP)
|
2013-03-14 00:38:37 -06:00
|
|
|
RET
|
|
|
|
|
2015-01-23 18:56:47 -07:00
|
|
|
// func closeonexec(fd int32)
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·closeonexec(SB),NOSPLIT,$32
|
2013-03-14 00:38:37 -06:00
|
|
|
MOVL $92, AX // fcntl
|
|
|
|
// 0(SP) is where the caller PC would be; kernel skips it
|
|
|
|
MOVL fd+0(FP), BX
|
|
|
|
MOVL BX, 4(SP) // fd
|
|
|
|
MOVL $2, 8(SP) // F_SETFD
|
|
|
|
MOVL $1, 12(SP) // FD_CLOEXEC
|
|
|
|
INT $0x80
|
|
|
|
JAE 2(PC)
|
|
|
|
NEGL AX
|
|
|
|
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.
|
|
|
|
|
|
|
|
MOVL SP, AX // hide argument read from vet (vet thinks this function is using the Go calling convention)
|
|
|
|
MOVL 4(AX), DI // m
|
|
|
|
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-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
|
|
|
|
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-03 11:30:31 -06:00
|
|
|
TEXT runtime·pthread_self_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
|
2018-04-30 17:21:02 -06:00
|
|
|
CALL libc_pthread_self(SB)
|
2018-05-03 11:30:31 -06:00
|
|
|
MOVL 16(SP), CX
|
|
|
|
MOVL AX, (CX) // Save result.
|
2018-04-30 17:21:02 -06:00
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
|
|
|
RET
|
|
|
|
|
2018-05-03 11:30:31 -06:00
|
|
|
TEXT runtime·pthread_kill_trampoline(SB),NOSPLIT,$0
|
2018-04-30 17:21:02 -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 thread ID
|
2018-04-30 17:21:02 -06:00
|
|
|
MOVL AX, 0(SP)
|
2018-05-03 11:30:31 -06:00
|
|
|
MOVL 4(CX), AX // arg 2 sig
|
|
|
|
MOVL AX, 4(SP)
|
2018-04-30 17:21:02 -06:00
|
|
|
CALL libc_pthread_kill(SB)
|
|
|
|
MOVL BP, SP
|
|
|
|
POPL BP
|
|
|
|
RET
|