Title: [192967] trunk/Source/_javascript_Core
Revision
192967
Author
benja...@webkit.org
Date
2015-12-02 14:12:35 -0800 (Wed, 02 Dec 2015)

Log Message

[JSC] Add a function attribute for Pure functions in B3
https://bugs.webkit.org/show_bug.cgi?id=151741

Patch by Benjamin Poulain <bpoul...@apple.com> on 2015-12-02
Reviewed by Geoffrey Garen.

We have plenty of functions without side effects
when lowering DFG.
This patch adds the "PureCall" flag to B3's CCall
to make sure those functions do not prevent optimizations.

* b3/B3CCallValue.h:
* b3/testb3.cpp:
(JSC::B3::testCallSimplePure):
(JSC::B3::run):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (192966 => 192967)


--- trunk/Source/_javascript_Core/ChangeLog	2015-12-02 22:09:58 UTC (rev 192966)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-12-02 22:12:35 UTC (rev 192967)
@@ -1,3 +1,20 @@
+2015-12-02  Benjamin Poulain  <bpoul...@apple.com>
+
+        [JSC] Add a function attribute for Pure functions in B3
+        https://bugs.webkit.org/show_bug.cgi?id=151741
+
+        Reviewed by Geoffrey Garen.
+
+        We have plenty of functions without side effects
+        when lowering DFG.
+        This patch adds the "PureCall" flag to B3's CCall
+        to make sure those functions do not prevent optimizations.
+
+        * b3/B3CCallValue.h:
+        * b3/testb3.cpp:
+        (JSC::B3::testCallSimplePure):
+        (JSC::B3::run):
+
 2015-12-02  Mark Lam  <mark....@apple.com>
 
         Removed unnecessary #if USE(JSVALUE64).

Modified: trunk/Source/_javascript_Core/b3/B3CCallValue.h (192966 => 192967)


--- trunk/Source/_javascript_Core/b3/B3CCallValue.h	2015-12-02 22:09:58 UTC (rev 192966)
+++ trunk/Source/_javascript_Core/b3/B3CCallValue.h	2015-12-02 22:12:35 UTC (rev 192967)
@@ -35,6 +35,7 @@
 
 class JS_EXPORT_PRIVATE CCallValue : public Value {
 public:
+    enum PureFunctionTag { PureFunction };
     static bool accepts(Opcode opcode) { return opcode == CCall; }
 
     ~CCallValue();
@@ -50,6 +51,12 @@
         , effects(Effects::forCall())
     {
     }
+
+    template<typename... Arguments>
+    CCallValue(unsigned index, Type type, Origin origin, PureFunctionTag, Arguments... arguments)
+        : Value(index, CheckedOpcode, CCall, type, origin, arguments...)
+    {
+    }
 };
 
 } } // namespace JSC::B3

Modified: trunk/Source/_javascript_Core/b3/testb3.cpp (192966 => 192967)


--- trunk/Source/_javascript_Core/b3/testb3.cpp	2015-12-02 22:09:58 UTC (rev 192966)
+++ trunk/Source/_javascript_Core/b3/testb3.cpp	2015-12-02 22:12:35 UTC (rev 192967)
@@ -4724,6 +4724,21 @@
     CHECK(compileAndRun<int>(proc, a, b) == a + b);
 }
 
+void testCallSimplePure(int a, int b)
+{
+    Procedure proc;
+    BasicBlock* root = proc.addBlock();
+    root->appendNew<ControlValue>(
+        proc, Return, Origin(),
+        root->appendNew<CCallValue>(
+            proc, Int32, Origin(), CCallValue::PureFunction,
+            root->appendNew<ConstPtrValue>(proc, Origin(), bitwise_cast<void*>(simpleFunction)),
+            root->appendNew<ArgumentRegValue>(proc, Origin(), GPRInfo::argumentGPR0),
+            root->appendNew<ArgumentRegValue>(proc, Origin(), GPRInfo::argumentGPR1)));
+
+    CHECK(compileAndRun<int>(proc, a, b) == a + b);
+}
+
 int functionWithHellaArguments(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l, int m, int n, int o, int p, int q, int r, int s, int t, int u, int v, int w, int x, int y, int z)
 {
     return (a << 0) + (b << 1) + (c << 2) + (d << 3) + (e << 4) + (f << 5) + (g << 6) + (h << 7) + (i << 8) + (j << 9) + (k << 10) + (l << 11) + (m << 12) + (n << 13) + (o << 14) + (p << 15) + (q << 16) + (r << 17) + (s << 18) + (t << 19) + (u << 20) + (v << 21) + (w << 22) + (x << 23) + (y << 24) + (z << 25);
@@ -5991,6 +6006,7 @@
     RUN(testInt32ToDoublePartialRegisterWithoutStall());
 
     RUN(testCallSimple(1, 2));
+    RUN(testCallSimplePure(1, 2));
     RUN(testCallFunctionWithHellaArguments());
 
     RUN(testReturnDouble(0.0));
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to