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

Unified Diff: src/compiler/generic-node-inl.h

Issue 644083003: [turbofan] Reduce memory consumption of graph building (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add missing arraysize Created 6 years, 2 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
Index: src/compiler/generic-node-inl.h
diff --git a/src/compiler/generic-node-inl.h b/src/compiler/generic-node-inl.h
index 76313af514b644a0a96a44419317ee9034f7d3bc..30f8f680938125e19b5dcd7d1fd95732a4000cf9 100644
--- a/src/compiler/generic-node-inl.h
+++ b/src/compiler/generic-node-inl.h
@@ -16,13 +16,16 @@ namespace internal {
namespace compiler {
template <class B, class S>
-GenericNode<B, S>::GenericNode(GenericGraphBase* graph, int input_count)
+GenericNode<B, S>::GenericNode(GenericGraphBase* graph, int input_count,
+ int reserve_input_count)
: BaseClass(graph->zone()),
input_count_(input_count),
+ reserve_input_count_(reserve_input_count),
has_appendable_inputs_(false),
use_count_(0),
first_use_(NULL),
last_use_(NULL) {
+ DCHECK(reserve_input_count <= kMaxReservedInputs);
inputs_.static_ = reinterpret_cast<Input*>(this + 1);
AssignUniqueID(graph);
}
@@ -154,12 +157,18 @@ void GenericNode<B, S>::EnsureAppendableInputs(Zone* zone) {
template <class B, class S>
void GenericNode<B, S>::AppendInput(Zone* zone, GenericNode<B, S>* to_append) {
- EnsureAppendableInputs(zone);
Use* new_use = new (zone) Use;
Input new_input;
new_input.to = to_append;
new_input.use = new_use;
- inputs_.appendable_->push_back(new_input);
+ if (reserve_input_count_ > 0) {
+ DCHECK(!has_appendable_inputs_);
+ reserve_input_count_--;
+ inputs_.static_[input_count_] = new_input;
+ } else {
+ EnsureAppendableInputs(zone);
+ inputs_.appendable_->push_back(new_input);
+ }
new_use->input_index = input_count_;
new_use->from = this;
to_append->AppendUse(new_use);
@@ -224,15 +233,17 @@ inline bool GenericNode<B, S>::OwnedBy(GenericNode* owner) const {
}
template <class B, class S>
-S* GenericNode<B, S>::New(GenericGraphBase* graph, int input_count,
- S** inputs) {
+S* GenericNode<B, S>::New(GenericGraphBase* graph, int input_count, S** inputs,
+ bool has_extensible_inputs) {
size_t node_size = sizeof(GenericNode);
- size_t inputs_size = input_count * sizeof(Input);
+ size_t reserve_input_count =
+ has_extensible_inputs ? kDefaultReservedInputs : 0;
+ size_t inputs_size = (input_count + reserve_input_count) * sizeof(Input);
size_t uses_size = input_count * sizeof(Use);
int size = static_cast<int>(node_size + inputs_size + uses_size);
Zone* zone = graph->zone();
void* buffer = zone->New(size);
- S* result = new (buffer) S(graph, input_count);
+ S* result = new (buffer) S(graph, input_count, reserve_input_count);
Input* input =
reinterpret_cast<Input*>(reinterpret_cast<char*>(buffer) + node_size);
Use* use =
« no previous file with comments | « src/compiler/generic-node.h ('k') | src/compiler/graph.cc » ('j') | src/compiler/graph.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698