OLD | NEW |
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 #include "src/hydrogen.h" | 5 #include "src/hydrogen.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "src/v8.h" | 9 #include "src/v8.h" |
10 | 10 |
(...skipping 4816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4827 DCHECK(current_block()->HasPredecessor()); | 4827 DCHECK(current_block()->HasPredecessor()); |
4828 return Bailout(kWithStatement); | 4828 return Bailout(kWithStatement); |
4829 } | 4829 } |
4830 | 4830 |
4831 | 4831 |
4832 void HOptimizedGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) { | 4832 void HOptimizedGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) { |
4833 DCHECK(!HasStackOverflow()); | 4833 DCHECK(!HasStackOverflow()); |
4834 DCHECK(current_block() != NULL); | 4834 DCHECK(current_block() != NULL); |
4835 DCHECK(current_block()->HasPredecessor()); | 4835 DCHECK(current_block()->HasPredecessor()); |
4836 | 4836 |
4837 // We only optimize switch statements with a bounded number of clauses. | |
4838 const int kCaseClauseLimit = 128; | |
4839 ZoneList<CaseClause*>* clauses = stmt->cases(); | 4837 ZoneList<CaseClause*>* clauses = stmt->cases(); |
4840 int clause_count = clauses->length(); | 4838 int clause_count = clauses->length(); |
4841 ZoneList<HBasicBlock*> body_blocks(clause_count, zone()); | 4839 ZoneList<HBasicBlock*> body_blocks(clause_count, zone()); |
4842 if (clause_count > kCaseClauseLimit) { | |
4843 return Bailout(kSwitchStatementTooManyClauses); | |
4844 } | |
4845 | 4840 |
4846 CHECK_ALIVE(VisitForValue(stmt->tag())); | 4841 CHECK_ALIVE(VisitForValue(stmt->tag())); |
4847 Add<HSimulate>(stmt->EntryId()); | 4842 Add<HSimulate>(stmt->EntryId()); |
4848 HValue* tag_value = Top(); | 4843 HValue* tag_value = Top(); |
4849 Type* tag_type = stmt->tag()->bounds().lower; | 4844 Type* tag_type = stmt->tag()->bounds().lower; |
4850 | 4845 |
4851 // 1. Build all the tests, with dangling true branches | 4846 // 1. Build all the tests, with dangling true branches |
4852 BailoutId default_id = BailoutId::None(); | 4847 BailoutId default_id = BailoutId::None(); |
4853 for (int i = 0; i < clause_count; ++i) { | 4848 for (int i = 0; i < clause_count; ++i) { |
4854 CaseClause* clause = clauses->at(i); | 4849 CaseClause* clause = clauses->at(i); |
(...skipping 7649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12504 if (ShouldProduceTraceOutput()) { | 12499 if (ShouldProduceTraceOutput()) { |
12505 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 12500 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
12506 } | 12501 } |
12507 | 12502 |
12508 #ifdef DEBUG | 12503 #ifdef DEBUG |
12509 graph_->Verify(false); // No full verify. | 12504 graph_->Verify(false); // No full verify. |
12510 #endif | 12505 #endif |
12511 } | 12506 } |
12512 | 12507 |
12513 } } // namespace v8::internal | 12508 } } // namespace v8::internal |
OLD | NEW |