| OLD | NEW |
| 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 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 int ReserveIdRange(int n) { | 39 int ReserveIdRange(int n) { |
| 40 int tmp = next_id_; | 40 int tmp = next_id_; |
| 41 next_id_ += n; | 41 next_id_ += n; |
| 42 return tmp; | 42 return tmp; |
| 43 } | 43 } |
| 44 | 44 |
| 45 void IncrementNodeCount() { properties_.add_node_count(1); } | 45 void IncrementNodeCount() { properties_.add_node_count(1); } |
| 46 void DisableCrankshaft(BailoutReason reason) { | 46 void DisableCrankshaft(BailoutReason reason) { |
| 47 dont_crankshaft_reason_ = reason; | 47 dont_crankshaft_reason_ = reason; |
| 48 properties_.flags()->Add(kDontSelfOptimize); | |
| 49 } | 48 } |
| 50 // TODO(turbofan): Remove the dont_turbofan_reason once no nodes are | 49 // TODO(turbofan): Remove the dont_turbofan_reason once no nodes are |
| 51 // DontTurbofanNode. That set of nodes must be kept in sync with | 50 // DontTurbofanNode. That set of nodes must be kept in sync with |
| 52 // Pipeline::GenerateCode. | 51 // Pipeline::GenerateCode. |
| 53 void DisableTurbofan(BailoutReason reason) { | 52 void DisableTurbofan(BailoutReason reason) { |
| 54 dont_crankshaft_reason_ = reason; | 53 dont_crankshaft_reason_ = reason; |
| 55 dont_turbofan_reason_ = reason; | 54 dont_turbofan_reason_ = reason; |
| 56 DisableSelfOptimization(); | |
| 57 } | |
| 58 void DisableSelfOptimization() { | |
| 59 properties_.flags()->Add(kDontSelfOptimize); | |
| 60 } | 55 } |
| 61 void DisableCaching(BailoutReason reason) { | 56 void DisableCaching(BailoutReason reason) { |
| 62 dont_crankshaft_reason_ = reason; | 57 dont_crankshaft_reason_ = reason; |
| 63 DisableSelfOptimization(); | |
| 64 properties_.flags()->Add(kDontCache); | 58 properties_.flags()->Add(kDontCache); |
| 65 } | 59 } |
| 66 | 60 |
| 67 template <typename Node> | 61 template <typename Node> |
| 68 void ReserveFeedbackSlots(Node* node) { | 62 void ReserveFeedbackSlots(Node* node) { |
| 69 FeedbackVectorRequirements reqs = node->ComputeFeedbackRequirements(); | 63 FeedbackVectorRequirements reqs = node->ComputeFeedbackRequirements(); |
| 70 if (reqs.slots() > 0) { | 64 if (reqs.slots() > 0) { |
| 71 node->SetFirstFeedbackSlot( | 65 node->SetFirstFeedbackSlot( |
| 72 FeedbackVectorSlot(properties_.feedback_slots())); | 66 FeedbackVectorSlot(properties_.feedback_slots())); |
| 73 properties_.increase_feedback_slots(reqs.slots()); | 67 properties_.increase_feedback_slots(reqs.slots()); |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 void AstNumberingVisitor::VisitWithStatement(WithStatement* node) { | 290 void AstNumberingVisitor::VisitWithStatement(WithStatement* node) { |
| 297 IncrementNodeCount(); | 291 IncrementNodeCount(); |
| 298 DisableCrankshaft(kWithStatement); | 292 DisableCrankshaft(kWithStatement); |
| 299 Visit(node->expression()); | 293 Visit(node->expression()); |
| 300 Visit(node->statement()); | 294 Visit(node->statement()); |
| 301 } | 295 } |
| 302 | 296 |
| 303 | 297 |
| 304 void AstNumberingVisitor::VisitDoWhileStatement(DoWhileStatement* node) { | 298 void AstNumberingVisitor::VisitDoWhileStatement(DoWhileStatement* node) { |
| 305 IncrementNodeCount(); | 299 IncrementNodeCount(); |
| 306 DisableSelfOptimization(); | |
| 307 node->set_base_id(ReserveIdRange(DoWhileStatement::num_ids())); | 300 node->set_base_id(ReserveIdRange(DoWhileStatement::num_ids())); |
| 308 Visit(node->body()); | 301 Visit(node->body()); |
| 309 Visit(node->cond()); | 302 Visit(node->cond()); |
| 310 } | 303 } |
| 311 | 304 |
| 312 | 305 |
| 313 void AstNumberingVisitor::VisitWhileStatement(WhileStatement* node) { | 306 void AstNumberingVisitor::VisitWhileStatement(WhileStatement* node) { |
| 314 IncrementNodeCount(); | 307 IncrementNodeCount(); |
| 315 DisableSelfOptimization(); | |
| 316 node->set_base_id(ReserveIdRange(WhileStatement::num_ids())); | 308 node->set_base_id(ReserveIdRange(WhileStatement::num_ids())); |
| 317 Visit(node->cond()); | 309 Visit(node->cond()); |
| 318 Visit(node->body()); | 310 Visit(node->body()); |
| 319 } | 311 } |
| 320 | 312 |
| 321 | 313 |
| 322 void AstNumberingVisitor::VisitTryCatchStatement(TryCatchStatement* node) { | 314 void AstNumberingVisitor::VisitTryCatchStatement(TryCatchStatement* node) { |
| 323 IncrementNodeCount(); | 315 IncrementNodeCount(); |
| 324 DisableTurbofan(kTryCatchStatement); | 316 DisableTurbofan(kTryCatchStatement); |
| 325 Visit(node->try_block()); | 317 Visit(node->try_block()); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 void AstNumberingVisitor::VisitCompareOperation(CompareOperation* node) { | 356 void AstNumberingVisitor::VisitCompareOperation(CompareOperation* node) { |
| 365 IncrementNodeCount(); | 357 IncrementNodeCount(); |
| 366 node->set_base_id(ReserveIdRange(CompareOperation::num_ids())); | 358 node->set_base_id(ReserveIdRange(CompareOperation::num_ids())); |
| 367 Visit(node->left()); | 359 Visit(node->left()); |
| 368 Visit(node->right()); | 360 Visit(node->right()); |
| 369 } | 361 } |
| 370 | 362 |
| 371 | 363 |
| 372 void AstNumberingVisitor::VisitForInStatement(ForInStatement* node) { | 364 void AstNumberingVisitor::VisitForInStatement(ForInStatement* node) { |
| 373 IncrementNodeCount(); | 365 IncrementNodeCount(); |
| 374 DisableSelfOptimization(); | |
| 375 ReserveFeedbackSlots(node); | 366 ReserveFeedbackSlots(node); |
| 376 node->set_base_id(ReserveIdRange(ForInStatement::num_ids())); | 367 node->set_base_id(ReserveIdRange(ForInStatement::num_ids())); |
| 377 Visit(node->each()); | 368 Visit(node->each()); |
| 378 Visit(node->enumerable()); | 369 Visit(node->enumerable()); |
| 379 Visit(node->body()); | 370 Visit(node->body()); |
| 380 } | 371 } |
| 381 | 372 |
| 382 | 373 |
| 383 void AstNumberingVisitor::VisitForOfStatement(ForOfStatement* node) { | 374 void AstNumberingVisitor::VisitForOfStatement(ForOfStatement* node) { |
| 384 IncrementNodeCount(); | 375 IncrementNodeCount(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 void AstNumberingVisitor::VisitCaseClause(CaseClause* node) { | 417 void AstNumberingVisitor::VisitCaseClause(CaseClause* node) { |
| 427 IncrementNodeCount(); | 418 IncrementNodeCount(); |
| 428 node->set_base_id(ReserveIdRange(CaseClause::num_ids())); | 419 node->set_base_id(ReserveIdRange(CaseClause::num_ids())); |
| 429 if (!node->is_default()) Visit(node->label()); | 420 if (!node->is_default()) Visit(node->label()); |
| 430 VisitStatements(node->statements()); | 421 VisitStatements(node->statements()); |
| 431 } | 422 } |
| 432 | 423 |
| 433 | 424 |
| 434 void AstNumberingVisitor::VisitForStatement(ForStatement* node) { | 425 void AstNumberingVisitor::VisitForStatement(ForStatement* node) { |
| 435 IncrementNodeCount(); | 426 IncrementNodeCount(); |
| 436 DisableSelfOptimization(); | |
| 437 node->set_base_id(ReserveIdRange(ForStatement::num_ids())); | 427 node->set_base_id(ReserveIdRange(ForStatement::num_ids())); |
| 438 if (node->init() != NULL) Visit(node->init()); | 428 if (node->init() != NULL) Visit(node->init()); |
| 439 if (node->cond() != NULL) Visit(node->cond()); | 429 if (node->cond() != NULL) Visit(node->cond()); |
| 440 if (node->next() != NULL) Visit(node->next()); | 430 if (node->next() != NULL) Visit(node->next()); |
| 441 Visit(node->body()); | 431 Visit(node->body()); |
| 442 } | 432 } |
| 443 | 433 |
| 444 | 434 |
| 445 void AstNumberingVisitor::VisitClassLiteral(ClassLiteral* node) { | 435 void AstNumberingVisitor::VisitClassLiteral(ClassLiteral* node) { |
| 446 IncrementNodeCount(); | 436 IncrementNodeCount(); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 } | 540 } |
| 551 | 541 |
| 552 | 542 |
| 553 bool AstNumbering::Renumber(FunctionLiteral* function, Zone* zone) { | 543 bool AstNumbering::Renumber(FunctionLiteral* function, Zone* zone) { |
| 554 AstNumberingVisitor visitor(zone); | 544 AstNumberingVisitor visitor(zone); |
| 555 visitor.Renumber(function); | 545 visitor.Renumber(function); |
| 556 return !visitor.HasStackOverflow(); | 546 return !visitor.HasStackOverflow(); |
| 557 } | 547 } |
| 558 } | 548 } |
| 559 } // namespace v8::internal | 549 } // namespace v8::internal |
| OLD | NEW |