Optimizes an assembly-language conversion from int to Smi in codegen.
authorwhessev8 <whessev8@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 23 Jan 2009 13:58:49 +0000 (13:58 +0000)
committerwhessev8 <whessev8@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 23 Jan 2009 13:58:49 +0000 (13:58 +0000)
Review URL: http://codereview.chromium.org/18551

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1137 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/codegen-ia32.cc

index 602b66d..5678030 100644 (file)
@@ -1127,14 +1127,14 @@ void CodeGenerator::SmiOperation(Token::Value op,
         __ j(not_zero, deferred->enter(), not_taken);
         __ sar(ebx, kSmiTagSize);
         __ shl(ebx, shift_value);
-        // 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));
+        // Convert the int to a Smi, and check that it is in
+        // the range of valid Smis.
+        ASSERT(kSmiTagSize == times_2);  // Adjust code if not true.
+        ASSERT(kSmiTag == 0);  // Adjust code if not true.
+        __ add(ebx, Operand(ebx));
+        __ j(overflow, deferred->enter(), not_taken);
+        __ mov(eax, Operand(ebx));
+
         __ bind(deferred->exit());
         frame_->Push(eax);
       }