OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 } | 98 } |
99 | 99 |
100 // Predicates testing the state of the encapsulated label. | 100 // Predicates testing the state of the encapsulated label. |
101 bool is_bound() const { return is_bound_; } | 101 bool is_bound() const { return is_bound_; } |
102 bool is_linked() const { return is_linked_; } | 102 bool is_linked() const { return is_linked_; } |
103 bool is_unused() const { return !is_bound() && !is_linked(); } | 103 bool is_unused() const { return !is_bound() && !is_linked(); } |
104 | 104 |
105 // Emit a jump to the target. There must be a current frame at the | 105 // Emit a jump to the target. There must be a current frame at the |
106 // jump and there will be no current frame after the jump. | 106 // jump and there will be no current frame after the jump. |
107 virtual void Jump(); | 107 virtual void Jump(); |
108 void Jump(Result* arg); | 108 virtual void Jump(Result* arg); |
109 void Jump(Result* arg0, Result* arg1); | 109 void Jump(Result* arg0, Result* arg1); |
110 void Jump(Result* arg0, Result* arg1, Result* arg2); | 110 void Jump(Result* arg0, Result* arg1, Result* arg2); |
111 | 111 |
112 // Emit a conditional branch to the target. There must be a current | 112 // Emit a conditional branch to the target. There must be a current |
113 // frame at the branch. The current frame will fall through to the | 113 // frame at the branch. The current frame will fall through to the |
114 // code after the branch. | 114 // code after the branch. |
115 virtual void Branch(Condition cc, Hint hint = no_hint); | 115 virtual void Branch(Condition cc, Hint hint = no_hint); |
116 void Branch(Condition cc, Result* arg, Hint hint = no_hint); | 116 virtual void Branch(Condition cc, Result* arg, Hint hint = no_hint); |
117 void Branch(Condition cc, Result* arg0, Result* arg1, Hint hint = no_hint); | 117 void Branch(Condition cc, Result* arg0, Result* arg1, Hint hint = no_hint); |
118 void Branch(Condition cc, | 118 void Branch(Condition cc, |
119 Result* arg0, | 119 Result* arg0, |
120 Result* arg1, | 120 Result* arg1, |
121 Result* arg2, | 121 Result* arg2, |
122 Hint hint = no_hint); | 122 Hint hint = no_hint); |
123 void Branch(Condition cc, | 123 void Branch(Condition cc, |
124 Result* arg0, | 124 Result* arg0, |
125 Result* arg1, | 125 Result* arg1, |
126 Result* arg2, | 126 Result* arg2, |
127 Result* arg3, | 127 Result* arg3, |
128 Hint hint = no_hint); | 128 Hint hint = no_hint); |
129 | 129 |
130 // Bind a jump target. If there is no current frame at the binding | 130 // Bind a jump target. If there is no current frame at the binding |
131 // site, there must be at least one frame reaching via a forward | 131 // site, there must be at least one frame reaching via a forward |
132 // jump. | 132 // jump. |
133 // | 133 // |
134 // The number of mergable elements is a number of frame elements | 134 // The number of mergable elements is a number of frame elements |
135 // counting from the top down which must be "mergable" (not | 135 // counting from the top down which must be "mergable" (not |
136 // constants or copies) in the entry frame at the jump target. | 136 // constants or copies) in the entry frame at the jump target. |
137 // Backward jumps to the target must contain the same constants and | 137 // Backward jumps to the target must contain the same constants and |
138 // sharing as the entry frame, except for the mergable elements. | 138 // sharing as the entry frame, except for the mergable elements. |
139 // | 139 // |
140 // A mergable elements argument of kAllElements indicates that all | 140 // A mergable elements argument of kAllElements indicates that all |
141 // frame elements must be mergable. Mergable elements are ignored | 141 // frame elements must be mergable. Mergable elements are ignored |
142 // completely for forward-only jump targets. | 142 // completely for forward-only jump targets. |
143 virtual void Bind(int mergable_elements = kAllElements); | 143 virtual void Bind(int mergable_elements = kAllElements); |
144 void Bind(Result* arg, int mergable_elements = kAllElements); | 144 virtual void Bind(Result* arg, int mergable_elements = kAllElements); |
145 void Bind(Result* arg0, Result* arg1, int mergable_elements = kAllElements); | 145 void Bind(Result* arg0, Result* arg1, int mergable_elements = kAllElements); |
146 void Bind(Result* arg0, | 146 void Bind(Result* arg0, |
147 Result* arg1, | 147 Result* arg1, |
148 Result* arg2, | 148 Result* arg2, |
149 int mergable_elements = kAllElements); | 149 int mergable_elements = kAllElements); |
150 void Bind(Result* arg0, | 150 void Bind(Result* arg0, |
151 Result* arg1, | 151 Result* arg1, |
152 Result* arg2, | 152 Result* arg2, |
153 Result* arg3, | 153 Result* arg3, |
154 int mergable_elements = kAllElements); | 154 int mergable_elements = kAllElements); |
(...skipping 29 matching lines...) Expand all Loading... |
184 | 184 |
185 // The actual entry label of the block. | 185 // The actual entry label of the block. |
186 Label entry_label_; | 186 Label entry_label_; |
187 | 187 |
188 // A target is bound if its Bind member function has been called. | 188 // A target is bound if its Bind member function has been called. |
189 // It is linked if it is not bound but its Jump, Branch, or Call | 189 // It is linked if it is not bound but its Jump, Branch, or Call |
190 // member functions have been called. | 190 // member functions have been called. |
191 bool is_bound_; | 191 bool is_bound_; |
192 bool is_linked_; | 192 bool is_linked_; |
193 | 193 |
| 194 // Implementations of Jump, Branch, and Bind with all arguments and |
| 195 // return values using the virtual frame. |
| 196 void DoJump(); |
| 197 void DoBranch(Condition cc, Hint hint); |
| 198 void DoBind(int mergable_elements); |
| 199 |
194 private: | 200 private: |
195 // Add a virtual frame reaching this labeled block via a forward | 201 // Add a virtual frame reaching this labeled block via a forward |
196 // jump, and a fresh label for its merge code. | 202 // jump, and a fresh label for its merge code. |
197 void AddReachingFrame(VirtualFrame* frame); | 203 void AddReachingFrame(VirtualFrame* frame); |
198 | 204 |
199 // Choose an element from a pair of frame elements to be in the | 205 // Choose an element from a pair of frame elements to be in the |
200 // expected frame. Return null if they are incompatible. | 206 // expected frame. Return null if they are incompatible. |
201 FrameElement* Combine(FrameElement* left, FrameElement* right); | 207 FrameElement* Combine(FrameElement* left, FrameElement* right); |
202 | 208 |
203 // Compute a frame to use for entry to this block. Mergable | 209 // Compute a frame to use for entry to this block. Mergable |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 // Copy the state of this break target to the destination. The | 242 // Copy the state of this break target to the destination. The |
237 // lists of forward-reaching frames and merge-point labels are | 243 // lists of forward-reaching frames and merge-point labels are |
238 // copied. All virtual frame pointers are copied, not the | 244 // copied. All virtual frame pointers are copied, not the |
239 // pointed-to frames. The previous state of the destination is | 245 // pointed-to frames. The previous state of the destination is |
240 // overwritten, without deallocating pointed-to virtual frames. | 246 // overwritten, without deallocating pointed-to virtual frames. |
241 void CopyTo(BreakTarget* destination); | 247 void CopyTo(BreakTarget* destination); |
242 | 248 |
243 // Emit a jump to the target. There must be a current frame at the | 249 // Emit a jump to the target. There must be a current frame at the |
244 // jump and there will be no current frame after the jump. | 250 // jump and there will be no current frame after the jump. |
245 virtual void Jump(); | 251 virtual void Jump(); |
| 252 virtual void Jump(Result* arg); |
246 | 253 |
247 // Emit a conditional branch to the target. There must be a current | 254 // Emit a conditional branch to the target. There must be a current |
248 // frame at the branch. The current frame will fall through to the | 255 // frame at the branch. The current frame will fall through to the |
249 // code after the branch. | 256 // code after the branch. |
250 virtual void Branch(Condition cc, Hint hint = no_hint); | 257 virtual void Branch(Condition cc, Hint hint = no_hint); |
| 258 virtual void Branch(Condition cc, Result* arg, Hint hint = no_hint); |
251 | 259 |
252 // Bind a break target. If there is no current frame at the binding | 260 // Bind a break target. If there is no current frame at the binding |
253 // site, there must be at least one frame reaching via a forward | 261 // site, there must be at least one frame reaching via a forward |
254 // jump. | 262 // jump. |
255 virtual void Bind(int mergable_elements = kAllElements); | 263 virtual void Bind(int mergable_elements = kAllElements); |
| 264 virtual void Bind(Result* arg, int mergable_elements = kAllElements); |
256 | 265 |
257 // Setter for expected height. | 266 // Setter for expected height. |
258 void set_expected_height(int expected) { expected_height_ = expected; } | 267 void set_expected_height(int expected) { expected_height_ = expected; } |
259 | 268 |
260 private: | 269 private: |
261 // The expected height of the expression stack where the target will | 270 // The expected height of the expression stack where the target will |
262 // be bound, statically known at initialization time. | 271 // be bound, statically known at initialization time. |
263 int expected_height_; | 272 int expected_height_; |
264 | 273 |
265 DISALLOW_COPY_AND_ASSIGN(BreakTarget); | 274 DISALLOW_COPY_AND_ASSIGN(BreakTarget); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 bool is_shadowing_; | 316 bool is_shadowing_; |
308 #endif | 317 #endif |
309 | 318 |
310 DISALLOW_COPY_AND_ASSIGN(ShadowTarget); | 319 DISALLOW_COPY_AND_ASSIGN(ShadowTarget); |
311 }; | 320 }; |
312 | 321 |
313 | 322 |
314 } } // namespace v8::internal | 323 } } // namespace v8::internal |
315 | 324 |
316 #endif // V8_JUMP_TARGET_H_ | 325 #endif // V8_JUMP_TARGET_H_ |
OLD | NEW |