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 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1190 | 1190 |
1191 Node* const dollar_char = Int32Constant('$'); | 1191 Node* const dollar_char = Int32Constant('$'); |
1192 Node* const index_of_dollar = | 1192 Node* const index_of_dollar = |
1193 StringIndexOfChar(context, replace, dollar_char, smi_zero); | 1193 StringIndexOfChar(context, replace, dollar_char, smi_zero); |
1194 GotoUnless(SmiIsNegative(index_of_dollar), &next); | 1194 GotoUnless(SmiIsNegative(index_of_dollar), &next); |
1195 | 1195 |
1196 // Searching by traversing a cons string tree and replace with cons of | 1196 // Searching by traversing a cons string tree and replace with cons of |
1197 // slices works only when the replaced string is a single character, being | 1197 // slices works only when the replaced string is a single character, being |
1198 // replaced by a simple string and only pays off for long strings. | 1198 // replaced by a simple string and only pays off for long strings. |
1199 // TODO(jgruber): Reevaluate if this is still beneficial. | 1199 // TODO(jgruber): Reevaluate if this is still beneficial. |
1200 TailCallRuntime(Runtime::kStringReplaceOneCharWithString, context, | 1200 // TODO(jgruber): TailCallRuntime when it correctly handles adapter frames. |
1201 subject_string, search_string, replace); | 1201 Return(CallRuntime(Runtime::kStringReplaceOneCharWithString, context, |
| 1202 subject_string, search_string, replace)); |
1202 | 1203 |
1203 Bind(&next); | 1204 Bind(&next); |
1204 } | 1205 } |
1205 | 1206 |
1206 // TODO(jgruber): Extend StringIndexOfChar to handle two-byte strings and | 1207 // TODO(jgruber): Extend StringIndexOfChar to handle two-byte strings and |
1207 // longer substrings - we can handle up to 8 chars (one-byte) / 4 chars | 1208 // longer substrings - we can handle up to 8 chars (one-byte) / 4 chars |
1208 // (2-byte). | 1209 // (2-byte). |
1209 | 1210 |
1210 Callable indexof_stub = CodeFactory::StringIndexOf(isolate()); | 1211 Callable indexof_stub = CodeFactory::StringIndexOf(isolate()); |
1211 Node* const match_start_index = | 1212 Node* const match_start_index = |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1855 CallRuntime(Runtime::kThrowIncompatibleMethodReceiver, context, | 1856 CallRuntime(Runtime::kThrowIncompatibleMethodReceiver, context, |
1856 HeapConstant(factory()->NewStringFromAsciiChecked( | 1857 HeapConstant(factory()->NewStringFromAsciiChecked( |
1857 "String Iterator.prototype.next", TENURED)), | 1858 "String Iterator.prototype.next", TENURED)), |
1858 iterator); | 1859 iterator); |
1859 Return(result); // Never reached. | 1860 Return(result); // Never reached. |
1860 } | 1861 } |
1861 } | 1862 } |
1862 | 1863 |
1863 } // namespace internal | 1864 } // namespace internal |
1864 } // namespace v8 | 1865 } // namespace v8 |
OLD | NEW |