| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 ASSERT(cgen != NULL); | 60 ASSERT(cgen != NULL); |
| 61 ASSERT(cgen_ == NULL); | 61 ASSERT(cgen_ == NULL); |
| 62 cgen_ = cgen; | 62 cgen_ = cgen; |
| 63 masm_ = cgen->masm(); | 63 masm_ = cgen->masm(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 | 66 |
| 67 void JumpTarget::Jump() { | 67 void JumpTarget::Jump() { |
| 68 ASSERT(cgen_ != NULL); | 68 ASSERT(cgen_ != NULL); |
| 69 ASSERT(cgen_->has_valid_frame()); | 69 ASSERT(cgen_->has_valid_frame()); |
| 70 ASSERT(!cgen_->has_cc()); | |
| 71 // Live non-frame registers are not allowed at unconditional jumps | 70 // Live non-frame registers are not allowed at unconditional jumps |
| 72 // because we have no way of invalidating the corresponding results | 71 // because we have no way of invalidating the corresponding results |
| 73 // which are still live in the C++ code. | 72 // which are still live in the C++ code. |
| 74 ASSERT(cgen_->HasValidEntryRegisters()); | 73 ASSERT(cgen_->HasValidEntryRegisters()); |
| 75 | 74 |
| 76 if (is_bound()) { | 75 if (is_bound()) { |
| 77 // Backward jump. There is an expected frame to merge to. | 76 // Backward jump. There is an expected frame to merge to. |
| 78 cgen_->frame()->MergeTo(expected_frame_); | 77 cgen_->frame()->MergeTo(expected_frame_); |
| 79 cgen_->DeleteFrame(); | 78 cgen_->DeleteFrame(); |
| 80 __ jmp(&entry_label_); | 79 __ jmp(&entry_label_); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 105 | 104 |
| 106 cgen_->frame()->Push(arg0); | 105 cgen_->frame()->Push(arg0); |
| 107 cgen_->frame()->Push(arg1); | 106 cgen_->frame()->Push(arg1); |
| 108 Jump(); | 107 Jump(); |
| 109 } | 108 } |
| 110 | 109 |
| 111 | 110 |
| 112 void JumpTarget::Branch(Condition cc, Hint hint) { | 111 void JumpTarget::Branch(Condition cc, Hint hint) { |
| 113 ASSERT(cgen_ != NULL); | 112 ASSERT(cgen_ != NULL); |
| 114 ASSERT(cgen_->has_valid_frame()); | 113 ASSERT(cgen_->has_valid_frame()); |
| 115 ASSERT(!cgen_->has_cc()); | |
| 116 | 114 |
| 117 if (is_bound()) { | 115 if (is_bound()) { |
| 118 // Backward branch. We have an expected frame to merge to on the | 116 // Backward branch. We have an expected frame to merge to on the |
| 119 // backward edge. We negate the condition and emit the merge code | 117 // backward edge. We negate the condition and emit the merge code |
| 120 // here. | 118 // here. |
| 121 // | 119 // |
| 122 // TODO(): we should try to avoid negating the condition in the case | 120 // TODO(): we should try to avoid negating the condition in the case |
| 123 // where there is no merge code to emit. Otherwise, we emit a | 121 // where there is no merge code to emit. Otherwise, we emit a |
| 124 // branch around an unconditional jump. | 122 // branch around an unconditional jump. |
| 125 Label original_fall_through; | 123 Label original_fall_through; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 | 205 |
| 208 void JumpTarget::Call() { | 206 void JumpTarget::Call() { |
| 209 // Call is used to push the address of the catch block on the stack as | 207 // Call is used to push the address of the catch block on the stack as |
| 210 // a return address when compiling try/catch and try/finally. We | 208 // a return address when compiling try/catch and try/finally. We |
| 211 // fully spill the frame before making the call. The expected frame | 209 // fully spill the frame before making the call. The expected frame |
| 212 // at the label (which should be the only one) is the spilled current | 210 // at the label (which should be the only one) is the spilled current |
| 213 // frame plus an in-memory return address. The "fall-through" frame | 211 // frame plus an in-memory return address. The "fall-through" frame |
| 214 // at the return site is the spilled current frame. | 212 // at the return site is the spilled current frame. |
| 215 ASSERT(cgen_ != NULL); | 213 ASSERT(cgen_ != NULL); |
| 216 ASSERT(cgen_->has_valid_frame()); | 214 ASSERT(cgen_->has_valid_frame()); |
| 217 ASSERT(!cgen_->has_cc()); | |
| 218 // There are no non-frame references across the call. | 215 // There are no non-frame references across the call. |
| 219 ASSERT(cgen_->HasValidEntryRegisters()); | 216 ASSERT(cgen_->HasValidEntryRegisters()); |
| 220 ASSERT(!is_linked()); | 217 ASSERT(!is_linked()); |
| 221 | 218 |
| 222 cgen_->frame()->SpillAll(); | 219 cgen_->frame()->SpillAll(); |
| 223 VirtualFrame* target_frame = new VirtualFrame(cgen_->frame()); | 220 VirtualFrame* target_frame = new VirtualFrame(cgen_->frame()); |
| 224 target_frame->Adjust(1); | 221 target_frame->Adjust(1); |
| 225 AddReachingFrame(target_frame); | 222 AddReachingFrame(target_frame); |
| 226 __ call(&merge_labels_.last()); | 223 __ call(&merge_labels_.last()); |
| 227 } | 224 } |
| 228 | 225 |
| 229 | 226 |
| 230 void JumpTarget::Bind() { | 227 void JumpTarget::Bind() { |
| 231 ASSERT(cgen_ != NULL); | 228 ASSERT(cgen_ != NULL); |
| 232 ASSERT(is_linked() || cgen_->has_valid_frame()); | 229 ASSERT(is_linked() || cgen_->has_valid_frame()); |
| 233 ASSERT(!cgen_->has_cc()); | |
| 234 ASSERT(!is_bound()); | 230 ASSERT(!is_bound()); |
| 235 ASSERT(!cgen_->has_cc()); | |
| 236 | 231 |
| 237 if (is_linked()) { | 232 if (is_linked()) { |
| 238 // There were forward jumps. A mergable frame is created and all | 233 // There were forward jumps. A mergable frame is created and all |
| 239 // the frames reaching the block via forward jumps are merged to it. | 234 // the frames reaching the block via forward jumps are merged to it. |
| 240 ASSERT(reaching_frames_.length() == merge_labels_.length()); | 235 ASSERT(reaching_frames_.length() == merge_labels_.length()); |
| 241 | 236 |
| 242 // Choose a frame as the basis of the expected frame, and make it | 237 // Choose a frame as the basis of the expected frame, and make it |
| 243 // mergable. If there is a current frame use it, otherwise use the | 238 // mergable. If there is a current frame use it, otherwise use the |
| 244 // first in the list (there will be at least one). | 239 // first in the list (there will be at least one). |
| 245 int start_index = 0; | 240 int start_index = 0; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 other_target_->set_code_generator(cgen_); | 367 other_target_->set_code_generator(cgen_); |
| 373 #ifdef DEBUG | 368 #ifdef DEBUG |
| 374 is_shadowing_ = false; | 369 is_shadowing_ = false; |
| 375 #endif | 370 #endif |
| 376 } | 371 } |
| 377 | 372 |
| 378 #undef __ | 373 #undef __ |
| 379 | 374 |
| 380 | 375 |
| 381 } } // namespace v8::internal | 376 } } // namespace v8::internal |
| OLD | NEW |