Title: [225153] trunk
Revision
225153
Author
[email protected]
Date
2017-11-26 19:45:57 -0800 (Sun, 26 Nov 2017)

Log Message

[FTL] Support DeleteById and DeleteByVal
https://bugs.webkit.org/show_bug.cgi?id=180022

Reviewed by Saam Barati.

JSTests:

* stress/delete-by-id.js: Added.
(shouldBe):
(test1):
(test2):
* stress/delete-by-val-ftl.js: Added.
(shouldBe):
(test1):
(test2):

Source/_javascript_Core:

We should increase the coverage of FTL. Even if the code includes DeleteById,
it does not mean that remaining part of the code should not be optimized in FTL.
Right now, even CallEval and `with` scope are handled in FTL.

This patch just adds DeleteById and DeleteByVal handling to FTL to allow optimizing
code including them.

* ftl/FTLCapabilities.cpp:
(JSC::FTL::canCompile):
* ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::compileNode):
(JSC::FTL::DFG::LowerDFGToB3::compileDeleteById):
(JSC::FTL::DFG::LowerDFGToB3::compileDeleteByVal):

Modified Paths

Added Paths

Diff

Modified: trunk/JSTests/ChangeLog (225152 => 225153)


--- trunk/JSTests/ChangeLog	2017-11-27 02:19:53 UTC (rev 225152)
+++ trunk/JSTests/ChangeLog	2017-11-27 03:45:57 UTC (rev 225153)
@@ -1,5 +1,21 @@
 2017-11-26  Yusuke Suzuki  <[email protected]>
 
+        [FTL] Support DeleteById and DeleteByVal
+        https://bugs.webkit.org/show_bug.cgi?id=180022
+
+        Reviewed by Saam Barati.
+
+        * stress/delete-by-id.js: Added.
+        (shouldBe):
+        (test1):
+        (test2):
+        * stress/delete-by-val-ftl.js: Added.
+        (shouldBe):
+        (test1):
+        (test2):
+
+2017-11-26  Yusuke Suzuki  <[email protected]>
+
         [DFG] Introduce {Set,Map,WeakMap}Fields
         https://bugs.webkit.org/show_bug.cgi?id=179925
 

Added: trunk/JSTests/stress/delete-by-id.js (0 => 225153)


--- trunk/JSTests/stress/delete-by-id.js	                        (rev 0)
+++ trunk/JSTests/stress/delete-by-id.js	2017-11-27 03:45:57 UTC (rev 225153)
@@ -0,0 +1,28 @@
+function shouldBe(actual, expected)
+{
+    if (actual !== expected)
+        throw new Error('bad value: ' + actual);
+}
+
+function test1(object)
+{
+    return delete object.cocoa;
+}
+noInline(test1);
+
+function test2(object)
+{
+    return delete object.cappuccino;
+}
+noInline(test2);
+
+for (var i = 0; i < 1e5; ++i) {
+    var object = {
+        cocoa: 42
+    };
+    Object.defineProperty(object, "cappuccino", {
+        value: 42
+    });
+    shouldBe(test1(object), true);
+    shouldBe(test2(object), false);
+}

Added: trunk/JSTests/stress/delete-by-val-ftl.js (0 => 225153)


--- trunk/JSTests/stress/delete-by-val-ftl.js	                        (rev 0)
+++ trunk/JSTests/stress/delete-by-val-ftl.js	2017-11-27 03:45:57 UTC (rev 225153)
@@ -0,0 +1,28 @@
+function shouldBe(actual, expected)
+{
+    if (actual !== expected)
+        throw new Error('bad value: ' + actual);
+}
+
+function test1(object, key)
+{
+    return delete object[key];
+}
+noInline(test1);
+
+function test2(object, key)
+{
+    return delete object[key];
+}
+noInline(test2);
+
+for (var i = 0; i < 1e5; ++i) {
+    var object = {
+        cocoa: 42
+    };
+    Object.defineProperty(object, "cappuccino", {
+        value: 42
+    });
+    shouldBe(test1(object, "cocoa"), true);
+    shouldBe(test2(object, "cappuccino"), false);
+}

Modified: trunk/Source/_javascript_Core/ChangeLog (225152 => 225153)


--- trunk/Source/_javascript_Core/ChangeLog	2017-11-27 02:19:53 UTC (rev 225152)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-11-27 03:45:57 UTC (rev 225153)
@@ -1,5 +1,26 @@
 2017-11-26  Yusuke Suzuki  <[email protected]>
 
+        [FTL] Support DeleteById and DeleteByVal
+        https://bugs.webkit.org/show_bug.cgi?id=180022
+
+        Reviewed by Saam Barati.
+
+        We should increase the coverage of FTL. Even if the code includes DeleteById,
+        it does not mean that remaining part of the code should not be optimized in FTL.
+        Right now, even CallEval and `with` scope are handled in FTL.
+
+        This patch just adds DeleteById and DeleteByVal handling to FTL to allow optimizing
+        code including them.
+
+        * ftl/FTLCapabilities.cpp:
+        (JSC::FTL::canCompile):
+        * ftl/FTLLowerDFGToB3.cpp:
+        (JSC::FTL::DFG::LowerDFGToB3::compileNode):
+        (JSC::FTL::DFG::LowerDFGToB3::compileDeleteById):
+        (JSC::FTL::DFG::LowerDFGToB3::compileDeleteByVal):
+
+2017-11-26  Yusuke Suzuki  <[email protected]>
+
         [DFG] Introduce {Set,Map,WeakMap}Fields
         https://bugs.webkit.org/show_bug.cgi?id=179925
 

Modified: trunk/Source/_javascript_Core/ftl/FTLCapabilities.cpp (225152 => 225153)


--- trunk/Source/_javascript_Core/ftl/FTLCapabilities.cpp	2017-11-27 02:19:53 UTC (rev 225152)
+++ trunk/Source/_javascript_Core/ftl/FTLCapabilities.cpp	2017-11-27 03:45:57 UTC (rev 225153)
@@ -268,6 +268,8 @@
     case PutGetterSetterById:
     case PutGetterByVal:
     case PutSetterByVal:
+    case DeleteById:
+    case DeleteByVal:
     case CreateRest:
     case GetRestLength:
     case RegExpExec:

Modified: trunk/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp (225152 => 225153)


--- trunk/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp	2017-11-27 02:19:53 UTC (rev 225152)
+++ trunk/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp	2017-11-27 03:45:57 UTC (rev 225153)
@@ -706,6 +706,12 @@
         case PutSetterByVal:
             compilePutAccessorByVal();
             break;
+        case DeleteById:
+            compileDeleteById();
+            break;
+        case DeleteByVal:
+            compileDeleteByVal();
+            break;
         case GetButterfly:
         case GetButterflyWithoutCaging:
             compileGetButterfly();
@@ -4210,6 +4216,20 @@
             m_out.operation(m_node->op() == PutGetterByVal ? operationPutGetterByVal : operationPutSetterByVal),
             m_callFrame, base, subscript, m_out.constInt32(m_node->accessorAttributes()), accessor);
     }
+
+    void compileDeleteById()
+    {
+        LValue base = lowJSValue(m_node->child1());
+        auto uid = m_graph.identifiers()[m_node->identifierNumber()];
+        setBoolean(m_out.notZero64(vmCall(Int64, m_out.operation(operationDeleteById), m_callFrame, base, m_out.constIntPtr(uid))));
+    }
+
+    void compileDeleteByVal()
+    {
+        LValue base = lowJSValue(m_node->child1());
+        LValue subscript = lowJSValue(m_node->child2());
+        setBoolean(m_out.notZero64(vmCall(Int64, m_out.operation(operationDeleteByVal), m_callFrame, base, subscript)));
+    }
     
     void compileArrayPush()
     {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to