Reviewers: Sven Panne,
Description:
[turbofan] More const-correctness changes.
Also get rid of the DeleteNode and ChangeOperator methods in Graph.
TEST=compiler-unittests,cctest,mjsunit
[email protected]
Please review this at https://codereview.chromium.org/540863002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+27, -44 lines):
M src/compiler/graph.h
M src/compiler/graph.cc
M src/compiler/machine-operator-reducer.cc
M src/compiler/simplified-operator-reducer.cc
Index: src/compiler/graph.cc
diff --git a/src/compiler/graph.cc b/src/compiler/graph.cc
index
f49ce3411343773b64e5bac519dd507cb5b9746e..7b5f228aa163ffd1a4ddc02d218cf095efedb6a0
100644
--- a/src/compiler/graph.cc
+++ b/src/compiler/graph.cc
@@ -21,7 +21,7 @@ namespace compiler {
Graph::Graph(Zone* zone) : GenericGraph<Node>(zone), decorators_(zone) {}
-Node* Graph::NewNode(Operator* op, int input_count, Node** inputs) {
+Node* Graph::NewNode(const Operator* op, int input_count, Node** inputs) {
DCHECK_LE(op->InputCount(), input_count);
Node* result = Node::New(this, input_count, inputs);
result->Initialize(op);
@@ -32,21 +32,6 @@ Node* Graph::NewNode(Operator* op, int input_count,
Node** inputs) {
return result;
}
-
-void Graph::ChangeOperator(Node* node, Operator* op) { node->set_op(op); }
-
-
-void Graph::DeleteNode(Node* node) {
-#if DEBUG
- // Nodes can't be deleted if they have uses.
- Node::Uses::iterator use_iterator(node->uses().begin());
- DCHECK(use_iterator == node->uses().end());
-#endif
-
-#if DEBUG
- memset(node, 0xDE, sizeof(Node));
-#endif
-}
-}
-}
-} // namespace v8::internal::compiler
+} // namespace compiler
+} // namespace internal
+} // namespace v8
Index: src/compiler/graph.h
diff --git a/src/compiler/graph.h b/src/compiler/graph.h
index
e59cc8870fb8aac19132fd019c6bff0d7882d6ac..07eb02f9c99bfa26d11485055b6ea62e717439e5
100644
--- a/src/compiler/graph.h
+++ b/src/compiler/graph.h
@@ -25,39 +25,36 @@ class Graph : public GenericGraph<Node> {
explicit Graph(Zone* zone);
// Base implementation used by all factory methods.
- Node* NewNode(Operator* op, int input_count, Node** inputs);
+ Node* NewNode(const Operator* op, int input_count, Node** inputs);
// Factories for nodes with static input counts.
- Node* NewNode(Operator* op) {
+ Node* NewNode(const Operator* op) {
return NewNode(op, 0, static_cast<Node**>(NULL));
}
- Node* NewNode(Operator* op, Node* n1) { return NewNode(op, 1, &n1); }
- Node* NewNode(Operator* op, Node* n1, Node* n2) {
+ Node* NewNode(const Operator* op, Node* n1) { return NewNode(op, 1,
&n1); }
+ Node* NewNode(const Operator* op, Node* n1, Node* n2) {
Node* nodes[] = {n1, n2};
return NewNode(op, arraysize(nodes), nodes);
}
- Node* NewNode(Operator* op, Node* n1, Node* n2, Node* n3) {
+ Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3) {
Node* nodes[] = {n1, n2, n3};
return NewNode(op, arraysize(nodes), nodes);
}
- Node* NewNode(Operator* op, Node* n1, Node* n2, Node* n3, Node* n4) {
+ Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node*
n4) {
Node* nodes[] = {n1, n2, n3, n4};
return NewNode(op, arraysize(nodes), nodes);
}
- Node* NewNode(Operator* op, Node* n1, Node* n2, Node* n3, Node* n4,
+ Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4,
Node* n5) {
Node* nodes[] = {n1, n2, n3, n4, n5};
return NewNode(op, arraysize(nodes), nodes);
}
- Node* NewNode(Operator* op, Node* n1, Node* n2, Node* n3, Node* n4,
Node* n5,
- Node* n6) {
+ Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4,
+ Node* n5, Node* n6) {
Node* nodes[] = {n1, n2, n3, n4, n5, n6};
return NewNode(op, arraysize(nodes), nodes);
}
- void ChangeOperator(Node* node, Operator* op);
- void DeleteNode(Node* node);
-
template <class Visitor>
void VisitNodeUsesFrom(Node* node, Visitor* visitor);
@@ -88,8 +85,9 @@ class GraphDecorator : public ZoneObject {
virtual ~GraphDecorator() {}
virtual void Decorate(Node* node) = 0;
};
-}
-}
-} // namespace v8::internal::compiler
+
+} // namespace compiler
+} // namespace internal
+} // namespace v8
#endif // V8_COMPILER_GRAPH_H_
Index: src/compiler/machine-operator-reducer.cc
diff --git a/src/compiler/machine-operator-reducer.cc
b/src/compiler/machine-operator-reducer.cc
index
4a7bff9ac6797ba5af63d06fc765eca2cf723480..6f2e28ed7d479e7bbbe5be3dc880b02db23576d4
100644
--- a/src/compiler/machine-operator-reducer.cc
+++ b/src/compiler/machine-operator-reducer.cc
@@ -66,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());
+ node->set_op(machine()->Word32Ror());
node->ReplaceInput(0, mleft.left().node());
node->ReplaceInput(1, mleft.right().node());
return Changed(node);
@@ -75,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());
+ node->set_op(machine()->Word32Ror());
node->ReplaceInput(0, mleft.left().node());
node->ReplaceInput(1, mleft.right().node());
return Changed(node);
@@ -91,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());
+ node->set_op(machine()->Word32Ror());
node->ReplaceInput(0, mright.left().node());
node->ReplaceInput(1, mright.right().node());
return Changed(node);
@@ -100,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());
+ node->set_op(machine()->Word32Ror());
node->ReplaceInput(0, mright.left().node());
node->ReplaceInput(1, mright.right().node());
return Changed(node);
@@ -193,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());
+ node->set_op(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());
+ node->set_op(machine()->Word32Shl());
node->ReplaceInput(1,
Int32Constant(WhichPowerOf2(m.right().Value())));
return Changed(node);
}
@@ -217,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());
+ node->set_op(machine()->Int32Sub());
node->ReplaceInput(0, Int32Constant(0));
node->ReplaceInput(1, m.left().node());
return Changed(node);
@@ -234,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());
+ node->set_op(machine()->Word32Shr());
node->ReplaceInput(1,
Int32Constant(WhichPowerOf2(m.right().Value())));
return Changed(node);
}
@@ -263,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());
+ node->set_op(machine()->Word32And());
node->ReplaceInput(1, Int32Constant(m.right().Value() - 1));
return Changed(node);
}
Index: src/compiler/simplified-operator-reducer.cc
diff --git a/src/compiler/simplified-operator-reducer.cc
b/src/compiler/simplified-operator-reducer.cc
index
ac6153e25086e5fe1863f36ec3f703260a43a5b9..f05c345cefe2cf7baf822703ad51bccdf8f1f6e0
100644
--- a/src/compiler/simplified-operator-reducer.cc
+++ b/src/compiler/simplified-operator-reducer.cc
@@ -99,7 +99,7 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) {
Reduction SimplifiedOperatorReducer::Change(Node* node, Operator* op,
Node* a) {
- graph()->ChangeOperator(node, op);
+ node->set_op(op);
node->ReplaceInput(0, a);
return Changed(node);
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.