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

Unified Diff: src/compiler/graph.cc

Issue 838783002: [turbofan] Cleanup Graph and related classes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Parameter pack causes compile errors. Created 5 years, 11 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/graph.h ('k') | src/compiler/graph-builder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/graph.cc
diff --git a/src/compiler/graph.cc b/src/compiler/graph.cc
index 995046b74e46e72a4cb1e6811c4cc3f75c55f403..1650bdfdd76a57d1c17e6546518701438f0f1d36 100644
--- a/src/compiler/graph.cc
+++ b/src/compiler/graph.cc
@@ -4,14 +4,10 @@
#include "src/compiler/graph.h"
-#include "src/compiler/common-operator.h"
-#include "src/compiler/graph-inl.h"
+#include <algorithm>
+
+#include "src/base/bits.h"
#include "src/compiler/node.h"
-#include "src/compiler/node-aux-data-inl.h"
-#include "src/compiler/node-properties.h"
-#include "src/compiler/node-properties-inl.h"
-#include "src/compiler/opcodes.h"
-#include "src/compiler/operator-properties.h"
namespace v8 {
namespace internal {
@@ -19,30 +15,44 @@ namespace compiler {
Graph::Graph(Zone* zone)
: zone_(zone),
- start_(NULL),
- end_(NULL),
+ start_(nullptr),
+ end_(nullptr),
mark_max_(0),
next_node_id_(0),
decorators_(zone) {}
void Graph::Decorate(Node* node) {
- for (ZoneVector<GraphDecorator*>::iterator i = decorators_.begin();
- i != decorators_.end(); ++i) {
- (*i)->Decorate(node);
- }
+ for (auto const decorator : decorators_) decorator->Decorate(node);
+}
+
+
+void Graph::AddDecorator(GraphDecorator* decorator) {
+ decorators_.push_back(decorator);
+}
+
+
+void Graph::RemoveDecorator(GraphDecorator* decorator) {
+ auto const it = std::find(decorators_.begin(), decorators_.end(), decorator);
+ DCHECK(it != decorators_.end());
+ decorators_.erase(it);
}
Node* Graph::NewNode(const Operator* op, int input_count, Node** inputs,
bool incomplete) {
DCHECK_LE(op->ValueInputCount(), input_count);
- Node* result = Node::New(this, input_count, inputs, incomplete);
- result->Initialize(op);
- if (!incomplete) {
- Decorate(result);
- }
- return result;
+ Node* const node =
+ Node::New(zone(), NextNodeId(), op, input_count, inputs, incomplete);
+ if (!incomplete) Decorate(node);
+ return node;
+}
+
+
+NodeId Graph::NextNodeId() {
+ NodeId const id = next_node_id_;
+ CHECK(!base::bits::SignedAddOverflow32(id, 1, &next_node_id_));
+ return id;
}
} // namespace compiler
« no previous file with comments | « src/compiler/graph.h ('k') | src/compiler/graph-builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698