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

Side by Side Diff: src/hydrogen.cc

Issue 22876009: Improve and simplify removal of unreachable code (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review feedback Created 7 years, 2 months 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-deoptimizing-mark.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 21 matching lines...) Expand all
32 #include "v8.h" 32 #include "v8.h"
33 #include "codegen.h" 33 #include "codegen.h"
34 #include "full-codegen.h" 34 #include "full-codegen.h"
35 #include "hashmap.h" 35 #include "hashmap.h"
36 #include "hydrogen-bce.h" 36 #include "hydrogen-bce.h"
37 #include "hydrogen-bch.h" 37 #include "hydrogen-bch.h"
38 #include "hydrogen-canonicalize.h" 38 #include "hydrogen-canonicalize.h"
39 #include "hydrogen-check-elimination.h" 39 #include "hydrogen-check-elimination.h"
40 #include "hydrogen-dce.h" 40 #include "hydrogen-dce.h"
41 #include "hydrogen-dehoist.h" 41 #include "hydrogen-dehoist.h"
42 #include "hydrogen-deoptimizing-mark.h"
43 #include "hydrogen-environment-liveness.h" 42 #include "hydrogen-environment-liveness.h"
44 #include "hydrogen-escape-analysis.h" 43 #include "hydrogen-escape-analysis.h"
45 #include "hydrogen-infer-representation.h" 44 #include "hydrogen-infer-representation.h"
46 #include "hydrogen-infer-types.h" 45 #include "hydrogen-infer-types.h"
47 #include "hydrogen-load-elimination.h" 46 #include "hydrogen-load-elimination.h"
48 #include "hydrogen-gvn.h" 47 #include "hydrogen-gvn.h"
49 #include "hydrogen-mark-deoptimize.h" 48 #include "hydrogen-mark-deoptimize.h"
49 #include "hydrogen-mark-unreachable.h"
50 #include "hydrogen-minus-zero.h" 50 #include "hydrogen-minus-zero.h"
51 #include "hydrogen-osr.h" 51 #include "hydrogen-osr.h"
52 #include "hydrogen-range-analysis.h" 52 #include "hydrogen-range-analysis.h"
53 #include "hydrogen-redundant-phi.h" 53 #include "hydrogen-redundant-phi.h"
54 #include "hydrogen-removable-simulates.h" 54 #include "hydrogen-removable-simulates.h"
55 #include "hydrogen-representation-changes.h" 55 #include "hydrogen-representation-changes.h"
56 #include "hydrogen-sce.h" 56 #include "hydrogen-sce.h"
57 #include "hydrogen-uint32-analysis.h" 57 #include "hydrogen-uint32-analysis.h"
58 #include "lithium-allocator.h" 58 #include "lithium-allocator.h"
59 #include "parser.h" 59 #include "parser.h"
(...skipping 29 matching lines...) Expand all
89 dominator_(NULL), 89 dominator_(NULL),
90 dominated_blocks_(4, graph->zone()), 90 dominated_blocks_(4, graph->zone()),
91 last_environment_(NULL), 91 last_environment_(NULL),
92 argument_count_(-1), 92 argument_count_(-1),
93 first_instruction_index_(-1), 93 first_instruction_index_(-1),
94 last_instruction_index_(-1), 94 last_instruction_index_(-1),
95 deleted_phis_(4, graph->zone()), 95 deleted_phis_(4, graph->zone()),
96 parent_loop_header_(NULL), 96 parent_loop_header_(NULL),
97 inlined_entry_block_(NULL), 97 inlined_entry_block_(NULL),
98 is_inline_return_target_(false), 98 is_inline_return_target_(false),
99 is_deoptimizing_(false), 99 is_reachable_(true),
100 dominates_loop_successors_(false), 100 dominates_loop_successors_(false),
101 is_osr_entry_(false) { } 101 is_osr_entry_(false) { }
102 102
103 103
104 Isolate* HBasicBlock::isolate() const { 104 Isolate* HBasicBlock::isolate() const {
105 return graph_->isolate(); 105 return graph_->isolate();
106 } 106 }
107 107
108 108
109 void HBasicBlock::MarkUnreachable() {
110 is_reachable_ = false;
111 }
112
113
109 void HBasicBlock::AttachLoopInformation() { 114 void HBasicBlock::AttachLoopInformation() {
110 ASSERT(!IsLoopHeader()); 115 ASSERT(!IsLoopHeader());
111 loop_information_ = new(zone()) HLoopInformation(this, zone()); 116 loop_information_ = new(zone()) HLoopInformation(this, zone());
112 } 117 }
113 118
114 119
115 void HBasicBlock::DetachLoopInformation() { 120 void HBasicBlock::DetachLoopInformation() {
116 ASSERT(IsLoopHeader()); 121 ASSERT(IsLoopHeader());
117 loop_information_ = NULL; 122 loop_information_ = NULL;
118 } 123 }
(...skipping 2157 matching lines...) Expand 10 before | Expand all | Expand 10 after
2276 entry_block_(NULL), 2281 entry_block_(NULL),
2277 blocks_(8, info->zone()), 2282 blocks_(8, info->zone()),
2278 values_(16, info->zone()), 2283 values_(16, info->zone()),
2279 phi_list_(NULL), 2284 phi_list_(NULL),
2280 uint32_instructions_(NULL), 2285 uint32_instructions_(NULL),
2281 osr_(NULL), 2286 osr_(NULL),
2282 info_(info), 2287 info_(info),
2283 zone_(info->zone()), 2288 zone_(info->zone()),
2284 is_recursive_(false), 2289 is_recursive_(false),
2285 use_optimistic_licm_(false), 2290 use_optimistic_licm_(false),
2286 has_soft_deoptimize_(false),
2287 depends_on_empty_array_proto_elements_(false), 2291 depends_on_empty_array_proto_elements_(false),
2288 type_change_checksum_(0), 2292 type_change_checksum_(0),
2289 maximum_environment_size_(0), 2293 maximum_environment_size_(0),
2290 no_side_effects_scope_count_(0) { 2294 no_side_effects_scope_count_(0) {
2291 if (info->IsStub()) { 2295 if (info->IsStub()) {
2292 HydrogenCodeStub* stub = info->code_stub(); 2296 HydrogenCodeStub* stub = info->code_stub();
2293 CodeStubInterfaceDescriptor* descriptor = 2297 CodeStubInterfaceDescriptor* descriptor =
2294 stub->GetInterfaceDescriptor(isolate_); 2298 stub->GetInterfaceDescriptor(isolate_);
2295 start_environment_ = 2299 start_environment_ =
2296 new(zone_) HEnvironment(zone_, descriptor->environment_length()); 2300 new(zone_) HEnvironment(zone_, descriptor->environment_length());
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
3123 3127
3124 #ifdef DEBUG 3128 #ifdef DEBUG
3125 // Do a full verify after building the graph and computing dominators. 3129 // Do a full verify after building the graph and computing dominators.
3126 Verify(true); 3130 Verify(true);
3127 #endif 3131 #endif
3128 3132
3129 if (FLAG_analyze_environment_liveness && maximum_environment_size() != 0) { 3133 if (FLAG_analyze_environment_liveness && maximum_environment_size() != 0) {
3130 Run<HEnvironmentLivenessAnalysisPhase>(); 3134 Run<HEnvironmentLivenessAnalysisPhase>();
3131 } 3135 }
3132 3136
3133 Run<HPropagateDeoptimizingMarkPhase>();
3134 if (!CheckConstPhiUses()) { 3137 if (!CheckConstPhiUses()) {
3135 *bailout_reason = kUnsupportedPhiUseOfConstVariable; 3138 *bailout_reason = kUnsupportedPhiUseOfConstVariable;
3136 return false; 3139 return false;
3137 } 3140 }
3138 Run<HRedundantPhiEliminationPhase>(); 3141 Run<HRedundantPhiEliminationPhase>();
3139 if (!CheckArgumentsPhiUses()) { 3142 if (!CheckArgumentsPhiUses()) {
3140 *bailout_reason = kUnsupportedPhiUseOfArguments; 3143 *bailout_reason = kUnsupportedPhiUseOfArguments;
3141 return false; 3144 return false;
3142 } 3145 }
3143 3146
3147 // Find and mark unreachable code to simplify optimizations, especially gvn,
3148 // where unreachable code could unnecessarily defeat LICM.
3149 Run<HMarkUnreachableBlocksPhase>();
3150
3144 if (FLAG_check_elimination) Run<HCheckEliminationPhase>(); 3151 if (FLAG_check_elimination) Run<HCheckEliminationPhase>();
3145 if (FLAG_dead_code_elimination) Run<HDeadCodeEliminationPhase>(); 3152 if (FLAG_dead_code_elimination) Run<HDeadCodeEliminationPhase>();
3146 if (FLAG_use_escape_analysis) Run<HEscapeAnalysisPhase>(); 3153 if (FLAG_use_escape_analysis) Run<HEscapeAnalysisPhase>();
3147 3154
3148 if (FLAG_load_elimination) Run<HLoadEliminationPhase>(); 3155 if (FLAG_load_elimination) Run<HLoadEliminationPhase>();
3149 3156
3150 CollectPhis(); 3157 CollectPhis();
3151 3158
3152 if (has_osr()) osr()->FinishOsrValues(); 3159 if (has_osr()) osr()->FinishOsrValues();
3153 3160
(...skipping 26 matching lines...) Expand all
3180 // Eliminate redundant stack checks on backwards branches. 3187 // Eliminate redundant stack checks on backwards branches.
3181 Run<HStackCheckEliminationPhase>(); 3188 Run<HStackCheckEliminationPhase>();
3182 3189
3183 if (FLAG_array_bounds_checks_elimination) Run<HBoundsCheckEliminationPhase>(); 3190 if (FLAG_array_bounds_checks_elimination) Run<HBoundsCheckEliminationPhase>();
3184 if (FLAG_array_bounds_checks_hoisting) Run<HBoundsCheckHoistingPhase>(); 3191 if (FLAG_array_bounds_checks_hoisting) Run<HBoundsCheckHoistingPhase>();
3185 if (FLAG_array_index_dehoisting) Run<HDehoistIndexComputationsPhase>(); 3192 if (FLAG_array_index_dehoisting) Run<HDehoistIndexComputationsPhase>();
3186 if (FLAG_dead_code_elimination) Run<HDeadCodeEliminationPhase>(); 3193 if (FLAG_dead_code_elimination) Run<HDeadCodeEliminationPhase>();
3187 3194
3188 RestoreActualValues(); 3195 RestoreActualValues();
3189 3196
3197 // Find unreachable code a second time, GVN and other optimizations may have
3198 // made blocks unreachable that were previously reachable.
3199 Run<HMarkUnreachableBlocksPhase>();
3200
3190 return true; 3201 return true;
3191 } 3202 }
3192 3203
3193 3204
3194 void HGraph::RestoreActualValues() { 3205 void HGraph::RestoreActualValues() {
3195 HPhase phase("H_Restore actual values", this); 3206 HPhase phase("H_Restore actual values", this);
3196 3207
3197 for (int block_index = 0; block_index < blocks()->length(); block_index++) { 3208 for (int block_index = 0; block_index < blocks()->length(); block_index++) {
3198 HBasicBlock* block = blocks()->at(block_index); 3209 HBasicBlock* block = blocks()->at(block_index);
3199 3210
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
3614 3625
3615 // Identify the block where normal (non-fall-through) control flow 3626 // Identify the block where normal (non-fall-through) control flow
3616 // goes to. 3627 // goes to.
3617 HBasicBlock* normal_block = NULL; 3628 HBasicBlock* normal_block = NULL;
3618 if (clause->is_default()) { 3629 if (clause->is_default()) {
3619 if (last_block != NULL) { 3630 if (last_block != NULL) {
3620 normal_block = last_block; 3631 normal_block = last_block;
3621 last_block = NULL; // Cleared to indicate we've handled it. 3632 last_block = NULL; // Cleared to indicate we've handled it.
3622 } 3633 }
3623 } else { 3634 } else {
3635 // If the current test block is deoptimizing due to an unhandled clause
3636 // of the switch, the test instruction is in the next block since the
3637 // deopt must end the current block.
3638 if (curr_test_block->IsDeoptimizing()) {
3639 ASSERT(curr_test_block->end()->SecondSuccessor() == NULL);
3640 curr_test_block = curr_test_block->end()->FirstSuccessor();
3641 }
3624 normal_block = curr_test_block->end()->FirstSuccessor(); 3642 normal_block = curr_test_block->end()->FirstSuccessor();
3625 curr_test_block = curr_test_block->end()->SecondSuccessor(); 3643 curr_test_block = curr_test_block->end()->SecondSuccessor();
3626 } 3644 }
3627 3645
3628 // Identify a block to emit the body into. 3646 // Identify a block to emit the body into.
3629 if (normal_block == NULL) { 3647 if (normal_block == NULL) {
3630 if (fall_through_block == NULL) { 3648 if (fall_through_block == NULL) {
3631 // (a) Unreachable. 3649 // (a) Unreachable.
3632 if (clause->is_default()) { 3650 if (clause->is_default()) {
3633 continue; // Might still be reachable clause bodies. 3651 continue; // Might still be reachable clause bodies.
(...skipping 6195 matching lines...) Expand 10 before | Expand all | Expand 10 after
9829 if (ShouldProduceTraceOutput()) { 9847 if (ShouldProduceTraceOutput()) {
9830 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 9848 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
9831 } 9849 }
9832 9850
9833 #ifdef DEBUG 9851 #ifdef DEBUG
9834 graph_->Verify(false); // No full verify. 9852 graph_->Verify(false); // No full verify.
9835 #endif 9853 #endif
9836 } 9854 }
9837 9855
9838 } } // namespace v8::internal 9856 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-deoptimizing-mark.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698