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 | 6 |
7 #include "src/builtins/builtins-constructor.h" | 7 #include "src/builtins/builtins-constructor.h" |
8 #include "src/builtins/builtins-utils.h" | 8 #include "src/builtins/builtins-utils.h" |
9 #include "src/builtins/builtins.h" | 9 #include "src/builtins/builtins.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 2430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2441 Branch(IsCallableMap(LoadMap(replace_value)), &if_iscallable, | 2441 Branch(IsCallableMap(LoadMap(replace_value)), &if_iscallable, |
2442 &checkreplacestring); | 2442 &checkreplacestring); |
2443 | 2443 |
2444 // 3. Does ToString({replace_value}) contain '$'? | 2444 // 3. Does ToString({replace_value}) contain '$'? |
2445 Bind(&checkreplacestring); | 2445 Bind(&checkreplacestring); |
2446 { | 2446 { |
2447 Callable tostring_callable = CodeFactory::ToString(isolate()); | 2447 Callable tostring_callable = CodeFactory::ToString(isolate()); |
2448 Node* const replace_string = | 2448 Node* const replace_string = |
2449 CallStub(tostring_callable, context, replace_value); | 2449 CallStub(tostring_callable, context, replace_value); |
2450 | 2450 |
2451 Node* const dollar_char = Int32Constant('$'); | 2451 Callable indexof_callable = CodeFactory::StringIndexOf(isolate()); |
2452 GotoUnless(SmiEqual(StringIndexOfChar(context, replace_string, dollar_char, | 2452 Node* const dollar_string = HeapConstant( |
2453 SmiConstant(0)), | 2453 isolate()->factory()->LookupSingleCharacterStringFromCode('$')); |
2454 SmiConstant(-1)), | 2454 Node* const dollar_ix = CallStub(indexof_callable, context, replace_string, |
2455 &runtime); | 2455 dollar_string, SmiConstant(0)); |
| 2456 GotoUnless(SmiEqual(dollar_ix, SmiConstant(-1)), &runtime); |
2456 | 2457 |
2457 Return( | 2458 Return( |
2458 ReplaceSimpleStringFastPath(context, regexp, string, replace_string)); | 2459 ReplaceSimpleStringFastPath(context, regexp, string, replace_string)); |
2459 } | 2460 } |
2460 | 2461 |
2461 // {regexp} is unmodified and {replace_value} is callable. | 2462 // {regexp} is unmodified and {replace_value} is callable. |
2462 Bind(&if_iscallable); | 2463 Bind(&if_iscallable); |
2463 { | 2464 { |
2464 Node* const replace_fn = replace_value; | 2465 Node* const replace_fn = replace_value; |
2465 | 2466 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2540 Bind(&if_matched); | 2541 Bind(&if_matched); |
2541 { | 2542 { |
2542 Node* result = | 2543 Node* result = |
2543 ConstructNewResultFromMatchInfo(context, regexp, match_indices, string); | 2544 ConstructNewResultFromMatchInfo(context, regexp, match_indices, string); |
2544 Return(result); | 2545 Return(result); |
2545 } | 2546 } |
2546 } | 2547 } |
2547 | 2548 |
2548 } // namespace internal | 2549 } // namespace internal |
2549 } // namespace v8 | 2550 } // namespace v8 |
OLD | NEW |