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

Unified Diff: src/compiler/instruction-selector.cc

Issue 1455833004: [turbofan]: Implement tail calls with more callee than caller parameters (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Improve comment Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/instruction-codes.h ('k') | src/compiler/instruction-selector-impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/instruction-selector.cc
diff --git a/src/compiler/instruction-selector.cc b/src/compiler/instruction-selector.cc
index 4200d0d93784f493e4216f3f776fe31d9e3b1817..eb286109f8e2092b3c08596f3f2a649a8de61303 100644
--- a/src/compiler/instruction-selector.cc
+++ b/src/compiler/instruction-selector.cc
@@ -507,6 +507,40 @@ void InstructionSelector::InitializeCallBuffer(Node* call, CallBuffer* buffer,
}
DCHECK_EQ(input_count, buffer->instruction_args.size() + pushed_count -
buffer->frame_state_value_count());
+ if (call_tail && stack_param_delta != 0) {
+ // For tail calls that change the size of their parameter list, move the
+ // saved caller return address, parent frame pointer and parent constant
+ // pool pointer to just above the parameters.
+
+ // Return address
+ LinkageLocation saved_return_location =
+ LinkageLocation::ForSavedCallerReturnAddress();
+ InstructionOperand return_address =
+ g.UsePointerLocation(LinkageLocation::ConvertToTailCallerLocation(
+ saved_return_location, stack_param_delta),
+ saved_return_location);
+ buffer->instruction_args.push_back(return_address);
+
+ // Parent frame pointer
+ LinkageLocation saved_frame_location =
+ LinkageLocation::ForSavedCallerFramePtr();
+ InstructionOperand saved_frame =
+ g.UsePointerLocation(LinkageLocation::ConvertToTailCallerLocation(
+ saved_frame_location, stack_param_delta),
+ saved_frame_location);
+ buffer->instruction_args.push_back(saved_frame);
+
+ if (V8_EMBEDDED_CONSTANT_POOL) {
+ // Constant pool pointer
+ LinkageLocation saved_cp_location =
+ LinkageLocation::ForSavedCallerConstantPool();
+ InstructionOperand saved_cp =
+ g.UsePointerLocation(LinkageLocation::ConvertToTailCallerLocation(
+ saved_cp_location, stack_param_delta),
+ saved_cp_location);
+ buffer->instruction_args.push_back(saved_cp);
+ }
+ }
}
@@ -1287,6 +1321,9 @@ void InstructionSelector::VisitTailCall(Node* node) {
buffer.instruction_args.push_back(g.TempImmediate(stack_param_delta));
+ Emit(kArchPrepareTailCall, g.NoOutput(),
+ g.TempImmediate(stack_param_delta));
+
// Emit the tailcall instruction.
Emit(opcode, 0, nullptr, buffer.instruction_args.size(),
&buffer.instruction_args.front());
« no previous file with comments | « src/compiler/instruction-codes.h ('k') | src/compiler/instruction-selector-impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698