Upgrade V8 to version 4.9.385.28
https://chromium.googlesource.com/v8/v8/+/4.9.385.28
FPIIM-449
Change-Id: I4b2e74289d4bf3667f2f3dc8aa2e541f63e26eb4
diff --git a/src/compiler/graph-reducer.h b/src/compiler/graph-reducer.h
index 09a650c..683c345 100644
--- a/src/compiler/graph-reducer.h
+++ b/src/compiler/graph-reducer.h
@@ -5,20 +5,30 @@
#ifndef V8_COMPILER_GRAPH_REDUCER_H_
#define V8_COMPILER_GRAPH_REDUCER_H_
-#include "src/compiler/graph.h"
+#include "src/compiler/node-marker.h"
#include "src/zone-containers.h"
namespace v8 {
namespace internal {
namespace compiler {
+// Forward declarations.
+class Graph;
+class Node;
+
+
+// NodeIds are identifying numbers for nodes that can be used to index auxiliary
+// out-of-line data associated with each node.
+typedef uint32_t NodeId;
+
+
// Represents the result of trying to reduce a node in the graph.
-class Reduction FINAL {
+class Reduction final {
public:
- explicit Reduction(Node* replacement = NULL) : replacement_(replacement) {}
+ explicit Reduction(Node* replacement = nullptr) : replacement_(replacement) {}
Node* replacement() const { return replacement_; }
- bool Changed() const { return replacement() != NULL; }
+ bool Changed() const { return replacement() != nullptr; }
private:
Node* replacement_;
@@ -32,26 +42,88 @@
// phase.
class Reducer {
public:
- Reducer() {}
virtual ~Reducer() {}
// Try to reduce a node if possible.
virtual Reduction Reduce(Node* node) = 0;
+ // Invoked by the {GraphReducer} when all nodes are done. Can be used to
+ // do additional reductions at the end, which in turn can cause a new round
+ // of reductions.
+ virtual void Finalize();
+
// Helper functions for subclasses to produce reductions for a node.
static Reduction NoChange() { return Reduction(); }
static Reduction Replace(Node* node) { return Reduction(node); }
static Reduction Changed(Node* node) { return Reduction(node); }
+};
+
+
+// An advanced reducer can also edit the graphs by changing and replacing nodes
+// other than the one currently being reduced.
+class AdvancedReducer : public Reducer {
+ public:
+ // Observe the actions of this reducer.
+ class Editor {
+ public:
+ virtual ~Editor() {}
+
+ // Replace {node} with {replacement}.
+ virtual void Replace(Node* node, Node* replacement) = 0;
+ // Revisit the {node} again later.
+ virtual void Revisit(Node* node) = 0;
+ // Replace value uses of {node} with {value} and effect uses of {node} with
+ // {effect}. If {effect == nullptr}, then use the effect input to {node}.
+ // All
+ // control uses will be relaxed assuming {node} cannot throw.
+ virtual void ReplaceWithValue(Node* node, Node* value, Node* effect,
+ Node* control) = 0;
+ };
+
+ explicit AdvancedReducer(Editor* editor) : editor_(editor) {}
+
+ protected:
+ // Helper functions for subclasses to produce reductions for a node.
+ static Reduction Replace(Node* node) { return Reducer::Replace(node); }
+
+ // Helper functions for subclasses to edit the graph.
+ void Replace(Node* node, Node* replacement) {
+ DCHECK_NOT_NULL(editor_);
+ editor_->Replace(node, replacement);
+ }
+ void Revisit(Node* node) {
+ DCHECK_NOT_NULL(editor_);
+ editor_->Revisit(node);
+ }
+ void ReplaceWithValue(Node* node, Node* value, Node* effect = nullptr,
+ Node* control = nullptr) {
+ DCHECK_NOT_NULL(editor_);
+ editor_->ReplaceWithValue(node, value, effect, control);
+ }
+
+ // Relax the effects of {node} by immediately replacing effect and control
+ // uses of {node} with the effect and control input to {node}.
+ // TODO(turbofan): replace the effect input to {node} with {graph->start()}.
+ void RelaxEffectsAndControls(Node* node) {
+ ReplaceWithValue(node, node, nullptr, nullptr);
+ }
+
+ // Relax the control uses of {node} by immediately replacing them with the
+ // control input to {node}.
+ void RelaxControls(Node* node) {
+ ReplaceWithValue(node, node, node, nullptr);
+ }
private:
- DISALLOW_COPY_AND_ASSIGN(Reducer);
+ Editor* const editor_;
};
// Performs an iterative reduction of a node graph.
-class GraphReducer FINAL {
+class GraphReducer : public AdvancedReducer::Editor {
public:
- GraphReducer(Graph* graph, Zone* zone);
+ GraphReducer(Zone* zone, Graph* graph, Node* dead = nullptr);
+ ~GraphReducer();
Graph* graph() const { return graph_; }
@@ -74,15 +146,30 @@
// Reduce the node on top of the stack.
void ReduceTop();
+ // Replace {node} with {replacement}.
+ void Replace(Node* node, Node* replacement) final;
+
+ // Replace value uses of {node} with {value} and effect uses of {node} with
+ // {effect}. If {effect == nullptr}, then use the effect input to {node}. All
+ // control uses will be relaxed assuming {node} cannot throw.
+ void ReplaceWithValue(Node* node, Node* value, Node* effect,
+ Node* control) final;
+
+ // Replace all uses of {node} with {replacement} if the id of {replacement} is
+ // less than or equal to {max_id}. Otherwise, replace all uses of {node} whose
+ // id is less than or equal to {max_id} with the {replacement}.
+ void Replace(Node* node, Node* replacement, NodeId max_id);
+
// Node stack operations.
void Pop();
void Push(Node* node);
// Revisit queue operations.
bool Recurse(Node* node);
- void Revisit(Node* node);
+ void Revisit(Node* node) final;
- Graph* graph_;
+ Graph* const graph_;
+ Node* const dead_;
NodeMarker<State> state_;
ZoneVector<Reducer*> reducers_;
ZoneStack<Node*> revisit_;