Changeset 139835 in webkit


Ignore:
Timestamp:
Jan 15, 2013 9:47:09 PM (11 years ago)
Author:
msaboff@apple.com
Message:

DFG X86: division in the used-as-int case doesn't correctly check for -231/-1
https://bugs.webkit.org/show_bug.cgi?id=106978

Reviewed by Filip Pizlo.

Source/JavaScriptCore:

Changed the numerator equal to -231 check to just return if we expect an integer
result, since the check is after we have determined that the denominator is -1.
The int result of -2
31 / -1 is -231, so just return the numerator as the result.

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileIntegerArithDivForX86):

LayoutTests:

Added a new DFG check for -231 / -1 when we expect and integer result.

  • fast/js/integer-division-neg2tothe32-by-neg1-expected.txt:
  • fast/js/script-tests/integer-division-neg2tothe32-by-neg1.js:

(myDivExpectingInt):

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r139834 r139835  
     12013-01-15  Michael Saboff  <msaboff@apple.com>
     2
     3        DFG X86: division in the used-as-int case doesn't correctly check for -2^31/-1
     4        https://bugs.webkit.org/show_bug.cgi?id=106978
     5
     6        Reviewed by Filip Pizlo.
     7
     8        Added a new DFG check for -2^31 / -1 when we expect and integer result.
     9
     10        * fast/js/integer-division-neg2tothe32-by-neg1-expected.txt:
     11        * fast/js/script-tests/integer-division-neg2tothe32-by-neg1.js:
     12        (myDivExpectingInt):
     13
    1142013-01-15  Dominic Cooney  <dominicc@chromium.org>
    215
  • trunk/LayoutTests/fast/js/integer-division-neg2tothe32-by-neg1-expected.txt

    r111481 r139835  
    28042804PASS myOtherModNeg2ToThe31(v) is -0
    28052805PASS myOtherModNeg2ToThe31(3) is -2
     2806PASS myDivExpectingInt(x, y) is x
    28062807PASS successfullyParsed is true
    28072808
  • trunk/LayoutTests/fast/js/script-tests/integer-division-neg2tothe32-by-neg1.js

    r111481 r139835  
    5151}
    5252
     53function myDivExpectingInt(a, b) {
     54    return (a / b) | 0;
     55}
     56
    5357var w = 4;
    5458var v = 2;
     
    7781    shouldBe("myOtherModNeg2ToThe31(v)", "-0");
    7882    shouldBe("myOtherModNeg2ToThe31(3)", "-2");
     83    shouldBe("myDivExpectingInt(x, y)", "x");
    7984}
    8085
  • trunk/Source/JavaScriptCore/ChangeLog

    r139821 r139835  
     12013-01-15  Michael Saboff  <msaboff@apple.com>
     2
     3        DFG X86: division in the used-as-int case doesn't correctly check for -2^31/-1
     4        https://bugs.webkit.org/show_bug.cgi?id=106978
     5
     6        Reviewed by Filip Pizlo.
     7
     8        Changed the numerator equal to -2^31 check to just return if we expect an integer
     9        result, since the check is after we have determined that the denominator is -1.
     10        The int result of -2^31 / -1 is -2^31, so just return the numerator as the result.
     11
     12        * dfg/DFGSpeculativeJIT.cpp:
     13        (JSC::DFG::SpeculativeJIT::compileIntegerArithDivForX86):
     14
    1152013-01-15  Levi Weintraub  <leviw@chromium.org>
    216
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp

    r139541 r139835  
    33193319    } else {
    33203320        JITCompiler::Jump zero = m_jit.branchTest32(JITCompiler::Zero, op2GPR);
    3321         JITCompiler::Jump notNeg2ToThe31 = m_jit.branch32(JITCompiler::Equal, op1GPR, TrustedImm32(-2147483647-1));
     3321        JITCompiler::Jump isNeg2ToThe31 = m_jit.branch32(JITCompiler::Equal, op1GPR, TrustedImm32(-2147483647-1));
    33223322        zero.link(&m_jit);
    33233323        m_jit.move(TrustedImm32(0), eax.gpr());
     3324        isNeg2ToThe31.link(&m_jit);
    33243325        done = m_jit.jump();
    3325         notNeg2ToThe31.link(&m_jit);
    33263326    }
    33273327   
Note: See TracChangeset for help on using the changeset viewer.