| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 where_to_go.top_of_stack_state_ = R0_TOS; | 65 where_to_go.top_of_stack_state_ = R0_TOS; |
| 66 MergeTo(&where_to_go); | 66 MergeTo(&where_to_go); |
| 67 // Pop the register off the stack so it is detached from the frame. | 67 // Pop the register off the stack so it is detached from the frame. |
| 68 element_count_ -= 1; | 68 element_count_ -= 1; |
| 69 top_of_stack_state_ = NO_TOS_REGISTERS; | 69 top_of_stack_state_ = NO_TOS_REGISTERS; |
| 70 } | 70 } |
| 71 | 71 |
| 72 | 72 |
| 73 void VirtualFrame::MergeTo(VirtualFrame* expected) { | 73 void VirtualFrame::MergeTo(VirtualFrame* expected) { |
| 74 if (Equals(expected)) return; | 74 if (Equals(expected)) return; |
| 75 MergeTOSTo(expected->top_of_stack_state_); |
| 76 ASSERT(register_allocation_map_ == expected->register_allocation_map_); |
| 77 } |
| 78 |
| 79 |
| 80 void VirtualFrame::MergeTOSTo( |
| 81 VirtualFrame::TopOfStack expected_top_of_stack_state) { |
| 75 #define CASE_NUMBER(a, b) ((a) * TOS_STATES + (b)) | 82 #define CASE_NUMBER(a, b) ((a) * TOS_STATES + (b)) |
| 76 switch (CASE_NUMBER(top_of_stack_state_, expected->top_of_stack_state_)) { | 83 switch (CASE_NUMBER(top_of_stack_state_, expected_top_of_stack_state)) { |
| 77 case CASE_NUMBER(NO_TOS_REGISTERS, NO_TOS_REGISTERS): | 84 case CASE_NUMBER(NO_TOS_REGISTERS, NO_TOS_REGISTERS): |
| 78 break; | 85 break; |
| 79 case CASE_NUMBER(NO_TOS_REGISTERS, R0_TOS): | 86 case CASE_NUMBER(NO_TOS_REGISTERS, R0_TOS): |
| 80 __ pop(r0); | 87 __ pop(r0); |
| 81 break; | 88 break; |
| 82 case CASE_NUMBER(NO_TOS_REGISTERS, R1_TOS): | 89 case CASE_NUMBER(NO_TOS_REGISTERS, R1_TOS): |
| 83 __ pop(r1); | 90 __ pop(r1); |
| 84 break; | 91 break; |
| 85 case CASE_NUMBER(NO_TOS_REGISTERS, R0_R1_TOS): | 92 case CASE_NUMBER(NO_TOS_REGISTERS, R0_R1_TOS): |
| 86 __ pop(r0); | 93 __ pop(r0); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 break; | 154 break; |
| 148 case CASE_NUMBER(R1_R0_TOS, R0_R1_TOS): | 155 case CASE_NUMBER(R1_R0_TOS, R0_R1_TOS): |
| 149 __ Swap(r0, r1, ip); | 156 __ Swap(r0, r1, ip); |
| 150 break; | 157 break; |
| 151 case CASE_NUMBER(R1_R0_TOS, R1_R0_TOS): | 158 case CASE_NUMBER(R1_R0_TOS, R1_R0_TOS): |
| 152 break; | 159 break; |
| 153 default: | 160 default: |
| 154 UNREACHABLE(); | 161 UNREACHABLE(); |
| 155 #undef CASE_NUMBER | 162 #undef CASE_NUMBER |
| 156 } | 163 } |
| 157 ASSERT(register_allocation_map_ == expected->register_allocation_map_); | 164 top_of_stack_state_ = expected_top_of_stack_state; |
| 158 } | 165 } |
| 159 | 166 |
| 160 | 167 |
| 161 void VirtualFrame::Enter() { | 168 void VirtualFrame::Enter() { |
| 162 Comment cmnt(masm(), "[ Enter JS frame"); | 169 Comment cmnt(masm(), "[ Enter JS frame"); |
| 163 | 170 |
| 164 #ifdef DEBUG | 171 #ifdef DEBUG |
| 165 // Verify that r1 contains a JS function. The following code relies | 172 // Verify that r1 contains a JS function. The following code relies |
| 166 // on r2 being available for use. | 173 // on r2 being available for use. |
| 167 if (FLAG_debug_code) { | 174 if (FLAG_debug_code) { |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 return; | 627 return; |
| 621 } | 628 } |
| 622 } | 629 } |
| 623 EnsureOneFreeTOSRegister(); | 630 EnsureOneFreeTOSRegister(); |
| 624 top_of_stack_state_ = kStateAfterPush[top_of_stack_state_]; | 631 top_of_stack_state_ = kStateAfterPush[top_of_stack_state_]; |
| 625 Register dest = kTopRegister[top_of_stack_state_]; | 632 Register dest = kTopRegister[top_of_stack_state_]; |
| 626 __ Move(dest, reg); | 633 __ Move(dest, reg); |
| 627 } | 634 } |
| 628 | 635 |
| 629 | 636 |
| 637 void VirtualFrame::OverwriteStackPosition(Register reg, int this_far_down) { |
| 638 int virtual_elements = kVirtualElements[top_of_stack_state_]; |
| 639 if (this_far_down == 0) { |
| 640 Pop(); |
| 641 Register dest = GetTOSRegister(); |
| 642 if (dest.is(reg)) { |
| 643 // We already popped one item off the top of the stack. If the only |
| 644 // free register is the one we were asked to push then we have been |
| 645 // asked to push a register that was already in use, which cannot |
| 646 // happen. It therefore folows that there are two free TOS registers: |
| 647 ASSERT(top_of_stack_state_ == NO_TOS_REGISTERS); |
| 648 dest = dest.is(r0) ? r1 : r0; |
| 649 } |
| 650 __ mov(dest, reg); |
| 651 EmitPush(dest); |
| 652 } else if (this_far_down == 1) { |
| 653 int virtual_elements = kVirtualElements[top_of_stack_state_]; |
| 654 if (virtual_elements < 2) { |
| 655 __ str(reg, ElementAt(this_far_down)); |
| 656 } else { |
| 657 ASSERT(virtual_elements == 2); |
| 658 ASSERT(!reg.is(r0)); |
| 659 ASSERT(!reg.is(r1)); |
| 660 Register dest = kBottomRegister[top_of_stack_state_]; |
| 661 __ mov(dest, reg); |
| 662 } |
| 663 } else { |
| 664 ASSERT(this_far_down >= 2); |
| 665 ASSERT(virtual_elements <= 2); |
| 666 __ str(reg, ElementAt(this_far_down)); |
| 667 } |
| 668 } |
| 669 |
| 670 |
| 630 Register VirtualFrame::GetTOSRegister() { | 671 Register VirtualFrame::GetTOSRegister() { |
| 631 if (SpilledScope::is_spilled()) return r0; | 672 if (SpilledScope::is_spilled()) return r0; |
| 632 | 673 |
| 633 EnsureOneFreeTOSRegister(); | 674 EnsureOneFreeTOSRegister(); |
| 634 return kTopRegister[kStateAfterPush[top_of_stack_state_]]; | 675 return kTopRegister[kStateAfterPush[top_of_stack_state_]]; |
| 635 } | 676 } |
| 636 | 677 |
| 637 | 678 |
| 638 void VirtualFrame::EmitPush(Operand operand) { | 679 void VirtualFrame::EmitPush(Operand operand) { |
| 639 element_count_++; | 680 element_count_++; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 default: | 743 default: |
| 703 UNREACHABLE(); | 744 UNREACHABLE(); |
| 704 break; | 745 break; |
| 705 } | 746 } |
| 706 ASSERT(register_allocation_map_ == 0); // Not yet implemented. | 747 ASSERT(register_allocation_map_ == 0); // Not yet implemented. |
| 707 } | 748 } |
| 708 | 749 |
| 709 #undef __ | 750 #undef __ |
| 710 | 751 |
| 711 } } // namespace v8::internal | 752 } } // namespace v8::internal |
| OLD | NEW |