Fix a bug when shifting left by zero. Ensure that the left operand is

writable (non-aliased) so it can be used for the result in the slow
case.

Review URL: http://codereview.chromium.org/118496

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2134 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent bedff67b
...@@ -1691,6 +1691,8 @@ void CodeGenerator::ConstantSmiBinaryOperation(Token::Value op, ...@@ -1691,6 +1691,8 @@ void CodeGenerator::ConstantSmiBinaryOperation(Token::Value op,
int shift_value = int_value & 0x1f; int shift_value = int_value & 0x1f;
operand->ToRegister(); operand->ToRegister();
if (shift_value == 0) { if (shift_value == 0) {
// Spill operand so it can be overwritten in the slow case.
frame_->Spill(operand->reg());
DeferredInlineSmiOperation* deferred = DeferredInlineSmiOperation* deferred =
new DeferredInlineSmiOperation(op, new DeferredInlineSmiOperation(op,
operand->reg(), operand->reg(),
......
...@@ -585,3 +585,10 @@ function testShiftNonSmis() { ...@@ -585,3 +585,10 @@ function testShiftNonSmis() {
} }
testShiftNonSmis(); testShiftNonSmis();
// Verify that we handle the (optimized) corner case of shifting by
// zero even for non-smis.
function shiftByZero(n) { return n << 0; }
assertEquals(3, shiftByZero(3.1415));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment