From: whessev8 Date: Fri, 23 Jan 2009 13:06:15 +0000 (+0000) Subject: Optimizes check for Smi range in the code generator. X-Git-Tag: upstream/4.7.83~24762 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ffd1b25cfb9d89b9f87cbc59f114b5f7d849b100;p=platform%2Fupstream%2Fv8.git Optimizes check for Smi range in the code generator. The check whether a 32-bit signed integer is in the Smi range is now Sign bit( value + 0x40000000 ) == 0, done with a single cmp instruction. Review URL: http://codereview.chromium.org/18710 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1134 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/codegen-ia32.cc b/src/codegen-ia32.cc index a02f545..602b66d 100644 --- a/src/codegen-ia32.cc +++ b/src/codegen-ia32.cc @@ -1127,9 +1127,11 @@ void CodeGenerator::SmiOperation(Token::Value op, __ j(not_zero, deferred->enter(), not_taken); __ sar(ebx, kSmiTagSize); __ shl(ebx, shift_value); - __ lea(ecx, Operand(ebx, 0x40000000)); - __ test(ecx, Immediate(0x80000000)); - __ j(not_zero, deferred->enter(), not_taken); + // This is the Smi check for the shifted result. + // After signed subtraction of 0xc0000000, the valid + // Smis are positive. + __ cmp(ebx, 0xc0000000); + __ j(sign, deferred->enter(), not_taken); // tag result and store it in TOS (eax) ASSERT(kSmiTagSize == times_2); // adjust code if not the case __ lea(eax, Operand(ebx, ebx, times_1, kSmiTag)); @@ -4274,9 +4276,8 @@ void GenericBinaryOpStub::GenerateSmiCode(MacroAssembler* masm, Label* slow) { case Token::SHL: __ shl(eax); // Check that the *signed* result fits in a smi. - __ lea(ecx, Operand(eax, 0x40000000)); - __ test(ecx, Immediate(0x80000000)); - __ j(not_zero, slow, not_taken); + __ cmp(eax, 0xc0000000); + __ j(sign, slow, not_taken); break; default: UNREACHABLE();