]> Cypherpunks repositories - gostls13.git/commit
runtime: use goc2c as much as possible
authorRuss Cox <rsc@golang.org>
Thu, 20 Feb 2014 20:58:47 +0000 (15:58 -0500)
committerRuss Cox <rsc@golang.org>
Thu, 20 Feb 2014 20:58:47 +0000 (15:58 -0500)
commit67c83db60db744c17316a4dc1d590c9649d66e6c
tree7267152625e9423585ae9f350fdbbb1afa8bc681
parent258c278e12ba90502bb4805343592a926b6d9a7a
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
30 files changed:
src/cmd/dist/buildruntime.c
src/cmd/dist/goc2c.c
src/pkg/runtime/alg.goc [moved from src/pkg/runtime/alg.c with 95% similarity]
src/pkg/runtime/cgocall.c
src/pkg/runtime/chan.goc [moved from src/pkg/runtime/chan.c with 80% similarity]
src/pkg/runtime/chan.h [new file with mode: 0644]
src/pkg/runtime/complex.goc [moved from src/pkg/runtime/complex.c with 92% similarity]
src/pkg/runtime/cpuprof.goc [moved from src/pkg/runtime/cpuprof.c with 99% similarity]
src/pkg/runtime/defs.c [moved from src/pkg/runtime/export_test.c with 51% similarity]
src/pkg/runtime/export_test.go
src/pkg/runtime/hashmap.goc [moved from src/pkg/runtime/hashmap.c with 71% similarity]
src/pkg/runtime/hashmap.h [new file with mode: 0644]
src/pkg/runtime/hashmap_fast.c
src/pkg/runtime/iface.goc [moved from src/pkg/runtime/iface.c with 72% similarity]
src/pkg/runtime/lfstack.goc [moved from src/pkg/runtime/lfstack.c with 92% similarity]
src/pkg/runtime/malloc.goc
src/pkg/runtime/malloc.h
src/pkg/runtime/mgc0.c
src/pkg/runtime/parfor.c
src/pkg/runtime/pprof/pprof_test.go
src/pkg/runtime/print.c
src/pkg/runtime/proc.c
src/pkg/runtime/rdebug.goc [new file with mode: 0644]
src/pkg/runtime/runtime.c
src/pkg/runtime/runtime.h
src/pkg/runtime/runtime1.goc
src/pkg/runtime/slice.goc [moved from src/pkg/runtime/slice.c with 90% similarity]
src/pkg/runtime/stack.c
src/pkg/runtime/string.goc
src/pkg/runtime/symtab.goc [moved from src/pkg/runtime/symtab.c with 95% similarity]