Changeset 187089 in webkit


Ignore:
Timestamp:
Jul 20, 2015 10:27:39 PM (9 years ago)
Author:
matthew_hanson@apple.com
Message:

Merge r186819. rdar://problem/21729083

Location:
branches/safari-601.1-branch/Source/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-601.1-branch/Source/JavaScriptCore/ChangeLog

    r187080 r187089  
     12015-07-20  Matthew Hanson  <matthew_hanson@apple.com>
     2
     3        Merge r186819. rdar://problem/21729083
     4
     5    2015-07-14  Matthew Mirman  <mmirman@apple.com>
     6
     7            Repatch. Makes compileArithSub in the DFG ensure that the constant is an int32.
     8            https://bugs.webkit.org/show_bug.cgi?id=146910
     9            rdar://problem/21729083
     10
     11            Reviewed by Filip Pizlo.
     12
     13            Also fixes the debug build problem where all edges are assumed to
     14            have UntypedUse before the fixup phase.
     15
     16            * dfg/DFGSpeculativeJIT.cpp:
     17            (JSC::DFG::SpeculativeJIT::compileArithSub):
     18            * dfg/DFGValidate.cpp:
     19            (JSC::DFG::Validate::validateEdgeWithDoubleResultIfNecessary):
     20            * tests/stress/arith-add-with-constants.js: Added some tests for this case.
     21            (arithAdd42WrittenAsInteger):
     22            (testArithAdd42WrittenAsInteger):
     23            (arithSub42WrittenAsDouble):
     24            (testArithSub42WrittenAsDouble):
     25            (doubleConstant):
     26            (testDoubleConstant): Added test for the case of +0.0 and Math.min(0.0)
     27            (arithAdd42WrittenAsDouble): Deleted.
     28            (testArithAdd42WrittenAsDouble): Deleted.
     29
    1302015-07-20  Matthew Hanson  <matthew_hanson@apple.com>
    231
  • branches/safari-601.1-branch/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp

    r186753 r187089  
    29902990        ASSERT(!shouldCheckNegativeZero(node->arithMode()));
    29912991       
    2992         if (node->child2()->isNumberConstant()) {
     2992        if (node->child2()->isInt32Constant()) {
    29932993            SpeculateInt32Operand op1(this, node->child1());
    29942994            int32_t imm2 = node->child2()->asInt32();
     
    30073007        }
    30083008           
    3009         if (node->child1()->isNumberConstant()) {
     3009        if (node->child1()->isInt32Constant()) {
    30103010            int32_t imm1 = node->child1()->asInt32();
    30113011            SpeculateInt32Operand op2(this, node->child2());
  • branches/safari-601.1-branch/Source/JavaScriptCore/dfg/DFGValidate.cpp

    r186753 r187089  
    545545
    546546        if (m_graph.m_planStage < PlanStage::AfterFixup)
    547             VALIDATE((node, edge), edge.useKind() == UntypedUse);
    548         else
    549             VALIDATE((node, edge), edge.useKind() == DoubleRepUse || edge.useKind() == DoubleRepRealUse || edge.useKind() == DoubleRepMachineIntUse);
     547            return;
     548       
     549        VALIDATE((node, edge), edge.useKind() == DoubleRepUse || edge.useKind() == DoubleRepRealUse || edge.useKind() == DoubleRepMachineIntUse);
    550550    }
    551551
  • branches/safari-601.1-branch/Source/JavaScriptCore/tests/stress/arith-add-with-constants.js

    r180813 r187089  
    168168
    169169
    170 function arithAdd42WrittenAsDouble(x) {
    171     var a = x + 42.0;
    172     var b = 42. + x;
    173     if (!(isNaN(x) && isNaN(a) && isNaN(b)) && a !== b)
    174         throw "Internal error on arithAdd42WrittenAsDouble, a = " + a + " b = " + b;
    175     return a;
    176 }
    177 noInline(arithAdd42WrittenAsDouble);
    178 
    179 function testArithAdd42WrittenAsDouble() {
    180     for (var i = 0; i < 1e4; ++i) {
    181         var result = arithAdd42WrittenAsDouble(13);
     170
     171
     172// Test "value + 42".
     173function arithAdd42WrittenAsInteger(x) {
     174    var a = x + 42;
     175    var b = 42 + x;
     176    if (!(isNaN(x) && isNaN(a) && isNaN(b)) && a !== b)
     177        throw "Internal error on arithAdd42WrittenAsInteger, a = " + a + " b = " + b;
     178    return a;
     179}
     180noInline(arithAdd42WrittenAsInteger);
     181
     182function testArithAdd42WrittenAsInteger() {
     183    for (var i = 0; i < 1e4; ++i) {
     184        var result = arithAdd42WrittenAsInteger(13);
    182185        if (result !== 55) {
    183             throw "arithAdd42WrittenAsDouble(i) = " + result + ", expected 55";
    184         }
    185     }
    186 
    187     for (var i = 0; i < 1e4; ++i) {
    188         var result = arithAdd42WrittenAsDouble(-0);
     186            throw "arithAdd42WrittenAsInteger(13) = " + result + ", expected 55";
     187        }
     188    }
     189
     190    for (var i = 0; i < 1e4; ++i) {
     191        var result = arithAdd42WrittenAsInteger(-0);
    189192        if (result !== 42) {
    190             throw "arithAdd42WrittenAsDouble(-0) = " + result + ", expected 42";
    191         }
    192     }
    193 
    194     for (var i = 0; i < 1e4; ++i) {
    195         var result = arithAdd42WrittenAsDouble(13.3);
     193            throw "arithAdd42WrittenAsInteger(-0) = " + result + ", expected 42";
     194        }
     195    }
     196
     197    for (var i = 0; i < 1e4; ++i) {
     198        var result = arithAdd42WrittenAsInteger(13.3);
    196199        if (result !== 55.3) {
    197             throw "arithAdd42WrittenAsDouble(13.3) = " + result + ", expected 55.3";
    198         }
    199     }
    200 
    201     for (var i = 0; i < 1e4; ++i) {;
    202         var result = arithAdd42WrittenAsDouble(NaN);
    203         if (!isNaN(result)) {
    204             throw "arithAdd42WrittenAsDouble(NaN) = " + result + ", expected NaN";
    205         }
    206     }
    207 
    208     for (var i = 0; i < 1e4; ++i) {;
    209         var result = arithAdd42WrittenAsDouble(Infinity);
    210         if (isFinite(result)) {
    211             throw "arithAdd42WrittenAsDouble(Infinity) = " + result + ", expected Infinity";
    212         }
    213     }
    214 
    215     for (var i = 0; i < 1e4; ++i) {;
    216         var result = arithAdd42WrittenAsDouble(-Infinity);
    217         if (isFinite(result) || result >= 0) {
    218             throw "arithAdd42WrittenAsDouble(-Infinity) = " + result + ", expected -Infinity";
    219         }
    220     }
    221 }
    222 testArithAdd42WrittenAsDouble();
     200            throw "arithAdd42WrittenAsInteger(13.3) = " + result + ", expected 55.3";
     201        }
     202    }
     203
     204    for (var i = 0; i < 1e4; ++i) {;
     205        var result = arithAdd42WrittenAsInteger(NaN);
     206        if (!isNaN(result)) {
     207            throw "arithAdd42WrittenAsInteger(NaN) = " + result + ", expected NaN";
     208        }
     209    }
     210
     211    for (var i = 0; i < 1e4; ++i) {;
     212        var result = arithAdd42WrittenAsInteger(Infinity);
     213        if (isFinite(result)) {
     214            throw "arithAdd42WrittenAsInteger(Infinity) = " + result + ", expected Infinity";
     215        }
     216    }
     217
     218    for (var i = 0; i < 1e4; ++i) {;
     219        var result = arithAdd42WrittenAsInteger(-Infinity);
     220        if (isFinite(result) || result >= 0) {
     221            throw "arithAdd42WrittenAsInteger(-Infinity) = " + result + ", expected -Infinity";
     222        }
     223    }
     224}
     225testArithAdd42WrittenAsInteger();
     226
     227function arithSub42WrittenAsDouble(x) {
     228    var a = (x|0) - 42.0;
     229    var b = -42. + (x|0);
     230    if (!(isNaN(x) && isNaN(a) && isNaN(b)) && a !== b)
     231        throw "Internal error on arithSub42WrittenAsDouble, a = " + a + " b = " + b;
     232    return a;
     233}
     234noInline(arithSub42WrittenAsDouble);
     235
     236function testArithSub42WrittenAsDouble() {
     237    for (var i = 0; i < 1e4; ++i) {
     238        var result = arithSub42WrittenAsDouble(13);
     239        if (result !== -29) {
     240            throw "arithSub42WrittenAsDouble(13) = " + result + ", expected -29";
     241        }
     242    }
     243
     244    for (var i = 0; i < 1e4; ++i) {
     245        var result = arithSub42WrittenAsDouble(-0);
     246        if (result !== -42) {
     247            throw "arithSub42WrittenAsDouble(-0) = " + result + ", expected -42";
     248        }
     249    }
     250
     251    for (var i = 0; i < 1e4; ++i) {
     252        var result = arithSub42WrittenAsDouble(13.3);
     253        if (result !== -29) {
     254            throw "arithSub42WrittenAsDouble(13.3) = " + result + ", expected -29";
     255        }
     256    }
     257}
     258testArithSub42WrittenAsDouble();
     259
     260
     261function doubleConstant(){
     262    Math.min(0.0);
     263    +0.0;
     264} noInline(doubleConstant);
     265
     266function testDoubleConstant(){
     267    for (var i = 0; i < 1e4; ++i) {
     268        doubleConstant();
     269    }
     270}
     271testDoubleConstant();
Note: See TracChangeset for help on using the changeset viewer.