diff options
| author | Russ Cox <rsc@golang.org> | 2014-02-20 15:58:47 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2014-02-20 15:58:47 -0500 |
| commit | 67c83db60db744c17316a4dc1d590c9649d66e6c (patch) | |
| tree | 7267152625e9423585ae9f350fdbbb1afa8bc681 /src/pkg/runtime/runtime.c | |
| parent | 258c278e12ba90502bb4805343592a926b6d9a7a (diff) | |
| download | go-67c83db60db744c17316a4dc1d590c9649d66e6c.tar.xz | |
runtime: use goc2c as much as possible
Package runtime's C functions written to be called from Go
started out written in C using carefully constructed argument
lists and the FLUSH macro to write a result back to memory.
For some functions, the appropriate parameter list ended up
being architecture-dependent due to differences in alignment,
so we added 'goc2c', which takes a .goc file containing Go func
declarations but C bodies, rewrites the Go func declaration to
equivalent C declarations for the target architecture, adds the
needed FLUSH statements, and writes out an equivalent C file.
That C file is compiled as part of package runtime.
Native Client's x86-64 support introduces the most complex
alignment rules yet, breaking many functions that could until
now be portably written in C. Using goc2c for those avoids the
breakage.
Separately, Keith's work on emitting stack information from
the C compiler would require the hand-written functions
to add #pragmas specifying how many arguments are result
parameters. Using goc2c for those avoids maintaining #pragmas.
For both reasons, use goc2c for as many Go-called C functions
as possible.
This CL is a replay of the bulk of CL 15400047 and CL 15790043,
both of which were reviewed as part of the NaCl port and are
checked in to the NaCl branch. This CL is part of bringing the
NaCl code into the main tree.
No new code here, just reformatting and occasional movement
into .h files.
LGTM=r
R=dave, alex.brainman, r
CC=golang-codereviews
https://golang.org/cl/65220044
Diffstat (limited to 'src/pkg/runtime/runtime.c')
| -rw-r--r-- | src/pkg/runtime/runtime.c | 81 |
1 files changed, 0 insertions, 81 deletions
diff --git a/src/pkg/runtime/runtime.c b/src/pkg/runtime/runtime.c index 6065714a6e..08a395fbe2 100644 --- a/src/pkg/runtime/runtime.c +++ b/src/pkg/runtime/runtime.c @@ -10,14 +10,6 @@ enum { maxround = sizeof(uintptr), }; -/* - * We assume that all architectures turn faults and the like - * into apparent calls to runtime.sigpanic. If we see a "call" - * to runtime.sigpanic, we do not back up the PC to find the - * line number of the CALL instruction, because there is no CALL. - */ -void runtime·sigpanic(void); - // The GOTRACEBACK environment variable controls the // behavior of a Go program that is crashing and exiting. // GOTRACEBACK=0 suppress all tracebacks @@ -130,16 +122,6 @@ runtime·goenvs_unix(void) syscall·envs.cap = n; } -void -runtime·getgoroot(String out) -{ - byte *p; - - p = runtime·getenv("GOROOT"); - out = runtime·gostringnocopy(p); - FLUSH(&out); -} - int32 runtime·atoi(byte *p) { @@ -276,62 +258,6 @@ runtime·check(void) TestAtomic64(); } -void -runtime·Caller(intgo skip, uintptr retpc, String retfile, intgo retline, bool retbool) -{ - Func *f, *g; - uintptr pc; - uintptr rpc[2]; - - /* - * Ask for two PCs: the one we were asked for - * and what it called, so that we can see if it - * "called" sigpanic. - */ - retpc = 0; - if(runtime·callers(1+skip-1, rpc, 2) < 2) { - retfile = runtime·emptystring; - retline = 0; - retbool = false; - } else if((f = runtime·findfunc(rpc[1])) == nil) { - retfile = runtime·emptystring; - retline = 0; - retbool = true; // have retpc at least - } else { - retpc = rpc[1]; - pc = retpc; - g = runtime·findfunc(rpc[0]); - if(pc > f->entry && (g == nil || g->entry != (uintptr)runtime·sigpanic)) - pc--; - retline = runtime·funcline(f, pc, &retfile); - retbool = true; - } - FLUSH(&retpc); - FLUSH(&retfile); - FLUSH(&retline); - FLUSH(&retbool); -} - -void -runtime·Callers(intgo skip, Slice pc, intgo retn) -{ - // runtime.callers uses pc.array==nil as a signal - // to print a stack trace. Pick off 0-length pc here - // so that we don't let a nil pc slice get to it. - if(pc.len == 0) - retn = 0; - else - retn = runtime·callers(skip, (uintptr*)pc.array, pc.len); - FLUSH(&retn); -} - -void -runtime·FuncForPC(uintptr pc, void *retf) -{ - retf = runtime·findfunc(pc); - FLUSH(&retf); -} - uint32 runtime·fastrand1(void) { @@ -375,13 +301,6 @@ runtime·tickspersecond(void) return res; } -void -runtime∕pprof·runtime_cyclesPerSecond(int64 res) -{ - res = runtime·tickspersecond(); - FLUSH(&res); -} - DebugVars runtime·debug; static struct { |
