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 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 } | 706 } |
707 | 707 |
708 void SetArgsInRegisters() { args_in_registers_ = true; } | 708 void SetArgsInRegisters() { args_in_registers_ = true; } |
709 void SetArgsReversed() { args_reversed_ = true; } | 709 void SetArgsReversed() { args_reversed_ = true; } |
710 bool HasSmiCodeInStub() { return (flags_ & NO_SMI_CODE_IN_STUB) == 0; } | 710 bool HasSmiCodeInStub() { return (flags_ & NO_SMI_CODE_IN_STUB) == 0; } |
711 bool HasArgumentsInRegisters() { return args_in_registers_; } | 711 bool HasArgumentsInRegisters() { return args_in_registers_; } |
712 bool HasArgumentsReversed() { return args_reversed_; } | 712 bool HasArgumentsReversed() { return args_reversed_; } |
713 }; | 713 }; |
714 | 714 |
715 | 715 |
| 716 class StringStubBase: public CodeStub { |
| 717 public: |
| 718 // Generate code for copying characters using a simple loop. This should only |
| 719 // be used in places where the number of characters is small and the |
| 720 // additional setup and checking in GenerateCopyCharactersREP adds too much |
| 721 // overhead. Copying of overlapping regions is not supported. |
| 722 void GenerateCopyCharacters(MacroAssembler* masm, |
| 723 Register dest, |
| 724 Register src, |
| 725 Register count, |
| 726 bool ascii); |
| 727 |
| 728 // Generate code for copying characters using the rep movs instruction. |
| 729 // Copies rcx characters from rsi to rdi. Copying of overlapping regions is |
| 730 // not supported. |
| 731 void GenerateCopyCharactersREP(MacroAssembler* masm, |
| 732 Register dest, // Must be rdi. |
| 733 Register src, // Must be rsi. |
| 734 Register count, // Must be rcx. |
| 735 bool ascii); |
| 736 }; |
| 737 |
| 738 |
716 // Flag that indicates how to generate code for the stub StringAddStub. | 739 // Flag that indicates how to generate code for the stub StringAddStub. |
717 enum StringAddFlags { | 740 enum StringAddFlags { |
718 NO_STRING_ADD_FLAGS = 0, | 741 NO_STRING_ADD_FLAGS = 0, |
719 NO_STRING_CHECK_IN_STUB = 1 << 0 // Omit string check in stub. | 742 NO_STRING_CHECK_IN_STUB = 1 << 0 // Omit string check in stub. |
720 }; | 743 }; |
721 | 744 |
722 | 745 |
723 class StringAddStub: public CodeStub { | 746 class StringAddStub: public StringStubBase { |
724 public: | 747 public: |
725 explicit StringAddStub(StringAddFlags flags) { | 748 explicit StringAddStub(StringAddFlags flags) { |
726 string_check_ = ((flags & NO_STRING_CHECK_IN_STUB) == 0); | 749 string_check_ = ((flags & NO_STRING_CHECK_IN_STUB) == 0); |
727 } | 750 } |
728 | 751 |
729 private: | 752 private: |
730 Major MajorKey() { return StringAdd; } | 753 Major MajorKey() { return StringAdd; } |
731 int MinorKey() { return string_check_ ? 0 : 1; } | 754 int MinorKey() { return string_check_ ? 0 : 1; } |
732 | 755 |
733 void Generate(MacroAssembler* masm); | 756 void Generate(MacroAssembler* masm); |
734 | 757 |
735 void GenerateCopyCharacters(MacroAssembler* masm, | |
736 Register desc, | |
737 Register src, | |
738 Register count, | |
739 bool ascii); | |
740 | |
741 // Should the stub check whether arguments are strings? | 758 // Should the stub check whether arguments are strings? |
742 bool string_check_; | 759 bool string_check_; |
743 }; | 760 }; |
744 | 761 |
745 | 762 |
| 763 class SubStringStub: public StringStubBase { |
| 764 public: |
| 765 SubStringStub() {} |
| 766 |
| 767 private: |
| 768 Major MajorKey() { return SubString; } |
| 769 int MinorKey() { return 0; } |
| 770 |
| 771 void Generate(MacroAssembler* masm); |
| 772 }; |
| 773 |
| 774 |
746 class StringCompareStub: public CodeStub { | 775 class StringCompareStub: public CodeStub { |
747 public: | 776 public: |
748 explicit StringCompareStub() {} | 777 explicit StringCompareStub() {} |
749 | 778 |
750 // Compare two flat ascii strings and returns result in rax after popping two | 779 // Compare two flat ascii strings and returns result in rax after popping two |
751 // arguments from the stack. | 780 // arguments from the stack. |
752 static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm, | 781 static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm, |
753 Register left, | 782 Register left, |
754 Register right, | 783 Register right, |
755 Register scratch1, | 784 Register scratch1, |
756 Register scratch2, | 785 Register scratch2, |
757 Register scratch3, | 786 Register scratch3, |
758 Register scratch4); | 787 Register scratch4); |
759 | 788 |
760 private: | 789 private: |
761 Major MajorKey() { return StringCompare; } | 790 Major MajorKey() { return StringCompare; } |
762 int MinorKey() { return 0; } | 791 int MinorKey() { return 0; } |
763 | 792 |
764 void Generate(MacroAssembler* masm); | 793 void Generate(MacroAssembler* masm); |
765 }; | 794 }; |
766 | 795 |
767 | 796 |
768 } } // namespace v8::internal | 797 } } // namespace v8::internal |
769 | 798 |
770 #endif // V8_X64_CODEGEN_X64_H_ | 799 #endif // V8_X64_CODEGEN_X64_H_ |
OLD | NEW |