Changeset 164461 in webkit


Ignore:
Timestamp:
Feb 20, 2014 6:01:28 PM (10 years ago)
Author:
ggaren@apple.com
Message:

Math.imul gives wrong results
https://bugs.webkit.org/show_bug.cgi?id=126345

Reviewed by Mark Hahnenberg.

Source/JavaScriptCore:

Don't truncate non-int doubles to 0 -- that's just not how ToInt32 works.
Instead, take a slow path that will do the right thing.

  • jit/ThunkGenerators.cpp:

(JSC::imulThunkGenerator):

LayoutTests:

Test this edge case of a double just outside the int range.

  • js/dom/imul-expected.txt:
  • js/dom/script-tests/imul.js:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r164457 r164461  
     12014-02-20  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Math.imul gives wrong results
     4        https://bugs.webkit.org/show_bug.cgi?id=126345
     5
     6        Reviewed by Mark Hahnenberg.
     7
     8        Test this edge case of a double just outside the int range.
     9
     10        * js/dom/imul-expected.txt:
     11        * js/dom/script-tests/imul.js:
     12
    1132014-02-20  Brady Eidson  <beidson@apple.com>
    214
  • trunk/LayoutTests/js/dom/imul-expected.txt

    r156066 r164461  
    2222PASS Math.imul(-Infinity, Infinity) is 0
    2323PASS Math.imul(-Infinity, -Infinity) is 0
     24PASS Math.imul(0xffffffff, 5) is -5
    2425PASS testIMul(2,2,10000) is 40000
    2526PASS testIMul(2.5,2,10000) is 40000
  • trunk/LayoutTests/js/dom/script-tests/imul.js

    r156066 r164461  
    2121shouldBe("Math.imul(-Infinity, Infinity)", "0");
    2222shouldBe("Math.imul(-Infinity, -Infinity)", "0");
     23shouldBe("Math.imul(0xffffffff, 5)", "-5");
    2324
    2425function testIMul(left, right, count)
  • trunk/Source/JavaScriptCore/ChangeLog

    r164459 r164461  
     12014-02-20  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Math.imul gives wrong results
     4        https://bugs.webkit.org/show_bug.cgi?id=126345
     5
     6        Reviewed by Mark Hahnenberg.
     7
     8        Don't truncate non-int doubles to 0 -- that's just not how ToInt32 works.
     9        Instead, take a slow path that will do the right thing.
     10
     11        * jit/ThunkGenerators.cpp:
     12        (JSC::imulThunkGenerator):
     13
    1142014-02-20  Filip Pizlo  <fpizlo@apple.com>
    215
  • trunk/Source/JavaScriptCore/jit/ThunkGenerators.cpp

    r164039 r164461  
    925925        jit.loadDoubleArgument(0, SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::regT0);
    926926        jit.branchTruncateDoubleToInt32(SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::regT0, SpecializedThunkJIT::BranchIfTruncateSuccessful).linkTo(doneLoadingArg0, &jit);
    927         jit.xor32(SpecializedThunkJIT::regT0, SpecializedThunkJIT::regT0);
    928         jit.jump(doneLoadingArg0);
     927        jit.appendFailure(jit.jump());
    929928    } else
    930929        jit.appendFailure(nonIntArg0Jump);
     
    934933        jit.loadDoubleArgument(1, SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::regT1);
    935934        jit.branchTruncateDoubleToInt32(SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::regT1, SpecializedThunkJIT::BranchIfTruncateSuccessful).linkTo(doneLoadingArg1, &jit);
    936         jit.xor32(SpecializedThunkJIT::regT1, SpecializedThunkJIT::regT1);
    937         jit.jump(doneLoadingArg1);
     935        jit.appendFailure(jit.jump());
    938936    } else
    939937        jit.appendFailure(nonIntArg1Jump);
Note: See TracChangeset for help on using the changeset viewer.