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

Side by Side Diff: src/compiler/control-builders.cc

Issue 426233002: Land the Fan (disabled) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "control-builders.h"
6
7 namespace v8 {
8 namespace internal {
9 namespace compiler {
10
11
12 void IfBuilder::If(Node* condition) {
13 builder_->NewBranch(condition);
14 else_environment_ = environment()->CopyForConditional();
15 }
16
17
18 void IfBuilder::Then() {
19 builder_->NewIfTrue();
20 }
21
22
23 void IfBuilder::Else() {
24 builder_->NewMerge();
25 then_environment_ = environment();
26 set_environment(else_environment_);
27 builder_->NewIfFalse();
28 }
29
30
31 void IfBuilder::End() {
32 then_environment_->Merge(environment());
33 set_environment(then_environment_);
34 }
35
36
37 void LoopBuilder::BeginLoop() {
38 builder_->NewLoop();
39 loop_environment_ = environment()->CopyForLoop();
40 continue_environment_ = environment()->CopyAsUnreachable();
41 break_environment_ = environment()->CopyAsUnreachable();
42 }
43
44
45 void LoopBuilder::Continue() {
46 continue_environment_->Merge(environment());
47 environment()->MarkAsUnreachable();
48 }
49
50
51 void LoopBuilder::Break() {
52 break_environment_->Merge(environment());
53 environment()->MarkAsUnreachable();
54 }
55
56
57 void LoopBuilder::EndBody() {
58 continue_environment_->Merge(environment());
59 set_environment(continue_environment_);
60 }
61
62
63 void LoopBuilder::EndLoop() {
64 loop_environment_->Merge(environment());
65 set_environment(break_environment_);
66 }
67
68
69 void LoopBuilder::BreakUnless(Node* condition) {
70 IfBuilder control_if(builder_);
71 control_if.If(condition);
72 control_if.Then();
73 control_if.Else();
74 Break();
75 control_if.End();
76 }
77
78
79 void SwitchBuilder::BeginSwitch() {
80 body_environment_ = environment()->CopyAsUnreachable();
81 label_environment_ = environment()->CopyAsUnreachable();
82 break_environment_ = environment()->CopyAsUnreachable();
83 body_environments_.AddBlock(NULL, case_count(), zone());
84 }
85
86
87 void SwitchBuilder::BeginLabel(int index, Node* condition) {
88 builder_->NewBranch(condition);
89 label_environment_ = environment()->CopyForConditional();
90 builder_->NewIfTrue();
91 body_environments_[index] = environment();
92 }
93
94
95 void SwitchBuilder::EndLabel() {
96 set_environment(label_environment_);
97 builder_->NewIfFalse();
98 }
99
100
101 void SwitchBuilder::DefaultAt(int index) {
102 label_environment_ = environment()->CopyAsUnreachable();
103 body_environments_[index] = environment();
104 }
105
106
107 void SwitchBuilder::BeginCase(int index) {
108 set_environment(body_environments_[index]);
109 environment()->Merge(body_environment_);
110 }
111
112
113 void SwitchBuilder::Break() {
114 break_environment_->Merge(environment());
115 environment()->MarkAsUnreachable();
116 }
117
118
119 void SwitchBuilder::EndCase() {
120 body_environment_ = environment();
121 }
122
123
124 void SwitchBuilder::EndSwitch() {
125 break_environment_->Merge(label_environment_);
126 break_environment_->Merge(environment());
127 set_environment(break_environment_);
128 }
129
130
131 void BlockBuilder::BeginBlock() {
132 break_environment_ = environment()->CopyAsUnreachable();
133 }
134
135
136 void BlockBuilder::Break() {
137 break_environment_->Merge(environment());
138 environment()->MarkAsUnreachable();
139 }
140
141
142 void BlockBuilder::EndBlock() {
143 break_environment_->Merge(environment());
144 set_environment(break_environment_);
145 }
146
147
148 } } } // namespace v8::internal::compiler
OLDNEW
« no previous file with comments | « src/compiler/control-builders.h ('k') | src/compiler/frame.h » ('j') | src/lithium-inl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698