From d5b94e9704e0ebbb9f797ab835d4fc72c0c298eb Mon Sep 17 00:00:00 2001 From: "sgjesse@chromium.org" Date: Tue, 4 Jan 2011 11:02:58 +0000 Subject: [PATCH] Addresses some performance regression in the GenericBinaryOpStub on ARM following Crankshaft introduction. BUG=none TEST=none Patch by Rodolph Perfetta from ARM Ltd. Review URL: http://codereview.chromium.org/5781010 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6146 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/code-stubs-arm.cc | 11 +++++++++-- src/arm/code-stubs-arm.h | 6 +++++- src/arm/full-codegen-arm.cc | 2 ++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc index c9c9823..577ac63 100644 --- a/src/arm/code-stubs-arm.cc +++ b/src/arm/code-stubs-arm.cc @@ -1222,16 +1222,22 @@ void GenericBinaryOpStub::HandleBinaryOpSlowCases( bool generate_code_to_calculate_answer = true; if (ShouldGenerateFPCode()) { + // DIV has neither SmiSmi fast code nor specialized slow code. + // So don't try to patch a DIV Stub. if (runtime_operands_type_ == BinaryOpIC::DEFAULT) { switch (op_) { case Token::ADD: case Token::SUB: case Token::MUL: - case Token::DIV: GenerateTypeTransition(masm); // Tail call. generate_code_to_calculate_answer = false; break; + case Token::DIV: + // DIV has neither SmiSmi fast code nor specialized slow code. + // So don't try to patch a DIV Stub. + break; + default: break; } @@ -1292,7 +1298,8 @@ void GenericBinaryOpStub::HandleBinaryOpSlowCases( // HEAP_NUMBERS stub is slower than GENERIC on a pair of smis. // r0 is known to be a smi. If r1 is also a smi then switch to GENERIC. Label r1_is_not_smi; - if (runtime_operands_type_ == BinaryOpIC::HEAP_NUMBERS) { + if ((runtime_operands_type_ == BinaryOpIC::HEAP_NUMBERS) && + HasSmiSmiFastPath()) { __ tst(r1, Operand(kSmiTagMask)); __ b(ne, &r1_is_not_smi); GenerateTypeTransition(masm); // Tail call. diff --git a/src/arm/code-stubs-arm.h b/src/arm/code-stubs-arm.h index e17a745..9fa8687 100644 --- a/src/arm/code-stubs-arm.h +++ b/src/arm/code-stubs-arm.h @@ -77,7 +77,7 @@ class GenericBinaryOpStub : public CodeStub { rhs_(rhs), constant_rhs_(constant_rhs), specialized_on_rhs_(RhsIsOneWeWantToOptimizeFor(op, constant_rhs)), - runtime_operands_type_(BinaryOpIC::DEFAULT), + runtime_operands_type_(BinaryOpIC::UNINIT_OR_SMI), name_(NULL) { } GenericBinaryOpStub(int key, BinaryOpIC::TypeInfo type_info) @@ -178,6 +178,10 @@ class GenericBinaryOpStub : public CodeStub { return lhs_is_r0 ? r1 : r0; } + bool HasSmiSmiFastPath() { + return op_ != Token::DIV; + } + bool ShouldGenerateSmiCode() { return ((op_ != Token::DIV && op_ != Token::MOD) || specialized_on_rhs_) && runtime_operands_type_ != BinaryOpIC::HEAP_NUMBERS && diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc index d254918..0275730 100644 --- a/src/arm/full-codegen-arm.cc +++ b/src/arm/full-codegen-arm.cc @@ -38,6 +38,8 @@ #include "scopes.h" #include "stub-cache.h" +#include "arm/code-stubs-arm.h" + namespace v8 { namespace internal { -- 2.7.4