| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 #include "src/builtins/builtins-regexp.h" | 5 #include "src/builtins/builtins-regexp.h" |
| 6 #include "src/builtins/builtins-utils.h" | 6 #include "src/builtins/builtins-utils.h" |
| 7 #include "src/builtins/builtins.h" | 7 #include "src/builtins/builtins.h" |
| 8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
| 9 #include "src/code-stub-assembler.h" | 9 #include "src/code-stub-assembler.h" |
| 10 #include "src/regexp/regexp-utils.h" | 10 #include "src/regexp/regexp-utils.h" |
| (...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 CSA_ASSERT(this, TaggedIsSmi(position)); | 825 CSA_ASSERT(this, TaggedIsSmi(position)); |
| 826 | 826 |
| 827 Label zero_length_needle(this), call_runtime_unchecked(this), | 827 Label zero_length_needle(this), call_runtime_unchecked(this), |
| 828 return_minus_1(this), check_search_string(this), continue_fast_path(this); | 828 return_minus_1(this), check_search_string(this), continue_fast_path(this); |
| 829 | 829 |
| 830 Node* needle_length = SmiUntag(LoadStringLength(search_string)); | 830 Node* needle_length = SmiUntag(LoadStringLength(search_string)); |
| 831 // Use faster/complex runtime fallback for long search strings. | 831 // Use faster/complex runtime fallback for long search strings. |
| 832 GotoIf(IntPtrLessThan(IntPtrConstant(1), needle_length), | 832 GotoIf(IntPtrLessThan(IntPtrConstant(1), needle_length), |
| 833 &call_runtime_unchecked); | 833 &call_runtime_unchecked); |
| 834 Node* string_length = SmiUntag(LoadStringLength(receiver)); | 834 Node* string_length = SmiUntag(LoadStringLength(receiver)); |
| 835 Node* start_position = SmiUntag(position); | 835 Node* start_position = IntPtrMax(SmiUntag(position), IntPtrConstant(0)); |
| 836 | 836 |
| 837 GotoIf(IntPtrEqual(IntPtrConstant(0), needle_length), &zero_length_needle); | 837 GotoIf(IntPtrEqual(IntPtrConstant(0), needle_length), &zero_length_needle); |
| 838 // Check that the needle fits in the start position. | 838 // Check that the needle fits in the start position. |
| 839 GotoUnless(IntPtrLessThanOrEqual(needle_length, | 839 GotoUnless(IntPtrLessThanOrEqual(needle_length, |
| 840 IntPtrSub(string_length, start_position)), | 840 IntPtrSub(string_length, start_position)), |
| 841 &return_minus_1); | 841 &return_minus_1); |
| 842 // Only support one-byte strings on the fast path. | 842 // Only support one-byte strings on the fast path. |
| 843 BranchIfSimpleOneByteStringInstanceType(instance_type, &check_search_string, | 843 BranchIfSimpleOneByteStringInstanceType(instance_type, &check_search_string, |
| 844 &call_runtime_unchecked); | 844 &call_runtime_unchecked); |
| 845 Bind(&check_search_string); | 845 Bind(&check_search_string); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 933 search_string.Bind(arguments.AtIndex(0)); | 933 search_string.Bind(arguments.AtIndex(0)); |
| 934 position.Bind(SmiConstant(0)); | 934 position.Bind(SmiConstant(0)); |
| 935 Goto(&fast_path); | 935 Goto(&fast_path); |
| 936 } | 936 } |
| 937 Bind(&argc_2); | 937 Bind(&argc_2); |
| 938 { | 938 { |
| 939 Comment("2 Argument case"); | 939 Comment("2 Argument case"); |
| 940 search_string.Bind(arguments.AtIndex(0)); | 940 search_string.Bind(arguments.AtIndex(0)); |
| 941 position.Bind(arguments.AtIndex(1)); | 941 position.Bind(arguments.AtIndex(1)); |
| 942 GotoUnless(TaggedIsSmi(position.value()), &call_runtime); | 942 GotoUnless(TaggedIsSmi(position.value()), &call_runtime); |
| 943 position.Bind(SmiMax(position.value(), SmiConstant(0))); | |
| 944 Goto(&fast_path); | 943 Goto(&fast_path); |
| 945 } | 944 } |
| 946 | 945 |
| 947 Bind(&fast_path); | 946 Bind(&fast_path); |
| 948 { | 947 { |
| 949 Comment("Fast Path"); | 948 Comment("Fast Path"); |
| 950 GotoIf(TaggedIsSmi(receiver), &call_runtime); | 949 GotoIf(TaggedIsSmi(receiver), &call_runtime); |
| 951 Node* needle = search_string.value(); | 950 Node* needle = search_string.value(); |
| 952 GotoIf(TaggedIsSmi(needle), &call_runtime); | 951 GotoIf(TaggedIsSmi(needle), &call_runtime); |
| 953 | 952 |
| (...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1874 CallRuntime(Runtime::kThrowIncompatibleMethodReceiver, context, | 1873 CallRuntime(Runtime::kThrowIncompatibleMethodReceiver, context, |
| 1875 HeapConstant(factory()->NewStringFromAsciiChecked( | 1874 HeapConstant(factory()->NewStringFromAsciiChecked( |
| 1876 "String Iterator.prototype.next", TENURED)), | 1875 "String Iterator.prototype.next", TENURED)), |
| 1877 iterator); | 1876 iterator); |
| 1878 Return(result); // Never reached. | 1877 Return(result); // Never reached. |
| 1879 } | 1878 } |
| 1880 } | 1879 } |
| 1881 | 1880 |
| 1882 } // namespace internal | 1881 } // namespace internal |
| 1883 } // namespace v8 | 1882 } // namespace v8 |
| OLD | NEW |