| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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; | 71 expected_frame_ = current_frame; |
| 72 code_generator_->set_frame(NULL); | 72 expected_frame_->EnsureMergable(); |
| 73 // The frame at the actual function return will always have height zero. | 73 // The frame at the actual function return will always have height zero. |
| 74 if (code_generator_->IsActualFunctionReturn(this)) { | 74 if (code_generator_->IsActualFunctionReturn(this)) { |
| 75 expected_frame_->Forget(expected_frame_->height()); | 75 expected_frame_->Forget(expected_frame_->height()); |
| 76 } | 76 } |
| 77 code_generator_->set_frame(NULL); |
| 77 } else { | 78 } else { |
| 78 // No code needs to be emitted to merge to the expected frame at the | 79 // No code needs to be emitted to merge to the expected frame at the |
| 79 // actual function return. | 80 // actual function return. |
| 80 if (!code_generator_->IsActualFunctionReturn(this)) { | 81 if (!code_generator_->IsActualFunctionReturn(this)) { |
| 81 current_frame->MergeTo(expected_frame_); | 82 current_frame->MergeTo(expected_frame_); |
| 82 } | 83 } |
| 83 code_generator_->delete_frame(); | 84 code_generator_->delete_frame(); |
| 84 } | 85 } |
| 85 | 86 |
| 86 __ jmp(&label_); | 87 __ jmp(&label_); |
| 87 // Postcondition: there is no current frame but there is an expected frame | 88 // Postcondition: there is no current frame but there is an expected frame |
| 88 // at the label. | 89 // at the label. |
| 89 } | 90 } |
| 90 | 91 |
| 91 | 92 |
| 92 void JumpTarget::Branch(Condition cc, Hint hint) { | 93 void JumpTarget::Branch(Condition cc, Hint hint) { |
| 93 // Precondition: there is a current frame. There may or may not be an | 94 // Precondition: there is a current frame. There may or may not be an |
| 94 // expected frame at the label. | 95 // expected frame at the label. |
| 95 ASSERT(code_generator_ != NULL); | 96 ASSERT(code_generator_ != NULL); |
| 96 ASSERT(masm_ != NULL); | 97 ASSERT(masm_ != NULL); |
| 97 | 98 |
| 98 VirtualFrame* current_frame = code_generator_->frame(); | 99 VirtualFrame* current_frame = code_generator_->frame(); |
| 99 ASSERT(current_frame != NULL); | 100 ASSERT(current_frame != NULL); |
| 100 | 101 |
| 101 if (expected_frame_ == NULL) { | 102 if (expected_frame_ == NULL) { |
| 102 expected_frame_ = new VirtualFrame(current_frame); | 103 expected_frame_ = new VirtualFrame(current_frame); |
| 104 expected_frame_->EnsureMergable(); |
| 103 // The frame at the actual function return will always have height zero. | 105 // The frame at the actual function return will always have height zero. |
| 104 if (code_generator_->IsActualFunctionReturn(this)) { | 106 if (code_generator_->IsActualFunctionReturn(this)) { |
| 105 expected_frame_->Forget(expected_frame_->height()); | 107 expected_frame_->Forget(expected_frame_->height()); |
| 106 } | 108 } |
| 107 } else { | 109 } else { |
| 108 // No code needs to be emitted to merge to the expected frame at the | 110 // No code needs to be emitted to merge to the expected frame at the |
| 109 // actual function return. | 111 // actual function return. |
| 110 if (!code_generator_->IsActualFunctionReturn(this)) { | 112 if (!code_generator_->IsActualFunctionReturn(this)) { |
| 111 current_frame->MergeTo(expected_frame_); | 113 current_frame->MergeTo(expected_frame_); |
| 112 } | 114 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 123 // at the label. | 125 // at the label. |
| 124 ASSERT(code_generator_ != NULL); | 126 ASSERT(code_generator_ != NULL); |
| 125 ASSERT(masm_ != NULL); | 127 ASSERT(masm_ != NULL); |
| 126 ASSERT(!code_generator_->IsActualFunctionReturn(this)); | 128 ASSERT(!code_generator_->IsActualFunctionReturn(this)); |
| 127 | 129 |
| 128 VirtualFrame* current_frame = code_generator_->frame(); | 130 VirtualFrame* current_frame = code_generator_->frame(); |
| 129 ASSERT(current_frame != NULL); | 131 ASSERT(current_frame != NULL); |
| 130 ASSERT(expected_frame_ == NULL); | 132 ASSERT(expected_frame_ == NULL); |
| 131 | 133 |
| 132 expected_frame_ = new VirtualFrame(current_frame); | 134 expected_frame_ = new VirtualFrame(current_frame); |
| 135 expected_frame_->EnsureMergable(); |
| 133 // Adjust the expected frame's height to account for the return address | 136 // Adjust the expected frame's height to account for the return address |
| 134 // pushed by the call instruction. | 137 // pushed by the call instruction. |
| 135 expected_frame_->Adjust(1); | 138 expected_frame_->Adjust(1); |
| 136 | 139 |
| 137 __ call(&label_); | 140 __ call(&label_); |
| 138 // Postcondition: there is both a current frame and an expected frame at | 141 // Postcondition: there is both a current frame and an expected frame at |
| 139 // the label. The current frame is one shorter than the one at the label | 142 // the label. The current frame is one shorter than the one at the label |
| 140 // (which contains the return address in memory). | 143 // (which contains the return address in memory). |
| 141 } | 144 } |
| 142 | 145 |
| 143 | 146 |
| 144 void JumpTarget::Bind() { | 147 void JumpTarget::Bind() { |
| 145 // Precondition: there is either a current frame or an expected frame at | 148 // Precondition: there is either a current frame or an expected frame at |
| 146 // the label (and possibly both). The label is unbound. | 149 // the label (and possibly both). The label is unbound. |
| 147 ASSERT(code_generator_ != NULL); | 150 ASSERT(code_generator_ != NULL); |
| 148 ASSERT(masm_ != NULL); | 151 ASSERT(masm_ != NULL); |
| 149 | 152 |
| 150 VirtualFrame* current_frame = code_generator_->frame(); | 153 VirtualFrame* current_frame = code_generator_->frame(); |
| 151 ASSERT(current_frame != NULL || expected_frame_ != NULL); | 154 ASSERT(current_frame != NULL || expected_frame_ != NULL); |
| 152 ASSERT(!label_.is_bound()); | 155 ASSERT(!label_.is_bound()); |
| 153 | 156 |
| 154 if (expected_frame_ == NULL) { | 157 if (expected_frame_ == NULL) { |
| 155 expected_frame_ = new VirtualFrame(current_frame); | 158 expected_frame_ = new VirtualFrame(current_frame); |
| 159 expected_frame_->EnsureMergable(); |
| 156 // The frame at the actual function return will always have height zero. | 160 // The frame at the actual function return will always have height zero. |
| 157 if (code_generator_->IsActualFunctionReturn(this)) { | 161 if (code_generator_->IsActualFunctionReturn(this)) { |
| 158 expected_frame_->Forget(expected_frame_->height()); | 162 expected_frame_->Forget(expected_frame_->height()); |
| 159 } | 163 } |
| 160 } else if (current_frame == NULL) { | 164 } else if (current_frame == NULL) { |
| 161 code_generator_->set_frame(new VirtualFrame(expected_frame_)); | 165 code_generator_->set_frame(new VirtualFrame(expected_frame_)); |
| 162 } else { | 166 } else { |
| 163 // No code needs to be emitted to merge to the expected frame at the | 167 // No code needs to be emitted to merge to the expected frame at the |
| 164 // actual function return. | 168 // actual function return. |
| 165 if (!code_generator_->IsActualFunctionReturn(this)) { | 169 if (!code_generator_->IsActualFunctionReturn(this)) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 | 209 |
| 206 #ifdef DEBUG | 210 #ifdef DEBUG |
| 207 is_shadowing_ = false; | 211 is_shadowing_ = false; |
| 208 #endif | 212 #endif |
| 209 } | 213 } |
| 210 | 214 |
| 211 #undef __ | 215 #undef __ |
| 212 | 216 |
| 213 | 217 |
| 214 } } // namespace v8::internal | 218 } } // namespace v8::internal |
| OLD | NEW |