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

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

Issue 670953003: Move feedback slot allocation to post-pass (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased patch 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
« no previous file with comments | « src/ast.cc ('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"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 } 57 }
58 void DisableSelfOptimization() { 58 void DisableSelfOptimization() {
59 properties_.flags()->Add(kDontSelfOptimize); 59 properties_.flags()->Add(kDontSelfOptimize);
60 } 60 }
61 void DisableCaching(BailoutReason reason) { 61 void DisableCaching(BailoutReason reason) {
62 dont_crankshaft_reason_ = reason; 62 dont_crankshaft_reason_ = reason;
63 DisableSelfOptimization(); 63 DisableSelfOptimization();
64 properties_.flags()->Add(kDontCache); 64 properties_.flags()->Add(kDontCache);
65 } 65 }
66 66
67 template <typename Node>
68 void ReserveFeedbackSlots(Node* node) {
69 FeedbackVectorRequirements reqs = node->ComputeFeedbackRequirements();
70 if (reqs.slots() > 0) {
71 node->SetFirstFeedbackSlot(
72 FeedbackVectorSlot(properties_.feedback_slots()));
73 properties_.increase_feedback_slots(reqs.slots());
74 }
75 if (reqs.ic_slots() > 0) {
76 node->SetFirstFeedbackICSlot(
77 FeedbackVectorICSlot(properties_.ic_feedback_slots()));
78 properties_.increase_ic_feedback_slots(reqs.ic_slots());
79 }
80 }
81
67 BailoutReason dont_optimize_reason() const { 82 BailoutReason dont_optimize_reason() const {
68 return (dont_turbofan_reason_ != kNoReason) ? dont_turbofan_reason_ 83 return (dont_turbofan_reason_ != kNoReason) ? dont_turbofan_reason_
69 : dont_crankshaft_reason_; 84 : dont_crankshaft_reason_;
70 } 85 }
71 86
72 int next_id_; 87 int next_id_;
73 AstProperties properties_; 88 AstProperties properties_;
74 BailoutReason dont_crankshaft_reason_; 89 BailoutReason dont_crankshaft_reason_;
75 BailoutReason dont_turbofan_reason_; 90 BailoutReason dont_turbofan_reason_;
76 91
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 IncrementNodeCount(); 153 IncrementNodeCount();
139 node->set_base_id(ReserveIdRange(RegExpLiteral::num_ids())); 154 node->set_base_id(ReserveIdRange(RegExpLiteral::num_ids()));
140 } 155 }
141 156
142 157
143 void AstNumberingVisitor::VisitVariableProxy(VariableProxy* node) { 158 void AstNumberingVisitor::VisitVariableProxy(VariableProxy* node) {
144 IncrementNodeCount(); 159 IncrementNodeCount();
145 if (node->var()->IsLookupSlot()) { 160 if (node->var()->IsLookupSlot()) {
146 DisableCrankshaft(kReferenceToAVariableWhichRequiresDynamicLookup); 161 DisableCrankshaft(kReferenceToAVariableWhichRequiresDynamicLookup);
147 } 162 }
163 ReserveFeedbackSlots(node);
148 node->set_base_id(ReserveIdRange(VariableProxy::num_ids())); 164 node->set_base_id(ReserveIdRange(VariableProxy::num_ids()));
149 } 165 }
150 166
151 167
152 void AstNumberingVisitor::VisitThisFunction(ThisFunction* node) { 168 void AstNumberingVisitor::VisitThisFunction(ThisFunction* node) {
153 IncrementNodeCount(); 169 IncrementNodeCount();
154 node->set_base_id(ReserveIdRange(ThisFunction::num_ids())); 170 node->set_base_id(ReserveIdRange(ThisFunction::num_ids()));
155 } 171 }
156 172
157 173
158 void AstNumberingVisitor::VisitSuperReference(SuperReference* node) { 174 void AstNumberingVisitor::VisitSuperReference(SuperReference* node) {
159 IncrementNodeCount(); 175 IncrementNodeCount();
160 DisableTurbofan(kSuperReference); 176 DisableTurbofan(kSuperReference);
177 ReserveFeedbackSlots(node);
161 node->set_base_id(ReserveIdRange(SuperReference::num_ids())); 178 node->set_base_id(ReserveIdRange(SuperReference::num_ids()));
162 Visit(node->this_var()); 179 Visit(node->this_var());
163 } 180 }
164 181
165 182
166 void AstNumberingVisitor::VisitModuleDeclaration(ModuleDeclaration* node) { 183 void AstNumberingVisitor::VisitModuleDeclaration(ModuleDeclaration* node) {
167 IncrementNodeCount(); 184 IncrementNodeCount();
168 DisableCrankshaft(kModuleDeclaration); 185 DisableCrankshaft(kModuleDeclaration);
169 VisitVariableProxy(node->proxy()); 186 VisitVariableProxy(node->proxy());
170 Visit(node->module()); 187 Visit(node->module());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 225
209 void AstNumberingVisitor::VisitReturnStatement(ReturnStatement* node) { 226 void AstNumberingVisitor::VisitReturnStatement(ReturnStatement* node) {
210 IncrementNodeCount(); 227 IncrementNodeCount();
211 Visit(node->expression()); 228 Visit(node->expression());
212 } 229 }
213 230
214 231
215 void AstNumberingVisitor::VisitYield(Yield* node) { 232 void AstNumberingVisitor::VisitYield(Yield* node) {
216 IncrementNodeCount(); 233 IncrementNodeCount();
217 DisableCrankshaft(kYield); 234 DisableCrankshaft(kYield);
235 ReserveFeedbackSlots(node);
218 node->set_base_id(ReserveIdRange(Yield::num_ids())); 236 node->set_base_id(ReserveIdRange(Yield::num_ids()));
219 Visit(node->generator_object()); 237 Visit(node->generator_object());
220 Visit(node->expression()); 238 Visit(node->expression());
221 } 239 }
222 240
223 241
224 void AstNumberingVisitor::VisitThrow(Throw* node) { 242 void AstNumberingVisitor::VisitThrow(Throw* node) {
225 IncrementNodeCount(); 243 IncrementNodeCount();
226 node->set_base_id(ReserveIdRange(Throw::num_ids())); 244 node->set_base_id(ReserveIdRange(Throw::num_ids()));
227 Visit(node->exception()); 245 Visit(node->exception());
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 void AstNumberingVisitor::VisitTryFinallyStatement(TryFinallyStatement* node) { 330 void AstNumberingVisitor::VisitTryFinallyStatement(TryFinallyStatement* node) {
313 IncrementNodeCount(); 331 IncrementNodeCount();
314 DisableTurbofan(kTryFinallyStatement); 332 DisableTurbofan(kTryFinallyStatement);
315 Visit(node->try_block()); 333 Visit(node->try_block());
316 Visit(node->finally_block()); 334 Visit(node->finally_block());
317 } 335 }
318 336
319 337
320 void AstNumberingVisitor::VisitProperty(Property* node) { 338 void AstNumberingVisitor::VisitProperty(Property* node) {
321 IncrementNodeCount(); 339 IncrementNodeCount();
340 ReserveFeedbackSlots(node);
322 node->set_base_id(ReserveIdRange(Property::num_ids())); 341 node->set_base_id(ReserveIdRange(Property::num_ids()));
323 Visit(node->key()); 342 Visit(node->key());
324 Visit(node->obj()); 343 Visit(node->obj());
325 } 344 }
326 345
327 346
328 void AstNumberingVisitor::VisitAssignment(Assignment* node) { 347 void AstNumberingVisitor::VisitAssignment(Assignment* node) {
329 IncrementNodeCount(); 348 IncrementNodeCount();
330 node->set_base_id(ReserveIdRange(Assignment::num_ids())); 349 node->set_base_id(ReserveIdRange(Assignment::num_ids()));
331 if (node->is_compound()) VisitBinaryOperation(node->binary_operation()); 350 if (node->is_compound()) VisitBinaryOperation(node->binary_operation());
(...skipping 14 matching lines...) Expand all
346 IncrementNodeCount(); 365 IncrementNodeCount();
347 node->set_base_id(ReserveIdRange(CompareOperation::num_ids())); 366 node->set_base_id(ReserveIdRange(CompareOperation::num_ids()));
348 Visit(node->left()); 367 Visit(node->left());
349 Visit(node->right()); 368 Visit(node->right());
350 } 369 }
351 370
352 371
353 void AstNumberingVisitor::VisitForInStatement(ForInStatement* node) { 372 void AstNumberingVisitor::VisitForInStatement(ForInStatement* node) {
354 IncrementNodeCount(); 373 IncrementNodeCount();
355 DisableSelfOptimization(); 374 DisableSelfOptimization();
375 ReserveFeedbackSlots(node);
356 node->set_base_id(ReserveIdRange(ForInStatement::num_ids())); 376 node->set_base_id(ReserveIdRange(ForInStatement::num_ids()));
357 Visit(node->each()); 377 Visit(node->each());
358 Visit(node->enumerable()); 378 Visit(node->enumerable());
359 Visit(node->body()); 379 Visit(node->body());
360 } 380 }
361 381
362 382
363 void AstNumberingVisitor::VisitForOfStatement(ForOfStatement* node) { 383 void AstNumberingVisitor::VisitForOfStatement(ForOfStatement* node) {
364 IncrementNodeCount(); 384 IncrementNodeCount();
365 DisableTurbofan(kForOfStatement); 385 DisableTurbofan(kForOfStatement);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 IncrementNodeCount(); 474 IncrementNodeCount();
455 node->set_base_id(ReserveIdRange(node->num_ids())); 475 node->set_base_id(ReserveIdRange(node->num_ids()));
456 for (int i = 0; i < node->values()->length(); i++) { 476 for (int i = 0; i < node->values()->length(); i++) {
457 Visit(node->values()->at(i)); 477 Visit(node->values()->at(i));
458 } 478 }
459 } 479 }
460 480
461 481
462 void AstNumberingVisitor::VisitCall(Call* node) { 482 void AstNumberingVisitor::VisitCall(Call* node) {
463 IncrementNodeCount(); 483 IncrementNodeCount();
484 ReserveFeedbackSlots(node);
464 node->set_base_id(ReserveIdRange(Call::num_ids())); 485 node->set_base_id(ReserveIdRange(Call::num_ids()));
465 Visit(node->expression()); 486 Visit(node->expression());
466 VisitArguments(node->arguments()); 487 VisitArguments(node->arguments());
467 } 488 }
468 489
469 490
470 void AstNumberingVisitor::VisitCallNew(CallNew* node) { 491 void AstNumberingVisitor::VisitCallNew(CallNew* node) {
471 IncrementNodeCount(); 492 IncrementNodeCount();
493 ReserveFeedbackSlots(node);
472 node->set_base_id(ReserveIdRange(CallNew::num_ids())); 494 node->set_base_id(ReserveIdRange(CallNew::num_ids()));
473 Visit(node->expression()); 495 Visit(node->expression());
474 VisitArguments(node->arguments()); 496 VisitArguments(node->arguments());
475 } 497 }
476 498
477 499
478 void AstNumberingVisitor::VisitStatements(ZoneList<Statement*>* statements) { 500 void AstNumberingVisitor::VisitStatements(ZoneList<Statement*>* statements) {
479 if (statements == NULL) return; 501 if (statements == NULL) return;
480 for (int i = 0; i < statements->length(); i++) { 502 for (int i = 0; i < statements->length(); i++) {
481 Visit(statements->at(i)); 503 Visit(statements->at(i));
(...skipping 18 matching lines...) Expand all
500 522
501 void AstNumberingVisitor::VisitFunctionLiteral(FunctionLiteral* node) { 523 void AstNumberingVisitor::VisitFunctionLiteral(FunctionLiteral* node) {
502 IncrementNodeCount(); 524 IncrementNodeCount();
503 node->set_base_id(ReserveIdRange(FunctionLiteral::num_ids())); 525 node->set_base_id(ReserveIdRange(FunctionLiteral::num_ids()));
504 // We don't recurse into the declarations or body of the function literal: 526 // We don't recurse into the declarations or body of the function literal:
505 // you have to separately Renumber() each FunctionLiteral that you compile. 527 // you have to separately Renumber() each FunctionLiteral that you compile.
506 } 528 }
507 529
508 530
509 void AstNumberingVisitor::Renumber(FunctionLiteral* node) { 531 void AstNumberingVisitor::Renumber(FunctionLiteral* node) {
510 properties_.flags()->Add(*node->flags());
511 properties_.increase_feedback_slots(node->slot_count());
512 properties_.increase_ic_feedback_slots(node->ic_slot_count());
513
514 if (node->scope()->HasIllegalRedeclaration()) { 532 if (node->scope()->HasIllegalRedeclaration()) {
515 node->scope()->VisitIllegalRedeclaration(this); 533 node->scope()->VisitIllegalRedeclaration(this);
516 return; 534 return;
517 } 535 }
518 536
519 Scope* scope = node->scope(); 537 Scope* scope = node->scope();
520 VisitDeclarations(scope->declarations()); 538 VisitDeclarations(scope->declarations());
521 if (scope->is_function_scope() && scope->function() != NULL) { 539 if (scope->is_function_scope() && scope->function() != NULL) {
522 // Visit the name of the named function expression. 540 // Visit the name of the named function expression.
523 Visit(scope->function()); 541 Visit(scope->function());
524 } 542 }
525 VisitStatements(node->body()); 543 VisitStatements(node->body());
526 544
527 node->set_ast_properties(&properties_); 545 node->set_ast_properties(&properties_);
528 node->set_dont_optimize_reason(dont_optimize_reason()); 546 node->set_dont_optimize_reason(dont_optimize_reason());
529 } 547 }
530 548
531 549
532 bool AstNumbering::Renumber(FunctionLiteral* function, Zone* zone) { 550 bool AstNumbering::Renumber(FunctionLiteral* function, Zone* zone) {
533 AstNumberingVisitor visitor(zone); 551 AstNumberingVisitor visitor(zone);
534 visitor.Renumber(function); 552 visitor.Renumber(function);
535 return !visitor.HasStackOverflow(); 553 return !visitor.HasStackOverflow();
536 } 554 }
537 } 555 }
538 } // namespace v8::internal 556 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.cc ('k') | src/compiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698