| 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 10 matching lines...) Expand all Loading... |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include "v8.h" | 28 #include "v8.h" |
| 29 | 29 |
| 30 #include "codegen-inl.h" | 30 #include "codegen-inl.h" |
| 31 #include "jump-target-inl.h" |
| 31 #include "register-allocator-inl.h" | 32 #include "register-allocator-inl.h" |
| 32 | 33 |
| 33 namespace v8 { namespace internal { | 34 namespace v8 { namespace internal { |
| 34 | 35 |
| 35 // ------------------------------------------------------------------------- | 36 // ------------------------------------------------------------------------- |
| 36 // JumpTarget implementation. | 37 // JumpTarget implementation. |
| 37 | 38 |
| 38 #define __ ACCESS_MASM(masm_) | 39 #define __ ACCESS_MASM(cgen()->masm()) |
| 39 | 40 |
| 40 void JumpTarget::DoJump() { | 41 void JumpTarget::DoJump() { |
| 41 ASSERT(cgen_ != NULL); | 42 ASSERT(cgen()->has_valid_frame()); |
| 42 ASSERT(cgen_->has_valid_frame()); | |
| 43 // Live non-frame registers are not allowed at unconditional jumps | 43 // Live non-frame registers are not allowed at unconditional jumps |
| 44 // because we have no way of invalidating the corresponding results | 44 // because we have no way of invalidating the corresponding results |
| 45 // which are still live in the C++ code. | 45 // which are still live in the C++ code. |
| 46 ASSERT(cgen_->HasValidEntryRegisters()); | 46 ASSERT(cgen()->HasValidEntryRegisters()); |
| 47 | 47 |
| 48 if (is_bound()) { | 48 if (is_bound()) { |
| 49 // Backward jump. There is an expected frame to merge to. | 49 // Backward jump. There is an expected frame to merge to. |
| 50 ASSERT(direction_ == BIDIRECTIONAL); | 50 ASSERT(direction_ == BIDIRECTIONAL); |
| 51 cgen_->frame()->MergeTo(entry_frame_); | 51 cgen()->frame()->MergeTo(entry_frame_); |
| 52 cgen_->DeleteFrame(); | 52 cgen()->DeleteFrame(); |
| 53 __ jmp(&entry_label_); | 53 __ jmp(&entry_label_); |
| 54 } else { | 54 } else { |
| 55 // Preconfigured entry frame is not used on ARM. | 55 // Preconfigured entry frame is not used on ARM. |
| 56 ASSERT(entry_frame_ == NULL); | 56 ASSERT(entry_frame_ == NULL); |
| 57 // Forward jump. The current frame is added to the end of the list | 57 // Forward jump. The current frame is added to the end of the list |
| 58 // of frames reaching the target block and a jump to the merge code | 58 // of frames reaching the target block and a jump to the merge code |
| 59 // is emitted. | 59 // is emitted. |
| 60 AddReachingFrame(cgen_->frame()); | 60 AddReachingFrame(cgen()->frame()); |
| 61 RegisterFile empty; | 61 RegisterFile empty; |
| 62 cgen_->SetFrame(NULL, &empty); | 62 cgen()->SetFrame(NULL, &empty); |
| 63 __ jmp(&merge_labels_.last()); | 63 __ jmp(&merge_labels_.last()); |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 | 67 |
| 68 void JumpTarget::DoBranch(Condition cc, Hint ignored) { | 68 void JumpTarget::DoBranch(Condition cc, Hint ignored) { |
| 69 ASSERT(cgen_ != NULL); | 69 ASSERT(cgen()->has_valid_frame()); |
| 70 ASSERT(cgen_->has_valid_frame()); | |
| 71 | 70 |
| 72 if (is_bound()) { | 71 if (is_bound()) { |
| 73 ASSERT(direction_ == BIDIRECTIONAL); | 72 ASSERT(direction_ == BIDIRECTIONAL); |
| 74 // Backward branch. We have an expected frame to merge to on the | 73 // Backward branch. We have an expected frame to merge to on the |
| 75 // backward edge. | 74 // backward edge. |
| 76 | 75 |
| 77 // Swap the current frame for a copy (we do the swapping to get | 76 // Swap the current frame for a copy (we do the swapping to get |
| 78 // the off-frame registers off the fall through) to use for the | 77 // the off-frame registers off the fall through) to use for the |
| 79 // branch. | 78 // branch. |
| 80 VirtualFrame* fall_through_frame = cgen_->frame(); | 79 VirtualFrame* fall_through_frame = cgen()->frame(); |
| 81 VirtualFrame* branch_frame = new VirtualFrame(fall_through_frame); | 80 VirtualFrame* branch_frame = new VirtualFrame(fall_through_frame); |
| 82 RegisterFile non_frame_registers = RegisterAllocator::Reserved(); | 81 RegisterFile non_frame_registers = RegisterAllocator::Reserved(); |
| 83 cgen_->SetFrame(branch_frame, &non_frame_registers); | 82 cgen()->SetFrame(branch_frame, &non_frame_registers); |
| 84 | 83 |
| 85 // Check if we can avoid merge code. | 84 // Check if we can avoid merge code. |
| 86 cgen_->frame()->PrepareMergeTo(entry_frame_); | 85 cgen()->frame()->PrepareMergeTo(entry_frame_); |
| 87 if (cgen_->frame()->Equals(entry_frame_)) { | 86 if (cgen()->frame()->Equals(entry_frame_)) { |
| 88 // Branch right in to the block. | 87 // Branch right in to the block. |
| 89 cgen_->DeleteFrame(); | 88 cgen()->DeleteFrame(); |
| 90 __ b(cc, &entry_label_); | 89 __ b(cc, &entry_label_); |
| 91 cgen_->SetFrame(fall_through_frame, &non_frame_registers); | 90 cgen()->SetFrame(fall_through_frame, &non_frame_registers); |
| 92 return; | 91 return; |
| 93 } | 92 } |
| 94 | 93 |
| 95 // Check if we can reuse existing merge code. | 94 // Check if we can reuse existing merge code. |
| 96 for (int i = 0; i < reaching_frames_.length(); i++) { | 95 for (int i = 0; i < reaching_frames_.length(); i++) { |
| 97 if (reaching_frames_[i] != NULL && | 96 if (reaching_frames_[i] != NULL && |
| 98 cgen_->frame()->Equals(reaching_frames_[i])) { | 97 cgen()->frame()->Equals(reaching_frames_[i])) { |
| 99 // Branch to the merge code. | 98 // Branch to the merge code. |
| 100 cgen_->DeleteFrame(); | 99 cgen()->DeleteFrame(); |
| 101 __ b(cc, &merge_labels_[i]); | 100 __ b(cc, &merge_labels_[i]); |
| 102 cgen_->SetFrame(fall_through_frame, &non_frame_registers); | 101 cgen()->SetFrame(fall_through_frame, &non_frame_registers); |
| 103 return; | 102 return; |
| 104 } | 103 } |
| 105 } | 104 } |
| 106 | 105 |
| 107 // To emit the merge code here, we negate the condition and branch | 106 // To emit the merge code here, we negate the condition and branch |
| 108 // around the merge code on the fall through path. | 107 // around the merge code on the fall through path. |
| 109 Label original_fall_through; | 108 Label original_fall_through; |
| 110 __ b(NegateCondition(cc), &original_fall_through); | 109 __ b(NegateCondition(cc), &original_fall_through); |
| 111 cgen_->frame()->MergeTo(entry_frame_); | 110 cgen()->frame()->MergeTo(entry_frame_); |
| 112 cgen_->DeleteFrame(); | 111 cgen()->DeleteFrame(); |
| 113 __ b(&entry_label_); | 112 __ b(&entry_label_); |
| 114 cgen_->SetFrame(fall_through_frame, &non_frame_registers); | 113 cgen()->SetFrame(fall_through_frame, &non_frame_registers); |
| 115 __ bind(&original_fall_through); | 114 __ bind(&original_fall_through); |
| 116 | 115 |
| 117 } else { | 116 } else { |
| 118 // Preconfigured entry frame is not used on ARM. | 117 // Preconfigured entry frame is not used on ARM. |
| 119 ASSERT(entry_frame_ == NULL); | 118 ASSERT(entry_frame_ == NULL); |
| 120 // Forward branch. A copy of the current frame is added to the end | 119 // Forward branch. A copy of the current frame is added to the end |
| 121 // of the list of frames reaching the target block and a branch to | 120 // of the list of frames reaching the target block and a branch to |
| 122 // the merge code is emitted. | 121 // the merge code is emitted. |
| 123 AddReachingFrame(new VirtualFrame(cgen_->frame())); | 122 AddReachingFrame(new VirtualFrame(cgen()->frame())); |
| 124 __ b(cc, &merge_labels_.last()); | 123 __ b(cc, &merge_labels_.last()); |
| 125 } | 124 } |
| 126 } | 125 } |
| 127 | 126 |
| 128 | 127 |
| 129 void JumpTarget::Call() { | 128 void JumpTarget::Call() { |
| 130 // Call is used to push the address of the catch block on the stack as | 129 // Call is used to push the address of the catch block on the stack as |
| 131 // a return address when compiling try/catch and try/finally. We | 130 // a return address when compiling try/catch and try/finally. We |
| 132 // fully spill the frame before making the call. The expected frame | 131 // fully spill the frame before making the call. The expected frame |
| 133 // at the label (which should be the only one) is the spilled current | 132 // at the label (which should be the only one) is the spilled current |
| 134 // frame plus an in-memory return address. The "fall-through" frame | 133 // frame plus an in-memory return address. The "fall-through" frame |
| 135 // at the return site is the spilled current frame. | 134 // at the return site is the spilled current frame. |
| 136 ASSERT(cgen_ != NULL); | 135 ASSERT(cgen()->has_valid_frame()); |
| 137 ASSERT(cgen_->has_valid_frame()); | |
| 138 // There are no non-frame references across the call. | 136 // There are no non-frame references across the call. |
| 139 ASSERT(cgen_->HasValidEntryRegisters()); | 137 ASSERT(cgen()->HasValidEntryRegisters()); |
| 140 ASSERT(!is_linked()); | 138 ASSERT(!is_linked()); |
| 141 | 139 |
| 142 cgen_->frame()->SpillAll(); | 140 cgen()->frame()->SpillAll(); |
| 143 VirtualFrame* target_frame = new VirtualFrame(cgen_->frame()); | 141 VirtualFrame* target_frame = new VirtualFrame(cgen()->frame()); |
| 144 target_frame->Adjust(1); | 142 target_frame->Adjust(1); |
| 145 // We do not expect a call with a preconfigured entry frame. | 143 // We do not expect a call with a preconfigured entry frame. |
| 146 ASSERT(entry_frame_ == NULL); | 144 ASSERT(entry_frame_ == NULL); |
| 147 AddReachingFrame(target_frame); | 145 AddReachingFrame(target_frame); |
| 148 __ bl(&merge_labels_.last()); | 146 __ bl(&merge_labels_.last()); |
| 149 } | 147 } |
| 150 | 148 |
| 151 | 149 |
| 152 void JumpTarget::DoBind(int mergable_elements) { | 150 void JumpTarget::DoBind(int mergable_elements) { |
| 153 ASSERT(cgen_ != NULL); | |
| 154 ASSERT(!is_bound()); | 151 ASSERT(!is_bound()); |
| 155 | 152 |
| 156 // Live non-frame registers are not allowed at the start of a basic | 153 // Live non-frame registers are not allowed at the start of a basic |
| 157 // block. | 154 // block. |
| 158 ASSERT(!cgen_->has_valid_frame() || cgen_->HasValidEntryRegisters()); | 155 ASSERT(!cgen()->has_valid_frame() || cgen()->HasValidEntryRegisters()); |
| 159 | 156 |
| 160 if (direction_ == FORWARD_ONLY) { | 157 if (direction_ == FORWARD_ONLY) { |
| 161 // A simple case: no forward jumps and no possible backward jumps. | 158 // A simple case: no forward jumps and no possible backward jumps. |
| 162 if (!is_linked()) { | 159 if (!is_linked()) { |
| 163 // The stack pointer can be floating above the top of the | 160 // The stack pointer can be floating above the top of the |
| 164 // virtual frame before the bind. Afterward, it should not. | 161 // virtual frame before the bind. Afterward, it should not. |
| 165 ASSERT(cgen_->has_valid_frame()); | 162 ASSERT(cgen()->has_valid_frame()); |
| 166 VirtualFrame* frame = cgen_->frame(); | 163 VirtualFrame* frame = cgen()->frame(); |
| 167 int difference = | 164 int difference = |
| 168 frame->stack_pointer_ - (frame->elements_.length() - 1); | 165 frame->stack_pointer_ - (frame->elements_.length() - 1); |
| 169 if (difference > 0) { | 166 if (difference > 0) { |
| 170 frame->stack_pointer_ -= difference; | 167 frame->stack_pointer_ -= difference; |
| 171 __ add(sp, sp, Operand(difference * kPointerSize)); | 168 __ add(sp, sp, Operand(difference * kPointerSize)); |
| 172 } | 169 } |
| 173 __ bind(&entry_label_); | 170 __ bind(&entry_label_); |
| 174 return; | 171 return; |
| 175 } | 172 } |
| 176 | 173 |
| 177 // Another simple case: no fall through, a single forward jump, | 174 // Another simple case: no fall through, a single forward jump, |
| 178 // and no possible backward jumps. | 175 // and no possible backward jumps. |
| 179 if (!cgen_->has_valid_frame() && reaching_frames_.length() == 1) { | 176 if (!cgen()->has_valid_frame() && reaching_frames_.length() == 1) { |
| 180 // Pick up the only reaching frame, take ownership of it, and | 177 // Pick up the only reaching frame, take ownership of it, and |
| 181 // use it for the block about to be emitted. | 178 // use it for the block about to be emitted. |
| 182 VirtualFrame* frame = reaching_frames_[0]; | 179 VirtualFrame* frame = reaching_frames_[0]; |
| 183 RegisterFile reserved = RegisterAllocator::Reserved(); | 180 RegisterFile reserved = RegisterAllocator::Reserved(); |
| 184 cgen_->SetFrame(frame, &reserved); | 181 cgen()->SetFrame(frame, &reserved); |
| 185 reaching_frames_[0] = NULL; | 182 reaching_frames_[0] = NULL; |
| 186 __ bind(&merge_labels_[0]); | 183 __ bind(&merge_labels_[0]); |
| 187 | 184 |
| 188 // The stack pointer can be floating above the top of the | 185 // The stack pointer can be floating above the top of the |
| 189 // virtual frame before the bind. Afterward, it should not. | 186 // virtual frame before the bind. Afterward, it should not. |
| 190 int difference = | 187 int difference = |
| 191 frame->stack_pointer_ - (frame->elements_.length() - 1); | 188 frame->stack_pointer_ - (frame->elements_.length() - 1); |
| 192 if (difference > 0) { | 189 if (difference > 0) { |
| 193 frame->stack_pointer_ -= difference; | 190 frame->stack_pointer_ -= difference; |
| 194 __ add(sp, sp, Operand(difference * kPointerSize)); | 191 __ add(sp, sp, Operand(difference * kPointerSize)); |
| 195 } | 192 } |
| 196 __ bind(&entry_label_); | 193 __ bind(&entry_label_); |
| 197 return; | 194 return; |
| 198 } | 195 } |
| 199 } | 196 } |
| 200 | 197 |
| 201 // If there is a current frame, record it as the fall-through. It | 198 // If there is a current frame, record it as the fall-through. It |
| 202 // is owned by the reaching frames for now. | 199 // is owned by the reaching frames for now. |
| 203 bool had_fall_through = false; | 200 bool had_fall_through = false; |
| 204 if (cgen_->has_valid_frame()) { | 201 if (cgen()->has_valid_frame()) { |
| 205 had_fall_through = true; | 202 had_fall_through = true; |
| 206 AddReachingFrame(cgen_->frame()); // Return value ignored. | 203 AddReachingFrame(cgen()->frame()); // Return value ignored. |
| 207 RegisterFile empty; | 204 RegisterFile empty; |
| 208 cgen_->SetFrame(NULL, &empty); | 205 cgen()->SetFrame(NULL, &empty); |
| 209 } | 206 } |
| 210 | 207 |
| 211 // Compute the frame to use for entry to the block. | 208 // Compute the frame to use for entry to the block. |
| 212 if (entry_frame_ == NULL) { | 209 if (entry_frame_ == NULL) { |
| 213 ComputeEntryFrame(mergable_elements); | 210 ComputeEntryFrame(mergable_elements); |
| 214 } | 211 } |
| 215 | 212 |
| 216 // Some moves required to merge to an expected frame require purely | 213 // Some moves required to merge to an expected frame require purely |
| 217 // frame state changes, and do not require any code generation. | 214 // frame state changes, and do not require any code generation. |
| 218 // Perform those first to increase the possibility of finding equal | 215 // Perform those first to increase the possibility of finding equal |
| (...skipping 16 matching lines...) Expand all Loading... |
| 235 for (int i = reaching_frames_.length() - 1; i >= 0; i--) { | 232 for (int i = reaching_frames_.length() - 1; i >= 0; i--) { |
| 236 VirtualFrame* frame = reaching_frames_[i]; | 233 VirtualFrame* frame = reaching_frames_[i]; |
| 237 | 234 |
| 238 if (frame != NULL) { | 235 if (frame != NULL) { |
| 239 // Does the frame (probably) need merge code? | 236 // Does the frame (probably) need merge code? |
| 240 if (!frame->Equals(entry_frame_)) { | 237 if (!frame->Equals(entry_frame_)) { |
| 241 // We could have a valid frame as the fall through to the | 238 // We could have a valid frame as the fall through to the |
| 242 // binding site or as the fall through from a previous merge | 239 // binding site or as the fall through from a previous merge |
| 243 // code block. Jump around the code we are about to | 240 // code block. Jump around the code we are about to |
| 244 // generate. | 241 // generate. |
| 245 if (cgen_->has_valid_frame()) { | 242 if (cgen()->has_valid_frame()) { |
| 246 cgen_->DeleteFrame(); | 243 cgen()->DeleteFrame(); |
| 247 __ b(&entry_label_); | 244 __ b(&entry_label_); |
| 248 } | 245 } |
| 249 // Pick up the frame for this block. Assume ownership if | 246 // Pick up the frame for this block. Assume ownership if |
| 250 // there cannot be backward jumps. | 247 // there cannot be backward jumps. |
| 251 RegisterFile reserved = RegisterAllocator::Reserved(); | 248 RegisterFile reserved = RegisterAllocator::Reserved(); |
| 252 if (direction_ == BIDIRECTIONAL) { | 249 if (direction_ == BIDIRECTIONAL) { |
| 253 cgen_->SetFrame(new VirtualFrame(frame), &reserved); | 250 cgen()->SetFrame(new VirtualFrame(frame), &reserved); |
| 254 } else { | 251 } else { |
| 255 cgen_->SetFrame(frame, &reserved); | 252 cgen()->SetFrame(frame, &reserved); |
| 256 reaching_frames_[i] = NULL; | 253 reaching_frames_[i] = NULL; |
| 257 } | 254 } |
| 258 __ bind(&merge_labels_[i]); | 255 __ bind(&merge_labels_[i]); |
| 259 | 256 |
| 260 // Loop over the remaining (non-null) reaching frames, | 257 // Loop over the remaining (non-null) reaching frames, |
| 261 // looking for any that can share merge code with this one. | 258 // looking for any that can share merge code with this one. |
| 262 for (int j = 0; j < i; j++) { | 259 for (int j = 0; j < i; j++) { |
| 263 VirtualFrame* other = reaching_frames_[j]; | 260 VirtualFrame* other = reaching_frames_[j]; |
| 264 if (other != NULL && other->Equals(cgen_->frame())) { | 261 if (other != NULL && other->Equals(cgen()->frame())) { |
| 265 // Set the reaching frame element to null to avoid | 262 // Set the reaching frame element to null to avoid |
| 266 // processing it later, and then bind its entry label. | 263 // processing it later, and then bind its entry label. |
| 267 reaching_frames_[j] = NULL; | 264 reaching_frames_[j] = NULL; |
| 268 __ bind(&merge_labels_[j]); | 265 __ bind(&merge_labels_[j]); |
| 269 } | 266 } |
| 270 } | 267 } |
| 271 | 268 |
| 272 // Emit the merge code. | 269 // Emit the merge code. |
| 273 cgen_->frame()->MergeTo(entry_frame_); | 270 cgen()->frame()->MergeTo(entry_frame_); |
| 274 } else if (i == reaching_frames_.length() - 1 && had_fall_through) { | 271 } else if (i == reaching_frames_.length() - 1 && had_fall_through) { |
| 275 // If this is the fall through, and it didn't need merge | 272 // If this is the fall through, and it didn't need merge |
| 276 // code, we need to pick up the frame so we can jump around | 273 // code, we need to pick up the frame so we can jump around |
| 277 // subsequent merge blocks if necessary. | 274 // subsequent merge blocks if necessary. |
| 278 RegisterFile reserved = RegisterAllocator::Reserved(); | 275 RegisterFile reserved = RegisterAllocator::Reserved(); |
| 279 cgen_->SetFrame(frame, &reserved); | 276 cgen()->SetFrame(frame, &reserved); |
| 280 reaching_frames_[i] = NULL; | 277 reaching_frames_[i] = NULL; |
| 281 } | 278 } |
| 282 } | 279 } |
| 283 } | 280 } |
| 284 | 281 |
| 285 // The code generator may not have a current frame if there was no | 282 // The code generator may not have a current frame if there was no |
| 286 // fall through and none of the reaching frames needed merging. | 283 // fall through and none of the reaching frames needed merging. |
| 287 // In that case, clone the entry frame as the current frame. | 284 // In that case, clone the entry frame as the current frame. |
| 288 if (!cgen_->has_valid_frame()) { | 285 if (!cgen()->has_valid_frame()) { |
| 289 RegisterFile reserved_registers = RegisterAllocator::Reserved(); | 286 RegisterFile reserved_registers = RegisterAllocator::Reserved(); |
| 290 cgen_->SetFrame(new VirtualFrame(entry_frame_), &reserved_registers); | 287 cgen()->SetFrame(new VirtualFrame(entry_frame_), &reserved_registers); |
| 291 } | 288 } |
| 292 | 289 |
| 293 // There may be unprocessed reaching frames that did not need | 290 // There may be unprocessed reaching frames that did not need |
| 294 // merge code. They will have unbound merge labels. Bind their | 291 // merge code. They will have unbound merge labels. Bind their |
| 295 // merge labels to be the same as the entry label and deallocate | 292 // merge labels to be the same as the entry label and deallocate |
| 296 // them. | 293 // them. |
| 297 for (int i = 0; i < reaching_frames_.length(); i++) { | 294 for (int i = 0; i < reaching_frames_.length(); i++) { |
| 298 if (!merge_labels_[i].is_bound()) { | 295 if (!merge_labels_[i].is_bound()) { |
| 299 reaching_frames_[i] = NULL; | 296 reaching_frames_[i] = NULL; |
| 300 __ bind(&merge_labels_[i]); | 297 __ bind(&merge_labels_[i]); |
| 301 } | 298 } |
| 302 } | 299 } |
| 303 | 300 |
| 304 // There are non-NULL reaching frames with bound labels for each | 301 // There are non-NULL reaching frames with bound labels for each |
| 305 // merge block, but only on backward targets. | 302 // merge block, but only on backward targets. |
| 306 } else { | 303 } else { |
| 307 // There were no forward jumps. There must be a current frame and | 304 // There were no forward jumps. There must be a current frame and |
| 308 // this must be a bidirectional target. | 305 // this must be a bidirectional target. |
| 309 ASSERT(reaching_frames_.length() == 1); | 306 ASSERT(reaching_frames_.length() == 1); |
| 310 ASSERT(reaching_frames_[0] != NULL); | 307 ASSERT(reaching_frames_[0] != NULL); |
| 311 ASSERT(direction_ == BIDIRECTIONAL); | 308 ASSERT(direction_ == BIDIRECTIONAL); |
| 312 | 309 |
| 313 // Use a copy of the reaching frame so the original can be saved | 310 // Use a copy of the reaching frame so the original can be saved |
| 314 // for possible reuse as a backward merge block. | 311 // for possible reuse as a backward merge block. |
| 315 RegisterFile reserved = RegisterAllocator::Reserved(); | 312 RegisterFile reserved = RegisterAllocator::Reserved(); |
| 316 cgen_->SetFrame(new VirtualFrame(reaching_frames_[0]), &reserved); | 313 cgen()->SetFrame(new VirtualFrame(reaching_frames_[0]), &reserved); |
| 317 __ bind(&merge_labels_[0]); | 314 __ bind(&merge_labels_[0]); |
| 318 cgen_->frame()->MergeTo(entry_frame_); | 315 cgen()->frame()->MergeTo(entry_frame_); |
| 319 } | 316 } |
| 320 | 317 |
| 321 __ bind(&entry_label_); | 318 __ bind(&entry_label_); |
| 322 } | 319 } |
| 323 | 320 |
| 324 #undef __ | 321 #undef __ |
| 325 | 322 |
| 326 | 323 |
| 327 } } // namespace v8::internal | 324 } } // namespace v8::internal |
| OLD | NEW |