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

Changeset 285452 in webkit


Ignore:
Timestamp:
Nov 8, 2021, 5:08:35 PM (5 years ago)
Author:
Kocsen Chung
Message:

Cherry-pick r282212. rdar://problem/85165960

Differential testing: incorrect constant propagation around Uint8ClampedArray
https://bugs.webkit.org/show_bug.cgi?id=229869

JSTests:

Reviewed by Saam Barati.

  • stress/Uint8ClampedArrayClampsInt52Positive.js: Added. (let.x.123.test): (noInline.test.int32pos1): (255.int32pos2): (1.int32neg1): (0.int32neg2): (0.int52pos1): (255.int52pos2): (255.int52neg1): (0.int52neg2): (0.int52neg3): (0.int52pos3): (255.int8):

Source/JavaScriptCore:

We casted int52 values to int32 before clamping, which caused any value with the 32nd bit
set to be interpreted as negative. The fix is to check the full-size value when deciding to clamp.

Reviewed by Saam Barati.

  • ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileCompareStrictEq):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@282212 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-612-branch
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-612-branch/JSTests/ChangeLog

    r285315 r285452  
     12021-11-08  Kocsen Chung  <kocsen_chung@apple.com>
     2
     3        Cherry-pick r282212. rdar://problem/85165960
     4
     5    Differential testing: incorrect constant propagation around Uint8ClampedArray
     6    https://bugs.webkit.org/show_bug.cgi?id=229869
     7   
     8    JSTests:
     9   
     10    Reviewed by Saam Barati.
     11   
     12    * stress/Uint8ClampedArrayClampsInt52Positive.js: Added.
     13    (let.x.123.test):
     14    (noInline.test.int32pos1):
     15    (255.int32pos2):
     16    (1.int32neg1):
     17    (0.int32neg2):
     18    (0.int52pos1):
     19    (255.int52pos2):
     20    (255.int52neg1):
     21    (0.int52neg2):
     22    (0.int52neg3):
     23    (0.int52pos3):
     24    (255.int8):
     25   
     26    Source/JavaScriptCore:
     27   
     28    We casted int52 values to int32 before clamping, which caused any value with the 32nd bit
     29    set to be interpreted as negative. The fix is to check the full-size value when deciding to clamp.
     30   
     31    Reviewed by Saam Barati.
     32   
     33    * ftl/FTLLowerDFGToB3.cpp:
     34    (JSC::FTL::DFG::LowerDFGToB3::compileCompareStrictEq):
     35   
     36   
     37    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@282212 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     38
     39    2021-09-09  Justin Michaud  <justin_michaud@apple.com>
     40
     41            Differential testing: incorrect constant propagation around Uint8ClampedArray
     42            https://bugs.webkit.org/show_bug.cgi?id=229869
     43
     44            Reviewed by Saam Barati.
     45
     46            * stress/Uint8ClampedArrayClampsInt52Positive.js: Added.
     47            (let.x.123.test):
     48            (noInline.test.int32pos1):
     49            (255.int32pos2):
     50            (1.int32neg1):
     51            (0.int32neg2):
     52            (0.int52pos1):
     53            (255.int52pos2):
     54            (255.int52neg1):
     55            (0.int52neg2):
     56            (0.int52neg3):
     57            (0.int52pos3):
     58            (255.int8):
     59
    1602021-11-04  Russell Epstein  <repstein@apple.com>
    261
  • branches/safari-612-branch/Source/JavaScriptCore/ChangeLog

    r285332 r285452  
     12021-11-08  Kocsen Chung  <kocsen_chung@apple.com>
     2
     3        Cherry-pick r282212. rdar://problem/85165960
     4
     5    Differential testing: incorrect constant propagation around Uint8ClampedArray
     6    https://bugs.webkit.org/show_bug.cgi?id=229869
     7   
     8    JSTests:
     9   
     10    Reviewed by Saam Barati.
     11   
     12    * stress/Uint8ClampedArrayClampsInt52Positive.js: Added.
     13    (let.x.123.test):
     14    (noInline.test.int32pos1):
     15    (255.int32pos2):
     16    (1.int32neg1):
     17    (0.int32neg2):
     18    (0.int52pos1):
     19    (255.int52pos2):
     20    (255.int52neg1):
     21    (0.int52neg2):
     22    (0.int52neg3):
     23    (0.int52pos3):
     24    (255.int8):
     25   
     26    Source/JavaScriptCore:
     27   
     28    We casted int52 values to int32 before clamping, which caused any value with the 32nd bit
     29    set to be interpreted as negative. The fix is to check the full-size value when deciding to clamp.
     30   
     31    Reviewed by Saam Barati.
     32   
     33    * ftl/FTLLowerDFGToB3.cpp:
     34    (JSC::FTL::DFG::LowerDFGToB3::compileCompareStrictEq):
     35   
     36   
     37    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@282212 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     38
     39    2021-09-09  Justin Michaud  <justin_michaud@apple.com>
     40
     41            Differential testing: incorrect constant propagation around Uint8ClampedArray
     42            https://bugs.webkit.org/show_bug.cgi?id=229869
     43
     44            We casted int52 values to int32 before clamping, which caused any value with the 32nd bit
     45            set to be interpreted as negative. The fix is to check the full-size value when deciding to clamp.
     46
     47            Reviewed by Saam Barati.
     48
     49            * ftl/FTLLowerDFGToB3.cpp:
     50            (JSC::FTL::DFG::LowerDFGToB3::compileCompareStrictEq):
     51
    1522021-11-04  Russell Epstein  <repstein@apple.com>
    253
  • branches/safari-612-branch/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp

    r285294 r285452  
    1785817858    LValue getIntTypedArrayStoreOperand(Edge edge, bool isClamped = false)
    1785917859    {
    17860         LValue intValue;
     17860        LValue valueAsInt32;
     17861        LValue value;
     17862        LValue zero;
     17863        LValue byteMax;
     17864       
    1786117865        switch (edge.useKind()) {
    1786217866        case Int52RepUse:
    1786317867        case Int32Use: {
    17864             if (edge.useKind() == Int32Use)
    17865                 intValue = lowInt32(edge);
    17866             else
    17867                 intValue = m_out.castToInt32(lowStrictInt52(edge));
    17868 
     17868            if (edge.useKind() == Int32Use) {
     17869                value = lowInt32(edge);
     17870                valueAsInt32 = value;
     17871                zero = m_out.int32Zero;
     17872                byteMax = m_out.constInt32(255);
     17873            } else {
     17874                value = lowStrictInt52(edge);
     17875                valueAsInt32 = m_out.castToInt32(value);
     17876                zero = m_out.int64Zero;
     17877                byteMax = m_out.constInt64(255);
     17878            }
     17879           
    1786917880            if (isClamped) {
    1787017881                LBasicBlock atLeastZero = m_out.newBlock();
     
    1787417885                intValues.append(m_out.anchor(m_out.int32Zero));
    1787517886                m_out.branch(
    17876                     m_out.lessThan(intValue, m_out.int32Zero),
     17887                    m_out.lessThan(value, zero),
    1787717888                    unsure(continuation), unsure(atLeastZero));
    1787817889                           
     
    1788017891                           
    1788117892                intValues.append(m_out.anchor(m_out.select(
    17882                     m_out.greaterThan(intValue, m_out.constInt32(255)),
     17893                    m_out.greaterThan(value, byteMax),
    1788317894                    m_out.constInt32(255),
    17884                     intValue)));
     17895                    valueAsInt32)));
    1788517896                m_out.jump(continuation);
    1788617897                           
    1788717898                m_out.appendTo(continuation, lastNext);
    17888                 intValue = m_out.phi(Int32, intValues);
     17899                valueAsInt32 = m_out.phi(Int32, intValues);
    1788917900            }
    1789017901            break;
     
    1791617927                           
    1791717928                m_out.appendTo(continuation, lastNext);
    17918                 intValue = m_out.phi(Int32, intValues);
     17929                valueAsInt32 = m_out.phi(Int32, intValues);
    1791917930            } else
    17920                 intValue = doubleToInt32(doubleValue);
     17931                valueAsInt32 = doubleToInt32(doubleValue);
    1792117932            break;
    1792217933        }
     
    1792617937        }
    1792717938       
    17928         return intValue;
     17939        return valueAsInt32;
    1792917940    }
    1793017941   
Note: See TracChangeset for help on using the changeset viewer.