1
0
mirror of https://github.com/golang/go synced 2024-11-23 07:00:05 -07:00
go/test/abi
Cherry Mui c10b980220 cmd/compile: restore tail call for method wrappers
For certain type of method wrappers we used to generate a tail
call. That was disabled in CL 307234 when register ABI is used,
because with the current IR it was difficult to generate a tail
call with the arguments in the right places. The problem was that
the IR does not contain a CALL-like node with arguments; instead,
it contains an OAS node that adjusts the receiver, than an
OTAILCALL node that just contains the target, but no argument
(with the assumption that the OAS node will put the adjusted
receiver in the right place). With register ABI, putting
arguments in registers are done in SSA. The assignment (OAS)
doesn't put the receiver in register.

This CL changes the IR of a tail call to take an actual OCALL
node. Specifically, a tail call is represented as

OTAILCALL (OCALL target args...)

This way, the call target and args are connected through the OCALL
node. So the call can be analyzed in SSA and the args can be passed
in the right places.

(Alternatively, we could have OTAILCALL node directly take the
target and the args, without the OCALL node. Using an OCALL node is
convenient as there are existing code that processes OCALL nodes
which do not need to be changed. Also, a tail call is similar to
ORETURN (OCALL target args...), except it doesn't preserve the
frame. I did the former but I'm open to change.)

The SSA representation is similar. Previously, the IR lowers to
a Store the receiver then a BlockRetJmp which jumps to the target
(without putting the arg in register). Now we use a TailCall op,
which takes the target and the args. The call expansion pass and
the register allocator handles TailCall pretty much like a
StaticCall, and it will do the right ABI analysis and put the args
in the right places. (Args other than the receiver are already in
the right places. For register args it generates no code for them.
For stack args currently it generates a self copy. I'll work on
optimize that out.) BlockRetJmp is still used, signaling it is a
tail call. The actual call is made in the TailCall op so
BlockRetJmp generates no code (we could use BlockExit if we like).

This slightly reduces binary size:
              old        new
cmd/go     14003088   13953936
cmd/link    6275552    6271456

Change-Id: I2d16d8d419fe1f17554916d317427383e17e27f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/350145
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
2021-09-17 22:59:44 +00:00
..
bad_internal_offsets.go
bad_select_crash.go test/abi: reenable test on windows 2021-04-16 13:38:02 +00:00
convF_criteria.go cmd/compile: fix buglet in walk convert phase relating to convF32/64 2021-04-08 19:58:50 +00:00
convF_criteria.out cmd/compile: fix buglet in walk convert phase relating to convF32/64 2021-04-08 19:58:50 +00:00
convT64_criteria.go cmd/compile: fix buglet in walk convert phase relating to convT64 2021-04-08 17:44:21 +00:00
convT64_criteria.out cmd/compile: fix buglet in walk convert phase relating to convT64 2021-04-08 17:44:21 +00:00
defer_aggregate.go
defer_recover_results.go cmd/compile: load results into registers on open defer return path 2021-04-06 20:22:15 +00:00
double_nested_addressed_struct.go
double_nested_struct.go
f_ret_z_not.go
f_ret_z_not.out
fibish_closure.go
fibish_closure.out
fibish.go
fibish.out
fuzz_trailing_zero_field.go cmd/compile: fix register/offset calculation for trailing empty field case. 2021-04-01 15:50:43 +00:00
idata.go cmd/compile: add "surprised by IData of Arg" case for register args 2021-04-05 20:11:08 +00:00
idata.out cmd/compile: add "surprised by IData of Arg" case for register args 2021-04-05 20:11:08 +00:00
leaf2.go
leaf.go
many_int_input.go
many_int_input.out
many_intstar_input.go
many_intstar_input.out
map.go cmd/compile: preserve pointerness when creating map key temp 2021-04-20 14:30:03 +00:00
method_wrapper.go cmd/compile: restore tail call for method wrappers 2021-09-17 22:59:44 +00:00
more_intstar_input.go
more_intstar_input.out
named_results.go
named_results.out
named_return_stuff.go
named_return_stuff.out
open_defer_1.go
part_live_2.go cmd/compile: pre-spill pointers in aggregate-typed register args 2021-04-07 03:42:11 +00:00
part_live.go cmd/compile: pre-spill pointers in aggregate-typed register args 2021-04-07 03:42:11 +00:00
result_live.go test: add test for CL 310589 2021-04-19 14:51:24 +00:00
result_regalloc.go cmd/compile: use desired register only if it satisfies register mask 2021-04-28 16:13:40 +00:00
return_stuff.go
return_stuff.out
s_sif_sif.go
spills3.go
spills4.go
store_reg_args.go
struct_3_string_input.go
struct_3_string_input.out
struct_lower_1.go
struct_lower_1.out
too_big_to_ssa.go
too_big_to_ssa.out
uglyfib.go
uglyfib.out
wrapdefer_largetmp.go cmd/compile: fix bug in defer wrapping 2021-04-23 01:16:19 +00:00
wrapdefer_largetmp.out cmd/compile: fix bug in defer wrapping 2021-04-23 01:16:19 +00:00
zombie_struct_select.go cmd/compile: mark unused values as invalid to prevent problems in expandCalls 2021-04-02 17:58:59 +00:00