Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2767)

Issue 135830043: code review 135830043: cmd/cc, runtime: convert C compilers to use Go calling ... (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
9 years, 8 months ago by rsc
Modified:
9 years, 7 months ago
Reviewers:
aram2, gobot, iant, dvyukov
CC:
golang-codereviews, 0intro, dave_cheney.net, brainman, dvyukov, iant, josharian, r
Visibility:
Public.

Description

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.

Patch Set 1 #

Patch Set 2 : diff -r 5f91941d28fb718be5e86b34e532e5fc0a83461b https://code.google.com/p/go/ #

Patch Set 3 : diff -r 5f91941d28fb718be5e86b34e532e5fc0a83461b https://code.google.com/p/go/ #

Patch Set 4 : diff -r 5f91941d28fb718be5e86b34e532e5fc0a83461b https://code.google.com/p/go/ #

Patch Set 5 : diff -r 5f91941d28fb718be5e86b34e532e5fc0a83461b https://code.google.com/p/go/ #

Patch Set 6 : diff -r 5f91941d28fb718be5e86b34e532e5fc0a83461b https://code.google.com/p/go/ #

Patch Set 7 : diff -r 5f91941d28fb718be5e86b34e532e5fc0a83461b https://code.google.com/p/go/ #

Patch Set 8 : diff -r 5f91941d28fb718be5e86b34e532e5fc0a83461b https://code.google.com/p/go/ #

Total comments: 15

Patch Set 9 : diff -r 9fafd63bc3c564070ce477ebaba1545f4a11b58f https://code.google.com/p/go/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+2043 lines, -2034 lines) Patch
M src/cmd/5c/cgen.c View 1 2 8 chunks +24 lines, -10 lines 0 comments Download
M src/cmd/5c/gc.h View 1 2 chunks +2 lines, -2 lines 0 comments Download
M src/cmd/5c/sgen.c View 1 1 chunk +1 line, -1 line 0 comments Download
M src/cmd/5c/txt.c View 1 1 chunk +34 lines, -6 lines 0 comments Download
M src/cmd/6c/cgen.c View 1 2 3 8 chunks +25 lines, -9 lines 0 comments Download
M src/cmd/6c/gc.h View 1 2 chunks +2 lines, -2 lines 0 comments Download
M src/cmd/6c/sgen.c View 1 1 chunk +1 line, -1 line 0 comments Download
M src/cmd/6c/txt.c View 1 1 chunk +34 lines, -6 lines 0 comments Download
M src/cmd/8c/cgen.c View 1 2 8 chunks +24 lines, -10 lines 0 comments Download
M src/cmd/8c/gc.h View 1 2 chunks +2 lines, -2 lines 0 comments Download
M src/cmd/8c/sgen.c View 1 1 chunk +1 line, -1 line 0 comments Download
M src/cmd/8c/txt.c View 1 2 1 chunk +34 lines, -6 lines 0 comments Download
M src/cmd/api/goapi.go View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M src/cmd/cc/cc.h View 1 1 chunk +1 line, -1 line 0 comments Download
M src/cmd/cc/dcl.c View 1 2 1 chunk +2 lines, -1 line 0 comments Download
M src/cmd/cc/pgen.c View 1 6 chunks +33 lines, -11 lines 0 comments Download
M src/pkg/runtime/alg.go View 1 1 chunk +3 lines, -0 lines 0 comments Download
M src/pkg/runtime/asm_386.s View 1 2 22 chunks +75 lines, -68 lines 0 comments Download
M src/pkg/runtime/asm_amd64.s View 1 2 17 chunks +75 lines, -61 lines 0 comments Download
M src/pkg/runtime/asm_amd64p32.s View 1 2 16 chunks +62 lines, -45 lines 0 comments Download
M src/pkg/runtime/asm_arm.s View 1 2 3 4 5 7 chunks +9 lines, -12 lines 0 comments Download
M src/pkg/runtime/memclr_plan9_amd64.s View 1 1 chunk +2 lines, -2 lines 0 comments Download
M src/pkg/runtime/memmove_nacl_amd64p32.s View 1 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/runtime/memmove_plan9_386.s View 1 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/runtime/memmove_plan9_amd64.s View 1 1 chunk +1 line, -1 line 0 comments Download
A src/pkg/runtime/os_darwin.go View 1 1 chunk +27 lines, -0 lines 0 comments Download
A src/pkg/runtime/os_dragonfly.go View 1 1 chunk +21 lines, -0 lines 0 comments Download
A src/pkg/runtime/os_freebsd.go View 1 1 chunk +20 lines, -0 lines 0 comments Download
A src/pkg/runtime/os_linux.go View 1 1 chunk +22 lines, -0 lines 0 comments Download
A src/pkg/runtime/os_nacl.go View 1 1 chunk +24 lines, -0 lines 0 comments Download
A src/pkg/runtime/os_netbsd.go View 1 1 chunk +23 lines, -0 lines 0 comments Download
A src/pkg/runtime/os_openbsd.go View 1 1 chunk +20 lines, -0 lines 0 comments Download
A src/pkg/runtime/os_plan9.go View 1 1 chunk +24 lines, -0 lines 0 comments Download
A src/pkg/runtime/os_solaris.go View 1 1 chunk +22 lines, -0 lines 0 comments Download
A src/pkg/runtime/os_windows.go View 1 1 chunk +12 lines, -0 lines 0 comments Download
M src/pkg/runtime/stubs.go View 1 2 3 4 5 6 7 8 1 chunk +45 lines, -0 lines 0 comments Download
M src/pkg/runtime/sys_darwin_386.s View 1 11 chunks +26 lines, -7 lines 0 comments Download
M src/pkg/runtime/sys_darwin_amd64.s View 1 13 chunks +92 lines, -67 lines 0 comments Download
M src/pkg/runtime/sys_dragonfly_386.s View 1 11 chunks +20 lines, -8 lines 0 comments Download
M src/pkg/runtime/sys_dragonfly_amd64.s View 1 9 chunks +67 lines, -53 lines 0 comments Download
M src/pkg/runtime/sys_freebsd_386.s View 1 10 chunks +18 lines, -8 lines 0 comments Download
M src/pkg/runtime/sys_freebsd_amd64.s View 1 9 chunks +66 lines, -54 lines 0 comments Download
M src/pkg/runtime/sys_freebsd_arm.s View 1 10 chunks +12 lines, -3 lines 0 comments Download
M src/pkg/runtime/sys_linux_386.s View 1 11 chunks +82 lines, -69 lines 0 comments Download
M src/pkg/runtime/sys_linux_amd64.s View 1 2 3 4 5 6 7 8 11 chunks +88 lines, -71 lines 0 comments Download
M src/pkg/runtime/sys_linux_arm.s View 1 2 3 4 5 17 chunks +24 lines, -9 lines 0 comments Download
M src/pkg/runtime/sys_nacl_386.s View 1 2 chunks +9 lines, -9 lines 0 comments Download
M src/pkg/runtime/sys_nacl_amd64p32.s View 1 8 chunks +54 lines, -49 lines 0 comments Download
M src/pkg/runtime/sys_nacl_arm.s View 1 5 chunks +46 lines, -46 lines 0 comments Download
M src/pkg/runtime/sys_netbsd_386.s View 1 10 chunks +17 lines, -7 lines 0 comments Download
M src/pkg/runtime/sys_netbsd_amd64.s View 1 11 chunks +66 lines, -52 lines 0 comments Download
M src/pkg/runtime/sys_netbsd_arm.s View 1 8 chunks +15 lines, -4 lines 0 comments Download
M src/pkg/runtime/sys_openbsd_386.s View 1 2 3 4 5 6 7 11 chunks +27 lines, -17 lines 0 comments Download
M src/pkg/runtime/sys_openbsd_amd64.s View 1 10 chunks +67 lines, -53 lines 0 comments Download
M src/pkg/runtime/sys_plan9_386.s View 1 5 chunks +50 lines, -18 lines 0 comments Download
M src/pkg/runtime/sys_plan9_amd64.s View 1 6 chunks +29 lines, -15 lines 0 comments Download
M src/pkg/runtime/sys_solaris_amd64.s View 1 3 chunks +3 lines, -1 line 0 comments Download
M src/pkg/runtime/sys_windows_386.s View 1 5 chunks +5 lines, -4 lines 0 comments Download
M src/pkg/runtime/sys_windows_amd64.s View 1 3 chunks +3 lines, -2 lines 0 comments Download
M src/pkg/runtime/vlop_386.s View 1 2 3 chunks +3 lines, -1 line 0 comments Download
M src/pkg/runtime/vlop_arm.s View 1 2 3 4 5 1 chunk +6 lines, -7 lines 0 comments Download
M src/pkg/runtime/vlrt.c View 1 2 3 4 5 6 12 chunks +436 lines, -349 lines 0 comments Download
R src/pkg/runtime/vlrt_arm.c View 1 2 3 4 5 1 chunk +0 lines, -769 lines 0 comments Download
M src/pkg/sync/atomic/asm_linux_arm.s View 1 2 3 4 5 6 1 chunk +2 lines, -22 lines 0 comments Download

Messages

Total messages: 20
rsc
Hello golang-codereviews@googlegroups.com (cc: dfc, iant, josharian, r), I'd like you to review this change to ...
9 years, 8 months ago (2014-08-27 05:03:47 UTC) #1
0intro
It seems runtime.seek is failing on Plan 9. cmd/go runtime: panic before malloc heap initialized ...
9 years, 8 months ago (2014-08-27 05:25:21 UTC) #2
dave_cheney.net
Solaris reports we've run out of stack in chansend1 runtime.chansend1: nosplit stack overflow 120 assumed ...
9 years, 8 months ago (2014-08-27 05:43:43 UTC) #3
dave_cheney.net
linux/arm is happen with this change. Thanks for unifying vlrt_{386,arm}.c https://codereview.appspot.com/135830043/diff/140001/src/pkg/runtime/sys_linux_amd64.s File src/pkg/runtime/sys_linux_amd64.s (right): https://codereview.appspot.com/135830043/diff/140001/src/pkg/runtime/sys_linux_amd64.s#newcode298 ...
9 years, 8 months ago (2014-08-27 06:08:26 UTC) #4
brainman
This is broken on windows in a multiple wonderful ways. :-) Alex
9 years, 8 months ago (2014-08-27 07:00:21 UTC) #5
dvyukov
Whoa! This is cool! Reasons for different calling conventions are pure historical, right? https://codereview.appspot.com/135830043/diff/140001/src/pkg/runtime/stubs.go File ...
9 years, 8 months ago (2014-08-27 09:03:29 UTC) #6
rsc
I'm trying to avoid making ANY more changes here. I will fix Windows and Solaris ...
9 years, 8 months ago (2014-08-27 11:14:29 UTC) #7
dave_cheney.net
On Wed, Aug 27, 2014 at 9:14 PM, <rsc@golang.org> wrote: > I'm trying to avoid ...
9 years, 8 months ago (2014-08-27 11:17:16 UTC) #8
rsc
On Wed, Aug 27, 2014 at 5:03 AM, <dvyukov@google.com> wrote: > Whoa! This is cool! ...
9 years, 8 months ago (2014-08-27 11:22:39 UTC) #9
rsc
On Wed, Aug 27, 2014 at 7:17 AM, Dave Cheney <dave@cheney.net> wrote: > man 2 ...
9 years, 8 months ago (2014-08-27 11:23:35 UTC) #10
dave_cheney.net
On Wed, Aug 27, 2014 at 9:23 PM, Russ Cox <rsc@golang.org> wrote: > On Wed, ...
9 years, 8 months ago (2014-08-27 11:26:25 UTC) #11
dvyukov
forget to hg upload
9 years, 8 months ago (2014-08-27 11:29:21 UTC) #12
rsc
On Wed, Aug 27, 2014 at 7:29 AM, <dvyukov@google.com> wrote: > forget to hg upload ...
9 years, 8 months ago (2014-08-27 11:31:23 UTC) #13
dvyukov
LGTM the code as-is requires some cleanups, but they will be done in separate changes ...
9 years, 8 months ago (2014-08-27 11:39:59 UTC) #14
iant
LGTM I tried to look at everything but there is really too much here to ...
9 years, 8 months ago (2014-08-27 13:01:58 UTC) #15
rsc
On Wed, Aug 27, 2014 at 9:01 AM, <iant@golang.org> wrote: > LGTM > > I ...
9 years, 8 months ago (2014-08-27 15:25:21 UTC) #16
rsc
https://codereview.appspot.com/135830043/diff/140001/src/pkg/runtime/vlop_386.s File src/pkg/runtime/vlop_386.s (right): https://codereview.appspot.com/135830043/diff/140001/src/pkg/runtime/vlop_386.s#newcode45 src/pkg/runtime/vlop_386.s:45: MOVL DX, AX On 2014/08/27 13:01:58, iant wrote: > ...
9 years, 8 months ago (2014-08-27 15:26:20 UTC) #17
rsc
*** Submitted as https://code.google.com/p/go/source/detail?r=05c3fee13eb3 *** cmd/cc, runtime: convert C compilers to use Go calling convention ...
9 years, 8 months ago (2014-08-27 15:32:22 UTC) #18
gobot
This CL appears to have broken the windows-amd64-perf builder. See http://build.golang.org/log/a749a712c84e1e2b78b173a771d1b1e752a3fec0
9 years, 8 months ago (2014-08-27 15:33:56 UTC) #19
aram2
9 years, 8 months ago (2014-08-27 19:05:47 UTC) #20
Great.

LGTM

-- 
Aram Hăvărneanu
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b