From f3b8a3c8a893113d9851b71bb4a036de3624dcc3 Mon Sep 17 00:00:00 2001 From: "mvstanton@chromium.org" Date: Tue, 12 Mar 2013 09:06:23 +0000 Subject: [PATCH] MIPS: To fully support hydrogen code stubs which accept a variable number of arguments, the HReturn/LReturn instruction needs to be able to determine argument count from a stack evaluation rather than as a constant from scope. Port r13888 (33905114) BUG= Review URL: https://codereview.chromium.org/12414011 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13910 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/mips/lithium-codegen-mips.cc | 15 ++++++++++++--- src/mips/lithium-codegen-mips.h | 1 - src/mips/lithium-mips.cc | 4 +++- src/mips/lithium-mips.h | 14 ++++++++++++-- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc index ab08399..3cd89b8 100644 --- a/src/mips/lithium-codegen-mips.cc +++ b/src/mips/lithium-codegen-mips.cc @@ -2558,11 +2558,20 @@ void LCodeGen::DoReturn(LReturn* instr) { } } if (NeedsEagerFrame()) { - int32_t sp_delta = (GetParameterCount() + 1) * kPointerSize; __ mov(sp, fp); __ Pop(ra, fp); - if (!info()->IsStub()) { - __ Addu(sp, sp, Operand(sp_delta)); + + if (instr->has_constant_parameter_count()) { + int parameter_count = ToInteger32(instr->constant_parameter_count()); + int32_t sp_delta = (parameter_count + 1) * kPointerSize; + if (sp_delta != 0) { + __ Addu(sp, sp, Operand(sp_delta)); + } + } else { + Register reg = ToRegister(instr->parameter_count()); + __ Addu(reg, reg, Operand(1)); + __ sll(at, reg, kPointerSizeLog2); + __ Addu(sp, sp, at); } } __ Jump(ra); diff --git a/src/mips/lithium-codegen-mips.h b/src/mips/lithium-codegen-mips.h index b4476c4..1d2a659 100644 --- a/src/mips/lithium-codegen-mips.h +++ b/src/mips/lithium-codegen-mips.h @@ -201,7 +201,6 @@ class LCodeGen BASE_EMBEDDED { Register temporary2); int GetStackSlotCount() const { return chunk()->spill_slot_count(); } - int GetParameterCount() const { return info()->num_parameters(); } void Abort(const char* reason); void Comment(const char* format, ...); diff --git a/src/mips/lithium-mips.cc b/src/mips/lithium-mips.cc index 533207c..b233d51 100644 --- a/src/mips/lithium-mips.cc +++ b/src/mips/lithium-mips.cc @@ -1804,7 +1804,9 @@ LInstruction* LChunkBuilder::DoClampToUint8(HClampToUint8* instr) { LInstruction* LChunkBuilder::DoReturn(HReturn* instr) { - return new(zone()) LReturn(UseFixed(instr->value(), v0)); + LOperand* parameter_count = UseRegisterOrConstant(instr->parameter_count()); + return new(zone()) LReturn(UseFixed(instr->value(), v0), + parameter_count); } diff --git a/src/mips/lithium-mips.h b/src/mips/lithium-mips.h index c5a00d7..ccaad71 100644 --- a/src/mips/lithium-mips.h +++ b/src/mips/lithium-mips.h @@ -1343,14 +1343,24 @@ class LArithmeticT: public LTemplateInstruction<1, 2, 0> { }; -class LReturn: public LTemplateInstruction<0, 1, 0> { +class LReturn: public LTemplateInstruction<0, 2, 0> { public: - explicit LReturn(LOperand* value) { + explicit LReturn(LOperand* value, LOperand* parameter_count) { inputs_[0] = value; + inputs_[1] = parameter_count; } LOperand* value() { return inputs_[0]; } + bool has_constant_parameter_count() { + return parameter_count()->IsConstantOperand(); + } + LConstantOperand* constant_parameter_count() { + ASSERT(has_constant_parameter_count()); + return LConstantOperand::cast(parameter_count()); + } + LOperand* parameter_count() { return inputs_[1]; } + DECLARE_CONCRETE_INSTRUCTION(Return, "return") }; -- 2.7.4