From ab65809a625c2692d008a0e4a8ee3b53d4ecc1ba Mon Sep 17 00:00:00 2001 From: "whesse@chromium.org" Date: Thu, 10 Jun 2010 14:37:49 +0000 Subject: [PATCH] Use static type information in ConstantIntBinaryOperation on x64. Review URL: http://codereview.chromium.org/2754004 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4836 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/x64/codegen-x64.cc | 41 ++++++++++++++++++++++++++++------------- src/x64/codegen-x64.h | 7 +++++++ 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/x64/codegen-x64.cc b/src/x64/codegen-x64.cc index a0b1b5b..342db60 100644 --- a/src/x64/codegen-x64.cc +++ b/src/x64/codegen-x64.cc @@ -6894,7 +6894,8 @@ Result CodeGenerator::ConstantSmiBinaryOperation(BinaryOperation* expr, smi_value, overwrite_mode); } - __ JumpIfNotSmi(operand->reg(), deferred->entry_label()); + JumpIfNotSmiUsingTypeInfo(operand->reg(), operand->type_info(), + deferred); __ SmiAddConstant(operand->reg(), operand->reg(), smi_value, @@ -6915,7 +6916,8 @@ Result CodeGenerator::ConstantSmiBinaryOperation(BinaryOperation* expr, DeferredCode* deferred = new DeferredInlineSmiSub(operand->reg(), smi_value, overwrite_mode); - __ JumpIfNotSmi(operand->reg(), deferred->entry_label()); + JumpIfNotSmiUsingTypeInfo(operand->reg(), operand->type_info(), + deferred); // A smi currently fits in a 32-bit Immediate. __ SmiSubConstant(operand->reg(), operand->reg(), @@ -6944,7 +6946,8 @@ Result CodeGenerator::ConstantSmiBinaryOperation(BinaryOperation* expr, operand->reg(), smi_value, overwrite_mode); - __ JumpIfNotSmi(operand->reg(), deferred->entry_label()); + JumpIfNotSmiUsingTypeInfo(operand->reg(), operand->type_info(), + deferred); __ SmiShiftArithmeticRightConstant(operand->reg(), operand->reg(), shift_value); @@ -6971,7 +6974,8 @@ Result CodeGenerator::ConstantSmiBinaryOperation(BinaryOperation* expr, operand->reg(), smi_value, overwrite_mode); - __ JumpIfNotSmi(operand->reg(), deferred->entry_label()); + JumpIfNotSmiUsingTypeInfo(operand->reg(), operand->type_info(), + deferred); __ SmiShiftLogicalRightConstant(answer.reg(), operand->reg(), shift_value, @@ -7003,12 +7007,8 @@ Result CodeGenerator::ConstantSmiBinaryOperation(BinaryOperation* expr, smi_value, operand->reg(), overwrite_mode); - if (!operand->type_info().IsSmi()) { - Condition is_smi = masm_->CheckSmi(operand->reg()); - deferred->Branch(NegateCondition(is_smi)); - } else if (FLAG_debug_code) { - __ AbortIfNotSmi(operand->reg()); - } + JumpIfNotSmiUsingTypeInfo(operand->reg(), operand->type_info(), + deferred); __ Move(answer.reg(), smi_value); __ SmiShiftLeft(answer.reg(), answer.reg(), operand->reg()); @@ -7029,7 +7029,8 @@ Result CodeGenerator::ConstantSmiBinaryOperation(BinaryOperation* expr, operand->reg(), smi_value, overwrite_mode); - __ JumpIfNotSmi(operand->reg(), deferred->entry_label()); + JumpIfNotSmiUsingTypeInfo(operand->reg(), operand->type_info(), + deferred); deferred->BindExit(); answer = *operand; } else { @@ -7042,7 +7043,8 @@ Result CodeGenerator::ConstantSmiBinaryOperation(BinaryOperation* expr, operand->reg(), smi_value, overwrite_mode); - __ JumpIfNotSmi(operand->reg(), deferred->entry_label()); + JumpIfNotSmiUsingTypeInfo(operand->reg(), operand->type_info(), + deferred); __ SmiShiftLeftConstant(answer.reg(), operand->reg(), shift_value); @@ -7068,7 +7070,8 @@ Result CodeGenerator::ConstantSmiBinaryOperation(BinaryOperation* expr, operand->reg(), smi_value, overwrite_mode); - __ JumpIfNotSmi(operand->reg(), deferred->entry_label()); + JumpIfNotSmiUsingTypeInfo(operand->reg(), operand->type_info(), + deferred); if (op == Token::BIT_AND) { __ SmiAndConstant(operand->reg(), operand->reg(), smi_value); } else if (op == Token::BIT_XOR) { @@ -7133,6 +7136,18 @@ Result CodeGenerator::ConstantSmiBinaryOperation(BinaryOperation* expr, } +void CodeGenerator::JumpIfNotSmiUsingTypeInfo(Register reg, + TypeInfo type, + DeferredCode* deferred) { + if (!type.IsSmi()) { + __ JumpIfNotSmi(reg, deferred->entry_label()); + } + if (FLAG_debug_code) { + __ AbortIfNotSmi(reg); + } +} + + void CodeGenerator::JumpIfNotBothSmiUsingTypeInfo(Register left, Register right, TypeInfo left_info, diff --git a/src/x64/codegen-x64.h b/src/x64/codegen-x64.h index fcf35f0..cd03d2a 100644 --- a/src/x64/codegen-x64.h +++ b/src/x64/codegen-x64.h @@ -477,6 +477,13 @@ class CodeGenerator: public AstVisitor { void GenericBinaryOperation(BinaryOperation* expr, OverwriteMode overwrite_mode); + // Emits code sequence that jumps to deferred code if the input + // is not a smi. Cannot be in MacroAssembler because it takes + // advantage of TypeInfo to skip unneeded checks. + void JumpIfNotSmiUsingTypeInfo(Register reg, + TypeInfo type, + DeferredCode* deferred); + // Emits code sequence that jumps to deferred code if the inputs // are not both smis. Cannot be in MacroAssembler because it takes // advantage of TypeInfo to skip unneeded checks. -- 2.7.4