Reviewers: Mads Ager, Description: Merge revision 7629 and 8402 to the 3.2 branch.
This fixes an issue with the optimized version of Math.abs on 64 bit. Please review this at http://codereview.chromium.org/7236028/ SVN Base: http://v8.googlecode.com/svn/branches/3.2/ Affected files: M src/x64/lithium-codegen-x64.cc M test/mjsunit/math-abs.js Index: src/x64/lithium-codegen-x64.cc =================================================================== --- src/x64/lithium-codegen-x64.cc (revision 8401) +++ src/x64/lithium-codegen-x64.cc (working copy) @@ -2690,7 +2690,9 @@ Register input_reg = ToRegister(instr->InputAt(0)); // Smi check. __ JumpIfNotSmi(input_reg, deferred->entry()); + __ SmiToInteger32(input_reg, input_reg); EmitIntegerMathAbs(instr); + __ Integer32ToSmi(input_reg, input_reg); __ bind(deferred->exit()); } } Index: test/mjsunit/math-abs.js =================================================================== --- test/mjsunit/math-abs.js (revision 8401) +++ test/mjsunit/math-abs.js (working copy) @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --max-new-space-size=256 +// Flags: --max-new-space-size=256 --allow-natives-syntax function zero() { var x = 0.5; @@ -96,3 +96,16 @@ for (var i = 0; i < 500; i++) { test(); } + +// Regression test for optimized version of Math.abs, see: +// http://codereview.chromium.org/6875002. +function foo(x) { + return Math.abs(x); +} +// Get some smi type feedback. +for(var i = 0; i < 1000; i++) { + foo(-i); +} +assertEquals(42, foo(-42)); +%OptimizeFunctionOnNextCall(foo) +assertEquals(42, foo(-42)); -- v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev
