⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 269783 in webkit


Ignore:
Timestamp:
Nov 13, 2020, 9:44:14 AM (6 years ago)
Author:
Adrian Perez de Castro
Message:

Merge r265891 - B3 IntRange is incorrect for negative masks
https://bugs.webkit.org/show_bug.cgi?id=215536
<rdar://problem/67130430>

Reviewed by Michael Saboff and Robin Morisset.

In the B3 ReduceStrength phase, we compute rangeForMask as (0, mask). This is correct for
positive values, but incorrect when negative. To fix it, we use (INT_MIN & mask, INT_MAX & mask)
as the range for negative masks.

  • b3/B3ReduceStrength.cpp:
  • b3/testb3.h:
  • b3/testb3_1.cpp:

(run):

  • b3/testb3_5.cpp:

(testCheckSubBitAnd):

Location:
releases/WebKitGTK/webkit-2.30/Source/JavaScriptCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • releases/WebKitGTK/webkit-2.30/Source/JavaScriptCore/ChangeLog

    r266594 r269783  
     12020-08-19  Tadeu Zagallo  <tzagallo@apple.com>
     2
     3        B3 IntRange is incorrect for negative masks
     4        https://bugs.webkit.org/show_bug.cgi?id=215536
     5        <rdar://problem/67130430>
     6
     7        Reviewed by Michael Saboff and Robin Morisset.
     8
     9        In the B3 ReduceStrength phase, we compute rangeForMask as (0, mask).  This is correct for
     10        positive values, but incorrect when negative. To fix it, we use `(INT_MIN & mask, INT_MAX & mask)`
     11        as the range for negative masks.
     12
     13        * b3/B3ReduceStrength.cpp:
     14        * b3/testb3.h:
     15        * b3/testb3_1.cpp:
     16        (run):
     17        * b3/testb3_5.cpp:
     18        (testCheckSubBitAnd):
     19
    1202020-09-03  Carlos Garcia Campos  <cgarcia@igalia.com>
    221
  • releases/WebKitGTK/webkit-2.30/Source/JavaScriptCore/b3/B3ReduceStrength.cpp

    r261755 r269783  
    124124        if (!(mask + 1))
    125125            return top<T>();
     126        if (mask < 0)
     127            return IntRange(INT_MIN & mask, mask & INT_MAX);
    126128        return IntRange(0, mask);
    127129    }
  • releases/WebKitGTK/webkit-2.30/Source/JavaScriptCore/b3/testb3.h

    r254832 r269783  
    805805void testCheckSubBadImm();
    806806void testCheckSub();
     807void testCheckSubBitAnd();
    807808double doubleSub(double, double);
    808809void testCheckSub64();
  • releases/WebKitGTK/webkit-2.30/Source/JavaScriptCore/b3/testb3_1.cpp

    r263635 r269783  
    497497    RUN(testCheckSubBadImm());
    498498    RUN(testCheckSub());
     499    RUN(testCheckSubBitAnd());
    499500    RUN(testCheckSub64());
    500501    RUN(testCheckSubFold(100, 200));
  • releases/WebKitGTK/webkit-2.30/Source/JavaScriptCore/b3/testb3_5.cpp

    r259786 r269783  
    11241124    CHECK(invoke<double>(*code, 42, 42) == 0.0);
    11251125    CHECK(invoke<double>(*code, -2147483647, 42) == -2147483689.0);
     1126}
     1127
     1128void testCheckSubBitAnd()
     1129{
     1130    Procedure proc;
     1131    if (proc.optLevel() < 1)
     1132        return;
     1133    BasicBlock* root = proc.addBlock();
     1134    Value* zero = root->appendNew<Const32Value>(proc, Origin(), 0);
     1135    Value* arg1 = root->appendNew<ArgumentRegValue>(proc, Origin(), GPRInfo::argumentGPR0);
     1136    Value* truncatedArg1 = root->appendNew<Value>(proc, Trunc, Origin(), arg1);
     1137    Value* minusTwo = root->appendNew<Const32Value>(proc, Origin(), -2);
     1138    Value* bitAnd = root->appendNew<Value>(proc, BitAnd, Origin(), truncatedArg1, minusTwo);
     1139    CheckValue* checkSub = root->appendNew<CheckValue>(proc, CheckSub, Origin(), zero, bitAnd);
     1140    checkSub->setGenerator([&] (CCallHelpers& jit, const StackmapGenerationParams&) {
     1141        AllowMacroScratchRegisterUsage allowScratch(jit);
     1142        jit.move(CCallHelpers::TrustedImm32(42), GPRInfo::returnValueGPR);
     1143        jit.emitFunctionEpilogue();
     1144        jit.ret();
     1145    });
     1146    root->appendNewControlValue(proc, Return, Origin(), checkSub);
     1147
     1148    auto code = compileProc(proc);
     1149
     1150    CHECK_EQ(invoke<int>(*code, 1), 0);
     1151    CHECK_EQ(invoke<int>(*code, 2), -2);
     1152    CHECK_EQ(invoke<int>(*code, 3), -2);
     1153    CHECK_EQ(invoke<int>(*code, -1), 2);
     1154    CHECK_EQ(invoke<int>(*code, -2), 2);
     1155    CHECK_EQ(invoke<int>(*code, -3), 4);
     1156    CHECK_EQ(invoke<int>(*code, INT_MAX), -(INT_MAX - 1));
     1157    CHECK_EQ(invoke<int>(*code, INT_MIN), 42);
    11261158}
    11271159
Note: See TracChangeset for help on using the changeset viewer.