| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 void JumpTarget::Jump() { | 62 void JumpTarget::Jump() { |
| 63 // Precondition: there is a current frame. There may or may not be an | 63 // Precondition: there is a current frame. There may or may not be an |
| 64 // expected frame at the label. | 64 // expected frame at the label. |
| 65 ASSERT(code_generator_ != NULL); | 65 ASSERT(code_generator_ != NULL); |
| 66 | 66 |
| 67 VirtualFrame* current_frame = code_generator_->frame(); | 67 VirtualFrame* current_frame = code_generator_->frame(); |
| 68 ASSERT(current_frame != NULL); | 68 ASSERT(current_frame != NULL); |
| 69 | 69 |
| 70 if (expected_frame_ == NULL) { | 70 if (expected_frame_ == NULL) { |
| 71 expected_frame_ = current_frame; | |
| 72 // The frame at the actual function return will always have height zero. | 71 // The frame at the actual function return will always have height zero. |
| 73 if (code_generator_->IsActualFunctionReturn(this)) { | 72 if (code_generator_->IsActualFunctionReturn(this)) { |
| 74 expected_frame_->Forget(expected_frame_->height()); | 73 current_frame->Forget(current_frame->height()); |
| 75 } | 74 } |
| 76 if (!expected_frame_->IsMergable()) { | 75 if (!current_frame->IsMergable()) { |
| 77 expected_frame_->MakeMergable(); | 76 current_frame->MakeMergable(); |
| 78 } | 77 } |
| 79 code_generator_->set_frame(NULL); | 78 expected_frame_ = current_frame; |
| 79 code_generator_->SetFrame(NULL); |
| 80 } else { | 80 } else { |
| 81 // No code needs to be emitted to merge to the expected frame at the | 81 // No code needs to be emitted to merge to the expected frame at the |
| 82 // actual function return. | 82 // actual function return. |
| 83 if (!code_generator_->IsActualFunctionReturn(this)) { | 83 if (!code_generator_->IsActualFunctionReturn(this)) { |
| 84 current_frame->MergeTo(expected_frame_); | 84 current_frame->MergeTo(expected_frame_); |
| 85 } | 85 } |
| 86 code_generator_->delete_frame(); | 86 code_generator_->DeleteFrame(); |
| 87 } | 87 } |
| 88 | 88 |
| 89 __ jmp(&label_); | 89 __ jmp(&label_); |
| 90 // Postcondition: there is no current frame but there is an expected frame | 90 // Postcondition: there is no current frame but there is an expected frame |
| 91 // at the label. | 91 // at the label. |
| 92 } | 92 } |
| 93 | 93 |
| 94 | 94 |
| 95 void JumpTarget::Branch(Condition cc, Hint hint) { | 95 void JumpTarget::Branch(Condition cc, Hint hint) { |
| 96 // Precondition: there is a current frame. There may or may not be an | 96 // Precondition: there is a current frame. There may or may not be an |
| 97 // expected frame at the label. | 97 // expected frame at the label. |
| 98 ASSERT(code_generator_ != NULL); | 98 ASSERT(code_generator_ != NULL); |
| 99 ASSERT(masm_ != NULL); | 99 ASSERT(masm_ != NULL); |
| 100 | 100 |
| 101 VirtualFrame* current_frame = code_generator_->frame(); | 101 VirtualFrame* current_frame = code_generator_->frame(); |
| 102 ASSERT(current_frame != NULL); | 102 ASSERT(current_frame != NULL); |
| 103 | 103 |
| 104 if (expected_frame_ == NULL) { | 104 if (expected_frame_ == NULL) { |
| 105 expected_frame_ = new VirtualFrame(current_frame); | 105 expected_frame_ = new VirtualFrame(current_frame); |
| 106 // The frame at the actual function return will always have height zero. | 106 // The frame at the actual function return will always have height zero. |
| 107 if (code_generator_->IsActualFunctionReturn(this)) { | 107 if (code_generator_->IsActualFunctionReturn(this)) { |
| 108 expected_frame_->Forget(expected_frame_->height()); | 108 expected_frame_->Forget(expected_frame_->height()); |
| 109 } | 109 } |
| 110 if (!expected_frame_->IsMergable()) { | 110 // For a branch, the frame at the fall-through basic block (not labeled) |
| 111 // does not need to be mergable, but only the other (labeled) one. That |
| 112 // is achieved by reversing the condition and emitting the make mergable |
| 113 // code as the actual fall-through block. This is necessary only when |
| 114 // MakeMergable will generate code. |
| 115 if (expected_frame_->RequiresMergeCode()) { |
| 116 Label original_fall_through; |
| 117 __ j(NegateCondition(cc), &original_fall_through, NegateHint(hint)); |
| 111 expected_frame_->MakeMergable(); | 118 expected_frame_->MakeMergable(); |
| 119 __ jmp(&label_); |
| 120 __ bind(&original_fall_through); |
| 121 } else { |
| 122 if (!expected_frame_->IsMergable()) { |
| 123 expected_frame_->MakeMergable(); |
| 124 } |
| 125 __ j(cc, &label_, hint); |
| 112 } | 126 } |
| 113 } else { | 127 } else { |
| 114 // No code needs to be emitted to merge to the expected frame at the | 128 // No code needs to be emitted to merge to the expected frame at the |
| 115 // actual function return. | 129 // actual function return. |
| 116 if (!code_generator_->IsActualFunctionReturn(this)) { | 130 if (!code_generator_->IsActualFunctionReturn(this)) { |
| 117 current_frame->MergeTo(expected_frame_); | 131 current_frame->MergeTo(expected_frame_); |
| 118 } | 132 } |
| 133 __ j(cc, &label_, hint); |
| 119 } | 134 } |
| 120 | |
| 121 __ j(cc, &label_, hint); | |
| 122 // Postcondition: there is both a current frame and an expected frame at | 135 // Postcondition: there is both a current frame and an expected frame at |
| 123 // the label and they match. | 136 // the label and they match. |
| 124 } | 137 } |
| 125 | 138 |
| 126 | 139 |
| 127 void JumpTarget::Call() { | 140 void JumpTarget::Call() { |
| 128 // Precondition: there is a current frame, and there is no expected frame | 141 // Precondition: there is a current frame, and there is no expected frame |
| 129 // at the label. | 142 // at the label. |
| 130 ASSERT(code_generator_ != NULL); | 143 ASSERT(code_generator_ != NULL); |
| 131 ASSERT(masm_ != NULL); | 144 ASSERT(masm_ != NULL); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 154 // Precondition: there is either a current frame or an expected frame at | 167 // Precondition: there is either a current frame or an expected frame at |
| 155 // the label (and possibly both). The label is unbound. | 168 // the label (and possibly both). The label is unbound. |
| 156 ASSERT(code_generator_ != NULL); | 169 ASSERT(code_generator_ != NULL); |
| 157 ASSERT(masm_ != NULL); | 170 ASSERT(masm_ != NULL); |
| 158 | 171 |
| 159 VirtualFrame* current_frame = code_generator_->frame(); | 172 VirtualFrame* current_frame = code_generator_->frame(); |
| 160 ASSERT(current_frame != NULL || expected_frame_ != NULL); | 173 ASSERT(current_frame != NULL || expected_frame_ != NULL); |
| 161 ASSERT(!label_.is_bound()); | 174 ASSERT(!label_.is_bound()); |
| 162 | 175 |
| 163 if (expected_frame_ == NULL) { | 176 if (expected_frame_ == NULL) { |
| 164 expected_frame_ = new VirtualFrame(current_frame); | 177 // When a label is bound the current frame becomes the expected frame at |
| 178 // the label. This requires the current frame to be mergable. |
| 165 // The frame at the actual function return will always have height zero. | 179 // The frame at the actual function return will always have height zero. |
| 166 if (code_generator_->IsActualFunctionReturn(this)) { | 180 if (code_generator_->IsActualFunctionReturn(this)) { |
| 167 expected_frame_->Forget(expected_frame_->height()); | 181 current_frame->Forget(current_frame->height()); |
| 168 } | 182 } |
| 169 if (!expected_frame_->IsMergable()) { | 183 if (!current_frame->IsMergable()) { |
| 170 expected_frame_->MakeMergable(); | 184 current_frame->MakeMergable(); |
| 171 } | 185 } |
| 186 expected_frame_ = new VirtualFrame(current_frame); |
| 172 } else if (current_frame == NULL) { | 187 } else if (current_frame == NULL) { |
| 173 code_generator_->set_frame(new VirtualFrame(expected_frame_)); | 188 code_generator_->SetFrame(new VirtualFrame(expected_frame_)); |
| 174 } else { | 189 } else { |
| 175 // No code needs to be emitted to merge to the expected frame at the | 190 // No code needs to be emitted to merge to the expected frame at the |
| 176 // actual function return. | 191 // actual function return. |
| 177 if (!code_generator_->IsActualFunctionReturn(this)) { | 192 if (!code_generator_->IsActualFunctionReturn(this)) { |
| 178 current_frame->MergeTo(expected_frame_); | 193 current_frame->MergeTo(expected_frame_); |
| 179 } | 194 } |
| 180 } | 195 } |
| 181 | 196 |
| 182 __ bind(&label_); | 197 __ bind(&label_); |
| 183 // Postcondition: there is both a current frame and an expected frame at | 198 // Postcondition: there is both a current frame and an expected frame at |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 | 232 |
| 218 #ifdef DEBUG | 233 #ifdef DEBUG |
| 219 is_shadowing_ = false; | 234 is_shadowing_ = false; |
| 220 #endif | 235 #endif |
| 221 } | 236 } |
| 222 | 237 |
| 223 #undef __ | 238 #undef __ |
| 224 | 239 |
| 225 | 240 |
| 226 } } // namespace v8::internal | 241 } } // namespace v8::internal |
| OLD | NEW |