| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 876 } | 876 } |
| 877 | 877 |
| 878 virtual int GetCodeKind() { return Code::BINARY_OP_IC; } | 878 virtual int GetCodeKind() { return Code::BINARY_OP_IC; } |
| 879 | 879 |
| 880 virtual InlineCacheState GetICState() { | 880 virtual InlineCacheState GetICState() { |
| 881 return BinaryOpIC::ToState(runtime_operands_type_); | 881 return BinaryOpIC::ToState(runtime_operands_type_); |
| 882 } | 882 } |
| 883 }; | 883 }; |
| 884 | 884 |
| 885 | 885 |
| 886 class StringHelper : public AllStatic { | 886 class StringStubBase: public CodeStub { |
| 887 public: | 887 public: |
| 888 // Generates fast code for getting a char code out of a string | |
| 889 // object at the given index. May bail out for three reasons (in the | |
| 890 // listed order): | |
| 891 // * Receiver is not a string (receiver_not_string label). | |
| 892 // * Index is not a positive smi (index_not_positive_smi label). | |
| 893 // * Some other reason (slow_case label). In this case it's | |
| 894 // guaranteed that the above conditions are not violated, | |
| 895 // e.g. it's safe to assume the receiver is a string and the | |
| 896 // index is a positive smi. | |
| 897 // When successful, object, index, and scratch are clobbered. | |
| 898 // Otherwise, scratch and result are clobbered. | |
| 899 static void GenerateFastCharCodeAt(MacroAssembler* masm, | |
| 900 Register object, | |
| 901 Register index, | |
| 902 Register scratch, | |
| 903 Register result, | |
| 904 Label* receiver_not_string, | |
| 905 Label* index_not_positive_smi, | |
| 906 Label* slow_case); | |
| 907 | |
| 908 // Generates code for creating a one-char string from the given char | |
| 909 // code. May do a runtime call, so any register can be clobbered | |
| 910 // and, if the given invoke flag specifies a call, an internal frame | |
| 911 // is required. In tail call mode the result must be eax register. | |
| 912 static void GenerateCharFromCode(MacroAssembler* masm, | |
| 913 Register code, | |
| 914 Register result, | |
| 915 InvokeFlag flag); | |
| 916 | |
| 917 // Generate code for copying characters using a simple loop. This should only | 888 // Generate code for copying characters using a simple loop. This should only |
| 918 // be used in places where the number of characters is small and the | 889 // be used in places where the number of characters is small and the |
| 919 // additional setup and checking in GenerateCopyCharactersREP adds too much | 890 // additional setup and checking in GenerateCopyCharactersREP adds too much |
| 920 // overhead. Copying of overlapping regions is not supported. | 891 // overhead. Copying of overlapping regions is not supported. |
| 921 static void GenerateCopyCharacters(MacroAssembler* masm, | 892 void GenerateCopyCharacters(MacroAssembler* masm, |
| 922 Register dest, | 893 Register dest, |
| 923 Register src, | 894 Register src, |
| 924 Register count, | 895 Register count, |
| 925 Register scratch, | 896 Register scratch, |
| 926 bool ascii); | 897 bool ascii); |
| 927 | 898 |
| 928 // Generate code for copying characters using the rep movs instruction. | 899 // Generate code for copying characters using the rep movs instruction. |
| 929 // Copies ecx characters from esi to edi. Copying of overlapping regions is | 900 // Copies ecx characters from esi to edi. Copying of overlapping regions is |
| 930 // not supported. | 901 // not supported. |
| 931 static void GenerateCopyCharactersREP(MacroAssembler* masm, | 902 void GenerateCopyCharactersREP(MacroAssembler* masm, |
| 932 Register dest, // Must be edi. | 903 Register dest, // Must be edi. |
| 933 Register src, // Must be esi. | 904 Register src, // Must be esi. |
| 934 Register count, // Must be ecx. | 905 Register count, // Must be ecx. |
| 935 Register scratch, // Neither of above. | 906 Register scratch, // Neither of the above. |
| 936 bool ascii); | 907 bool ascii); |
| 937 | 908 |
| 938 // Probe the symbol table for a two character string. If the string is | 909 // Probe the symbol table for a two character string. If the string is |
| 939 // not found by probing a jump to the label not_found is performed. This jump | 910 // not found by probing a jump to the label not_found is performed. This jump |
| 940 // does not guarantee that the string is not in the symbol table. If the | 911 // does not guarantee that the string is not in the symbol table. If the |
| 941 // string is found the code falls through with the string in register eax. | 912 // string is found the code falls through with the string in register eax. |
| 942 static void GenerateTwoCharacterSymbolTableProbe(MacroAssembler* masm, | 913 void GenerateTwoCharacterSymbolTableProbe(MacroAssembler* masm, |
| 943 Register c1, | 914 Register c1, |
| 944 Register c2, | 915 Register c2, |
| 945 Register scratch1, | 916 Register scratch1, |
| 946 Register scratch2, | 917 Register scratch2, |
| 947 Register scratch3, | 918 Register scratch3, |
| 948 Label* not_found); | 919 Label* not_found); |
| 949 | 920 |
| 950 // Generate string hash. | 921 // Generate string hash. |
| 951 static void GenerateHashInit(MacroAssembler* masm, | 922 void GenerateHashInit(MacroAssembler* masm, |
| 952 Register hash, | 923 Register hash, |
| 953 Register character, | 924 Register character, |
| 954 Register scratch); | 925 Register scratch); |
| 955 static void GenerateHashAddCharacter(MacroAssembler* masm, | 926 void GenerateHashAddCharacter(MacroAssembler* masm, |
| 956 Register hash, | 927 Register hash, |
| 957 Register character, | 928 Register character, |
| 958 Register scratch); | 929 Register scratch); |
| 959 static void GenerateHashGetHash(MacroAssembler* masm, | 930 void GenerateHashGetHash(MacroAssembler* masm, |
| 960 Register hash, | 931 Register hash, |
| 961 Register scratch); | 932 Register scratch); |
| 962 | |
| 963 private: | |
| 964 DISALLOW_IMPLICIT_CONSTRUCTORS(StringHelper); | |
| 965 }; | 933 }; |
| 966 | 934 |
| 967 | 935 |
| 968 // Flag that indicates how to generate code for the stub StringAddStub. | 936 // Flag that indicates how to generate code for the stub StringAddStub. |
| 969 enum StringAddFlags { | 937 enum StringAddFlags { |
| 970 NO_STRING_ADD_FLAGS = 0, | 938 NO_STRING_ADD_FLAGS = 0, |
| 971 NO_STRING_CHECK_IN_STUB = 1 << 0 // Omit string check in stub. | 939 NO_STRING_CHECK_IN_STUB = 1 << 0 // Omit string check in stub. |
| 972 }; | 940 }; |
| 973 | 941 |
| 974 | 942 |
| 975 class StringAddStub: public CodeStub { | 943 class StringAddStub: public StringStubBase { |
| 976 public: | 944 public: |
| 977 explicit StringAddStub(StringAddFlags flags) { | 945 explicit StringAddStub(StringAddFlags flags) { |
| 978 string_check_ = ((flags & NO_STRING_CHECK_IN_STUB) == 0); | 946 string_check_ = ((flags & NO_STRING_CHECK_IN_STUB) == 0); |
| 979 } | 947 } |
| 980 | 948 |
| 981 private: | 949 private: |
| 982 Major MajorKey() { return StringAdd; } | 950 Major MajorKey() { return StringAdd; } |
| 983 int MinorKey() { return string_check_ ? 0 : 1; } | 951 int MinorKey() { return string_check_ ? 0 : 1; } |
| 984 | 952 |
| 985 void Generate(MacroAssembler* masm); | 953 void Generate(MacroAssembler* masm); |
| 986 | 954 |
| 987 // Should the stub check whether arguments are strings? | 955 // Should the stub check whether arguments are strings? |
| 988 bool string_check_; | 956 bool string_check_; |
| 989 }; | 957 }; |
| 990 | 958 |
| 991 | 959 |
| 992 class SubStringStub: public CodeStub { | 960 class SubStringStub: public StringStubBase { |
| 993 public: | 961 public: |
| 994 SubStringStub() {} | 962 SubStringStub() {} |
| 995 | 963 |
| 996 private: | 964 private: |
| 997 Major MajorKey() { return SubString; } | 965 Major MajorKey() { return SubString; } |
| 998 int MinorKey() { return 0; } | 966 int MinorKey() { return 0; } |
| 999 | 967 |
| 1000 void Generate(MacroAssembler* masm); | 968 void Generate(MacroAssembler* masm); |
| 1001 }; | 969 }; |
| 1002 | 970 |
| 1003 | 971 |
| 1004 class StringCompareStub: public CodeStub { | 972 class StringCompareStub: public StringStubBase { |
| 1005 public: | 973 public: |
| 1006 explicit StringCompareStub() { | 974 explicit StringCompareStub() { |
| 1007 } | 975 } |
| 1008 | 976 |
| 1009 // Compare two flat ascii strings and returns result in eax after popping two | 977 // Compare two flat ascii strings and returns result in eax after popping two |
| 1010 // arguments from the stack. | 978 // arguments from the stack. |
| 1011 static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm, | 979 static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm, |
| 1012 Register left, | 980 Register left, |
| 1013 Register right, | 981 Register right, |
| 1014 Register scratch1, | 982 Register scratch1, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1088 return ObjectBits::encode(object_.code()) | | 1056 return ObjectBits::encode(object_.code()) | |
| 1089 AddressBits::encode(addr_.code()) | | 1057 AddressBits::encode(addr_.code()) | |
| 1090 ScratchBits::encode(scratch_.code()); | 1058 ScratchBits::encode(scratch_.code()); |
| 1091 } | 1059 } |
| 1092 }; | 1060 }; |
| 1093 | 1061 |
| 1094 | 1062 |
| 1095 } } // namespace v8::internal | 1063 } } // namespace v8::internal |
| 1096 | 1064 |
| 1097 #endif // V8_IA32_CODEGEN_IA32_H_ | 1065 #endif // V8_IA32_CODEGEN_IA32_H_ |
| OLD | NEW |