| 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 StringStubBase: public CodeStub { | 886 class StringHelper : public AllStatic { |
| 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 |
| 888 // Generate code for copying characters using a simple loop. This should only | 917 // Generate code for copying characters using a simple loop. This should only |
| 889 // be used in places where the number of characters is small and the | 918 // be used in places where the number of characters is small and the |
| 890 // additional setup and checking in GenerateCopyCharactersREP adds too much | 919 // additional setup and checking in GenerateCopyCharactersREP adds too much |
| 891 // overhead. Copying of overlapping regions is not supported. | 920 // overhead. Copying of overlapping regions is not supported. |
| 892 void GenerateCopyCharacters(MacroAssembler* masm, | 921 static void GenerateCopyCharacters(MacroAssembler* masm, |
| 893 Register dest, | 922 Register dest, |
| 894 Register src, | 923 Register src, |
| 895 Register count, | 924 Register count, |
| 896 Register scratch, | 925 Register scratch, |
| 897 bool ascii); | 926 bool ascii); |
| 898 | 927 |
| 899 // Generate code for copying characters using the rep movs instruction. | 928 // Generate code for copying characters using the rep movs instruction. |
| 900 // Copies ecx characters from esi to edi. Copying of overlapping regions is | 929 // Copies ecx characters from esi to edi. Copying of overlapping regions is |
| 901 // not supported. | 930 // not supported. |
| 902 void GenerateCopyCharactersREP(MacroAssembler* masm, | 931 static void GenerateCopyCharactersREP(MacroAssembler* masm, |
| 903 Register dest, // Must be edi. | 932 Register dest, // Must be edi. |
| 904 Register src, // Must be esi. | 933 Register src, // Must be esi. |
| 905 Register count, // Must be ecx. | 934 Register count, // Must be ecx. |
| 906 Register scratch, // Neither of the above. | 935 Register scratch, // Neither of above. |
| 907 bool ascii); | 936 bool ascii); |
| 908 | 937 |
| 909 // Probe the symbol table for a two character string. If the string is | 938 // Probe the symbol table for a two character string. If the string is |
| 910 // not found by probing a jump to the label not_found is performed. This jump | 939 // not found by probing a jump to the label not_found is performed. This jump |
| 911 // does not guarantee that the string is not in the symbol table. If the | 940 // does not guarantee that the string is not in the symbol table. If the |
| 912 // string is found the code falls through with the string in register eax. | 941 // string is found the code falls through with the string in register eax. |
| 913 void GenerateTwoCharacterSymbolTableProbe(MacroAssembler* masm, | 942 static void GenerateTwoCharacterSymbolTableProbe(MacroAssembler* masm, |
| 914 Register c1, | 943 Register c1, |
| 915 Register c2, | 944 Register c2, |
| 916 Register scratch1, | 945 Register scratch1, |
| 917 Register scratch2, | 946 Register scratch2, |
| 918 Register scratch3, | 947 Register scratch3, |
| 919 Label* not_found); | 948 Label* not_found); |
| 920 | 949 |
| 921 // Generate string hash. | 950 // Generate string hash. |
| 922 void GenerateHashInit(MacroAssembler* masm, | 951 static void GenerateHashInit(MacroAssembler* masm, |
| 923 Register hash, | 952 Register hash, |
| 924 Register character, | 953 Register character, |
| 925 Register scratch); | 954 Register scratch); |
| 926 void GenerateHashAddCharacter(MacroAssembler* masm, | 955 static void GenerateHashAddCharacter(MacroAssembler* masm, |
| 927 Register hash, | 956 Register hash, |
| 928 Register character, | 957 Register character, |
| 929 Register scratch); | 958 Register scratch); |
| 930 void GenerateHashGetHash(MacroAssembler* masm, | 959 static void GenerateHashGetHash(MacroAssembler* masm, |
| 931 Register hash, | 960 Register hash, |
| 932 Register scratch); | 961 Register scratch); |
| 962 |
| 963 private: |
| 964 DISALLOW_IMPLICIT_CONSTRUCTORS(StringHelper); |
| 933 }; | 965 }; |
| 934 | 966 |
| 935 | 967 |
| 936 // Flag that indicates how to generate code for the stub StringAddStub. | 968 // Flag that indicates how to generate code for the stub StringAddStub. |
| 937 enum StringAddFlags { | 969 enum StringAddFlags { |
| 938 NO_STRING_ADD_FLAGS = 0, | 970 NO_STRING_ADD_FLAGS = 0, |
| 939 NO_STRING_CHECK_IN_STUB = 1 << 0 // Omit string check in stub. | 971 NO_STRING_CHECK_IN_STUB = 1 << 0 // Omit string check in stub. |
| 940 }; | 972 }; |
| 941 | 973 |
| 942 | 974 |
| 943 class StringAddStub: public StringStubBase { | 975 class StringAddStub: public CodeStub { |
| 944 public: | 976 public: |
| 945 explicit StringAddStub(StringAddFlags flags) { | 977 explicit StringAddStub(StringAddFlags flags) { |
| 946 string_check_ = ((flags & NO_STRING_CHECK_IN_STUB) == 0); | 978 string_check_ = ((flags & NO_STRING_CHECK_IN_STUB) == 0); |
| 947 } | 979 } |
| 948 | 980 |
| 949 private: | 981 private: |
| 950 Major MajorKey() { return StringAdd; } | 982 Major MajorKey() { return StringAdd; } |
| 951 int MinorKey() { return string_check_ ? 0 : 1; } | 983 int MinorKey() { return string_check_ ? 0 : 1; } |
| 952 | 984 |
| 953 void Generate(MacroAssembler* masm); | 985 void Generate(MacroAssembler* masm); |
| 954 | 986 |
| 955 // Should the stub check whether arguments are strings? | 987 // Should the stub check whether arguments are strings? |
| 956 bool string_check_; | 988 bool string_check_; |
| 957 }; | 989 }; |
| 958 | 990 |
| 959 | 991 |
| 960 class SubStringStub: public StringStubBase { | 992 class SubStringStub: public CodeStub { |
| 961 public: | 993 public: |
| 962 SubStringStub() {} | 994 SubStringStub() {} |
| 963 | 995 |
| 964 private: | 996 private: |
| 965 Major MajorKey() { return SubString; } | 997 Major MajorKey() { return SubString; } |
| 966 int MinorKey() { return 0; } | 998 int MinorKey() { return 0; } |
| 967 | 999 |
| 968 void Generate(MacroAssembler* masm); | 1000 void Generate(MacroAssembler* masm); |
| 969 }; | 1001 }; |
| 970 | 1002 |
| 971 | 1003 |
| 972 class StringCompareStub: public StringStubBase { | 1004 class StringCompareStub: public CodeStub { |
| 973 public: | 1005 public: |
| 974 explicit StringCompareStub() { | 1006 explicit StringCompareStub() { |
| 975 } | 1007 } |
| 976 | 1008 |
| 977 // Compare two flat ascii strings and returns result in eax after popping two | 1009 // Compare two flat ascii strings and returns result in eax after popping two |
| 978 // arguments from the stack. | 1010 // arguments from the stack. |
| 979 static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm, | 1011 static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm, |
| 980 Register left, | 1012 Register left, |
| 981 Register right, | 1013 Register right, |
| 982 Register scratch1, | 1014 Register scratch1, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1056 return ObjectBits::encode(object_.code()) | | 1088 return ObjectBits::encode(object_.code()) | |
| 1057 AddressBits::encode(addr_.code()) | | 1089 AddressBits::encode(addr_.code()) | |
| 1058 ScratchBits::encode(scratch_.code()); | 1090 ScratchBits::encode(scratch_.code()); |
| 1059 } | 1091 } |
| 1060 }; | 1092 }; |
| 1061 | 1093 |
| 1062 | 1094 |
| 1063 } } // namespace v8::internal | 1095 } } // namespace v8::internal |
| 1064 | 1096 |
| 1065 #endif // V8_IA32_CODEGEN_IA32_H_ | 1097 #endif // V8_IA32_CODEGEN_IA32_H_ |
| OLD | NEW |