Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 598 | 598 |
| 599 void LCodeGen::DoDivI(LDivI* instr) { | 599 void LCodeGen::DoDivI(LDivI* instr) { |
| 600 Abort("Unimplemented: %s", "DoDivI");} | 600 Abort("Unimplemented: %s", "DoDivI");} |
| 601 | 601 |
| 602 | 602 |
| 603 void LCodeGen::DoMulI(LMulI* instr) { | 603 void LCodeGen::DoMulI(LMulI* instr) { |
| 604 Abort("Unimplemented: %s", "DoMultI");} | 604 Abort("Unimplemented: %s", "DoMultI");} |
| 605 | 605 |
| 606 | 606 |
| 607 void LCodeGen::DoBitI(LBitI* instr) { | 607 void LCodeGen::DoBitI(LBitI* instr) { |
| 608 Abort("Unimplemented: %s", "DoBitI");} | 608 LOperand* left = instr->InputAt(0); |
| 609 LOperand* right = instr->InputAt(1); | |
| 610 ASSERT(left->Equals(instr->result())); | |
| 611 ASSERT(left->IsRegister()); | |
| 612 | |
| 613 if (right->IsConstantOperand()) { | |
| 614 int right_operand = ToInteger32(LConstantOperand::cast(right)); | |
| 615 switch (instr->op()) { | |
| 616 case Token::BIT_AND: | |
| 617 __ andl(ToRegister(left), Immediate(right_operand)); | |
| 618 break; | |
| 619 case Token::BIT_OR: | |
| 620 __ orl(ToRegister(left), Immediate(right_operand)); | |
| 621 break; | |
| 622 case Token::BIT_XOR: | |
| 623 __ xorl(ToRegister(left), Immediate(right_operand)); | |
| 624 break; | |
| 625 default: | |
| 626 UNREACHABLE(); | |
| 627 break; | |
| 628 } | |
| 629 } else if (right->IsStackSlot()) { | |
| 630 switch (instr->op()) { | |
| 631 case Token::BIT_AND: | |
| 632 __ andl(ToRegister(left), ToOperand(right)); | |
| 633 break; | |
| 634 case Token::BIT_OR: | |
| 635 __ orl(ToRegister(left), ToOperand(right)); | |
| 636 break; | |
| 637 case Token::BIT_XOR: | |
| 638 __ xorl(ToRegister(left), ToOperand(right)); | |
| 639 break; | |
| 640 default: | |
| 641 UNREACHABLE(); | |
| 642 break; | |
| 643 } | |
| 644 } else { | |
| 645 ASSERT(right->IsRegister()); | |
| 646 switch (instr->op()) { | |
| 647 case Token::BIT_AND: | |
| 648 __ andl(ToRegister(left), ToRegister(right)); | |
| 649 break; | |
| 650 case Token::BIT_OR: | |
| 651 __ orl(ToRegister(left), ToRegister(right)); | |
| 652 break; | |
| 653 case Token::BIT_XOR: | |
| 654 __ xorl(ToRegister(left), ToRegister(right)); | |
| 655 break; | |
| 656 default: | |
| 657 UNREACHABLE(); | |
| 658 break; | |
| 659 } | |
| 660 } | |
| 661 } | |
| 609 | 662 |
| 610 | 663 |
| 611 void LCodeGen::DoShiftI(LShiftI* instr) { | 664 void LCodeGen::DoShiftI(LShiftI* instr) { |
| 612 Abort("Unimplemented: %s", "DoShiftI"); | 665 LOperand* left = instr->InputAt(0); |
| 666 LOperand* right = instr->InputAt(1); | |
| 667 ASSERT(left->Equals(instr->result())); | |
| 668 ASSERT(left->IsRegister()); | |
| 669 if (right->IsRegister()) { | |
| 670 ASSERT(ToRegister(right).is(rcx)); | |
| 671 | |
| 672 switch (instr->op()) { | |
| 673 case Token::SAR: | |
| 674 __ sarl_cl(ToRegister(left)); | |
| 675 break; | |
| 676 case Token::SHR: | |
| 677 __ shrl_cl(ToRegister(left)); | |
| 678 if (instr->can_deopt()) { | |
| 679 __ testl(ToRegister(left), Immediate(0x80000000)); | |
|
Lasse Reichstein
2011/02/04 09:51:25
Seems wasteful to compare to a 4-byte literal.
Jus
William Hesse
2011/02/04 14:37:12
Done.
| |
| 680 DeoptimizeIf(not_zero, instr->environment()); | |
| 681 } | |
| 682 break; | |
| 683 case Token::SHL: | |
| 684 __ shll_cl(ToRegister(left)); | |
| 685 break; | |
| 686 default: | |
| 687 UNREACHABLE(); | |
| 688 break; | |
| 689 } | |
| 690 } else { | |
| 691 int value = ToInteger32(LConstantOperand::cast(right)); | |
| 692 uint8_t shift_count = static_cast<uint8_t>(value & 0x1F); | |
| 693 switch (instr->op()) { | |
| 694 case Token::SAR: | |
| 695 if (shift_count != 0) { | |
| 696 __ sarl(ToRegister(left), Immediate(shift_count)); | |
| 697 } | |
| 698 break; | |
| 699 case Token::SHR: | |
| 700 if (shift_count == 0 && instr->can_deopt()) { | |
| 701 __ testl(ToRegister(left), Immediate(0x80000000)); | |
|
Lasse Reichstein
2011/02/04 09:51:25
Test to self and deopt if negative here too.
William Hesse
2011/02/04 14:37:12
Done.
| |
| 702 DeoptimizeIf(not_zero, instr->environment()); | |
| 703 } else { | |
| 704 __ shrl(ToRegister(left), Immediate(shift_count)); | |
| 705 } | |
| 706 break; | |
| 707 case Token::SHL: | |
| 708 if (shift_count != 0) { | |
| 709 __ shll(ToRegister(left), Immediate(shift_count)); | |
| 710 } | |
| 711 break; | |
| 712 default: | |
| 713 UNREACHABLE(); | |
| 714 break; | |
| 715 } | |
| 716 } | |
| 613 } | 717 } |
| 614 | 718 |
| 615 | 719 |
| 616 void LCodeGen::DoSubI(LSubI* instr) { | 720 void LCodeGen::DoSubI(LSubI* instr) { |
| 617 LOperand* left = instr->InputAt(0); | 721 LOperand* left = instr->InputAt(0); |
| 618 LOperand* right = instr->InputAt(1); | 722 LOperand* right = instr->InputAt(1); |
| 619 ASSERT(left->Equals(instr->result())); | 723 ASSERT(left->Equals(instr->result())); |
| 620 | 724 |
| 621 if (right->IsConstantOperand()) { | 725 if (right->IsConstantOperand()) { |
| 622 __ subl(ToRegister(left), | 726 __ subl(ToRegister(left), |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 656 } else { | 760 } else { |
| 657 uint64_t int_val = BitCast<uint64_t, double>(v); | 761 uint64_t int_val = BitCast<uint64_t, double>(v); |
| 658 __ Set(tmp, int_val); | 762 __ Set(tmp, int_val); |
| 659 __ movd(res, tmp); | 763 __ movd(res, tmp); |
| 660 } | 764 } |
| 661 } | 765 } |
| 662 } | 766 } |
| 663 | 767 |
| 664 | 768 |
| 665 void LCodeGen::DoConstantT(LConstantT* instr) { | 769 void LCodeGen::DoConstantT(LConstantT* instr) { |
| 666 ASSERT(instr->result()->IsRegister()); | 770 ASSERT(instr->result()->IsRegister()); |
| 667 __ Move(ToRegister(instr->result()), instr->value()); | 771 __ Move(ToRegister(instr->result()), instr->value()); |
| 668 } | 772 } |
| 669 | 773 |
| 670 | 774 |
| 671 void LCodeGen::DoJSArrayLength(LJSArrayLength* instr) { | 775 void LCodeGen::DoJSArrayLength(LJSArrayLength* instr) { |
| 672 Abort("Unimplemented: %s", "DoJSArrayLength"); | 776 Abort("Unimplemented: %s", "DoJSArrayLength"); |
| 673 } | 777 } |
| 674 | 778 |
| 675 | 779 |
| 676 void LCodeGen::DoFixedArrayLength(LFixedArrayLength* instr) { | 780 void LCodeGen::DoFixedArrayLength(LFixedArrayLength* instr) { |
| 677 Register result = ToRegister(instr->result()); | 781 Register result = ToRegister(instr->result()); |
| 678 Register array = ToRegister(instr->InputAt(0)); | 782 Register array = ToRegister(instr->InputAt(0)); |
| 679 __ movq(result, FieldOperand(array, FixedArray::kLengthOffset)); | 783 __ movq(result, FieldOperand(array, FixedArray::kLengthOffset)); |
| 680 } | 784 } |
| 681 | 785 |
| 682 | 786 |
| 683 void LCodeGen::DoValueOf(LValueOf* instr) { | 787 void LCodeGen::DoValueOf(LValueOf* instr) { |
| 684 Abort("Unimplemented: %s", "DoValueOf"); | 788 Abort("Unimplemented: %s", "DoValueOf"); |
| 685 } | 789 } |
| 686 | 790 |
| 687 | 791 |
| 688 void LCodeGen::DoBitNotI(LBitNotI* instr) { | 792 void LCodeGen::DoBitNotI(LBitNotI* instr) { |
| 689 Abort("Unimplemented: %s", "DoBitNotI"); | 793 LOperand* input = instr->InputAt(0); |
| 794 ASSERT(input->Equals(instr->result())); | |
| 795 __ not_(ToRegister(input)); | |
| 690 } | 796 } |
| 691 | 797 |
| 692 | 798 |
| 693 void LCodeGen::DoThrow(LThrow* instr) { | 799 void LCodeGen::DoThrow(LThrow* instr) { |
| 694 Abort("Unimplemented: %s", "DoThrow"); | 800 Abort("Unimplemented: %s", "DoThrow"); |
| 695 } | 801 } |
| 696 | 802 |
| 697 | 803 |
| 698 void LCodeGen::DoAddI(LAddI* instr) { | 804 void LCodeGen::DoAddI(LAddI* instr) { |
| 699 LOperand* left = instr->InputAt(0); | 805 LOperand* left = instr->InputAt(0); |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1194 } | 1300 } |
| 1195 | 1301 |
| 1196 | 1302 |
| 1197 void LCodeGen::DoHasCachedArrayIndex(LHasCachedArrayIndex* instr) { | 1303 void LCodeGen::DoHasCachedArrayIndex(LHasCachedArrayIndex* instr) { |
| 1198 Abort("Unimplemented: %s", "DoHasCachedArrayIndex"); | 1304 Abort("Unimplemented: %s", "DoHasCachedArrayIndex"); |
| 1199 } | 1305 } |
| 1200 | 1306 |
| 1201 | 1307 |
| 1202 void LCodeGen::DoHasCachedArrayIndexAndBranch( | 1308 void LCodeGen::DoHasCachedArrayIndexAndBranch( |
| 1203 LHasCachedArrayIndexAndBranch* instr) { | 1309 LHasCachedArrayIndexAndBranch* instr) { |
| 1204 Register input = ToRegister(instr->InputAt(0)); | 1310 Register input = ToRegister(instr->InputAt(0)); |
| 1205 | 1311 |
| 1206 int true_block = chunk_->LookupDestination(instr->true_block_id()); | 1312 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
| 1207 int false_block = chunk_->LookupDestination(instr->false_block_id()); | 1313 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
| 1208 | 1314 |
| 1209 __ testl(FieldOperand(input, String::kHashFieldOffset), | 1315 __ testl(FieldOperand(input, String::kHashFieldOffset), |
| 1210 Immediate(String::kContainsCachedArrayIndexMask)); | 1316 Immediate(String::kContainsCachedArrayIndexMask)); |
| 1211 EmitBranch(true_block, false_block, not_equal); | 1317 EmitBranch(true_block, false_block, not_equal); |
| 1212 } | 1318 } |
| 1213 | 1319 |
| 1214 | 1320 |
| (...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2123 | 2229 |
| 2124 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { | 2230 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { |
| 2125 Abort("Unimplemented: %s", "DoOsrEntry"); | 2231 Abort("Unimplemented: %s", "DoOsrEntry"); |
| 2126 } | 2232 } |
| 2127 | 2233 |
| 2128 #undef __ | 2234 #undef __ |
| 2129 | 2235 |
| 2130 } } // namespace v8::internal | 2236 } } // namespace v8::internal |
| 2131 | 2237 |
| 2132 #endif // V8_TARGET_ARCH_X64 | 2238 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |