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

Side by Side 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, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_COMPILER_GENERIC_NODE_INL_H_ 5 #ifndef V8_COMPILER_GENERIC_NODE_INL_H_
6 #define V8_COMPILER_GENERIC_NODE_INL_H_ 6 #define V8_COMPILER_GENERIC_NODE_INL_H_
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/compiler/generic-graph.h" 10 #include "src/compiler/generic-graph.h"
11 #include "src/compiler/generic-node.h" 11 #include "src/compiler/generic-node.h"
12 #include "src/zone.h" 12 #include "src/zone.h"
13 13
14 namespace v8 { 14 namespace v8 {
15 namespace internal { 15 namespace internal {
16 namespace compiler { 16 namespace compiler {
17 17
18 template <class B, class S> 18 template <class B, class S>
19 GenericNode<B, S>::GenericNode(GenericGraphBase* graph, int input_count) 19 GenericNode<B, S>::GenericNode(GenericGraphBase* graph, int input_count,
20 int reserve_input_count)
20 : BaseClass(graph->zone()), 21 : BaseClass(graph->zone()),
21 input_count_(input_count), 22 input_count_(input_count),
23 reserve_input_count_(reserve_input_count),
22 has_appendable_inputs_(false), 24 has_appendable_inputs_(false),
23 use_count_(0), 25 use_count_(0),
24 first_use_(NULL), 26 first_use_(NULL),
25 last_use_(NULL) { 27 last_use_(NULL) {
28 DCHECK(reserve_input_count <= kMaxReservedInputs);
26 inputs_.static_ = reinterpret_cast<Input*>(this + 1); 29 inputs_.static_ = reinterpret_cast<Input*>(this + 1);
27 AssignUniqueID(graph); 30 AssignUniqueID(graph);
28 } 31 }
29 32
30 template <class B, class S> 33 template <class B, class S>
31 inline void GenericNode<B, S>::AssignUniqueID(GenericGraphBase* graph) { 34 inline void GenericNode<B, S>::AssignUniqueID(GenericGraphBase* graph) {
32 id_ = graph->NextNodeID(); 35 id_ = graph->NextNodeID();
33 } 36 }
34 37
35 template <class B, class S> 38 template <class B, class S>
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 for (int i = 0; i < input_count_; ++i) { 150 for (int i = 0; i < input_count_; ++i) {
148 deque->push_back(inputs_.static_[i]); 151 deque->push_back(inputs_.static_[i]);
149 } 152 }
150 inputs_.appendable_ = deque; 153 inputs_.appendable_ = deque;
151 has_appendable_inputs_ = true; 154 has_appendable_inputs_ = true;
152 } 155 }
153 } 156 }
154 157
155 template <class B, class S> 158 template <class B, class S>
156 void GenericNode<B, S>::AppendInput(Zone* zone, GenericNode<B, S>* to_append) { 159 void GenericNode<B, S>::AppendInput(Zone* zone, GenericNode<B, S>* to_append) {
157 EnsureAppendableInputs(zone);
158 Use* new_use = new (zone) Use; 160 Use* new_use = new (zone) Use;
159 Input new_input; 161 Input new_input;
160 new_input.to = to_append; 162 new_input.to = to_append;
161 new_input.use = new_use; 163 new_input.use = new_use;
162 inputs_.appendable_->push_back(new_input); 164 if (reserve_input_count_ > 0) {
165 DCHECK(!has_appendable_inputs_);
166 reserve_input_count_--;
167 inputs_.static_[input_count_] = new_input;
168 } else {
169 EnsureAppendableInputs(zone);
170 inputs_.appendable_->push_back(new_input);
171 }
163 new_use->input_index = input_count_; 172 new_use->input_index = input_count_;
164 new_use->from = this; 173 new_use->from = this;
165 to_append->AppendUse(new_use); 174 to_append->AppendUse(new_use);
166 input_count_++; 175 input_count_++;
167 } 176 }
168 177
169 template <class B, class S> 178 template <class B, class S>
170 void GenericNode<B, S>::InsertInput(Zone* zone, int index, 179 void GenericNode<B, S>::InsertInput(Zone* zone, int index,
171 GenericNode<B, S>* to_insert) { 180 GenericNode<B, S>* to_insert) {
172 DCHECK(index >= 0 && index < InputCount()); 181 DCHECK(index >= 0 && index < InputCount());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 --use_count_; 226 --use_count_;
218 } 227 }
219 228
220 template <class B, class S> 229 template <class B, class S>
221 inline bool GenericNode<B, S>::OwnedBy(GenericNode* owner) const { 230 inline bool GenericNode<B, S>::OwnedBy(GenericNode* owner) const {
222 return first_use_ != NULL && first_use_->from == owner && 231 return first_use_ != NULL && first_use_->from == owner &&
223 first_use_->next == NULL; 232 first_use_->next == NULL;
224 } 233 }
225 234
226 template <class B, class S> 235 template <class B, class S>
227 S* GenericNode<B, S>::New(GenericGraphBase* graph, int input_count, 236 S* GenericNode<B, S>::New(GenericGraphBase* graph, int input_count, S** inputs,
228 S** inputs) { 237 bool has_extensible_inputs) {
229 size_t node_size = sizeof(GenericNode); 238 size_t node_size = sizeof(GenericNode);
230 size_t inputs_size = input_count * sizeof(Input); 239 size_t reserve_input_count =
240 has_extensible_inputs ? kDefaultReservedInputs : 0;
241 size_t inputs_size = (input_count + reserve_input_count) * sizeof(Input);
231 size_t uses_size = input_count * sizeof(Use); 242 size_t uses_size = input_count * sizeof(Use);
232 int size = static_cast<int>(node_size + inputs_size + uses_size); 243 int size = static_cast<int>(node_size + inputs_size + uses_size);
233 Zone* zone = graph->zone(); 244 Zone* zone = graph->zone();
234 void* buffer = zone->New(size); 245 void* buffer = zone->New(size);
235 S* result = new (buffer) S(graph, input_count); 246 S* result = new (buffer) S(graph, input_count, reserve_input_count);
236 Input* input = 247 Input* input =
237 reinterpret_cast<Input*>(reinterpret_cast<char*>(buffer) + node_size); 248 reinterpret_cast<Input*>(reinterpret_cast<char*>(buffer) + node_size);
238 Use* use = 249 Use* use =
239 reinterpret_cast<Use*>(reinterpret_cast<char*>(input) + inputs_size); 250 reinterpret_cast<Use*>(reinterpret_cast<char*>(input) + inputs_size);
240 251
241 for (int current = 0; current < input_count; ++current) { 252 for (int current = 0; current < input_count; ++current) {
242 GenericNode* to = *inputs++; 253 GenericNode* to = *inputs++;
243 input->to = to; 254 input->to = to;
244 input->use = use; 255 input->use = use;
245 use->input_index = current; 256 use->input_index = current;
246 use->from = result; 257 use->from = result;
247 to->AppendUse(use); 258 to->AppendUse(use);
248 ++use; 259 ++use;
249 ++input; 260 ++input;
250 } 261 }
251 return result; 262 return result;
252 } 263 }
253 } 264 }
254 } 265 }
255 } // namespace v8::internal::compiler 266 } // namespace v8::internal::compiler
256 267
257 #endif // V8_COMPILER_GENERIC_NODE_INL_H_ 268 #endif // V8_COMPILER_GENERIC_NODE_INL_H_
OLDNEW
« 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