Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Unified Diff: src/compiler/machine-operator-reducer.cc

Issue 526083002: [turbofan] Fix MachineOperatorReducer to use JSGraph as well. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/machine-operator-reducer.h ('k') | src/compiler/machine-operator-reducer-unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/machine-operator-reducer.cc
diff --git a/src/compiler/machine-operator-reducer.cc b/src/compiler/machine-operator-reducer.cc
index 07bb02f9da1973989f429eae471e0f9b71f2f779..4a7bff9ac6797ba5af63d06fc765eca2cf723480 100644
--- a/src/compiler/machine-operator-reducer.cc
+++ b/src/compiler/machine-operator-reducer.cc
@@ -5,50 +5,34 @@
#include "src/compiler/machine-operator-reducer.h"
#include "src/base/bits.h"
-#include "src/compiler/common-node-cache.h"
#include "src/compiler/generic-node-inl.h"
#include "src/compiler/graph.h"
+#include "src/compiler/js-graph.h"
#include "src/compiler/node-matchers.h"
namespace v8 {
namespace internal {
namespace compiler {
-MachineOperatorReducer::MachineOperatorReducer(Graph* graph)
- : graph_(graph),
- cache_(new (graph->zone()) CommonNodeCache(graph->zone())),
- common_(graph->zone()),
- machine_(graph->zone()) {}
+MachineOperatorReducer::MachineOperatorReducer(JSGraph* jsgraph)
+ : jsgraph_(jsgraph), machine_(jsgraph->zone()) {}
-MachineOperatorReducer::MachineOperatorReducer(Graph* graph,
- CommonNodeCache* cache)
- : graph_(graph),
- cache_(cache),
- common_(graph->zone()),
- machine_(graph->zone()) {}
+MachineOperatorReducer::~MachineOperatorReducer() {}
Node* MachineOperatorReducer::Float64Constant(volatile double value) {
- Node** loc = cache_->FindFloat64Constant(value);
- if (*loc == NULL) {
- *loc = graph_->NewNode(common_.Float64Constant(value));
- }
- return *loc;
+ return jsgraph()->Float64Constant(value);
}
Node* MachineOperatorReducer::Int32Constant(int32_t value) {
- Node** loc = cache_->FindInt32Constant(value);
- if (*loc == NULL) {
- *loc = graph_->NewNode(common_.Int32Constant(value));
- }
- return *loc;
+ return jsgraph()->Int32Constant(value);
}
Node* MachineOperatorReducer::Int64Constant(int64_t value) {
- return graph_->NewNode(common_.Int64Constant(value));
+ return graph()->NewNode(common()->Int64Constant(value));
}
@@ -82,7 +66,7 @@ Reduction MachineOperatorReducer::Reduce(Node* node) {
Int32BinopMatcher mrightright(mright.right().node());
if (mrightright.left().Is(32) &&
mrightright.right().node() == mleft.right().node()) {
- graph_->ChangeOperator(node, machine_.Word32Ror());
+ graph()->ChangeOperator(node, machine()->Word32Ror());
node->ReplaceInput(0, mleft.left().node());
node->ReplaceInput(1, mleft.right().node());
return Changed(node);
@@ -91,7 +75,7 @@ Reduction MachineOperatorReducer::Reduce(Node* node) {
// (x << K) | (x >> (32 - K)) => x ror K
if (mleft.right().IsInRange(0, 31) &&
mright.right().Is(32 - mleft.right().Value())) {
- graph_->ChangeOperator(node, machine_.Word32Ror());
+ graph()->ChangeOperator(node, machine()->Word32Ror());
node->ReplaceInput(0, mleft.left().node());
node->ReplaceInput(1, mleft.right().node());
return Changed(node);
@@ -107,7 +91,7 @@ Reduction MachineOperatorReducer::Reduce(Node* node) {
Int32BinopMatcher mleftright(mleft.right().node());
if (mleftright.left().Is(32) &&
mleftright.right().node() == mright.right().node()) {
- graph_->ChangeOperator(node, machine_.Word32Ror());
+ graph()->ChangeOperator(node, machine()->Word32Ror());
node->ReplaceInput(0, mright.left().node());
node->ReplaceInput(1, mright.right().node());
return Changed(node);
@@ -116,7 +100,7 @@ Reduction MachineOperatorReducer::Reduce(Node* node) {
// (x >> (32 - K)) | (x << K) => x ror K
if (mright.right().IsInRange(0, 31) &&
mleft.right().Is(32 - mright.right().Value())) {
- graph_->ChangeOperator(node, machine_.Word32Ror());
+ graph()->ChangeOperator(node, machine()->Word32Ror());
node->ReplaceInput(0, mright.left().node());
node->ReplaceInput(1, mright.right().node());
return Changed(node);
@@ -209,13 +193,13 @@ Reduction MachineOperatorReducer::Reduce(Node* node) {
return ReplaceInt32(m.left().Value() * m.right().Value());
}
if (m.right().Is(-1)) { // x * -1 => 0 - x
- graph_->ChangeOperator(node, machine_.Int32Sub());
+ graph()->ChangeOperator(node, machine()->Int32Sub());
node->ReplaceInput(0, Int32Constant(0));
node->ReplaceInput(1, m.left().node());
return Changed(node);
}
if (m.right().IsPowerOf2()) { // x * 2^n => x << n
- graph_->ChangeOperator(node, machine_.Word32Shl());
+ graph()->ChangeOperator(node, machine()->Word32Shl());
node->ReplaceInput(1, Int32Constant(WhichPowerOf2(m.right().Value())));
return Changed(node);
}
@@ -233,7 +217,7 @@ Reduction MachineOperatorReducer::Reduce(Node* node) {
return ReplaceInt32(m.left().Value() / m.right().Value());
}
if (m.right().Is(-1)) { // x / -1 => 0 - x
- graph_->ChangeOperator(node, machine_.Int32Sub());
+ graph()->ChangeOperator(node, machine()->Int32Sub());
node->ReplaceInput(0, Int32Constant(0));
node->ReplaceInput(1, m.left().node());
return Changed(node);
@@ -250,7 +234,7 @@ Reduction MachineOperatorReducer::Reduce(Node* node) {
return ReplaceInt32(m.left().Value() / m.right().Value());
}
if (m.right().IsPowerOf2()) { // x / 2^n => x >> n
- graph_->ChangeOperator(node, machine_.Word32Shr());
+ graph()->ChangeOperator(node, machine()->Word32Shr());
node->ReplaceInput(1, Int32Constant(WhichPowerOf2(m.right().Value())));
return Changed(node);
}
@@ -279,7 +263,7 @@ Reduction MachineOperatorReducer::Reduce(Node* node) {
return ReplaceInt32(m.left().Value() % m.right().Value());
}
if (m.right().IsPowerOf2()) { // x % 2^n => x & 2^n-1
- graph_->ChangeOperator(node, machine_.Word32And());
+ graph()->ChangeOperator(node, machine()->Word32And());
node->ReplaceInput(1, Int32Constant(m.right().Value() - 1));
return Changed(node);
}
@@ -447,6 +431,15 @@ Reduction MachineOperatorReducer::Reduce(Node* node) {
}
return NoChange();
}
+
+
+CommonOperatorBuilder* MachineOperatorReducer::common() const {
+ return jsgraph()->common();
}
-}
-} // namespace v8::internal::compiler
+
+
+Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); }
+
+} // namespace compiler
+} // namespace internal
+} // namespace v8
« no previous file with comments | « src/compiler/machine-operator-reducer.h ('k') | src/compiler/machine-operator-reducer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698