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

Side by Side Diff: src/ast-numbering.cc

Issue 660083005: AstNumberingVisitor does the work of AstConstructionVisitor (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ast-numbering.h ('k') | src/compiler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/ast.h" 7 #include "src/ast.h"
8 #include "src/ast-numbering.h" 8 #include "src/ast-numbering.h"
9 #include "src/compiler.h" 9 #include "src/compiler.h"
10 #include "src/scopes.h" 10 #include "src/scopes.h"
11 11
12 namespace v8 { 12 namespace v8 {
13 namespace internal { 13 namespace internal {
14 14
15 15
16 class AstNumberingVisitor FINAL : public AstVisitor { 16 class AstNumberingVisitor FINAL : public AstVisitor {
17 public: 17 public:
18 explicit AstNumberingVisitor(Zone* zone) 18 explicit AstNumberingVisitor(Zone* zone)
19 : AstVisitor(), next_id_(BailoutId::FirstUsable().ToInt()) { 19 : AstVisitor(),
20 next_id_(BailoutId::FirstUsable().ToInt()),
21 dont_crankshaft_reason_(kNoReason),
22 dont_turbofan_reason_(kNoReason) {
20 InitializeAstVisitor(zone); 23 InitializeAstVisitor(zone);
21 } 24 }
22 25
23 void Renumber(FunctionLiteral* node); 26 void Renumber(FunctionLiteral* node);
24 27
25 private: 28 private:
26 // AST node visitor interface. 29 // AST node visitor interface.
27 #define DEFINE_VISIT(type) virtual void Visit##type(type* node); 30 #define DEFINE_VISIT(type) virtual void Visit##type(type* node);
28 AST_NODE_LIST(DEFINE_VISIT) 31 AST_NODE_LIST(DEFINE_VISIT)
29 #undef DEFINE_VISIT 32 #undef DEFINE_VISIT
30 33
31 void VisitStatements(ZoneList<Statement*>* statements); 34 void VisitStatements(ZoneList<Statement*>* statements);
32 void VisitDeclarations(ZoneList<Declaration*>* declarations); 35 void VisitDeclarations(ZoneList<Declaration*>* declarations);
33 void VisitArguments(ZoneList<Expression*>* arguments); 36 void VisitArguments(ZoneList<Expression*>* arguments);
34 void VisitObjectLiteralProperty(ObjectLiteralProperty* property); 37 void VisitObjectLiteralProperty(ObjectLiteralProperty* property);
35 38
36 int ReserveIdRange(int n) { 39 int ReserveIdRange(int n) {
37 int tmp = next_id_; 40 int tmp = next_id_;
38 next_id_ += n; 41 next_id_ += n;
39 return tmp; 42 return tmp;
40 } 43 }
41 44
45 template <typename Node>
46 void AddSlotNode(Node* node) {
47 FeedbackVectorRequirements reqs = node->ComputeFeedbackRequirements();
48 if (reqs.slots() > 0) {
49 node->SetFirstFeedbackSlot(
50 FeedbackVectorSlot(properties_.feedback_slots()));
51 properties_.increase_feedback_slots(reqs.slots());
52 }
53 if (reqs.ic_slots() > 0) {
54 node->SetFirstFeedbackICSlot(
55 FeedbackVectorICSlot(properties_.ic_feedback_slots()));
56 properties_.increase_ic_feedback_slots(reqs.ic_slots());
57 }
58 }
59
60 void RegularNode() { properties_.add_node_count(1); }
61 template <typename Node>
62 void RegularNodeWithFeedbackSlots(Node* node) {
63 properties_.add_node_count(1);
64 AddSlotNode(node);
65 }
66 void DontOptimizeNode(BailoutReason reason) {
67 properties_.add_node_count(1);
68 dont_crankshaft_reason_ = reason;
69 properties_.flags()->Add(kDontSelfOptimize);
70 }
71 template <typename Node>
72 void DontOptimizeNodeWithFeedbackSlots(Node* node, BailoutReason reason) {
73 properties_.add_node_count(1);
74 AddSlotNode(node);
75 dont_crankshaft_reason_ = reason;
76 properties_.flags()->Add(kDontSelfOptimize);
77 }
78 // TODO(turbofan): Remove the dont_turbofan_reason once no nodes are
79 // DontTurbofanNode. That set of nodes must be kept in sync with
80 // Pipeline::GenerateCode.
81 void DontTurbofanNode(BailoutReason reason) {
82 properties_.add_node_count(1);
83 dont_crankshaft_reason_ = reason;
84 dont_turbofan_reason_ = reason;
85 properties_.flags()->Add(kDontSelfOptimize);
86 }
87 template <typename Node>
88 void DontTurbofanNodeWithFeedbackSlots(Node* node, BailoutReason reason) {
89 properties_.add_node_count(1);
90 AddSlotNode(node);
91 dont_crankshaft_reason_ = reason;
92 dont_turbofan_reason_ = reason;
93 properties_.flags()->Add(kDontSelfOptimize);
94 }
95 void DontSelfOptimizeNode() {
96 properties_.add_node_count(1);
97 properties_.flags()->Add(kDontSelfOptimize);
98 }
99 template <typename Node>
100 void DontSelfOptimizeNodeWithFeedbackSlots(Node* node) {
101 properties_.add_node_count(1);
102 AddSlotNode(node);
103 properties_.flags()->Add(kDontSelfOptimize);
104 }
105 void DontCacheNode(BailoutReason reason) {
106 properties_.add_node_count(1);
107 dont_crankshaft_reason_ = reason;
108 properties_.flags()->Add(kDontSelfOptimize);
109 properties_.flags()->Add(kDontCache);
110 }
111
42 int next_id_; 112 int next_id_;
113 AstProperties properties_;
114 BailoutReason dont_crankshaft_reason_;
115 BailoutReason dont_turbofan_reason_;
43 116
44 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); 117 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
45 DISALLOW_COPY_AND_ASSIGN(AstNumberingVisitor); 118 DISALLOW_COPY_AND_ASSIGN(AstNumberingVisitor);
46 }; 119 };
47 120
48 121
49 void AstNumberingVisitor::VisitVariableDeclaration(VariableDeclaration* node) { 122 void AstNumberingVisitor::VisitVariableDeclaration(VariableDeclaration* node) {
123 RegularNode();
50 VisitVariableProxy(node->proxy()); 124 VisitVariableProxy(node->proxy());
51 } 125 }
52 126
53 127
54 void AstNumberingVisitor::VisitExportDeclaration(ExportDeclaration* node) { 128 void AstNumberingVisitor::VisitExportDeclaration(ExportDeclaration* node) {
129 DontOptimizeNode(kExportDeclaration);
55 VisitVariableProxy(node->proxy()); 130 VisitVariableProxy(node->proxy());
56 } 131 }
57 132
58 133
59 void AstNumberingVisitor::VisitModuleUrl(ModuleUrl* node) {} 134 void AstNumberingVisitor::VisitModuleUrl(ModuleUrl* node) {
135 DontOptimizeNode(kModuleUrl);
136 }
60 137
61 138
62 void AstNumberingVisitor::VisitEmptyStatement(EmptyStatement* node) {} 139 void AstNumberingVisitor::VisitEmptyStatement(EmptyStatement* node) {
140 RegularNode();
141 }
63 142
64 143
65 void AstNumberingVisitor::VisitContinueStatement(ContinueStatement* node) {} 144 void AstNumberingVisitor::VisitContinueStatement(ContinueStatement* node) {
145 RegularNode();
146 }
66 147
67 148
68 void AstNumberingVisitor::VisitBreakStatement(BreakStatement* node) {} 149 void AstNumberingVisitor::VisitBreakStatement(BreakStatement* node) {
150 RegularNode();
151 }
69 152
70 153
71 void AstNumberingVisitor::VisitDebuggerStatement(DebuggerStatement* node) { 154 void AstNumberingVisitor::VisitDebuggerStatement(DebuggerStatement* node) {
155 DontOptimizeNode(kDebuggerStatement);
72 node->set_base_id(ReserveIdRange(DebuggerStatement::num_ids())); 156 node->set_base_id(ReserveIdRange(DebuggerStatement::num_ids()));
73 } 157 }
74 158
75 159
76 void AstNumberingVisitor::VisitNativeFunctionLiteral( 160 void AstNumberingVisitor::VisitNativeFunctionLiteral(
77 NativeFunctionLiteral* node) { 161 NativeFunctionLiteral* node) {
162 DontOptimizeNode(kNativeFunctionLiteral);
78 node->set_base_id(ReserveIdRange(NativeFunctionLiteral::num_ids())); 163 node->set_base_id(ReserveIdRange(NativeFunctionLiteral::num_ids()));
79 } 164 }
80 165
81 166
82 void AstNumberingVisitor::VisitLiteral(Literal* node) { 167 void AstNumberingVisitor::VisitLiteral(Literal* node) {
168 RegularNode();
83 node->set_base_id(ReserveIdRange(Literal::num_ids())); 169 node->set_base_id(ReserveIdRange(Literal::num_ids()));
84 } 170 }
85 171
86 172
87 void AstNumberingVisitor::VisitRegExpLiteral(RegExpLiteral* node) { 173 void AstNumberingVisitor::VisitRegExpLiteral(RegExpLiteral* node) {
174 RegularNode();
88 node->set_base_id(ReserveIdRange(RegExpLiteral::num_ids())); 175 node->set_base_id(ReserveIdRange(RegExpLiteral::num_ids()));
89 } 176 }
90 177
91 178
179 // In theory, for VariableProxy we'd have to add:
180 // if (node->var()->IsLookupSlot())
181 // set_dont_optimize_reason(kReferenceToAVariableWhichRequiresDynamicLookup);
182 // But node->var() is usually not bound yet at VariableProxy creation time, and
183 // LOOKUP variables only result from constructs that cannot be inlined anyway.
92 void AstNumberingVisitor::VisitVariableProxy(VariableProxy* node) { 184 void AstNumberingVisitor::VisitVariableProxy(VariableProxy* node) {
185 RegularNodeWithFeedbackSlots(node);
93 node->set_base_id(ReserveIdRange(VariableProxy::num_ids())); 186 node->set_base_id(ReserveIdRange(VariableProxy::num_ids()));
94 } 187 }
95 188
96 189
97 void AstNumberingVisitor::VisitThisFunction(ThisFunction* node) { 190 void AstNumberingVisitor::VisitThisFunction(ThisFunction* node) {
191 RegularNode();
98 node->set_base_id(ReserveIdRange(ThisFunction::num_ids())); 192 node->set_base_id(ReserveIdRange(ThisFunction::num_ids()));
99 } 193 }
100 194
101 195
102 void AstNumberingVisitor::VisitSuperReference(SuperReference* node) { 196 void AstNumberingVisitor::VisitSuperReference(SuperReference* node) {
197 DontTurbofanNodeWithFeedbackSlots(node, kSuperReference);
103 node->set_base_id(ReserveIdRange(SuperReference::num_ids())); 198 node->set_base_id(ReserveIdRange(SuperReference::num_ids()));
104 Visit(node->this_var()); 199 Visit(node->this_var());
105 } 200 }
106 201
107 202
108 void AstNumberingVisitor::VisitModuleDeclaration(ModuleDeclaration* node) { 203 void AstNumberingVisitor::VisitModuleDeclaration(ModuleDeclaration* node) {
204 DontOptimizeNode(kModuleDeclaration);
109 VisitVariableProxy(node->proxy()); 205 VisitVariableProxy(node->proxy());
110 Visit(node->module()); 206 Visit(node->module());
111 } 207 }
112 208
113 209
114 void AstNumberingVisitor::VisitImportDeclaration(ImportDeclaration* node) { 210 void AstNumberingVisitor::VisitImportDeclaration(ImportDeclaration* node) {
211 DontOptimizeNode(kImportDeclaration);
115 VisitVariableProxy(node->proxy()); 212 VisitVariableProxy(node->proxy());
116 Visit(node->module()); 213 Visit(node->module());
117 } 214 }
118 215
119 216
120 void AstNumberingVisitor::VisitModuleVariable(ModuleVariable* node) { 217 void AstNumberingVisitor::VisitModuleVariable(ModuleVariable* node) {
218 DontOptimizeNode(kModuleVariable);
121 Visit(node->proxy()); 219 Visit(node->proxy());
122 } 220 }
123 221
124 222
125 void AstNumberingVisitor::VisitModulePath(ModulePath* node) { 223 void AstNumberingVisitor::VisitModulePath(ModulePath* node) {
224 DontOptimizeNode(kModulePath);
126 Visit(node->module()); 225 Visit(node->module());
127 } 226 }
128 227
129 228
130 void AstNumberingVisitor::VisitModuleStatement(ModuleStatement* node) { 229 void AstNumberingVisitor::VisitModuleStatement(ModuleStatement* node) {
230 DontOptimizeNode(kModuleStatement);
131 Visit(node->body()); 231 Visit(node->body());
132 } 232 }
133 233
134 234
135 void AstNumberingVisitor::VisitExpressionStatement(ExpressionStatement* node) { 235 void AstNumberingVisitor::VisitExpressionStatement(ExpressionStatement* node) {
236 RegularNode();
136 Visit(node->expression()); 237 Visit(node->expression());
137 } 238 }
138 239
139 240
140 void AstNumberingVisitor::VisitReturnStatement(ReturnStatement* node) { 241 void AstNumberingVisitor::VisitReturnStatement(ReturnStatement* node) {
242 RegularNode();
141 Visit(node->expression()); 243 Visit(node->expression());
142 } 244 }
143 245
144 246
145 void AstNumberingVisitor::VisitYield(Yield* node) { 247 void AstNumberingVisitor::VisitYield(Yield* node) {
248 DontOptimizeNodeWithFeedbackSlots(node, kYield);
146 node->set_base_id(ReserveIdRange(Yield::num_ids())); 249 node->set_base_id(ReserveIdRange(Yield::num_ids()));
147 Visit(node->generator_object()); 250 Visit(node->generator_object());
148 Visit(node->expression()); 251 Visit(node->expression());
149 } 252 }
150 253
151 254
152 void AstNumberingVisitor::VisitThrow(Throw* node) { 255 void AstNumberingVisitor::VisitThrow(Throw* node) {
256 RegularNode();
153 node->set_base_id(ReserveIdRange(Throw::num_ids())); 257 node->set_base_id(ReserveIdRange(Throw::num_ids()));
154 Visit(node->exception()); 258 Visit(node->exception());
155 } 259 }
156 260
157 261
158 void AstNumberingVisitor::VisitUnaryOperation(UnaryOperation* node) { 262 void AstNumberingVisitor::VisitUnaryOperation(UnaryOperation* node) {
263 RegularNode();
159 node->set_base_id(ReserveIdRange(UnaryOperation::num_ids())); 264 node->set_base_id(ReserveIdRange(UnaryOperation::num_ids()));
160 Visit(node->expression()); 265 Visit(node->expression());
161 } 266 }
162 267
163 268
164 void AstNumberingVisitor::VisitCountOperation(CountOperation* node) { 269 void AstNumberingVisitor::VisitCountOperation(CountOperation* node) {
270 RegularNode();
165 node->set_base_id(ReserveIdRange(CountOperation::num_ids())); 271 node->set_base_id(ReserveIdRange(CountOperation::num_ids()));
166 Visit(node->expression()); 272 Visit(node->expression());
167 } 273 }
168 274
169 275
170 void AstNumberingVisitor::VisitBlock(Block* node) { 276 void AstNumberingVisitor::VisitBlock(Block* node) {
277 RegularNode();
171 node->set_base_id(ReserveIdRange(Block::num_ids())); 278 node->set_base_id(ReserveIdRange(Block::num_ids()));
172 if (node->scope() != NULL) VisitDeclarations(node->scope()->declarations()); 279 if (node->scope() != NULL) VisitDeclarations(node->scope()->declarations());
173 VisitStatements(node->statements()); 280 VisitStatements(node->statements());
174 } 281 }
175 282
176 283
177 void AstNumberingVisitor::VisitFunctionDeclaration(FunctionDeclaration* node) { 284 void AstNumberingVisitor::VisitFunctionDeclaration(FunctionDeclaration* node) {
285 RegularNode();
178 VisitVariableProxy(node->proxy()); 286 VisitVariableProxy(node->proxy());
179 VisitFunctionLiteral(node->fun()); 287 VisitFunctionLiteral(node->fun());
180 } 288 }
181 289
182 290
183 void AstNumberingVisitor::VisitModuleLiteral(ModuleLiteral* node) { 291 void AstNumberingVisitor::VisitModuleLiteral(ModuleLiteral* node) {
292 DontCacheNode(kModuleLiteral);
184 VisitBlock(node->body()); 293 VisitBlock(node->body());
185 } 294 }
186 295
187 296
188 void AstNumberingVisitor::VisitCallRuntime(CallRuntime* node) { 297 void AstNumberingVisitor::VisitCallRuntime(CallRuntime* node) {
298 RegularNodeWithFeedbackSlots(node);
299 if (node->is_jsruntime()) {
300 // Don't try to optimize JS runtime calls because we bailout on them.
301 dont_crankshaft_reason_ = kCallToAJavaScriptRuntimeFunction;
302 }
189 node->set_base_id(ReserveIdRange(CallRuntime::num_ids())); 303 node->set_base_id(ReserveIdRange(CallRuntime::num_ids()));
190 VisitArguments(node->arguments()); 304 VisitArguments(node->arguments());
191 } 305 }
192 306
193 307
194 void AstNumberingVisitor::VisitWithStatement(WithStatement* node) { 308 void AstNumberingVisitor::VisitWithStatement(WithStatement* node) {
309 DontOptimizeNode(kWithStatement);
195 Visit(node->expression()); 310 Visit(node->expression());
196 Visit(node->statement()); 311 Visit(node->statement());
197 } 312 }
198 313
199 314
200 void AstNumberingVisitor::VisitDoWhileStatement(DoWhileStatement* node) { 315 void AstNumberingVisitor::VisitDoWhileStatement(DoWhileStatement* node) {
316 DontSelfOptimizeNode();
201 node->set_base_id(ReserveIdRange(DoWhileStatement::num_ids())); 317 node->set_base_id(ReserveIdRange(DoWhileStatement::num_ids()));
202 Visit(node->body()); 318 Visit(node->body());
203 Visit(node->cond()); 319 Visit(node->cond());
204 } 320 }
205 321
206 322
207 void AstNumberingVisitor::VisitWhileStatement(WhileStatement* node) { 323 void AstNumberingVisitor::VisitWhileStatement(WhileStatement* node) {
324 DontSelfOptimizeNode();
208 node->set_base_id(ReserveIdRange(WhileStatement::num_ids())); 325 node->set_base_id(ReserveIdRange(WhileStatement::num_ids()));
209 Visit(node->cond()); 326 Visit(node->cond());
210 Visit(node->body()); 327 Visit(node->body());
211 } 328 }
212 329
213 330
214 void AstNumberingVisitor::VisitTryCatchStatement(TryCatchStatement* node) { 331 void AstNumberingVisitor::VisitTryCatchStatement(TryCatchStatement* node) {
332 DontTurbofanNode(kTryCatchStatement);
215 Visit(node->try_block()); 333 Visit(node->try_block());
216 Visit(node->catch_block()); 334 Visit(node->catch_block());
217 } 335 }
218 336
219 337
220 void AstNumberingVisitor::VisitTryFinallyStatement(TryFinallyStatement* node) { 338 void AstNumberingVisitor::VisitTryFinallyStatement(TryFinallyStatement* node) {
339 DontTurbofanNode(kTryFinallyStatement);
221 Visit(node->try_block()); 340 Visit(node->try_block());
222 Visit(node->finally_block()); 341 Visit(node->finally_block());
223 } 342 }
224 343
225 344
226 void AstNumberingVisitor::VisitProperty(Property* node) { 345 void AstNumberingVisitor::VisitProperty(Property* node) {
346 RegularNodeWithFeedbackSlots(node);
227 node->set_base_id(ReserveIdRange(Property::num_ids())); 347 node->set_base_id(ReserveIdRange(Property::num_ids()));
228 Visit(node->key()); 348 Visit(node->key());
229 Visit(node->obj()); 349 Visit(node->obj());
230 } 350 }
231 351
232 352
233 void AstNumberingVisitor::VisitAssignment(Assignment* node) { 353 void AstNumberingVisitor::VisitAssignment(Assignment* node) {
354 RegularNode();
234 node->set_base_id(ReserveIdRange(Assignment::num_ids())); 355 node->set_base_id(ReserveIdRange(Assignment::num_ids()));
235 if (node->is_compound()) VisitBinaryOperation(node->binary_operation()); 356 if (node->is_compound()) VisitBinaryOperation(node->binary_operation());
236 Visit(node->target()); 357 Visit(node->target());
237 Visit(node->value()); 358 Visit(node->value());
238 } 359 }
239 360
240 361
241 void AstNumberingVisitor::VisitBinaryOperation(BinaryOperation* node) { 362 void AstNumberingVisitor::VisitBinaryOperation(BinaryOperation* node) {
363 RegularNode();
242 node->set_base_id(ReserveIdRange(BinaryOperation::num_ids())); 364 node->set_base_id(ReserveIdRange(BinaryOperation::num_ids()));
243 Visit(node->left()); 365 Visit(node->left());
244 Visit(node->right()); 366 Visit(node->right());
245 } 367 }
246 368
247 369
248 void AstNumberingVisitor::VisitCompareOperation(CompareOperation* node) { 370 void AstNumberingVisitor::VisitCompareOperation(CompareOperation* node) {
371 RegularNode();
249 node->set_base_id(ReserveIdRange(CompareOperation::num_ids())); 372 node->set_base_id(ReserveIdRange(CompareOperation::num_ids()));
250 Visit(node->left()); 373 Visit(node->left());
251 Visit(node->right()); 374 Visit(node->right());
252 } 375 }
253 376
254 377
255 void AstNumberingVisitor::VisitForInStatement(ForInStatement* node) { 378 void AstNumberingVisitor::VisitForInStatement(ForInStatement* node) {
379 DontSelfOptimizeNodeWithFeedbackSlots(node);
256 node->set_base_id(ReserveIdRange(ForInStatement::num_ids())); 380 node->set_base_id(ReserveIdRange(ForInStatement::num_ids()));
257 Visit(node->each()); 381 Visit(node->each());
258 Visit(node->enumerable()); 382 Visit(node->enumerable());
259 Visit(node->body()); 383 Visit(node->body());
260 } 384 }
261 385
262 386
263 void AstNumberingVisitor::VisitForOfStatement(ForOfStatement* node) { 387 void AstNumberingVisitor::VisitForOfStatement(ForOfStatement* node) {
388 DontTurbofanNode(kForOfStatement);
264 node->set_base_id(ReserveIdRange(ForOfStatement::num_ids())); 389 node->set_base_id(ReserveIdRange(ForOfStatement::num_ids()));
265 Visit(node->assign_iterator()); 390 Visit(node->assign_iterator());
266 Visit(node->next_result()); 391 Visit(node->next_result());
267 Visit(node->result_done()); 392 Visit(node->result_done());
268 Visit(node->assign_each()); 393 Visit(node->assign_each());
269 Visit(node->body()); 394 Visit(node->body());
270 } 395 }
271 396
272 397
273 void AstNumberingVisitor::VisitConditional(Conditional* node) { 398 void AstNumberingVisitor::VisitConditional(Conditional* node) {
399 RegularNode();
274 node->set_base_id(ReserveIdRange(Conditional::num_ids())); 400 node->set_base_id(ReserveIdRange(Conditional::num_ids()));
275 Visit(node->condition()); 401 Visit(node->condition());
276 Visit(node->then_expression()); 402 Visit(node->then_expression());
277 Visit(node->else_expression()); 403 Visit(node->else_expression());
278 } 404 }
279 405
280 406
281 void AstNumberingVisitor::VisitIfStatement(IfStatement* node) { 407 void AstNumberingVisitor::VisitIfStatement(IfStatement* node) {
408 RegularNode();
282 node->set_base_id(ReserveIdRange(IfStatement::num_ids())); 409 node->set_base_id(ReserveIdRange(IfStatement::num_ids()));
283 Visit(node->condition()); 410 Visit(node->condition());
284 Visit(node->then_statement()); 411 Visit(node->then_statement());
285 if (node->HasElseStatement()) { 412 if (node->HasElseStatement()) {
286 Visit(node->else_statement()); 413 Visit(node->else_statement());
287 } 414 }
288 } 415 }
289 416
290 417
291 void AstNumberingVisitor::VisitSwitchStatement(SwitchStatement* node) { 418 void AstNumberingVisitor::VisitSwitchStatement(SwitchStatement* node) {
419 RegularNode();
292 node->set_base_id(ReserveIdRange(SwitchStatement::num_ids())); 420 node->set_base_id(ReserveIdRange(SwitchStatement::num_ids()));
293 Visit(node->tag()); 421 Visit(node->tag());
294 ZoneList<CaseClause*>* cases = node->cases(); 422 ZoneList<CaseClause*>* cases = node->cases();
295 for (int i = 0; i < cases->length(); i++) { 423 for (int i = 0; i < cases->length(); i++) {
296 VisitCaseClause(cases->at(i)); 424 VisitCaseClause(cases->at(i));
297 } 425 }
298 } 426 }
299 427
300 428
301 void AstNumberingVisitor::VisitCaseClause(CaseClause* node) { 429 void AstNumberingVisitor::VisitCaseClause(CaseClause* node) {
430 RegularNode();
302 node->set_base_id(ReserveIdRange(CaseClause::num_ids())); 431 node->set_base_id(ReserveIdRange(CaseClause::num_ids()));
303 if (!node->is_default()) Visit(node->label()); 432 if (!node->is_default()) Visit(node->label());
304 VisitStatements(node->statements()); 433 VisitStatements(node->statements());
305 } 434 }
306 435
307 436
308 void AstNumberingVisitor::VisitForStatement(ForStatement* node) { 437 void AstNumberingVisitor::VisitForStatement(ForStatement* node) {
438 DontSelfOptimizeNode();
309 node->set_base_id(ReserveIdRange(ForStatement::num_ids())); 439 node->set_base_id(ReserveIdRange(ForStatement::num_ids()));
310 if (node->init() != NULL) Visit(node->init()); 440 if (node->init() != NULL) Visit(node->init());
311 if (node->cond() != NULL) Visit(node->cond()); 441 if (node->cond() != NULL) Visit(node->cond());
312 if (node->next() != NULL) Visit(node->next()); 442 if (node->next() != NULL) Visit(node->next());
313 Visit(node->body()); 443 Visit(node->body());
314 } 444 }
315 445
316 446
317 void AstNumberingVisitor::VisitClassLiteral(ClassLiteral* node) { 447 void AstNumberingVisitor::VisitClassLiteral(ClassLiteral* node) {
448 DontTurbofanNode(kClassLiteral);
318 node->set_base_id(ReserveIdRange(ClassLiteral::num_ids())); 449 node->set_base_id(ReserveIdRange(ClassLiteral::num_ids()));
319 if (node->extends()) Visit(node->extends()); 450 if (node->extends()) Visit(node->extends());
320 if (node->constructor()) Visit(node->constructor()); 451 if (node->constructor()) Visit(node->constructor());
321 for (int i = 0; i < node->properties()->length(); i++) { 452 for (int i = 0; i < node->properties()->length(); i++) {
322 VisitObjectLiteralProperty(node->properties()->at(i)); 453 VisitObjectLiteralProperty(node->properties()->at(i));
323 } 454 }
324 } 455 }
325 456
326 457
327 void AstNumberingVisitor::VisitObjectLiteral(ObjectLiteral* node) { 458 void AstNumberingVisitor::VisitObjectLiteral(ObjectLiteral* node) {
459 RegularNode();
328 node->set_base_id(ReserveIdRange(ObjectLiteral::num_ids())); 460 node->set_base_id(ReserveIdRange(ObjectLiteral::num_ids()));
329 for (int i = 0; i < node->properties()->length(); i++) { 461 for (int i = 0; i < node->properties()->length(); i++) {
330 VisitObjectLiteralProperty(node->properties()->at(i)); 462 VisitObjectLiteralProperty(node->properties()->at(i));
331 } 463 }
332 } 464 }
333 465
334 466
335 void AstNumberingVisitor::VisitObjectLiteralProperty( 467 void AstNumberingVisitor::VisitObjectLiteralProperty(
336 ObjectLiteralProperty* node) { 468 ObjectLiteralProperty* node) {
337 Visit(node->key()); 469 Visit(node->key());
338 Visit(node->value()); 470 Visit(node->value());
339 } 471 }
340 472
341 473
342 void AstNumberingVisitor::VisitArrayLiteral(ArrayLiteral* node) { 474 void AstNumberingVisitor::VisitArrayLiteral(ArrayLiteral* node) {
475 RegularNode();
343 node->set_base_id(ReserveIdRange(node->num_ids())); 476 node->set_base_id(ReserveIdRange(node->num_ids()));
344 for (int i = 0; i < node->values()->length(); i++) { 477 for (int i = 0; i < node->values()->length(); i++) {
345 Visit(node->values()->at(i)); 478 Visit(node->values()->at(i));
346 } 479 }
347 } 480 }
348 481
349 482
350 void AstNumberingVisitor::VisitCall(Call* node) { 483 void AstNumberingVisitor::VisitCall(Call* node) {
484 RegularNodeWithFeedbackSlots(node);
351 node->set_base_id(ReserveIdRange(Call::num_ids())); 485 node->set_base_id(ReserveIdRange(Call::num_ids()));
352 Visit(node->expression()); 486 Visit(node->expression());
353 VisitArguments(node->arguments()); 487 VisitArguments(node->arguments());
354 } 488 }
355 489
356 490
357 void AstNumberingVisitor::VisitCallNew(CallNew* node) { 491 void AstNumberingVisitor::VisitCallNew(CallNew* node) {
492 RegularNodeWithFeedbackSlots(node);
358 node->set_base_id(ReserveIdRange(CallNew::num_ids())); 493 node->set_base_id(ReserveIdRange(CallNew::num_ids()));
359 Visit(node->expression()); 494 Visit(node->expression());
360 VisitArguments(node->arguments()); 495 VisitArguments(node->arguments());
361 } 496 }
362 497
363 498
364 void AstNumberingVisitor::VisitStatements(ZoneList<Statement*>* statements) { 499 void AstNumberingVisitor::VisitStatements(ZoneList<Statement*>* statements) {
365 if (statements == NULL) return; 500 if (statements == NULL) return;
366 for (int i = 0; i < statements->length(); i++) { 501 for (int i = 0; i < statements->length(); i++) {
367 Visit(statements->at(i)); 502 Visit(statements->at(i));
(...skipping 10 matching lines...) Expand all
378 513
379 514
380 void AstNumberingVisitor::VisitArguments(ZoneList<Expression*>* arguments) { 515 void AstNumberingVisitor::VisitArguments(ZoneList<Expression*>* arguments) {
381 for (int i = 0; i < arguments->length(); i++) { 516 for (int i = 0; i < arguments->length(); i++) {
382 Visit(arguments->at(i)); 517 Visit(arguments->at(i));
383 } 518 }
384 } 519 }
385 520
386 521
387 void AstNumberingVisitor::VisitFunctionLiteral(FunctionLiteral* node) { 522 void AstNumberingVisitor::VisitFunctionLiteral(FunctionLiteral* node) {
523 RegularNode();
388 node->set_base_id(ReserveIdRange(FunctionLiteral::num_ids())); 524 node->set_base_id(ReserveIdRange(FunctionLiteral::num_ids()));
389 // We don't recurse into the declarations or body of the function literal: 525 // We don't recurse into the declarations or body of the function literal:
390 // you have to separately Renumber() each FunctionLiteral that you compile. 526 // you have to separately Renumber() each FunctionLiteral that you compile.
391 } 527 }
392 528
393 529
394 void AstNumberingVisitor::Renumber(FunctionLiteral* node) { 530 void AstNumberingVisitor::Renumber(FunctionLiteral* node) {
395 if (node->scope()->HasIllegalRedeclaration()) { 531 if (node->scope()->HasIllegalRedeclaration()) {
396 node->scope()->VisitIllegalRedeclaration(this); 532 node->scope()->VisitIllegalRedeclaration(this);
397 return; 533 return;
398 } 534 }
399 535
400 Scope* scope = node->scope(); 536 Scope* scope = node->scope();
401 VisitDeclarations(scope->declarations()); 537 VisitDeclarations(scope->declarations());
402 if (scope->is_function_scope() && scope->function() != NULL) { 538 if (scope->is_function_scope() && scope->function() != NULL) {
403 // Visit the name of the named function expression. 539 // Visit the name of the named function expression.
404 Visit(scope->function()); 540 Visit(scope->function());
405 } 541 }
406 VisitStatements(node->body()); 542 VisitStatements(node->body());
543
544 node->set_ast_properties(&properties_);
545 BailoutReason dont_optimize_reason = (dont_turbofan_reason_ != kNoReason)
546 ? dont_turbofan_reason_
547 : dont_crankshaft_reason_;
548 node->set_dont_optimize_reason(dont_optimize_reason);
407 } 549 }
408 550
409 551
410 bool AstNumbering::Renumber(FunctionLiteral* function, Zone* zone) { 552 bool AstNumbering::Renumber(FunctionLiteral* function, Zone* zone) {
411 AstNumberingVisitor visitor(zone); 553 AstNumberingVisitor visitor(zone);
412 visitor.Renumber(function); 554 visitor.Renumber(function);
413 return !visitor.HasStackOverflow(); 555 return !visitor.HasStackOverflow();
414 } 556 }
557
558 bool AstNumbering::Renumber(FunctionLiteral* function,
559 Handle<SharedFunctionInfo> shared, Zone* zone) {
Sven Panne 2014/10/22 13:08:52 I don't think this actually belongs here: It just
wingo 2014/10/22 13:23:01 ACK. Unfortunately the fix is a bit more involved
560 if (!AstNumbering::Renumber(function, zone)) return false;
561 if (!shared.is_null()) {
562 shared->set_bailout_reason(function->dont_optimize_reason());
563 shared->set_ast_node_count(function->ast_node_count());
564 shared->set_dont_cache(function->flags()->Contains(kDontCache));
565 }
566 return true;
567 }
415 } 568 }
416 } // namespace v8::internal 569 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast-numbering.h ('k') | src/compiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698