1
0
mirror of https://github.com/golang/go synced 2024-10-04 06:11:21 -06:00
go/src/cmd/8g
Russ Cox f5184d3437 cmd/gc: correct handling of globals, func args, results
Globals, function arguments, and results are special cases in
registerization.

Globals must be flushed aggressively, because nearly any
operation can cause a panic, and the recovery code must see
the latest values. Globals also must be loaded aggressively,
because nearly any store through a pointer might be updating a
global: the compiler cannot see all the "address of"
operations on globals, especially exported globals. To
accomplish this, mark all globals as having their address
taken, which effectively disables registerization.

If a function contains a defer statement, the function results
must be flushed aggressively, because nearly any operation can
cause a panic, and the deferred code may call recover, causing
the original function to return the current values of its
function results. To accomplish this, mark all function
results as having their address taken if the function contains
any defer statements. This causes not just aggressive flushing
but also aggressive loading. The aggressive loading is
overkill but the best we can do in the current code.

Function arguments must be considered live at all safe points
in a function, because garbage collection always preserves
them: they must be up-to-date in order to be preserved
correctly. Accomplish this by marking them live at all call
sites. An earlier attempt at this marked function arguments as
having their address taken, which disabled registerization
completely, making programs slower. This CL's solution allows
registerization while preserving safety. The benchmark speedup
is caused by being able to registerize again (the earlier CL
lost the same amount).

benchmark                old ns/op     new ns/op     delta
BenchmarkEqualPort32     61.4          56.0          -8.79%

benchmark                old MB/s     new MB/s     speedup
BenchmarkEqualPort32     521.56       570.97       1.09x

Fixes #1304. (again)
Fixes #7944. (again)
Fixes #7984.
Fixes #7995.

LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews, iant, r
https://golang.org/cl/97500044
2014-05-15 15:34:53 -04:00
..
cgen64.c cmd/gc: contiguous loop layout 2012-05-30 18:07:39 -04:00
cgen.c cmd/gc: alias more variables during register allocation 2014-05-12 17:10:36 -04:00
doc.go cmd/godoc: use go/build to determine package and example files 2013-02-19 11:19:58 -08:00
galign.c cmd/gc, cmd/5g, cmd/6g, cmd/8g: introduce linkarchinit and add amd64p32 support 2014-03-07 15:33:44 +11:00
gg.h 5g, 8g: remove dead code 2014-02-25 14:43:53 -08:00
ggen.c cmd/6g, cmd/8g: disable Duff's device on NaCl. 2014-04-04 08:42:35 +02:00
gobj.c cmd/gc: bypass DATA instruction for data initialized to integer constant 2013-12-20 14:24:39 -05:00
gsubr.c cmd/gc: alias more variables during register allocation 2014-05-12 17:10:36 -04:00
Makefile build: delete make paraphernalia 2012-02-06 13:34:25 -05:00
opt.h cmd/gc: fix liveness vs regopt mismatch for input variables 2014-05-12 17:19:02 -04:00
peep.c cmd/gc: shorten temporary lifetimes when possible 2014-04-01 13:31:38 -04:00
prog.c cmd/8g: fix liveness for 387 build (including plan9) 2014-04-06 10:30:02 -04:00
reg.c cmd/gc: correct handling of globals, func args, results 2014-05-15 15:34:53 -04:00