Title: [215379] trunk/Source/_javascript_Core
Revision
215379
Author
keith_mil...@apple.com
Date
2017-04-14 16:20:19 -0700 (Fri, 14 Apr 2017)

Log Message

WebAssembly: B3IRGenerator should use phis for result types
https://bugs.webkit.org/show_bug.cgi?id=170863

Reviewed by Filip Pizlo.

Currently, we use variables for the result types of control flow in
Wasm. We did this originally since we weren't sure that the phis we
generated would be optimal. Since then, we have verified that the edges
in wasm control flow ensure that each upsilon will dominate its phi
so we don't need to use variables.

* wasm/WasmB3IRGenerator.cpp:
(JSC::Wasm::B3IRGenerator::ControlData::ControlData):
(JSC::Wasm::B3IRGenerator::addTopLevel):
(JSC::Wasm::B3IRGenerator::addBlock):
(JSC::Wasm::B3IRGenerator::addLoop):
(JSC::Wasm::B3IRGenerator::unify):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (215378 => 215379)


--- trunk/Source/_javascript_Core/ChangeLog	2017-04-14 23:03:19 UTC (rev 215378)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-04-14 23:20:19 UTC (rev 215379)
@@ -1,3 +1,23 @@
+2017-04-14  Keith Miller  <keith_mil...@apple.com>
+
+        WebAssembly: B3IRGenerator should use phis for result types
+        https://bugs.webkit.org/show_bug.cgi?id=170863
+
+        Reviewed by Filip Pizlo.
+
+        Currently, we use variables for the result types of control flow in
+        Wasm. We did this originally since we weren't sure that the phis we
+        generated would be optimal. Since then, we have verified that the edges
+        in wasm control flow ensure that each upsilon will dominate its phi
+        so we don't need to use variables.
+
+        * wasm/WasmB3IRGenerator.cpp:
+        (JSC::Wasm::B3IRGenerator::ControlData::ControlData):
+        (JSC::Wasm::B3IRGenerator::addTopLevel):
+        (JSC::Wasm::B3IRGenerator::addBlock):
+        (JSC::Wasm::B3IRGenerator::addLoop):
+        (JSC::Wasm::B3IRGenerator::unify):
+
 2017-04-14  Alex Christensen  <achristen...@webkit.org>
 
         Fix Windows build after r215368.

Modified: trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp (215378 => 215379)


--- trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp	2017-04-14 23:03:19 UTC (rev 215378)
+++ trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp	2017-04-14 23:20:19 UTC (rev 215379)
@@ -39,6 +39,7 @@
 #include "B3SlotBaseValue.h"
 #include "B3StackmapGenerationParams.h"
 #include "B3SwitchValue.h"
+#include "B3UpsilonValue.h"
 #include "B3Validate.h"
 #include "B3ValueInlines.h"
 #include "B3ValueKey.h"
@@ -77,13 +78,13 @@
 class B3IRGenerator {
 public:
     struct ControlData {
-        ControlData(Procedure& proc, Type signature, BlockType type, BasicBlock* continuation, BasicBlock* special = nullptr)
+        ControlData(Procedure& proc, Origin origin, Type signature, BlockType type, BasicBlock* continuation, BasicBlock* special = nullptr)
             : blockType(type)
             , continuation(continuation)
             , special(special)
         {
             if (signature != Void)
-                result.append(proc.addVariable(toB3Type(signature)));
+                result.append(proc.add<Value>(Phi, toB3Type(signature), origin));
         }
 
         ControlData()
@@ -131,7 +132,7 @@
             special = nullptr;
         }
 
-        using ResultList = Vector<Variable*, 1>;
+        using ResultList = Vector<Value*, 1>; // Value must be a Phi
 
         ResultList resultForBranch() const
         {
@@ -231,7 +232,7 @@
     ExpressionType emitLoadOp(LoadOpType, ExpressionType pointer, uint32_t offset);
     void emitStoreOp(StoreOpType, ExpressionType pointer, ExpressionType value, uint32_t offset);
 
-    void unify(Variable* target, const ExpressionType source);
+    void unify(const ExpressionType phi, const ExpressionType source);
     void unifyValuesWithBlock(const ExpressionList& resultStack, const ResultList& stack);
 
     void emitChecksForModOrDiv(B3::Opcode, ExpressionType left, ExpressionType right);
@@ -801,12 +802,12 @@
 
 B3IRGenerator::ControlData B3IRGenerator::addTopLevel(Type signature)
 {
-    return ControlData(m_proc, signature, BlockType::TopLevel, m_proc.addBlock());
+    return ControlData(m_proc, Origin(), signature, BlockType::TopLevel, m_proc.addBlock());
 }
 
 B3IRGenerator::ControlData B3IRGenerator::addBlock(Type signature)
 {
-    return ControlData(m_proc, signature, BlockType::Block, m_proc.addBlock());
+    return ControlData(m_proc, origin(), signature, BlockType::Block, m_proc.addBlock());
 }
 
 B3IRGenerator::ControlData B3IRGenerator::addLoop(Type signature)
@@ -816,7 +817,7 @@
     m_currentBlock->appendNewControlValue(m_proc, Jump, origin(), body);
     body->addPredecessor(m_currentBlock);
     m_currentBlock = body;
-    return ControlData(m_proc, signature, BlockType::Loop, continuation, body);
+    return ControlData(m_proc, origin(), signature, BlockType::Loop, continuation, body);
 }
 
 auto B3IRGenerator::addIf(ExpressionType condition, Type signature, ControlType& result) -> PartialResult
@@ -833,7 +834,7 @@
     notTaken->addPredecessor(m_currentBlock);
 
     m_currentBlock = taken;
-    result = ControlData(m_proc, signature, BlockType::If, continuation, notTaken);
+    result = ControlData(m_proc, origin(), signature, BlockType::If, continuation, notTaken);
     return { };
 }
 
@@ -918,8 +919,10 @@
         m_currentBlock->addPredecessor(data.special);
     }
 
-    for (Variable* result : data.result)
-        entry.enclosedExpressionStack.append(m_currentBlock->appendNew<VariableValue>(m_proc, B3::Get, origin(), result));
+    for (Value* result : data.result) {
+        m_currentBlock->append(result);
+        entry.enclosedExpressionStack.append(result);
+    }
 
     // TopLevel does not have any code after this so we need to make sure we emit a return here.
     if (data.type() == BlockType::TopLevel)
@@ -1097,9 +1100,9 @@
     return { };
 }
 
-void B3IRGenerator::unify(Variable* variable, ExpressionType source)
+void B3IRGenerator::unify(const ExpressionType phi, const ExpressionType source)
 {
-    m_currentBlock->appendNew<VariableValue>(m_proc, Set, origin(), variable, source);
+    m_currentBlock->appendNew<UpsilonValue>(m_proc, origin(), source, phi);
 }
 
 void B3IRGenerator::unifyValuesWithBlock(const ExpressionList& resultStack, const ResultList& result)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to