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