Commit 2b9112a5 authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Canonicalize return sequence for JSFunctions.

This optimization is already implemented in fullcodegen, and
basically makes sure that we do not unecessarily blow up the
code with duplicated return sequences everywhere.

R=danno@chromium.org

Review URL: https://codereview.chromium.org/1211373002

Cr-Commit-Position: refs/heads/master@{#29315}
parent 17486957
......@@ -1024,12 +1024,18 @@ void CodeGenerator::AssembleReturn() {
__ LeaveFrame(StackFrame::MANUAL);
__ Ret();
} else if (descriptor->IsJSFunctionCall() || needs_frame_) {
__ LeaveFrame(StackFrame::MANUAL);
int pop_count = descriptor->IsJSFunctionCall()
? static_cast<int>(descriptor->JSParameterCount())
: 0;
__ Drop(pop_count);
__ Ret();
// Canonicalize JSFunction return sites for now.
if (return_label_.is_bound()) {
__ b(&return_label_);
} else {
__ bind(&return_label_);
__ LeaveFrame(StackFrame::MANUAL);
int pop_count = descriptor->IsJSFunctionCall()
? static_cast<int>(descriptor->JSParameterCount())
: 0;
__ Drop(pop_count);
__ Ret();
}
} else {
__ Ret();
}
......
......@@ -1153,13 +1153,19 @@ void CodeGenerator::AssembleReturn() {
__ Pop(fp, lr);
__ Ret();
} else if (descriptor->IsJSFunctionCall() || needs_frame_) {
__ Mov(jssp, fp);
__ Pop(fp, lr);
int pop_count = descriptor->IsJSFunctionCall()
? static_cast<int>(descriptor->JSParameterCount())
: 0;
__ Drop(pop_count);
__ Ret();
// Canonicalize JSFunction return sites for now.
if (return_label_.is_bound()) {
__ B(&return_label_);
} else {
__ Bind(&return_label_);
__ Mov(jssp, fp);
__ Pop(fp, lr);
int pop_count = descriptor->IsJSFunctionCall()
? static_cast<int>(descriptor->JSParameterCount())
: 0;
__ Drop(pop_count);
__ Ret();
}
} else {
__ Ret();
}
......
......@@ -172,6 +172,7 @@ class CodeGenerator final : public GapResolver::Assembler {
InstructionSequence* const code_;
CompilationInfo* const info_;
Label* const labels_;
Label return_label_;
RpoNumber current_block_;
SourcePosition current_source_position_;
MacroAssembler masm_;
......
......@@ -1339,12 +1339,18 @@ void CodeGenerator::AssembleReturn() {
__ ret(0);
}
} else if (descriptor->IsJSFunctionCall() || needs_frame_) {
__ mov(esp, ebp); // Move stack pointer back to frame pointer.
__ pop(ebp); // Pop caller's frame pointer.
int pop_count = descriptor->IsJSFunctionCall()
? static_cast<int>(descriptor->JSParameterCount())
: 0;
__ Ret(pop_count * kPointerSize, ebx);
// Canonicalize JSFunction return sites for now.
if (return_label_.is_bound()) {
__ jmp(&return_label_);
} else {
__ bind(&return_label_);
__ mov(esp, ebp); // Move stack pointer back to frame pointer.
__ pop(ebp); // Pop caller's frame pointer.
int pop_count = descriptor->IsJSFunctionCall()
? static_cast<int>(descriptor->JSParameterCount())
: 0;
__ Ret(pop_count * kPointerSize, ebx);
}
} else {
__ ret(0);
}
......
......@@ -1141,12 +1141,18 @@ void CodeGenerator::AssembleReturn() {
__ Pop(ra, fp);
__ Ret();
} else if (descriptor->IsJSFunctionCall() || needs_frame_) {
__ mov(sp, fp);
__ Pop(ra, fp);
int pop_count = descriptor->IsJSFunctionCall()
? static_cast<int>(descriptor->JSParameterCount())
: 0;
__ DropAndRet(pop_count);
// Canonicalize JSFunction return sites for now.
if (return_label_.is_bound()) {
__ Branch(&return_label_);
} else {
__ bind(&return_label_);
__ mov(sp, fp);
__ Pop(ra, fp);
int pop_count = descriptor->IsJSFunctionCall()
? static_cast<int>(descriptor->JSParameterCount())
: 0;
__ DropAndRet(pop_count);
}
} else {
__ Ret();
}
......
......@@ -1214,12 +1214,18 @@ void CodeGenerator::AssembleReturn() {
__ Pop(ra, fp);
__ Ret();
} else if (descriptor->IsJSFunctionCall() || needs_frame_) {
__ mov(sp, fp);
__ Pop(ra, fp);
int pop_count = descriptor->IsJSFunctionCall()
? static_cast<int>(descriptor->JSParameterCount())
: 0;
__ DropAndRet(pop_count);
// Canonicalize JSFunction return sites for now.
if (return_label_.is_bound()) {
__ Branch(&return_label_);
} else {
__ bind(&return_label_);
__ mov(sp, fp);
__ Pop(ra, fp);
int pop_count = descriptor->IsJSFunctionCall()
? static_cast<int>(descriptor->JSParameterCount())
: 0;
__ DropAndRet(pop_count);
}
} else {
__ Ret();
}
......
......@@ -1538,12 +1538,18 @@ void CodeGenerator::AssembleReturn() {
__ ret(0);
}
} else if (descriptor->IsJSFunctionCall() || needs_frame_) {
__ movq(rsp, rbp); // Move stack pointer back to frame pointer.
__ popq(rbp); // Pop caller's frame pointer.
int pop_count = descriptor->IsJSFunctionCall()
? static_cast<int>(descriptor->JSParameterCount())
: 0;
__ Ret(pop_count * kPointerSize, rbx);
// Canonicalize JSFunction return sites for now.
if (return_label_.is_bound()) {
__ jmp(&return_label_);
} else {
__ bind(&return_label_);
__ movq(rsp, rbp); // Move stack pointer back to frame pointer.
__ popq(rbp); // Pop caller's frame pointer.
int pop_count = descriptor->IsJSFunctionCall()
? static_cast<int>(descriptor->JSParameterCount())
: 0;
__ Ret(pop_count * kPointerSize, rbx);
}
} else {
__ ret(0);
}
......
......@@ -1599,12 +1599,18 @@ void CodeGenerator::AssembleReturn() {
__ ret(0);
}
} else if (descriptor->IsJSFunctionCall() || needs_frame_) {
__ mov(esp, ebp); // Move stack pointer back to frame pointer.
__ pop(ebp); // Pop caller's frame pointer.
int pop_count = descriptor->IsJSFunctionCall()
? static_cast<int>(descriptor->JSParameterCount())
: 0;
__ Ret(pop_count * kPointerSize, ebx);
// Canonicalize JSFunction return sites for now.
if (return_label_.is_bound()) {
__ jmp(&return_label_);
} else {
__ bind(&return_label_);
__ mov(esp, ebp); // Move stack pointer back to frame pointer.
__ pop(ebp); // Pop caller's frame pointer.
int pop_count = descriptor->IsJSFunctionCall()
? static_cast<int>(descriptor->JSParameterCount())
: 0;
__ Ret(pop_count * kPointerSize, ebx);
}
} else {
__ ret(0);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment