Chromium Code Reviews| 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/compiler/control-builders.h" | 5 #include "src/compiler/control-builders.h" |
| 6 | 6 |
| 7 namespace v8 { | 7 namespace v8 { |
| 8 namespace internal { | 8 namespace internal { |
| 9 namespace compiler { | 9 namespace compiler { |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 void IfBuilder::End() { | 29 void IfBuilder::End() { |
| 30 then_environment_->Merge(environment()); | 30 then_environment_->Merge(environment()); |
| 31 set_environment(then_environment_); | 31 set_environment(then_environment_); |
| 32 } | 32 } |
| 33 | 33 |
| 34 | 34 |
| 35 void LoopBuilder::BeginLoop(BitVector* assigned, bool is_osr) { | 35 void LoopBuilder::BeginLoop(BitVector* assigned, bool is_osr) { |
| 36 loop_environment_ = environment()->CopyForLoop(assigned, is_osr); | 36 loop_environment_ = environment()->CopyForLoop(assigned, is_osr); |
| 37 continue_environment_ = environment()->CopyAsUnreachable(); | 37 continue_environment_ = environment()->CopyAsUnreachable(); |
| 38 break_environment_ = environment()->CopyAsUnreachable(); | 38 break_environment_ = environment()->CopyAsUnreachable(); |
| 39 assigned_ = assigned; | |
| 39 } | 40 } |
| 40 | 41 |
| 41 | 42 |
| 42 void LoopBuilder::Continue() { | 43 void LoopBuilder::Continue() { |
| 43 continue_environment_->Merge(environment()); | 44 continue_environment_->Merge(environment()); |
| 44 environment()->MarkAsUnreachable(); | 45 environment()->MarkAsUnreachable(); |
| 45 } | 46 } |
| 46 | 47 |
| 47 | 48 |
| 48 void LoopBuilder::Break() { | 49 void LoopBuilder::Break() { |
| 49 break_environment_->Merge(environment()); | 50 break_environment_->Merge(environment()); |
| 50 environment()->MarkAsUnreachable(); | 51 environment()->MarkAsUnreachable(); |
| 51 } | 52 } |
| 52 | 53 |
| 53 | 54 |
| 54 void LoopBuilder::EndBody() { | 55 void LoopBuilder::EndBody() { |
| 55 continue_environment_->Merge(environment()); | 56 continue_environment_->Merge(environment()); |
| 56 set_environment(continue_environment_); | 57 set_environment(continue_environment_); |
| 57 } | 58 } |
| 58 | 59 |
| 59 | 60 |
| 60 void LoopBuilder::EndLoop() { | 61 void LoopBuilder::EndLoop() { |
| 61 loop_environment_->Merge(environment()); | 62 loop_environment_->Merge(environment()); |
| 62 set_environment(break_environment_); | 63 set_environment(break_environment_); |
| 64 ExitLoop(); | |
| 63 } | 65 } |
| 64 | 66 |
| 65 | 67 |
| 66 void LoopBuilder::BreakUnless(Node* condition) { | 68 void LoopBuilder::BreakUnless(Node* condition) { |
| 67 IfBuilder control_if(builder_); | 69 IfBuilder control_if(builder_); |
| 68 control_if.If(condition); | 70 control_if.If(condition); |
| 69 control_if.Then(); | 71 control_if.Then(); |
| 70 control_if.Else(); | 72 control_if.Else(); |
| 71 Break(); | 73 Break(); |
| 72 control_if.End(); | 74 control_if.End(); |
| 73 } | 75 } |
| 74 | 76 |
| 75 | 77 |
| 76 void LoopBuilder::BreakWhen(Node* condition) { | 78 void LoopBuilder::BreakWhen(Node* condition) { |
| 77 IfBuilder control_if(builder_); | 79 IfBuilder control_if(builder_); |
| 78 control_if.If(condition); | 80 control_if.If(condition); |
| 79 control_if.Then(); | 81 control_if.Then(); |
| 80 Break(); | 82 Break(); |
| 81 control_if.Else(); | 83 control_if.Else(); |
| 82 control_if.End(); | 84 control_if.End(); |
| 83 } | 85 } |
| 84 | 86 |
| 87 void LoopBuilder::ExitLoop(Node** extra_value_to_rename) { | |
| 88 if (environment()->IsMarkedAsUnreachable()) return; | |
|
Michael Starzinger
2016/07/14 12:13:36
Please move the unreachability check into Environm
Jarin
2016/07/14 12:51:34
Done.
| |
| 89 builder_->BuildLoopExit(loop_environment_->GetControlDependency(), assigned_, | |
| 90 extra_value_to_rename); | |
| 91 } | |
| 85 | 92 |
| 86 void SwitchBuilder::BeginSwitch() { | 93 void SwitchBuilder::BeginSwitch() { |
| 87 body_environment_ = environment()->CopyAsUnreachable(); | 94 body_environment_ = environment()->CopyAsUnreachable(); |
| 88 label_environment_ = environment()->CopyAsUnreachable(); | 95 label_environment_ = environment()->CopyAsUnreachable(); |
| 89 break_environment_ = environment()->CopyAsUnreachable(); | 96 break_environment_ = environment()->CopyAsUnreachable(); |
| 90 } | 97 } |
| 91 | 98 |
| 92 | 99 |
| 93 void SwitchBuilder::BeginLabel(int index, Node* condition) { | 100 void SwitchBuilder::BeginLabel(int index, Node* condition) { |
| 94 builder_->NewBranch(condition); | 101 builder_->NewBranch(condition); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 223 } | 230 } |
| 224 | 231 |
| 225 | 232 |
| 226 void TryFinallyBuilder::EndFinally() { | 233 void TryFinallyBuilder::EndFinally() { |
| 227 // Nothing to be done here. | 234 // Nothing to be done here. |
| 228 } | 235 } |
| 229 | 236 |
| 230 } // namespace compiler | 237 } // namespace compiler |
| 231 } // namespace internal | 238 } // namespace internal |
| 232 } // namespace v8 | 239 } // namespace v8 |
| OLD | NEW |