| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 Result::Result(Register reg, CodeGenerator* cgen) | 43 Result::Result(Register reg, CodeGenerator* cgen) |
| 44 : type_(REGISTER), | 44 : type_(REGISTER), |
| 45 cgen_(cgen) { | 45 cgen_(cgen) { |
| 46 data_.reg_ = reg; | 46 data_.reg_ = reg; |
| 47 ASSERT(!reg.is(no_reg)); | 47 ASSERT(!reg.is(no_reg)); |
| 48 cgen_->allocator()->Use(reg); | 48 cgen_->allocator()->Use(reg); |
| 49 } | 49 } |
| 50 | 50 |
| 51 | 51 |
| 52 void Result::Unuse() { | 52 void Result::Unuse() { |
| 53 ASSERT(!reg().is(no_reg)); | 53 if (is_register()) { |
| 54 cgen_->allocator()->Unuse(reg()); | 54 cgen_->allocator()->Unuse(reg()); |
| 55 data_.reg_ = no_reg; | 55 } |
| 56 type_ = INVALID; |
| 57 } |
| 58 |
| 59 |
| 60 void Result::ToRegister() { |
| 61 ASSERT(is_valid()); |
| 62 if (is_constant()) { |
| 63 Register reg = cgen_->allocator()->Allocate(); |
| 64 ASSERT(!reg.is(no_reg)); |
| 65 cgen_->masm()->Set(reg, Immediate(handle())); |
| 66 data_.reg_ = reg; |
| 67 type_ = REGISTER; |
| 68 } |
| 69 ASSERT(is_register()); |
| 56 } | 70 } |
| 57 | 71 |
| 58 | 72 |
| 59 // ------------------------------------------------------------------------- | 73 // ------------------------------------------------------------------------- |
| 60 // VirtualFrame implementation. | 74 // VirtualFrame implementation. |
| 61 | 75 |
| 62 // On entry to a function, the virtual frame already contains the receiver, | 76 // On entry to a function, the virtual frame already contains the receiver, |
| 63 // the parameters, and a return address. All frame elements are in memory. | 77 // the parameters, and a return address. All frame elements are in memory. |
| 64 VirtualFrame::VirtualFrame(CodeGenerator* cgen) | 78 VirtualFrame::VirtualFrame(CodeGenerator* cgen) |
| 65 : cgen_(cgen), | 79 : cgen_(cgen), |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 bool should_break_cycles = false; | 521 bool should_break_cycles = false; |
| 508 bool any_moves_made; // Did we make any progress this iteration? | 522 bool any_moves_made; // Did we make any progress this iteration? |
| 509 do { | 523 do { |
| 510 any_moves_blocked = false; | 524 any_moves_blocked = false; |
| 511 any_moves_made = false; | 525 any_moves_made = false; |
| 512 int first_move_blocked = kIllegalIndex; | 526 int first_move_blocked = kIllegalIndex; |
| 513 int last_move_blocked = kIllegalIndex; | 527 int last_move_blocked = kIllegalIndex; |
| 514 for (int i = start; i <= end; i++) { | 528 for (int i = start; i <= end; i++) { |
| 515 FrameElement source = elements_[i]; | 529 FrameElement source = elements_[i]; |
| 516 FrameElement target = expected->elements_[i]; | 530 FrameElement target = expected->elements_[i]; |
| 517 if (source.is_register() && target.is_register() && | 531 if (source.is_register() && target.is_register()) { |
| 518 !target.reg().is(source.reg())) { | 532 if (target.reg().is(source.reg())) { |
| 519 // We need to move source to target. | |
| 520 if (frame_registers_.is_used(target.reg().code())) { | |
| 521 // The move is blocked because the target contains valid data. | |
| 522 // If we are stuck with only cycles remaining, then we spill source. | |
| 523 // Otherwise, we just need more iterations. | |
| 524 if (should_break_cycles) { | |
| 525 SpillElementAt(i); | |
| 526 should_break_cycles = false; | |
| 527 } else { // Record a blocked move. | |
| 528 if (!any_moves_blocked) { | |
| 529 first_move_blocked = i; | |
| 530 } | |
| 531 last_move_blocked = i; | |
| 532 any_moves_blocked = true; | |
| 533 } | |
| 534 } else { | |
| 535 // The move is not blocked. This frame element can be moved from | |
| 536 // its source register to its target register. | |
| 537 Use(target.reg()); | |
| 538 Unuse(source.reg()); | |
| 539 if (target.is_synced() && !source.is_synced()) { | 533 if (target.is_synced() && !source.is_synced()) { |
| 540 SyncElementAt(i); | 534 SyncElementAt(i); |
| 541 } | 535 } |
| 542 elements_[i] = target; | 536 elements_[i] = target; |
| 543 __ mov(target.reg(), source.reg()); | 537 } else { |
| 544 any_moves_made = true; | 538 // We need to move source to target. |
| 539 if (frame_registers_.is_used(target.reg().code())) { |
| 540 // The move is blocked because the target contains valid data. |
| 541 // If we are stuck with only cycles remaining, then we spill source. |
| 542 // Otherwise, we just need more iterations. |
| 543 if (should_break_cycles) { |
| 544 SpillElementAt(i); |
| 545 should_break_cycles = false; |
| 546 } else { // Record a blocked move. |
| 547 if (!any_moves_blocked) { |
| 548 first_move_blocked = i; |
| 549 } |
| 550 last_move_blocked = i; |
| 551 any_moves_blocked = true; |
| 552 } |
| 553 } else { |
| 554 // The move is not blocked. This frame element can be moved from |
| 555 // its source register to its target register. |
| 556 if (target.is_synced() && !source.is_synced()) { |
| 557 SyncElementAt(i); |
| 558 } |
| 559 Use(target.reg()); |
| 560 Unuse(source.reg()); |
| 561 elements_[i] = target; |
| 562 __ mov(target.reg(), source.reg()); |
| 563 any_moves_made = true; |
| 564 } |
| 545 } | 565 } |
| 546 } | 566 } |
| 547 } | 567 } |
| 548 // Update control flags for next iteration. | 568 // Update control flags for next iteration. |
| 549 should_break_cycles = (any_moves_blocked && !any_moves_made); | 569 should_break_cycles = (any_moves_blocked && !any_moves_made); |
| 550 if (any_moves_blocked) { | 570 if (any_moves_blocked) { |
| 551 start = first_move_blocked; | 571 start = first_move_blocked; |
| 552 end = last_move_blocked; | 572 end = last_move_blocked; |
| 553 } | 573 } |
| 554 } while (any_moves_blocked); | 574 } while (any_moves_blocked); |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 return false; | 910 return false; |
| 891 } | 911 } |
| 892 } | 912 } |
| 893 return true; | 913 return true; |
| 894 } | 914 } |
| 895 #endif | 915 #endif |
| 896 | 916 |
| 897 #undef __ | 917 #undef __ |
| 898 | 918 |
| 899 } } // namespace v8::internal | 919 } } // namespace v8::internal |
| OLD | NEW |