Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #if V8_TARGET_ARCH_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
| 6 | 6 |
| 7 #include "src/code-stubs.h" | 7 #include "src/code-stubs.h" |
| 8 #include "src/api-arguments.h" | 8 #include "src/api-arguments.h" |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 769 STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); | 769 STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); |
| 770 STATIC_ASSERT(Isolate::kJSRegexpStaticOffsetsVectorSize >= 2); | 770 STATIC_ASSERT(Isolate::kJSRegexpStaticOffsetsVectorSize >= 2); |
| 771 __ cmp(edx, Isolate::kJSRegexpStaticOffsetsVectorSize - 2); | 771 __ cmp(edx, Isolate::kJSRegexpStaticOffsetsVectorSize - 2); |
| 772 __ j(above, &runtime); | 772 __ j(above, &runtime); |
| 773 | 773 |
| 774 // Reset offset for possibly sliced string. | 774 // Reset offset for possibly sliced string. |
| 775 __ Move(edi, Immediate(0)); | 775 __ Move(edi, Immediate(0)); |
| 776 __ mov(eax, Operand(esp, kSubjectOffset)); | 776 __ mov(eax, Operand(esp, kSubjectOffset)); |
| 777 __ JumpIfSmi(eax, &runtime); | 777 __ JumpIfSmi(eax, &runtime); |
| 778 __ mov(edx, eax); // Make a copy of the original subject string. | 778 __ mov(edx, eax); // Make a copy of the original subject string. |
| 779 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); | |
| 780 __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset)); | |
| 781 | 779 |
| 782 // eax: subject string | 780 // eax: subject string |
| 783 // edx: subject string | 781 // edx: subject string |
| 784 // ebx: subject string instance type | 782 // ebx: subject string instance type |
|
Jakob Kummerow
2016/04/18 12:45:13
outdated comment
Yang
2016/04/18 12:48:39
Done.
| |
| 785 // ecx: RegExp data (FixedArray) | 783 // ecx: RegExp data (FixedArray) |
| 786 // Handle subject string according to its encoding and representation: | 784 // Handle subject string according to its encoding and representation: |
| 787 // (1) Sequential two byte? If yes, go to (9). | 785 // (1) Sequential two byte? If yes, go to (9). |
| 788 // (2) Sequential one byte? If yes, go to (6). | 786 // (2) Sequential one byte? If yes, go to (5). |
| 789 // (3) Anything but sequential or cons? If yes, go to (7). | 787 // (3) Sequential or cons? If not, go to (6). |
| 790 // (4) Cons string. If the string is flat, replace subject with first string. | 788 // (4) Cons string. If the string is flat, replace subject with first string |
| 791 // Otherwise bailout. | 789 // and go to (1). Otherwise bail out to runtime. |
| 792 // (5a) Is subject sequential two byte? If yes, go to (9). | 790 // (5) One byte sequential. Load regexp code for one byte. |
| 793 // (5b) Is subject external? If yes, go to (8). | |
| 794 // (6) One byte sequential. Load regexp code for one byte. | |
| 795 // (E) Carry on. | 791 // (E) Carry on. |
| 796 /// [...] | 792 /// [...] |
| 797 | 793 |
| 798 // Deferred code at the end of the stub: | 794 // Deferred code at the end of the stub: |
| 799 // (7) Not a long external string? If yes, go to (10). | 795 // (6) Long external string? If not, go to (10). |
| 800 // (8) External string. Make it, offset-wise, look like a sequential string. | 796 // (7) External string. Make it, offset-wise, look like a sequential string. |
| 801 // (8a) Is the external string one byte? If yes, go to (6). | 797 // (8) Is the external string one byte? If yes, go to (5). |
| 802 // (9) Two byte sequential. Load regexp code for one byte. Go to (E). | 798 // (9) Two byte sequential. Load regexp code for two byte. Go to (E). |
| 803 // (10) Short external string or not a string? If yes, bail out to runtime. | 799 // (10) Short external string or not a string? If yes, bail out to runtime. |
| 804 // (11) Sliced string. Replace subject with parent. Go to (5a). | 800 // (11) Sliced string. Replace subject with parent. Go to (1). |
| 805 | 801 |
| 806 Label seq_one_byte_string /* 6 */, seq_two_byte_string /* 9 */, | 802 Label seq_one_byte_string /* 5 */, seq_two_byte_string /* 9 */, |
| 807 external_string /* 8 */, check_underlying /* 5a */, | 803 external_string /* 7 */, check_underlying /* 1 */, |
| 808 not_seq_nor_cons /* 7 */, check_code /* E */, | 804 not_seq_nor_cons /* 6 */, check_code /* E */, not_long_external /* 10 */; |
| 809 not_long_external /* 10 */; | |
| 810 | 805 |
| 806 __ bind(&check_underlying); | |
| 811 // (1) Sequential two byte? If yes, go to (9). | 807 // (1) Sequential two byte? If yes, go to (9). |
| 808 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); | |
| 809 __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset)); | |
| 810 | |
| 812 __ and_(ebx, kIsNotStringMask | | 811 __ and_(ebx, kIsNotStringMask | |
| 813 kStringRepresentationMask | | 812 kStringRepresentationMask | |
| 814 kStringEncodingMask | | 813 kStringEncodingMask | |
| 815 kShortExternalStringMask); | 814 kShortExternalStringMask); |
| 816 STATIC_ASSERT((kStringTag | kSeqStringTag | kTwoByteStringTag) == 0); | 815 STATIC_ASSERT((kStringTag | kSeqStringTag | kTwoByteStringTag) == 0); |
| 817 __ j(zero, &seq_two_byte_string); // Go to (9). | 816 __ j(zero, &seq_two_byte_string); // Go to (9). |
| 818 | 817 |
| 819 // (2) Sequential one byte? If yes, go to (6). | 818 // (2) Sequential one byte? If yes, go to (5). |
| 820 // Any other sequential string must be one byte. | 819 // Any other sequential string must be one byte. |
| 821 __ and_(ebx, Immediate(kIsNotStringMask | | 820 __ and_(ebx, Immediate(kIsNotStringMask | |
| 822 kStringRepresentationMask | | 821 kStringRepresentationMask | |
| 823 kShortExternalStringMask)); | 822 kShortExternalStringMask)); |
| 824 __ j(zero, &seq_one_byte_string, Label::kNear); // Go to (6). | 823 __ j(zero, &seq_one_byte_string, Label::kNear); // Go to (5). |
| 825 | 824 |
| 826 // (3) Anything but sequential or cons? If yes, go to (7). | 825 // (3) Sequential or cons? If not, go to (6). |
| 827 // We check whether the subject string is a cons, since sequential strings | 826 // We check whether the subject string is a cons, since sequential strings |
| 828 // have already been covered. | 827 // have already been covered. |
| 829 STATIC_ASSERT(kConsStringTag < kExternalStringTag); | 828 STATIC_ASSERT(kConsStringTag < kExternalStringTag); |
| 830 STATIC_ASSERT(kSlicedStringTag > kExternalStringTag); | 829 STATIC_ASSERT(kSlicedStringTag > kExternalStringTag); |
| 831 STATIC_ASSERT(kIsNotStringMask > kExternalStringTag); | 830 STATIC_ASSERT(kIsNotStringMask > kExternalStringTag); |
| 832 STATIC_ASSERT(kShortExternalStringTag > kExternalStringTag); | 831 STATIC_ASSERT(kShortExternalStringTag > kExternalStringTag); |
| 833 __ cmp(ebx, Immediate(kExternalStringTag)); | 832 __ cmp(ebx, Immediate(kExternalStringTag)); |
| 834 __ j(greater_equal, ¬_seq_nor_cons); // Go to (7). | 833 __ j(greater_equal, ¬_seq_nor_cons); // Go to (6). |
| 835 | 834 |
| 836 // (4) Cons string. Check that it's flat. | 835 // (4) Cons string. Check that it's flat. |
| 837 // Replace subject with first string and reload instance type. | 836 // Replace subject with first string and reload instance type. |
| 838 __ cmp(FieldOperand(eax, ConsString::kSecondOffset), factory->empty_string()); | 837 __ cmp(FieldOperand(eax, ConsString::kSecondOffset), factory->empty_string()); |
| 839 __ j(not_equal, &runtime); | 838 __ j(not_equal, &runtime); |
| 840 __ mov(eax, FieldOperand(eax, ConsString::kFirstOffset)); | 839 __ mov(eax, FieldOperand(eax, ConsString::kFirstOffset)); |
| 841 __ bind(&check_underlying); | 840 __ jmp(&check_underlying); |
| 842 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); | |
| 843 __ mov(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset)); | |
| 844 | |
| 845 // (5a) Is subject sequential two byte? If yes, go to (9). | |
| 846 __ test_b(ebx, Immediate(kStringRepresentationMask | kStringEncodingMask)); | |
| 847 STATIC_ASSERT((kSeqStringTag | kTwoByteStringTag) == 0); | |
| 848 __ j(zero, &seq_two_byte_string); // Go to (9). | |
| 849 // (5b) Is subject external? If yes, go to (8). | |
| 850 __ test_b(ebx, Immediate(kStringRepresentationMask)); | |
| 851 // The underlying external string is never a short external string. | |
| 852 STATIC_ASSERT(ExternalString::kMaxShortLength < ConsString::kMinLength); | |
| 853 STATIC_ASSERT(ExternalString::kMaxShortLength < SlicedString::kMinLength); | |
| 854 __ j(not_zero, &external_string); // Go to (8). | |
| 855 | 841 |
| 856 // eax: sequential subject string (or look-alike, external string) | 842 // eax: sequential subject string (or look-alike, external string) |
| 857 // edx: original subject string | 843 // edx: original subject string |
| 858 // ecx: RegExp data (FixedArray) | 844 // ecx: RegExp data (FixedArray) |
| 859 // (6) One byte sequential. Load regexp code for one byte. | 845 // (5) One byte sequential. Load regexp code for one byte. |
| 860 __ bind(&seq_one_byte_string); | 846 __ bind(&seq_one_byte_string); |
| 861 // Load previous index and check range before edx is overwritten. We have | 847 // Load previous index and check range before edx is overwritten. We have |
| 862 // to use edx instead of eax here because it might have been only made to | 848 // to use edx instead of eax here because it might have been only made to |
| 863 // look like a sequential string when it actually is an external string. | 849 // look like a sequential string when it actually is an external string. |
| 864 __ mov(ebx, Operand(esp, kPreviousIndexOffset)); | 850 __ mov(ebx, Operand(esp, kPreviousIndexOffset)); |
| 865 __ JumpIfNotSmi(ebx, &runtime); | 851 __ JumpIfNotSmi(ebx, &runtime); |
| 866 __ cmp(ebx, FieldOperand(edx, String::kLengthOffset)); | 852 __ cmp(ebx, FieldOperand(edx, String::kLengthOffset)); |
| 867 __ j(above_equal, &runtime); | 853 __ j(above_equal, &runtime); |
| 868 __ mov(edx, FieldOperand(ecx, JSRegExp::kDataOneByteCodeOffset)); | 854 __ mov(edx, FieldOperand(ecx, JSRegExp::kDataOneByteCodeOffset)); |
| 869 __ Move(ecx, Immediate(1)); // Type is one byte. | 855 __ Move(ecx, Immediate(1)); // Type is one byte. |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1076 | 1062 |
| 1077 // Return last match info. | 1063 // Return last match info. |
| 1078 __ mov(eax, Operand(esp, kLastMatchInfoOffset)); | 1064 __ mov(eax, Operand(esp, kLastMatchInfoOffset)); |
| 1079 __ ret(4 * kPointerSize); | 1065 __ ret(4 * kPointerSize); |
| 1080 | 1066 |
| 1081 // Do the runtime call to execute the regexp. | 1067 // Do the runtime call to execute the regexp. |
| 1082 __ bind(&runtime); | 1068 __ bind(&runtime); |
| 1083 __ TailCallRuntime(Runtime::kRegExpExec); | 1069 __ TailCallRuntime(Runtime::kRegExpExec); |
| 1084 | 1070 |
| 1085 // Deferred code for string handling. | 1071 // Deferred code for string handling. |
| 1086 // (7) Not a long external string? If yes, go to (10). | 1072 // (6) Long external string? If not, go to (10). |
| 1087 __ bind(¬_seq_nor_cons); | 1073 __ bind(¬_seq_nor_cons); |
| 1088 // Compare flags are still set from (3). | 1074 // Compare flags are still set from (3). |
| 1089 __ j(greater, ¬_long_external, Label::kNear); // Go to (10). | 1075 __ j(greater, ¬_long_external, Label::kNear); // Go to (10). |
| 1090 | 1076 |
| 1091 // (8) External string. Short external strings have been ruled out. | 1077 // (7) External string. Short external strings have been ruled out. |
| 1092 __ bind(&external_string); | 1078 __ bind(&external_string); |
| 1093 // Reload instance type. | 1079 // Reload instance type. |
| 1094 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); | 1080 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); |
| 1095 __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset)); | 1081 __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset)); |
| 1096 if (FLAG_debug_code) { | 1082 if (FLAG_debug_code) { |
| 1097 // Assert that we do not have a cons or slice (indirect strings) here. | 1083 // Assert that we do not have a cons or slice (indirect strings) here. |
| 1098 // Sequential strings have already been ruled out. | 1084 // Sequential strings have already been ruled out. |
| 1099 __ test_b(ebx, Immediate(kIsIndirectStringMask)); | 1085 __ test_b(ebx, Immediate(kIsIndirectStringMask)); |
| 1100 __ Assert(zero, kExternalStringExpectedButNotFound); | 1086 __ Assert(zero, kExternalStringExpectedButNotFound); |
| 1101 } | 1087 } |
| 1102 __ mov(eax, FieldOperand(eax, ExternalString::kResourceDataOffset)); | 1088 __ mov(eax, FieldOperand(eax, ExternalString::kResourceDataOffset)); |
| 1103 // Move the pointer so that offset-wise, it looks like a sequential string. | 1089 // Move the pointer so that offset-wise, it looks like a sequential string. |
| 1104 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqOneByteString::kHeaderSize); | 1090 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqOneByteString::kHeaderSize); |
| 1105 __ sub(eax, Immediate(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); | 1091 __ sub(eax, Immediate(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); |
| 1106 STATIC_ASSERT(kTwoByteStringTag == 0); | 1092 STATIC_ASSERT(kTwoByteStringTag == 0); |
| 1107 // (8a) Is the external string one byte? If yes, go to (6). | 1093 // (8) Is the external string one byte? If yes, go to (5). |
| 1108 __ test_b(ebx, Immediate(kStringEncodingMask)); | 1094 __ test_b(ebx, Immediate(kStringEncodingMask)); |
| 1109 __ j(not_zero, &seq_one_byte_string); // Goto (6). | 1095 __ j(not_zero, &seq_one_byte_string); // Go to (5). |
| 1110 | 1096 |
| 1111 // eax: sequential subject string (or look-alike, external string) | 1097 // eax: sequential subject string (or look-alike, external string) |
| 1112 // edx: original subject string | 1098 // edx: original subject string |
| 1113 // ecx: RegExp data (FixedArray) | 1099 // ecx: RegExp data (FixedArray) |
| 1114 // (9) Two byte sequential. Load regexp code for one byte. Go to (E). | 1100 // (9) Two byte sequential. Load regexp code for two byte. Go to (E). |
| 1115 __ bind(&seq_two_byte_string); | 1101 __ bind(&seq_two_byte_string); |
| 1116 // Load previous index and check range before edx is overwritten. We have | 1102 // Load previous index and check range before edx is overwritten. We have |
| 1117 // to use edx instead of eax here because it might have been only made to | 1103 // to use edx instead of eax here because it might have been only made to |
| 1118 // look like a sequential string when it actually is an external string. | 1104 // look like a sequential string when it actually is an external string. |
| 1119 __ mov(ebx, Operand(esp, kPreviousIndexOffset)); | 1105 __ mov(ebx, Operand(esp, kPreviousIndexOffset)); |
| 1120 __ JumpIfNotSmi(ebx, &runtime); | 1106 __ JumpIfNotSmi(ebx, &runtime); |
| 1121 __ cmp(ebx, FieldOperand(edx, String::kLengthOffset)); | 1107 __ cmp(ebx, FieldOperand(edx, String::kLengthOffset)); |
| 1122 __ j(above_equal, &runtime); | 1108 __ j(above_equal, &runtime); |
| 1123 __ mov(edx, FieldOperand(ecx, JSRegExp::kDataUC16CodeOffset)); | 1109 __ mov(edx, FieldOperand(ecx, JSRegExp::kDataUC16CodeOffset)); |
| 1124 __ Move(ecx, Immediate(0)); // Type is two byte. | 1110 __ Move(ecx, Immediate(0)); // Type is two byte. |
| 1125 __ jmp(&check_code); // Go to (E). | 1111 __ jmp(&check_code); // Go to (E). |
| 1126 | 1112 |
| 1127 // (10) Not a string or a short external string? If yes, bail out to runtime. | 1113 // (10) Not a string or a short external string? If yes, bail out to runtime. |
| 1128 __ bind(¬_long_external); | 1114 __ bind(¬_long_external); |
| 1129 // Catch non-string subject or short external string. | 1115 // Catch non-string subject or short external string. |
| 1130 STATIC_ASSERT(kNotStringTag != 0 && kShortExternalStringTag !=0); | 1116 STATIC_ASSERT(kNotStringTag != 0 && kShortExternalStringTag !=0); |
| 1131 __ test(ebx, Immediate(kIsNotStringMask | kShortExternalStringTag)); | 1117 __ test(ebx, Immediate(kIsNotStringMask | kShortExternalStringTag)); |
| 1132 __ j(not_zero, &runtime); | 1118 __ j(not_zero, &runtime); |
| 1133 | 1119 |
| 1134 // (11) Sliced string. Replace subject with parent. Go to (5a). | 1120 // (11) Sliced string. Replace subject with parent. Go to (1). |
| 1135 // Load offset into edi and replace subject string with parent. | 1121 // Load offset into edi and replace subject string with parent. |
| 1136 __ mov(edi, FieldOperand(eax, SlicedString::kOffsetOffset)); | 1122 __ mov(edi, FieldOperand(eax, SlicedString::kOffsetOffset)); |
| 1137 __ mov(eax, FieldOperand(eax, SlicedString::kParentOffset)); | 1123 __ mov(eax, FieldOperand(eax, SlicedString::kParentOffset)); |
| 1138 __ jmp(&check_underlying); // Go to (5a). | 1124 __ jmp(&check_underlying); // Go to (1). |
| 1139 #endif // V8_INTERPRETED_REGEXP | 1125 #endif // V8_INTERPRETED_REGEXP |
| 1140 } | 1126 } |
| 1141 | 1127 |
| 1142 | 1128 |
| 1143 static int NegativeComparisonResult(Condition cc) { | 1129 static int NegativeComparisonResult(Condition cc) { |
| 1144 DCHECK(cc != equal); | 1130 DCHECK(cc != equal); |
| 1145 DCHECK((cc == less) || (cc == less_equal) | 1131 DCHECK((cc == less) || (cc == less_equal) |
| 1146 || (cc == greater) || (cc == greater_equal)); | 1132 || (cc == greater) || (cc == greater_equal)); |
| 1147 return (cc == greater || cc == greater_equal) ? LESS : GREATER; | 1133 return (cc == greater || cc == greater_equal) ? LESS : GREATER; |
| 1148 } | 1134 } |
| (...skipping 4859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6008 TypedArrayJumpTableEpilogue(masm, &table, &i8, &u8, &i16, &u16, &i32, &u32, | 5994 TypedArrayJumpTableEpilogue(masm, &table, &i8, &u8, &i16, &u16, &i32, &u32, |
| 6009 &u8); | 5995 &u8); |
| 6010 } | 5996 } |
| 6011 | 5997 |
| 6012 #undef __ | 5998 #undef __ |
| 6013 | 5999 |
| 6014 } // namespace internal | 6000 } // namespace internal |
| 6015 } // namespace v8 | 6001 } // namespace v8 |
| 6016 | 6002 |
| 6017 #endif // V8_TARGET_ARCH_IA32 | 6003 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |