From f622a232542128c3f47a11b01d5eea7db0304966 Mon Sep 17 00:00:00 2001 From: "sgjesse@chromium.org" Date: Wed, 16 Feb 2011 14:48:41 +0000 Subject: [PATCH] ARM: Remove crankshaft dependency on the generic binary operation stub The crankshaft code now only relies on the type recording binary operation stub. Added check for overwritable heap number in the type recording binary operation stub. Review URL: http://codereview.chromium.org/6529050 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6823 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/code-stubs-arm.cc | 26 +++++++++++++++----------- src/arm/lithium-codegen-arm.cc | 35 +++++++++++++++++++++++------------ src/arm/lithium-codegen-arm.h | 4 ++-- 3 files changed, 40 insertions(+), 25 deletions(-) diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc index cc49f7e..7aec206 100644 --- a/src/arm/code-stubs-arm.cc +++ b/src/arm/code-stubs-arm.cc @@ -2661,8 +2661,8 @@ void TypeRecordingBinaryOpStub::GenerateFPOperation(MacroAssembler* masm, // Allocate new heap number for result. Register result = r5; - __ AllocateHeapNumber( - result, scratch1, scratch2, heap_number_map, gc_required); + GenerateHeapResultAllocation( + masm, result, heap_number_map, scratch1, scratch2, gc_required); // Load the operands. if (smi_operands) { @@ -2811,8 +2811,14 @@ void TypeRecordingBinaryOpStub::GenerateFPOperation(MacroAssembler* masm, // Allocate new heap number for result. __ bind(&result_not_a_smi); - __ AllocateHeapNumber( - r5, scratch1, scratch2, heap_number_map, gc_required); + Register result = r5; + if (smi_operands) { + __ AllocateHeapNumber( + result, scratch1, scratch2, heap_number_map, gc_required); + } else { + GenerateHeapResultAllocation( + masm, result, heap_number_map, scratch1, scratch2, gc_required); + } // r2: Answer as signed int32. // r5: Heap number to write answer into. @@ -2934,21 +2940,19 @@ void TypeRecordingBinaryOpStub::GenerateHeapNumberStub(MacroAssembler* masm) { void TypeRecordingBinaryOpStub::GenerateGeneric(MacroAssembler* masm) { - Label call_runtime; + Label call_runtime, call_string_add_or_runtime; GenerateSmiCode(masm, &call_runtime, ALLOW_HEAPNUMBER_RESULTS); - // If all else fails, use the runtime system to get the correct - // result. - __ bind(&call_runtime); + GenerateFPOperation(masm, false, &call_string_add_or_runtime, &call_runtime); - // Try to add strings before calling runtime. + __ bind(&call_string_add_or_runtime); if (op_ == Token::ADD) { GenerateAddStrings(masm); } - GenericBinaryOpStub stub(op_, mode_, r1, r0); - __ TailCallStub(&stub); + __ bind(&call_runtime); + GenerateCallRuntime(masm); } diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index 1bfb3ad..2c916f6 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -987,7 +987,7 @@ void LCodeGen::DoModI(LModI* instr) { DeferredModI(LCodeGen* codegen, LModI* instr) : LDeferredCode(codegen), instr_(instr) { } virtual void Generate() { - codegen()->DoDeferredGenericBinaryStub(instr_, Token::MOD); + codegen()->DoDeferredBinaryOpStub(instr_, Token::MOD); } private: LModI* instr_; @@ -1016,7 +1016,7 @@ void LCodeGen::DoModI(LModI* instr) { __ bind(&ok); } - // Try a few common cases before using the generic stub. + // Try a few common cases before using the stub. Label call_stub; const int kUnfolds = 3; // Skip if either side is negative. @@ -1044,7 +1044,7 @@ void LCodeGen::DoModI(LModI* instr) { __ and_(result, scratch, Operand(left)); __ bind(&call_stub); - // Call the generic stub. The numbers in r0 and r1 have + // Call the stub. The numbers in r0 and r1 have // to be tagged to Smis. If that is not possible, deoptimize. DeferredModI* deferred = new DeferredModI(this, instr); __ TrySmiTag(left, &deoptimize, scratch); @@ -1070,7 +1070,7 @@ void LCodeGen::DoDivI(LDivI* instr) { DeferredDivI(LCodeGen* codegen, LDivI* instr) : LDeferredCode(codegen), instr_(instr) { } virtual void Generate() { - codegen()->DoDeferredGenericBinaryStub(instr_, Token::DIV); + codegen()->DoDeferredBinaryOpStub(instr_, Token::DIV); } private: LDivI* instr_; @@ -1123,7 +1123,7 @@ void LCodeGen::DoDivI(LDivI* instr) { __ mov(result, Operand(left, ASR, 2), LeaveCC, eq); __ b(eq, &done); - // Call the generic stub. The numbers in r0 and r1 have + // Call the stub. The numbers in r0 and r1 have // to be tagged to Smis. If that is not possible, deoptimize. DeferredDivI* deferred = new DeferredDivI(this, instr); @@ -1145,13 +1145,27 @@ void LCodeGen::DoDivI(LDivI* instr) { template -void LCodeGen::DoDeferredGenericBinaryStub(LTemplateInstruction<1, 2, T>* instr, - Token::Value op) { +void LCodeGen::DoDeferredBinaryOpStub(LTemplateInstruction<1, 2, T>* instr, + Token::Value op) { Register left = ToRegister(instr->InputAt(0)); Register right = ToRegister(instr->InputAt(1)); __ PushSafepointRegistersAndDoubles(); - GenericBinaryOpStub stub(op, OVERWRITE_LEFT, left, right); + // Move left to r1 and right to r0 for the stub call. + if (left.is(r1)) { + __ Move(r0, right); + } else if (left.is(r0) && right.is(r1)) { + __ Swap(r0, r1, r2); + } else if (left.is(r0)) { + ASSERT(!right.is(r1)); + __ mov(r1, r0); + __ mov(r0, right); + } else { + ASSERT(!left.is(r0) && !right.is(r0)); + __ mov(r0, right); + __ mov(r1, left); + } + TypeRecordingBinaryOpStub stub(op, OVERWRITE_LEFT); __ CallStub(&stub); RecordSafepointWithRegistersAndDoubles(instr->pointer_map(), 0, @@ -1431,10 +1445,7 @@ void LCodeGen::DoArithmeticT(LArithmeticT* instr) { ASSERT(ToRegister(instr->InputAt(1)).is(r0)); ASSERT(ToRegister(instr->result()).is(r0)); - // TODO(regis): Implement TypeRecordingBinaryOpStub and replace current - // GenericBinaryOpStub: - // TypeRecordingBinaryOpStub stub(instr->op(), NO_OVERWRITE); - GenericBinaryOpStub stub(instr->op(), NO_OVERWRITE, r1, r0); + TypeRecordingBinaryOpStub stub(instr->op(), NO_OVERWRITE); CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); } diff --git a/src/arm/lithium-codegen-arm.h b/src/arm/lithium-codegen-arm.h index 732db44..ef1f8f7 100644 --- a/src/arm/lithium-codegen-arm.h +++ b/src/arm/lithium-codegen-arm.h @@ -94,8 +94,8 @@ class LCodeGen BASE_EMBEDDED { // Deferred code support. template - void DoDeferredGenericBinaryStub(LTemplateInstruction<1, 2, T>* instr, - Token::Value op); + void DoDeferredBinaryOpStub(LTemplateInstruction<1, 2, T>* instr, + Token::Value op); void DoDeferredNumberTagD(LNumberTagD* instr); void DoDeferredNumberTagI(LNumberTagI* instr); void DoDeferredTaggedToI(LTaggedToI* instr); -- 2.7.4