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

Side by Side Diff: src/hydrogen.cc

Issue 8495011: Revert r9901 to make tree green again. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 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/hydrogen.h ('k') | src/hydrogen-instructions.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 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 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 HBasicBlock* loop_header) { 727 HBasicBlock* loop_header) {
728 if (block == NULL || visited->Contains(block->block_id())) return; 728 if (block == NULL || visited->Contains(block->block_id())) return;
729 if (block->parent_loop_header() != loop_header) return; 729 if (block->parent_loop_header() != loop_header) return;
730 visited->Add(block->block_id()); 730 visited->Add(block->block_id());
731 if (block->IsLoopHeader()) { 731 if (block->IsLoopHeader()) {
732 PostorderLoopBlocks(block->loop_information(), visited, order, loop_header); 732 PostorderLoopBlocks(block->loop_information(), visited, order, loop_header);
733 for (HSuccessorIterator it(block->end()); !it.Done(); it.Advance()) { 733 for (HSuccessorIterator it(block->end()); !it.Done(); it.Advance()) {
734 Postorder(it.Current(), visited, order, block); 734 Postorder(it.Current(), visited, order, block);
735 } 735 }
736 } else { 736 } else {
737 ASSERT(block->IsFinished());
738 for (HSuccessorIterator it(block->end()); !it.Done(); it.Advance()) { 737 for (HSuccessorIterator it(block->end()); !it.Done(); it.Advance()) {
739 Postorder(it.Current(), visited, order, loop_header); 738 Postorder(it.Current(), visited, order, loop_header);
740 } 739 }
741 } 740 }
742 ASSERT(block->end()->FirstSuccessor() == NULL || 741 ASSERT(block->end()->FirstSuccessor() == NULL ||
743 order->Contains(block->end()->FirstSuccessor()) || 742 order->Contains(block->end()->FirstSuccessor()) ||
744 block->end()->FirstSuccessor()->IsLoopHeader()); 743 block->end()->FirstSuccessor()->IsLoopHeader());
745 ASSERT(block->end()->SecondSuccessor() == NULL || 744 ASSERT(block->end()->SecondSuccessor() == NULL ||
746 order->Contains(block->end()->SecondSuccessor()) || 745 order->Contains(block->end()->SecondSuccessor()) ||
747 block->end()->SecondSuccessor()->IsLoopHeader()); 746 block->end()->SecondSuccessor()->IsLoopHeader());
(...skipping 1954 matching lines...) Expand 10 before | Expand all | Expand 10 after
2702 ASSERT(current_block()->HasPredecessor()); 2701 ASSERT(current_block()->HasPredecessor());
2703 // We only optimize switch statements with smi-literal smi comparisons, 2702 // We only optimize switch statements with smi-literal smi comparisons,
2704 // with a bounded number of clauses. 2703 // with a bounded number of clauses.
2705 const int kCaseClauseLimit = 128; 2704 const int kCaseClauseLimit = 128;
2706 ZoneList<CaseClause*>* clauses = stmt->cases(); 2705 ZoneList<CaseClause*>* clauses = stmt->cases();
2707 int clause_count = clauses->length(); 2706 int clause_count = clauses->length();
2708 if (clause_count > kCaseClauseLimit) { 2707 if (clause_count > kCaseClauseLimit) {
2709 return Bailout("SwitchStatement: too many clauses"); 2708 return Bailout("SwitchStatement: too many clauses");
2710 } 2709 }
2711 2710
2712 HValue* context = environment()->LookupContext();
2713
2714 CHECK_ALIVE(VisitForValue(stmt->tag())); 2711 CHECK_ALIVE(VisitForValue(stmt->tag()));
2715 AddSimulate(stmt->EntryId()); 2712 AddSimulate(stmt->EntryId());
2716 HValue* tag_value = Pop(); 2713 HValue* tag_value = Pop();
2717 HBasicBlock* first_test_block = current_block(); 2714 HBasicBlock* first_test_block = current_block();
2718 2715
2719 SwitchType switch_type = UNKNOWN_SWITCH; 2716 // 1. Build all the tests, with dangling true branches. Unconditionally
2720 2717 // deoptimize if we encounter a non-smi comparison.
2721 // 1. Extract clause type
2722 for (int i = 0; i < clause_count; ++i) { 2718 for (int i = 0; i < clause_count; ++i) {
2723 CaseClause* clause = clauses->at(i); 2719 CaseClause* clause = clauses->at(i);
2724 if (clause->is_default()) continue; 2720 if (clause->is_default()) continue;
2725 2721 if (!clause->label()->IsSmiLiteral()) {
2726 if (switch_type == UNKNOWN_SWITCH) { 2722 return Bailout("SwitchStatement: non-literal switch label");
2727 if (clause->label()->IsSmiLiteral()) {
2728 switch_type = SMI_SWITCH;
2729 } else if (clause->label()->IsStringLiteral()) {
2730 switch_type = STRING_SWITCH;
2731 } else {
2732 return Bailout("SwitchStatement: non-literal switch label");
2733 }
2734 } else if ((switch_type == STRING_SWITCH &&
2735 !clause->label()->IsStringLiteral()) ||
2736 (switch_type == SMI_SWITCH &&
2737 !clause->label()->IsSmiLiteral())) {
2738 return Bailout("SwitchStatemnt: mixed label types are not supported");
2739 }
2740 }
2741
2742 HUnaryControlInstruction* string_check = NULL;
2743 HBasicBlock* not_string_block = NULL;
2744
2745 // Test switch's tag value if all clauses are string literals
2746 if (switch_type == STRING_SWITCH) {
2747 string_check = new(zone()) HIsStringAndBranch(tag_value);
2748 first_test_block = graph()->CreateBasicBlock();
2749 not_string_block = graph()->CreateBasicBlock();
2750
2751 string_check->SetSuccessorAt(0, first_test_block);
2752 string_check->SetSuccessorAt(1, not_string_block);
2753 current_block()->Finish(string_check);
2754
2755 set_current_block(first_test_block);
2756 }
2757
2758 // 2. Build all the tests, with dangling true branches
2759 for (int i = 0; i < clause_count; ++i) {
2760 CaseClause* clause = clauses->at(i);
2761 if (clause->is_default()) continue;
2762
2763 if (switch_type == SMI_SWITCH) {
2764 clause->RecordTypeFeedback(oracle());
2765 } 2723 }
2766 2724
2767 // Generate a compare and branch. 2725 // Unconditionally deoptimize on the first non-smi compare.
2726 clause->RecordTypeFeedback(oracle());
2727 if (!clause->IsSmiCompare()) {
2728 // Finish with deoptimize and add uses of enviroment values to
2729 // account for invisible uses.
2730 current_block()->FinishExitWithDeoptimization(HDeoptimize::kUseAll);
2731 set_current_block(NULL);
2732 break;
2733 }
2734
2735 // Otherwise generate a compare and branch.
2768 CHECK_ALIVE(VisitForValue(clause->label())); 2736 CHECK_ALIVE(VisitForValue(clause->label()));
2769 HValue* label_value = Pop(); 2737 HValue* label_value = Pop();
2770 2738 HCompareIDAndBranch* compare =
2739 new(zone()) HCompareIDAndBranch(tag_value,
2740 label_value,
2741 Token::EQ_STRICT);
2742 compare->SetInputRepresentation(Representation::Integer32());
2743 HBasicBlock* body_block = graph()->CreateBasicBlock();
2771 HBasicBlock* next_test_block = graph()->CreateBasicBlock(); 2744 HBasicBlock* next_test_block = graph()->CreateBasicBlock();
2772 HBasicBlock* body_block = graph()->CreateBasicBlock();
2773
2774 HControlInstruction* compare;
2775
2776 if (switch_type == SMI_SWITCH) {
2777 if (!clause->IsSmiCompare()) {
2778 // Finish with deoptimize and add uses of enviroment values to
2779 // account for invisible uses.
2780 current_block()->FinishExitWithDeoptimization(HDeoptimize::kUseAll);
2781 set_current_block(NULL);
2782 break;
2783 }
2784
2785 HCompareIDAndBranch* compare_ =
2786 new(zone()) HCompareIDAndBranch(tag_value,
2787 label_value,
2788 Token::EQ_STRICT);
2789 compare_->SetInputRepresentation(Representation::Integer32());
2790 compare = compare_;
2791 } else {
2792 compare = new(zone()) HStringCompareAndBranch(context, tag_value,
2793 label_value,
2794 Token::EQ_STRICT);
2795 }
2796
2797 compare->SetSuccessorAt(0, body_block); 2745 compare->SetSuccessorAt(0, body_block);
2798 compare->SetSuccessorAt(1, next_test_block); 2746 compare->SetSuccessorAt(1, next_test_block);
2799 current_block()->Finish(compare); 2747 current_block()->Finish(compare);
2800
2801 set_current_block(next_test_block); 2748 set_current_block(next_test_block);
2802 } 2749 }
2803 2750
2804 // Save the current block to use for the default or to join with the 2751 // Save the current block to use for the default or to join with the
2805 // exit. This block is NULL if we deoptimized. 2752 // exit. This block is NULL if we deoptimized.
2806 HBasicBlock* last_block = current_block(); 2753 HBasicBlock* last_block = current_block();
2807 2754
2808 if (not_string_block != NULL) { 2755 // 2. Loop over the clauses and the linked list of tests in lockstep,
2809 last_block = CreateJoin(last_block, not_string_block, stmt->ExitId());
2810 }
2811
2812 // 3. Loop over the clauses and the linked list of tests in lockstep,
2813 // translating the clause bodies. 2756 // translating the clause bodies.
2814 HBasicBlock* curr_test_block = first_test_block; 2757 HBasicBlock* curr_test_block = first_test_block;
2815 HBasicBlock* fall_through_block = NULL; 2758 HBasicBlock* fall_through_block = NULL;
2816
2817 BreakAndContinueInfo break_info(stmt); 2759 BreakAndContinueInfo break_info(stmt);
2818 { BreakAndContinueScope push(&break_info, this); 2760 { BreakAndContinueScope push(&break_info, this);
2819 for (int i = 0; i < clause_count; ++i) { 2761 for (int i = 0; i < clause_count; ++i) {
2820 CaseClause* clause = clauses->at(i); 2762 CaseClause* clause = clauses->at(i);
2821 2763
2822 // Identify the block where normal (non-fall-through) control flow 2764 // Identify the block where normal (non-fall-through) control flow
2823 // goes to. 2765 // goes to.
2824 HBasicBlock* normal_block = NULL; 2766 HBasicBlock* normal_block = NULL;
2825 if (clause->is_default()) { 2767 if (clause->is_default()) {
2826 if (last_block != NULL) { 2768 if (last_block != NULL) {
(...skipping 4264 matching lines...) Expand 10 before | Expand all | Expand 10 after
7091 } 7033 }
7092 } 7034 }
7093 7035
7094 #ifdef DEBUG 7036 #ifdef DEBUG
7095 if (graph_ != NULL) graph_->Verify(false); // No full verify. 7037 if (graph_ != NULL) graph_->Verify(false); // No full verify.
7096 if (allocator_ != NULL) allocator_->Verify(); 7038 if (allocator_ != NULL) allocator_->Verify();
7097 #endif 7039 #endif
7098 } 7040 }
7099 7041
7100 } } // namespace v8::internal 7042 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698