Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(873)

Issue 1259203002: [turbofan] Implement tail calls with differing stack parameter counts (Closed)

Created:
5 years, 4 months ago by danno
Modified:
4 years, 11 months ago
Reviewers:
Benedikt Meurer, titzer
CC:
v8-dev
Base URL:
https://chromium.googlesource.com/v8/v8.git@master
Target Ref:
refs/pending/heads/master
Project:
v8
Visibility:
Public.

Description

[turbofan] Implement tail calls with differing stack parameter counts WORK IN PROGRESS, I'D APPRECIATE FEEDBACK BEFORE DOING THE OTHER PLATFORM PORTS This implementation loads as many parameters as possible before the tail call into registers and pushes the rest on the stack before deconstructing the frame. As the frame is torn down, callee parameters are replaced for the tail call by a mini parameter-handling interpreter, either by storing values that are already in registers or by popping and storing the parameter values from the stack. The return address is handled specially. If the number of parameters increases in tail call tall, the parameter value that will replace the return address must be in a register before the frame is deconstructed and frame desconstruction does a special value-swapping dance to make sure that the return address ends up at the top of all parameters before finishing the tail call.

Patch Set 1 #

Patch Set 2 : ia32 done #

Patch Set 3 : Tests pass #

Patch Set 4 : Cleanup #

Patch Set 5 : Latest #

Patch Set 6 : Fix comment #

Patch Set 7 : Remove stray change #

Patch Set 8 : Fix bugs in frameless tail calls #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+570 lines, -116 lines) Patch
M src/compiler/ast-graph-builder.cc View 1 chunk +6 lines, -1 line 1 comment Download
M src/compiler/code-generator.h View 1 2 3 4 5 6 7 2 chunks +3 lines, -3 lines 0 comments Download
M src/compiler/code-generator.cc View 1 2 3 4 5 6 7 1 chunk +1 line, -2 lines 0 comments Download
M src/compiler/frame.h View 1 2 3 chunks +26 lines, -3 lines 0 comments Download
M src/compiler/ia32/code-generator-ia32.cc View 1 2 3 4 5 6 7 8 chunks +130 lines, -17 lines 1 comment Download
M src/compiler/ia32/instruction-selector-ia32.cc View 1 2 3 4 5 6 7 2 chunks +125 lines, -20 lines 1 comment Download
M src/compiler/instruction.h View 1 2 3 4 5 6 7 4 chunks +13 lines, -1 line 0 comments Download
M src/compiler/instruction.cc View 1 chunk +3 lines, -1 line 0 comments Download
M src/compiler/instruction-selector.h View 1 2 3 4 5 6 1 chunk +3 lines, -0 lines 0 comments Download
M src/compiler/js-intrinsic-lowering.cc View 1 chunk +1 line, -1 line 0 comments Download
M src/compiler/js-operator.h View 3 chunks +7 lines, -4 lines 0 comments Download
M src/compiler/js-operator.cc View 1 2 2 chunks +6 lines, -3 lines 0 comments Download
M src/compiler/linkage.h View 1 chunk +4 lines, -1 line 0 comments Download
M src/compiler/linkage.cc View 4 chunks +29 lines, -21 lines 0 comments Download
M src/compiler/pipeline.cc View 8 chunks +9 lines, -12 lines 0 comments Download
M src/compiler/register-allocator.cc View 1 2 3 1 chunk +3 lines, -0 lines 0 comments Download
M test/cctest/cctest.gyp View 1 1 chunk +1 line, -0 lines 0 comments Download
M test/cctest/compiler/test-instruction.cc View 1 chunk +1 line, -1 line 0 comments Download
M test/cctest/compiler/test-jump-threading.cc View 1 chunk +1 line, -1 line 0 comments Download
A test/cctest/compiler/test-tail-calls.cc View 1 1 chunk +118 lines, -0 lines 0 comments Download
M test/mjsunit/call-runtime-tail.js View 1 chunk +1 line, -1 line 0 comments Download
M test/unittests/compiler/instruction-selector-unittest.cc View 1 2 3 1 chunk +2 lines, -1 line 0 comments Download
M test/unittests/compiler/instruction-sequence-unittest.cc View 1 chunk +1 line, -1 line 0 comments Download
M test/unittests/compiler/linkage-tail-call-unittest.cc View 13 chunks +76 lines, -21 lines 0 comments Download

Messages

Total messages: 3 (1 generated)
danno
Not for landing yet, but I'd appreciate feedback before doing the rest of the platform ...
5 years, 4 months ago (2015-07-29 08:49:50 UTC) #2
Benedikt Meurer
5 years, 4 months ago (2015-07-30 06:47:24 UTC) #3
https://codereview.chromium.org/1259203002/diff/140001/src/compiler/ast-graph...
File src/compiler/ast-graph-builder.cc (right):

https://codereview.chromium.org/1259203002/diff/140001/src/compiler/ast-graph...
src/compiler/ast-graph-builder.cc:2606: TailCallMode mode =
IMHO this will be highly confusing and might be a source of weird bugs in the
future. By just looking at a tail call site in a .js file you will be mostly
unable to tell whether it is actually a tailcall to the runtime or a regular
call. I'd really prefer to have this explicit at the tail call site so people
are aware of what they are doing, just like we do in the native code stubs,
where we have __ TailCallRuntime and __ CallRuntime.

https://codereview.chromium.org/1259203002/diff/140001/src/compiler/ia32/code...
File src/compiler/ia32/code-generator-ia32.cc (right):

https://codereview.chromium.org/1259203002/diff/140001/src/compiler/ia32/code...
src/compiler/ia32/code-generator-ia32.cc:287: void
CodeGenerator::AssembleTailCallSetup(Instruction* instr) {
This is quite a lot of (complex) per-architecture code. I have a bad feeling
about this. Can we make this into explicit instruction opcodes at least and do
this magic as part of the instruction selection? This code within code approach
frightens me.

https://codereview.chromium.org/1259203002/diff/140001/src/compiler/ia32/inst...
File src/compiler/ia32/instruction-selector-ia32.cc (right):

https://codereview.chromium.org/1259203002/diff/140001/src/compiler/ia32/inst...
src/compiler/ia32/instruction-selector-ia32.cc:912: bool
InstructionSelector::EmitTailCallSetup(Node* node, CallBuffer* buffer,
See my comment in code-generator-ia32.cc.
Can we somehow make the tail call setup into regular InstructionCodes? We
already have push and pop.

Powered by Google App Engine
This is Rietveld 408576698