Title: [285453] branches/safari-612-branch
Revision
285453
Author
[email protected]
Date
2021-11-08 17:08:38 -0800 (Mon, 08 Nov 2021)

Log Message

Cherry-pick r282821. rdar://problem/85167490

    Differential testing: live statement don't execute
    https://bugs.webkit.org/show_bug.cgi?id=229939

    Reviewed by Saam Barati.

    JSTests:

    * stress/in-by-val-should-throw.js: Added.
    (doesThrow):
    (noInline.doesThrow.noFTL.doesThrow.blackbox):
    (noInline.blackbox.doesNotThrow):
    (noInline.doesNotThrow.noFTL.doesNotThrow.main):

    Source/_javascript_Core:

    In statements are supposed to throw if they are applied to a non-object. We incorrectly converted
    InByVals into HasIndexedProperty any time they were a cell, so we silently converted non-objects. Before converting
    an InByVal, we first speculate that the base is an object now.

    We do not always require an object edge for HasIndexedProperty because enumerator next() does not
    throw if it encounters a cell that requires conversion during the call to toObject (for example, a
    string literal). That is, we should silently convert the string during enumeration, but not for an
    In statement, and so HasIndexedProperty is prepared to handle both cases.

    * dfg/DFGFixupPhase.cpp:
    (JSC::DFG::FixupPhase::fixupNode):
    (JSC::DFG::FixupPhase::convertToHasIndexedProperty):

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

Modified Paths

Added Paths

Diff

Modified: branches/safari-612-branch/JSTests/ChangeLog (285452 => 285453)


--- branches/safari-612-branch/JSTests/ChangeLog	2021-11-09 01:08:35 UTC (rev 285452)
+++ branches/safari-612-branch/JSTests/ChangeLog	2021-11-09 01:08:38 UTC (rev 285453)
@@ -1,5 +1,53 @@
 2021-11-08  Kocsen Chung  <[email protected]>
 
+        Cherry-pick r282821. rdar://problem/85167490
+
+    Differential testing: live statement don't execute
+    https://bugs.webkit.org/show_bug.cgi?id=229939
+    
+    Reviewed by Saam Barati.
+    
+    JSTests:
+    
+    * stress/in-by-val-should-throw.js: Added.
+    (doesThrow):
+    (noInline.doesThrow.noFTL.doesThrow.blackbox):
+    (noInline.blackbox.doesNotThrow):
+    (noInline.doesNotThrow.noFTL.doesNotThrow.main):
+    
+    Source/_javascript_Core:
+    
+    In statements are supposed to throw if they are applied to a non-object. We incorrectly converted
+    InByVals into HasIndexedProperty any time they were a cell, so we silently converted non-objects. Before converting
+    an InByVal, we first speculate that the base is an object now.
+    
+    We do not always require an object edge for HasIndexedProperty because enumerator next() does not
+    throw if it encounters a cell that requires conversion during the call to toObject (for example, a
+    string literal). That is, we should silently convert the string during enumeration, but not for an
+    In statement, and so HasIndexedProperty is prepared to handle both cases.
+    
+    * dfg/DFGFixupPhase.cpp:
+    (JSC::DFG::FixupPhase::fixupNode):
+    (JSC::DFG::FixupPhase::convertToHasIndexedProperty):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@282821 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-09-21  Justin Michaud  <[email protected]>
+
+            Differential testing: live statement don't execute
+            https://bugs.webkit.org/show_bug.cgi?id=229939
+
+            Reviewed by Saam Barati.
+
+            * stress/in-by-val-should-throw.js: Added.
+            (doesThrow):
+            (noInline.doesThrow.noFTL.doesThrow.blackbox):
+            (noInline.blackbox.doesNotThrow):
+            (noInline.doesNotThrow.noFTL.doesNotThrow.main):
+
+2021-11-08  Kocsen Chung  <[email protected]>
+
         Cherry-pick r282212. rdar://problem/85165960
 
     Differential testing: incorrect constant propagation around Uint8ClampedArray

Added: branches/safari-612-branch/JSTests/stress/in-by-val-should-throw.js (0 => 285453)


--- branches/safari-612-branch/JSTests/stress/in-by-val-should-throw.js	                        (rev 0)
+++ branches/safari-612-branch/JSTests/stress/in-by-val-should-throw.js	2021-11-09 01:08:38 UTC (rev 285453)
@@ -0,0 +1,85 @@
+function doesThrow() {
+    try {
+        1 in ""
+        return false
+    } catch(v45) {
+        return true
+    }
+}
+noInline(doesThrow)
+noFTL(doesThrow)
+
+function doesThrowFTL() {
+    try {
+        1 in ""
+        return false
+    } catch(v45) {
+        return true
+    }
+}
+noInline(doesThrowFTL)
+
+function blackbox() {
+    return { }
+}
+noInline(blackbox)
+
+function doesNotThrow() {
+    try {
+        1 in blackbox()
+        return false
+    } catch(v45) {
+        return true
+    }
+}
+noInline(doesNotThrow)
+noFTL(doesNotThrow)
+
+function trickster(o) {
+    try {
+        1 in o
+        return false
+    } catch(v45) {
+        return true
+    }
+}
+noInline(trickster)
+
+// Does not throw
+function enumeratorTest(o) {
+    let sum = 0
+    for (let i in o)
+        sum += o[i]
+    return sum
+}
+noInline(enumeratorTest)
+noInline(enumeratorTest)
+
+let indexedObject = []
+indexedObject.length = 10
+indexedObject.fill(1)
+
+function main() {
+    for (let j = 0; j < 50000; j++) {
+        if (!doesThrow())
+            throw new Error("Should throw!")
+        if (!doesThrowFTL())
+            throw new Error("Should throw!")
+        if (doesNotThrow())
+            throw new Error("Should not throw!")
+        
+            let o = {}
+        o["a" + j] = 0
+        if (trickster(o))
+            throw new Error("Should not throw!")
+        
+        enumeratorTest(indexedObject)
+    }
+    if (!trickster(""))
+        throw new Error("Should throw!")
+    enumeratorTest("")
+}
+noDFG(main)
+noFTL(main)
+noInline(main)
+main()
\ No newline at end of file

Modified: branches/safari-612-branch/Source/_javascript_Core/ChangeLog (285452 => 285453)


--- branches/safari-612-branch/Source/_javascript_Core/ChangeLog	2021-11-09 01:08:35 UTC (rev 285452)
+++ branches/safari-612-branch/Source/_javascript_Core/ChangeLog	2021-11-09 01:08:38 UTC (rev 285453)
@@ -1,5 +1,60 @@
 2021-11-08  Kocsen Chung  <[email protected]>
 
+        Cherry-pick r282821. rdar://problem/85167490
+
+    Differential testing: live statement don't execute
+    https://bugs.webkit.org/show_bug.cgi?id=229939
+    
+    Reviewed by Saam Barati.
+    
+    JSTests:
+    
+    * stress/in-by-val-should-throw.js: Added.
+    (doesThrow):
+    (noInline.doesThrow.noFTL.doesThrow.blackbox):
+    (noInline.blackbox.doesNotThrow):
+    (noInline.doesNotThrow.noFTL.doesNotThrow.main):
+    
+    Source/_javascript_Core:
+    
+    In statements are supposed to throw if they are applied to a non-object. We incorrectly converted
+    InByVals into HasIndexedProperty any time they were a cell, so we silently converted non-objects. Before converting
+    an InByVal, we first speculate that the base is an object now.
+    
+    We do not always require an object edge for HasIndexedProperty because enumerator next() does not
+    throw if it encounters a cell that requires conversion during the call to toObject (for example, a
+    string literal). That is, we should silently convert the string during enumeration, but not for an
+    In statement, and so HasIndexedProperty is prepared to handle both cases.
+    
+    * dfg/DFGFixupPhase.cpp:
+    (JSC::DFG::FixupPhase::fixupNode):
+    (JSC::DFG::FixupPhase::convertToHasIndexedProperty):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@282821 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-09-21  Justin Michaud  <[email protected]>
+
+            Differential testing: live statement don't execute
+            https://bugs.webkit.org/show_bug.cgi?id=229939
+
+            Reviewed by Saam Barati.
+
+            In statements are supposed to throw if they are applied to a non-object. We incorrectly converted
+            InByVals into HasIndexedProperty any time they were a cell, so we silently converted non-objects. Before converting
+            an InByVal, we first speculate that the base is an object now.
+
+            We do not always require an object edge for HasIndexedProperty because enumerator next() does not
+            throw if it encounters a cell that requires conversion during the call to toObject (for example, a
+            string literal). That is, we should silently convert the string during enumeration, but not for an
+            In statement, and so HasIndexedProperty is prepared to handle both cases.
+
+            * dfg/DFGFixupPhase.cpp:
+            (JSC::DFG::FixupPhase::fixupNode):
+            (JSC::DFG::FixupPhase::convertToHasIndexedProperty):
+
+2021-11-08  Kocsen Chung  <[email protected]>
+
         Cherry-pick r282212. rdar://problem/85165960
 
     Differential testing: incorrect constant propagation around Uint8ClampedArray

Modified: branches/safari-612-branch/Source/_javascript_Core/dfg/DFGFixupPhase.cpp (285452 => 285453)


--- branches/safari-612-branch/Source/_javascript_Core/dfg/DFGFixupPhase.cpp	2021-11-09 01:08:35 UTC (rev 285452)
+++ branches/safari-612-branch/Source/_javascript_Core/dfg/DFGFixupPhase.cpp	2021-11-09 01:08:38 UTC (rev 285453)
@@ -2095,7 +2095,8 @@
         }
 
         case InByVal: {
-            if (node->child2()->shouldSpeculateInt32()) {
+            if (node->child1()->shouldSpeculateObject()
+                && node->child2()->shouldSpeculateInt32()) {
                 convertToHasIndexedProperty(node);
                 break;
             }
@@ -4158,7 +4159,7 @@
         if (arrayMode.isJSArrayWithOriginalStructure() && arrayMode.speculation() == Array::InBounds)
             setSaneChainIfPossible(node, Array::InBoundsSaneChain);
 
-        fixEdge<CellUse>(m_graph.varArgChild(node, 0));
+        fixEdge<ObjectUse>(m_graph.varArgChild(node, 0));
         fixEdge<Int32Use>(m_graph.varArgChild(node, 1));
     }
 

Modified: branches/safari-612-branch/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp (285452 => 285453)


--- branches/safari-612-branch/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp	2021-11-09 01:08:35 UTC (rev 285452)
+++ branches/safari-612-branch/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp	2021-11-09 01:08:38 UTC (rev 285453)
@@ -15289,12 +15289,16 @@
 
 void SpeculativeJIT::compileHasIndexedProperty(Node* node, S_JITOperation_GCZ slowPathOperation, const ScopedLambda<std::tuple<GPRReg, GPRReg>()>& prefix)
 {
-    SpeculateCellOperand base(this, m_graph.varArgChild(node, 0));
+    auto baseEdge = m_graph.varArgChild(node, 0);
+    SpeculateCellOperand base(this, baseEdge);
 
     GPRReg baseGPR = base.gpr();
     GPRReg indexGPR = InvalidGPRReg;
     GPRReg resultGPR = InvalidGPRReg;
 
+    if (baseEdge.useKind() == ObjectUse)
+        speculateObject(baseEdge, baseGPR);
+
     MacroAssembler::JumpList slowCases;
     ArrayMode mode = node->arrayMode();
     switch (mode.type()) {

Modified: branches/safari-612-branch/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp (285452 => 285453)


--- branches/safari-612-branch/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp	2021-11-09 01:08:35 UTC (rev 285452)
+++ branches/safari-612-branch/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp	2021-11-09 01:08:38 UTC (rev 285453)
@@ -13176,9 +13176,13 @@
     LValue compileHasIndexedPropertyImpl(LValue index, S_JITOperation_GCZ slowPathOperation)
     {
         JSGlobalObject* globalObject = m_graph.globalObjectFor(m_origin.semantic);
-        LValue base = lowCell(m_graph.varArgChild(m_node, 0));
         ArrayMode mode = m_node->arrayMode();
 
+        auto baseEdge = m_graph.varArgChild(m_node, 0);
+        LValue base = lowCell(baseEdge);
+        if (baseEdge.useKind() == ObjectUse)
+            speculateObject(baseEdge, base);
+
         switch (m_node->arrayMode().type()) {
         case Array::Int32:
         case Array::Contiguous: {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to