Commit c01c2c88 authored by Russ Cox's avatar Russ Cox

runtime: eliminate Go -> C -> block paths for Solaris

LGTM=aram, r
R=golang-codereviews, aram, r
CC=golang-codereviews, iant, khr
https://golang.org/cl/141180043
parent b6951bcc
...@@ -72,7 +72,7 @@ type pollCache struct { ...@@ -72,7 +72,7 @@ type pollCache struct {
var pollcache pollCache var pollcache pollCache
func netpollServerInit() { func netpollServerInit() {
netpollinit() onM(netpollinit)
} }
func netpollOpen(fd uintptr) (*pollDesc, int) { func netpollOpen(fd uintptr) (*pollDesc, int) {
...@@ -93,7 +93,10 @@ func netpollOpen(fd uintptr) (*pollDesc, int) { ...@@ -93,7 +93,10 @@ func netpollOpen(fd uintptr) (*pollDesc, int) {
pd.wd = 0 pd.wd = 0
unlock(&pd.lock) unlock(&pd.lock)
errno := netpollopen(fd, pd) var errno int32
onM(func() {
errno = netpollopen(fd, pd)
})
return pd, int(errno) return pd, int(errno)
} }
...@@ -107,7 +110,9 @@ func netpollClose(pd *pollDesc) { ...@@ -107,7 +110,9 @@ func netpollClose(pd *pollDesc) {
if pd.rg != 0 && pd.rg != pdReady { if pd.rg != 0 && pd.rg != pdReady {
gothrow("netpollClose: blocked read on closing descriptor") gothrow("netpollClose: blocked read on closing descriptor")
} }
netpollclose(uintptr(pd.fd)) onM(func() {
netpollclose(uintptr(pd.fd))
})
pollcache.free(pd) pollcache.free(pd)
} }
...@@ -138,7 +143,9 @@ func netpollWait(pd *pollDesc, mode int) int { ...@@ -138,7 +143,9 @@ func netpollWait(pd *pollDesc, mode int) int {
} }
// As for now only Solaris uses level-triggered IO. // As for now only Solaris uses level-triggered IO.
if GOOS == "solaris" { if GOOS == "solaris" {
netpollarm(pd, mode) onM(func() {
netpollarm(pd, mode)
})
} }
for !netpollblock(pd, int32(mode), false) { for !netpollblock(pd, int32(mode), false) {
err = netpollcheckerr(pd, int32(mode)) err = netpollcheckerr(pd, int32(mode))
......
...@@ -386,36 +386,42 @@ runtime·semawakeup(M *mp) ...@@ -386,36 +386,42 @@ runtime·semawakeup(M *mp)
runtime·throw("sem_post"); runtime·throw("sem_post");
} }
#pragma textflag NOSPLIT
int32 int32
runtime·close(int32 fd) runtime·close(int32 fd)
{ {
return runtime·sysvicall1(libc·close, (uintptr)fd); return runtime·sysvicall1(libc·close, (uintptr)fd);
} }
#pragma textflag NOSPLIT
void void
runtime·exit(int32 r) runtime·exit(int32 r)
{ {
runtime·sysvicall1(libc·exit, (uintptr)r); runtime·sysvicall1(libc·exit, (uintptr)r);
} }
#pragma textflag NOSPLIT
/* int32 */ void /* int32 */ void
runtime·getcontext(Ucontext* context) runtime·getcontext(Ucontext* context)
{ {
runtime·sysvicall1(libc·getcontext, (uintptr)context); runtime·sysvicall1(libc·getcontext, (uintptr)context);
} }
#pragma textflag NOSPLIT
int32 int32
runtime·getrlimit(int32 res, Rlimit* rlp) runtime·getrlimit(int32 res, Rlimit* rlp)
{ {
return runtime·sysvicall2(libc·getrlimit, (uintptr)res, (uintptr)rlp); return runtime·sysvicall2(libc·getrlimit, (uintptr)res, (uintptr)rlp);
} }
#pragma textflag NOSPLIT
uint8* uint8*
runtime·mmap(byte* addr, uintptr len, int32 prot, int32 flags, int32 fildes, uint32 off) runtime·mmap(byte* addr, uintptr len, int32 prot, int32 flags, int32 fildes, uint32 off)
{ {
return (uint8*)runtime·sysvicall6(libc·mmap, (uintptr)addr, (uintptr)len, (uintptr)prot, (uintptr)flags, (uintptr)fildes, (uintptr)off); return (uint8*)runtime·sysvicall6(libc·mmap, (uintptr)addr, (uintptr)len, (uintptr)prot, (uintptr)flags, (uintptr)fildes, (uintptr)off);
} }
#pragma textflag NOSPLIT
void void
runtime·munmap(byte* addr, uintptr len) runtime·munmap(byte* addr, uintptr len)
{ {
...@@ -430,6 +436,7 @@ runtime·nanotime(void) ...@@ -430,6 +436,7 @@ runtime·nanotime(void)
return runtime·sysvicall0((uintptr)runtime·nanotime1); return runtime·sysvicall0((uintptr)runtime·nanotime1);
} }
#pragma textflag NOSPLIT
void void
time·now(int64 sec, int32 usec) time·now(int64 sec, int32 usec)
{ {
...@@ -442,6 +449,7 @@ time·now(int64 sec, int32 usec) ...@@ -442,6 +449,7 @@ time·now(int64 sec, int32 usec)
FLUSH(&usec); FLUSH(&usec);
} }
#pragma textflag NOSPLIT
int32 int32
runtime·open(int8* path, int32 oflag, int32 mode) runtime·open(int8* path, int32 oflag, int32 mode)
{ {
...@@ -490,6 +498,7 @@ runtime·raise(int32 sig) ...@@ -490,6 +498,7 @@ runtime·raise(int32 sig)
runtime·sysvicall1(libc·raise, (uintptr)sig); runtime·sysvicall1(libc·raise, (uintptr)sig);
} }
#pragma textflag NOSPLIT
int32 int32
runtime·read(int32 fd, void* buf, int32 nbyte) runtime·read(int32 fd, void* buf, int32 nbyte)
{ {
...@@ -563,6 +572,7 @@ runtime·usleep(uint32 µs) ...@@ -563,6 +572,7 @@ runtime·usleep(uint32 µs)
runtime·usleep1(µs); runtime·usleep1(µs);
} }
#pragma textflag NOSPLIT
int32 int32
runtime·write(uintptr fd, void* buf, int32 nbyte) runtime·write(uintptr fd, void* buf, int32 nbyte)
{ {
......
...@@ -138,10 +138,12 @@ func gorecover(argp uintptr) interface{} { ...@@ -138,10 +138,12 @@ func gorecover(argp uintptr) interface{} {
return nil return nil
} }
//go:nosplit
func startpanic() { func startpanic() {
onM(startpanic_m) onM(startpanic_m)
} }
//go:nosplit
func dopanic(unused int) { func dopanic(unused int) {
gp := getg() gp := getg()
mp := acquirem() mp := acquirem()
...@@ -152,10 +154,19 @@ func dopanic(unused int) { ...@@ -152,10 +154,19 @@ func dopanic(unused int) {
*(*int)(nil) = 0 *(*int)(nil) = 0
} }
//go:nosplit
func throw(s *byte) { func throw(s *byte) {
gothrow(gostringnocopy(s)) gp := getg()
if gp.m.throwing == 0 {
gp.m.throwing = 1
}
startpanic()
print("fatal error: ", gostringnocopy(s), "\n")
dopanic(0)
*(*int)(nil) = 0 // not reached
} }
//go:nosplit
func gothrow(s string) { func gothrow(s string) {
gp := getg() gp := getg()
if gp.m.throwing == 0 { if gp.m.throwing == 0 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment