| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 2738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2749 not_string_block = graph()->CreateBasicBlock(); | 2749 not_string_block = graph()->CreateBasicBlock(); |
| 2750 | 2750 |
| 2751 string_check->SetSuccessorAt(0, first_test_block); | 2751 string_check->SetSuccessorAt(0, first_test_block); |
| 2752 string_check->SetSuccessorAt(1, not_string_block); | 2752 string_check->SetSuccessorAt(1, not_string_block); |
| 2753 current_block()->Finish(string_check); | 2753 current_block()->Finish(string_check); |
| 2754 | 2754 |
| 2755 set_current_block(first_test_block); | 2755 set_current_block(first_test_block); |
| 2756 } | 2756 } |
| 2757 | 2757 |
| 2758 // 2. Build all the tests, with dangling true branches | 2758 // 2. Build all the tests, with dangling true branches |
| 2759 int default_id = AstNode::kNoNumber; |
| 2759 for (int i = 0; i < clause_count; ++i) { | 2760 for (int i = 0; i < clause_count; ++i) { |
| 2760 CaseClause* clause = clauses->at(i); | 2761 CaseClause* clause = clauses->at(i); |
| 2761 if (clause->is_default()) continue; | 2762 if (clause->is_default()) { |
| 2762 | 2763 default_id = clause->EntryId(); |
| 2764 continue; |
| 2765 } |
| 2763 if (switch_type == SMI_SWITCH) { | 2766 if (switch_type == SMI_SWITCH) { |
| 2764 clause->RecordTypeFeedback(oracle()); | 2767 clause->RecordTypeFeedback(oracle()); |
| 2765 } | 2768 } |
| 2766 | 2769 |
| 2767 // Generate a compare and branch. | 2770 // Generate a compare and branch. |
| 2768 CHECK_ALIVE(VisitForValue(clause->label())); | 2771 CHECK_ALIVE(VisitForValue(clause->label())); |
| 2769 HValue* label_value = Pop(); | 2772 HValue* label_value = Pop(); |
| 2770 | 2773 |
| 2771 HBasicBlock* next_test_block = graph()->CreateBasicBlock(); | 2774 HBasicBlock* next_test_block = graph()->CreateBasicBlock(); |
| 2772 HBasicBlock* body_block = graph()->CreateBasicBlock(); | 2775 HBasicBlock* body_block = graph()->CreateBasicBlock(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2799 current_block()->Finish(compare); | 2802 current_block()->Finish(compare); |
| 2800 | 2803 |
| 2801 set_current_block(next_test_block); | 2804 set_current_block(next_test_block); |
| 2802 } | 2805 } |
| 2803 | 2806 |
| 2804 // Save the current block to use for the default or to join with the | 2807 // Save the current block to use for the default or to join with the |
| 2805 // exit. This block is NULL if we deoptimized. | 2808 // exit. This block is NULL if we deoptimized. |
| 2806 HBasicBlock* last_block = current_block(); | 2809 HBasicBlock* last_block = current_block(); |
| 2807 | 2810 |
| 2808 if (not_string_block != NULL) { | 2811 if (not_string_block != NULL) { |
| 2809 last_block = CreateJoin(last_block, not_string_block, stmt->ExitId()); | 2812 int join_id = (default_id != AstNode::kNoNumber) |
| 2813 ? default_id |
| 2814 : stmt->ExitId(); |
| 2815 last_block = CreateJoin(last_block, not_string_block, join_id); |
| 2810 } | 2816 } |
| 2811 | 2817 |
| 2812 // 3. Loop over the clauses and the linked list of tests in lockstep, | 2818 // 3. Loop over the clauses and the linked list of tests in lockstep, |
| 2813 // translating the clause bodies. | 2819 // translating the clause bodies. |
| 2814 HBasicBlock* curr_test_block = first_test_block; | 2820 HBasicBlock* curr_test_block = first_test_block; |
| 2815 HBasicBlock* fall_through_block = NULL; | 2821 HBasicBlock* fall_through_block = NULL; |
| 2816 | 2822 |
| 2817 BreakAndContinueInfo break_info(stmt); | 2823 BreakAndContinueInfo break_info(stmt); |
| 2818 { BreakAndContinueScope push(&break_info, this); | 2824 { BreakAndContinueScope push(&break_info, this); |
| 2819 for (int i = 0; i < clause_count; ++i) { | 2825 for (int i = 0; i < clause_count; ++i) { |
| (...skipping 4401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7221 } | 7227 } |
| 7222 } | 7228 } |
| 7223 | 7229 |
| 7224 #ifdef DEBUG | 7230 #ifdef DEBUG |
| 7225 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 7231 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
| 7226 if (allocator_ != NULL) allocator_->Verify(); | 7232 if (allocator_ != NULL) allocator_->Verify(); |
| 7227 #endif | 7233 #endif |
| 7228 } | 7234 } |
| 7229 | 7235 |
| 7230 } } // namespace v8::internal | 7236 } } // namespace v8::internal |
| OLD | NEW |