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

Unified Diff: src/compiler/ia32/code-generator-ia32.cc

Issue 2446543002: [turbofan] Support variable size argument popping in TF-generated functions (Closed)
Patch Set: Fix tests and arm64 Created 4 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/common-operator-reducer.cc ('k') | src/compiler/instruction-selector.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/ia32/code-generator-ia32.cc
diff --git a/src/compiler/ia32/code-generator-ia32.cc b/src/compiler/ia32/code-generator-ia32.cc
index 2b8cf08cb71e81eb286fbed3009e2a33484fb48d..2e54e2a6341654c0e5bee142b65cba715c7c34b6 100644
--- a/src/compiler/ia32/code-generator-ia32.cc
+++ b/src/compiler/ia32/code-generator-ia32.cc
@@ -649,7 +649,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
break;
}
case kArchRet:
- AssembleReturn();
+ AssembleReturn(instr->InputAt(0));
break;
case kArchStackPointer:
__ mov(i.OutputRegister(), esp);
@@ -1981,8 +1981,7 @@ void CodeGenerator::AssembleConstructFrame() {
}
}
-
-void CodeGenerator::AssembleReturn() {
+void CodeGenerator::AssembleReturn(InstructionOperand* pop) {
CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
const RegList saves = descriptor->CalleeSavedRegisters();
@@ -1994,22 +1993,41 @@ void CodeGenerator::AssembleReturn() {
}
}
+ // Might need ecx for scratch if pop_size is too big or if there is a variable
+ // pop count.
+ DCHECK_EQ(0u, descriptor->CalleeSavedRegisters() & ecx.bit());
+ size_t pop_size = descriptor->StackParameterCount() * kPointerSize;
+ IA32OperandConverter g(this, nullptr);
if (descriptor->IsCFunctionCall()) {
AssembleDeconstructFrame();
} else if (frame_access_state()->has_frame()) {
- // Canonicalize JSFunction return sites for now.
- if (return_label_.is_bound()) {
- __ jmp(&return_label_);
- return;
+ // Canonicalize JSFunction return sites for now if they always have the same
+ // number of return args.
+ if (pop->IsImmediate() && g.ToConstant(pop).ToInt32() == 0) {
+ if (return_label_.is_bound()) {
+ __ jmp(&return_label_);
+ return;
+ } else {
+ __ bind(&return_label_);
+ AssembleDeconstructFrame();
+ }
} else {
- __ bind(&return_label_);
AssembleDeconstructFrame();
}
}
- size_t pop_size = descriptor->StackParameterCount() * kPointerSize;
- // Might need ecx for scratch if pop_size is too big.
+ DCHECK_EQ(0u, descriptor->CalleeSavedRegisters() & edx.bit());
DCHECK_EQ(0u, descriptor->CalleeSavedRegisters() & ecx.bit());
- __ Ret(static_cast<int>(pop_size), ecx);
+ if (pop->IsImmediate()) {
+ DCHECK_EQ(Constant::kInt32, g.ToConstant(pop).type());
+ pop_size += g.ToConstant(pop).ToInt32() * kPointerSize;
+ __ Ret(static_cast<int>(pop_size), ecx);
+ } else {
+ Register pop_reg = g.ToRegister(pop);
+ Register scratch_reg = pop_reg.is(ecx) ? edx : ecx;
+ __ pop(scratch_reg);
+ __ lea(esp, Operand(esp, pop_reg, times_4, static_cast<int>(pop_size)));
+ __ jmp(scratch_reg);
+ }
}
« no previous file with comments | « src/compiler/common-operator-reducer.cc ('k') | src/compiler/instruction-selector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698