| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 ASSERT(cgen_ == NULL); | 56 ASSERT(cgen_ == NULL); |
| 57 cgen_ = cgen; | 57 cgen_ = cgen; |
| 58 masm_ = cgen->masm(); | 58 masm_ = cgen->masm(); |
| 59 } | 59 } |
| 60 | 60 |
| 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(cgen_ != NULL); | 65 ASSERT(cgen_ != NULL); |
| 66 ASSERT(!cgen_->has_cc()); |
| 66 | 67 |
| 67 VirtualFrame* current_frame = cgen_->frame(); | 68 VirtualFrame* current_frame = cgen_->frame(); |
| 68 ASSERT(current_frame != NULL); | 69 ASSERT(current_frame != NULL); |
| 69 ASSERT(cgen_->HasValidEntryRegisters()); | 70 ASSERT(cgen_->HasValidEntryRegisters()); |
| 70 | 71 |
| 71 if (expected_frame_ == NULL) { | 72 if (expected_frame_ == NULL) { |
| 72 current_frame->MakeMergable(); | 73 current_frame->MakeMergable(); |
| 73 expected_frame_ = current_frame; | 74 expected_frame_ = current_frame; |
| 74 ASSERT(cgen_->HasValidEntryRegisters()); | 75 ASSERT(cgen_->HasValidEntryRegisters()); |
| 75 RegisterFile ignored; | 76 RegisterFile ignored; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 93 cgen_->frame()->Push(arg); | 94 cgen_->frame()->Push(arg); |
| 94 Jump(); | 95 Jump(); |
| 95 } | 96 } |
| 96 | 97 |
| 97 | 98 |
| 98 void JumpTarget::Branch(Condition cc, Hint hint) { | 99 void JumpTarget::Branch(Condition cc, Hint hint) { |
| 99 // Precondition: there is a current frame. There may or may not be an | 100 // Precondition: there is a current frame. There may or may not be an |
| 100 // expected frame at the label. | 101 // expected frame at the label. |
| 101 ASSERT(cgen_ != NULL); | 102 ASSERT(cgen_ != NULL); |
| 102 ASSERT(masm_ != NULL); | 103 ASSERT(masm_ != NULL); |
| 104 ASSERT(!cgen_->has_cc()); |
| 103 | 105 |
| 104 VirtualFrame* current_frame = cgen_->frame(); | 106 VirtualFrame* current_frame = cgen_->frame(); |
| 105 ASSERT(current_frame != NULL); | 107 ASSERT(current_frame != NULL); |
| 106 | 108 |
| 107 if (expected_frame_ == NULL) { | 109 if (expected_frame_ == NULL) { |
| 108 expected_frame_ = new VirtualFrame(current_frame); | 110 expected_frame_ = new VirtualFrame(current_frame); |
| 109 // For a branch, the frame at the fall-through basic block (not labeled) | 111 // For a branch, the frame at the fall-through basic block (not labeled) |
| 110 // does not need to be mergable, but only the other (labeled) one. That | 112 // does not need to be mergable, but only the other (labeled) one. That |
| 111 // is achieved by reversing the condition and emitting the make mergable | 113 // is achieved by reversing the condition and emitting the make mergable |
| 112 // code as the actual fall-through block. | 114 // code as the actual fall-through block. |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 ASSERT(arg1->type() == arg1_type); | 197 ASSERT(arg1->type() == arg1_type); |
| 196 ASSERT(!arg1->is_register() || arg1->reg().is(arg1_reg)); | 198 ASSERT(!arg1->is_register() || arg1->reg().is(arg1_reg)); |
| 197 } | 199 } |
| 198 | 200 |
| 199 | 201 |
| 200 void JumpTarget::Call() { | 202 void JumpTarget::Call() { |
| 201 // Precondition: there is a current frame, and there is no expected frame | 203 // Precondition: there is a current frame, and there is no expected frame |
| 202 // at the label. | 204 // at the label. |
| 203 ASSERT(cgen_ != NULL); | 205 ASSERT(cgen_ != NULL); |
| 204 ASSERT(masm_ != NULL); | 206 ASSERT(masm_ != NULL); |
| 207 ASSERT(!cgen_->has_cc()); |
| 205 | 208 |
| 206 VirtualFrame* current_frame = cgen_->frame(); | 209 VirtualFrame* current_frame = cgen_->frame(); |
| 207 ASSERT(current_frame != NULL); | 210 ASSERT(current_frame != NULL); |
| 208 ASSERT(expected_frame_ == NULL); | 211 ASSERT(expected_frame_ == NULL); |
| 209 ASSERT(cgen_->HasValidEntryRegisters()); | 212 ASSERT(cgen_->HasValidEntryRegisters()); |
| 210 | 213 |
| 211 expected_frame_ = new VirtualFrame(current_frame); | 214 expected_frame_ = new VirtualFrame(current_frame); |
| 212 expected_frame_->MakeMergable(); | 215 expected_frame_->MakeMergable(); |
| 213 // Adjust the expected frame's height to account for the return address | 216 // Adjust the expected frame's height to account for the return address |
| 214 // pushed by the call instruction. | 217 // pushed by the call instruction. |
| 215 expected_frame_->Adjust(1); | 218 expected_frame_->Adjust(1); |
| 216 ASSERT(cgen_->HasValidEntryRegisters()); | 219 ASSERT(cgen_->HasValidEntryRegisters()); |
| 217 | 220 |
| 218 __ call(&label_); | 221 __ call(&label_); |
| 219 // Postcondition: there is both a current frame and an expected frame at | 222 // Postcondition: there is both a current frame and an expected frame at |
| 220 // the label. The current frame is one shorter than the one at the label | 223 // the label. The current frame is one shorter than the one at the label |
| 221 // (which contains the return address in memory). | 224 // (which contains the return address in memory). |
| 222 } | 225 } |
| 223 | 226 |
| 224 | 227 |
| 225 void JumpTarget::Bind() { | 228 void JumpTarget::Bind() { |
| 226 // Precondition: there is either a current frame or an expected frame at | 229 // Precondition: there is either a current frame or an expected frame at |
| 227 // the label (and possibly both). The label is unbound. | 230 // the label (and possibly both). The label is unbound. |
| 228 ASSERT(cgen_ != NULL); | 231 ASSERT(cgen_ != NULL); |
| 229 ASSERT(masm_ != NULL); | 232 ASSERT(masm_ != NULL); |
| 233 ASSERT(!cgen_->has_cc()); |
| 230 | 234 |
| 231 VirtualFrame* current_frame = cgen_->frame(); | 235 VirtualFrame* current_frame = cgen_->frame(); |
| 232 ASSERT(current_frame != NULL || expected_frame_ != NULL); | 236 ASSERT(current_frame != NULL || expected_frame_ != NULL); |
| 233 ASSERT(!label_.is_bound()); | 237 ASSERT(!label_.is_bound()); |
| 234 | 238 |
| 235 if (expected_frame_ == NULL) { | 239 if (expected_frame_ == NULL) { |
| 236 ASSERT(cgen_->HasValidEntryRegisters()); | 240 ASSERT(cgen_->HasValidEntryRegisters()); |
| 237 // When a label is bound the current frame becomes the expected frame at | 241 // When a label is bound the current frame becomes the expected frame at |
| 238 // the label. This requires the current frame to be mergable. | 242 // the label. This requires the current frame to be mergable. |
| 239 current_frame->MakeMergable(); | 243 current_frame->MakeMergable(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 257 | 261 |
| 258 __ bind(&label_); | 262 __ bind(&label_); |
| 259 // Postcondition: there is both a current frame and an expected frame at | 263 // Postcondition: there is both a current frame and an expected frame at |
| 260 // the label and they match. The label is bound. | 264 // the label and they match. The label is bound. |
| 261 } | 265 } |
| 262 | 266 |
| 263 | 267 |
| 264 void JumpTarget::Bind(Result* arg) { | 268 void JumpTarget::Bind(Result* arg) { |
| 265 ASSERT(cgen_ != NULL); | 269 ASSERT(cgen_ != NULL); |
| 266 | 270 |
| 267 #ifdef DEBUG | |
| 268 // We want register results at the call site to stay in the same | |
| 269 // registers. | |
| 270 bool had_entry_frame = false; | |
| 271 Result::Type arg_type; | |
| 272 Register arg_reg; | |
| 273 #endif | |
| 274 | |
| 275 if (cgen_->has_valid_frame()) { | 271 if (cgen_->has_valid_frame()) { |
| 276 #ifdef DEBUG | |
| 277 had_entry_frame = true; | |
| 278 arg_type = arg->type(); | |
| 279 arg_reg = arg->is_register() ? arg->reg() : no_reg; | |
| 280 #endif | |
| 281 cgen_->frame()->Push(arg); | 272 cgen_->frame()->Push(arg); |
| 282 } | 273 } |
| 283 Bind(); | 274 Bind(); |
| 284 *arg = cgen_->frame()->Pop(); | 275 *arg = cgen_->frame()->Pop(); |
| 285 | |
| 286 ASSERT(!had_entry_frame || arg->type() == arg_type); | |
| 287 ASSERT(!had_entry_frame || !arg->is_register() || arg->reg().is(arg_reg)); | |
| 288 } | 276 } |
| 289 | 277 |
| 290 | 278 |
| 291 void JumpTarget::Bind(Result* arg0, Result* arg1) { | 279 void JumpTarget::Bind(Result* arg0, Result* arg1) { |
| 292 ASSERT(cgen_ != NULL); | 280 ASSERT(cgen_ != NULL); |
| 293 | 281 |
| 294 #ifdef DEBUG | |
| 295 // We want register results at the call site to stay in the same | |
| 296 // registers. | |
| 297 bool had_entry_frame = false; | |
| 298 Result::Type arg0_type; | |
| 299 Register arg0_reg; | |
| 300 Result::Type arg1_type; | |
| 301 Register arg1_reg; | |
| 302 #endif | |
| 303 | |
| 304 if (cgen_->frame() != NULL) { | 282 if (cgen_->frame() != NULL) { |
| 305 #ifdef DEBUG | |
| 306 had_entry_frame = true; | |
| 307 arg0_type = arg0->type(); | |
| 308 arg0_reg = arg0->is_register() ? arg0->reg() : no_reg; | |
| 309 arg1_type = arg1->type(); | |
| 310 arg1_reg = arg1->is_register() ? arg1->reg() : no_reg; | |
| 311 #endif | |
| 312 cgen_->frame()->Push(arg0); | 283 cgen_->frame()->Push(arg0); |
| 313 cgen_->frame()->Push(arg1); | 284 cgen_->frame()->Push(arg1); |
| 314 } | 285 } |
| 315 Bind(); | 286 Bind(); |
| 316 *arg1 = cgen_->frame()->Pop(); | 287 *arg1 = cgen_->frame()->Pop(); |
| 317 *arg0 = cgen_->frame()->Pop(); | 288 *arg0 = cgen_->frame()->Pop(); |
| 318 | |
| 319 ASSERT(!had_entry_frame || arg0->type() == arg0_type); | |
| 320 ASSERT(!had_entry_frame || | |
| 321 !arg0->is_register() || | |
| 322 arg0->reg().is(arg0_reg)); | |
| 323 ASSERT(!had_entry_frame || arg1->type() == arg1_type); | |
| 324 ASSERT(!had_entry_frame || | |
| 325 !arg1->is_register() || | |
| 326 arg1->reg().is(arg1_reg)); | |
| 327 } | 289 } |
| 328 | 290 |
| 329 | 291 |
| 330 // ------------------------------------------------------------------------- | 292 // ------------------------------------------------------------------------- |
| 331 // ShadowTarget implementation. | 293 // ShadowTarget implementation. |
| 332 | 294 |
| 333 ShadowTarget::ShadowTarget(JumpTarget* original) { | 295 ShadowTarget::ShadowTarget(JumpTarget* original) { |
| 334 ASSERT(original != NULL); | 296 ASSERT(original != NULL); |
| 335 original_target_ = original; | 297 original_target_ = original; |
| 336 original_pos_ = original->label()->pos_; | 298 original_pos_ = original->label()->pos_; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 359 | 321 |
| 360 #ifdef DEBUG | 322 #ifdef DEBUG |
| 361 is_shadowing_ = false; | 323 is_shadowing_ = false; |
| 362 #endif | 324 #endif |
| 363 } | 325 } |
| 364 | 326 |
| 365 #undef __ | 327 #undef __ |
| 366 | 328 |
| 367 | 329 |
| 368 } } // namespace v8::internal | 330 } } // namespace v8::internal |
| OLD | NEW |