Reviewers: Kasper Lund, Description: 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.
Please review this at http://codereview.chromium.org/118496 SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/ Affected files: M src/ia32/codegen-ia32.cc M test/mjsunit/smi-ops.js Index: test/mjsunit/smi-ops.js =================================================================== --- test/mjsunit/smi-ops.js (revision 2133) +++ test/mjsunit/smi-ops.js (working copy) @@ -585,3 +585,10 @@ } 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)); Index: src/ia32/codegen-ia32.cc =================================================================== --- src/ia32/codegen-ia32.cc (revision 2133) +++ src/ia32/codegen-ia32.cc (working copy) @@ -1691,6 +1691,8 @@ int shift_value = int_value & 0x1f; operand->ToRegister(); if (shift_value == 0) { + // Spill operand so it can be overwritten in the slow case. + frame_->Spill(operand->reg()); DeferredInlineSmiOperation* deferred = new DeferredInlineSmiOperation(op, operand->reg(), --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list v8-dev@googlegroups.com http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---