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-utils.h" | 5 #include "src/builtins/builtins-utils.h" |
6 #include "src/builtins/builtins.h" | 6 #include "src/builtins/builtins.h" |
7 | 7 |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/regexp/jsregexp.h" | 9 #include "src/regexp/jsregexp.h" |
10 #include "src/regexp/regexp-utils.h" | 10 #include "src/regexp/regexp-utils.h" |
(...skipping 1587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1598 BranchIfFastPath(a, context, map, &checkreplacecallable, &runtime); | 1598 BranchIfFastPath(a, context, map, &checkreplacecallable, &runtime); |
1599 | 1599 |
1600 a->Bind(&checkreplacecallable); | 1600 a->Bind(&checkreplacecallable); |
1601 Node* const regexp = receiver; | 1601 Node* const regexp = receiver; |
1602 | 1602 |
1603 // 2. Is {replace_value} callable? | 1603 // 2. Is {replace_value} callable? |
1604 Label checkreplacestring(a), if_iscallable(a, Label::kDeferred); | 1604 Label checkreplacestring(a), if_iscallable(a, Label::kDeferred); |
1605 a->GotoIf(a->TaggedIsSmi(replace_value), &checkreplacestring); | 1605 a->GotoIf(a->TaggedIsSmi(replace_value), &checkreplacestring); |
1606 | 1606 |
1607 Node* const replace_value_map = a->LoadMap(replace_value); | 1607 Node* const replace_value_map = a->LoadMap(replace_value); |
1608 a->Branch( | 1608 a->Branch(a->IsCallableMap(replace_value_map), &if_iscallable, |
1609 a->Word32Equal(a->Word32And(a->LoadMapBitField(replace_value_map), | 1609 &checkreplacestring); |
1610 a->Int32Constant(1 << Map::kIsCallable)), | |
1611 a->Int32Constant(0)), | |
1612 &checkreplacestring, &if_iscallable); | |
1613 | 1610 |
1614 // 3. Does ToString({replace_value}) contain '$'? | 1611 // 3. Does ToString({replace_value}) contain '$'? |
1615 a->Bind(&checkreplacestring); | 1612 a->Bind(&checkreplacestring); |
1616 { | 1613 { |
1617 Node* const replace_string = | 1614 Node* const replace_string = |
1618 a->CallStub(tostring_callable, context, replace_value); | 1615 a->CallStub(tostring_callable, context, replace_value); |
1619 | 1616 |
1620 Node* const dollar_char = a->IntPtrConstant('$'); | 1617 Node* const dollar_char = a->IntPtrConstant('$'); |
1621 Node* const smi_minusone = a->SmiConstant(Smi::FromInt(-1)); | 1618 Node* const smi_minusone = a->SmiConstant(Smi::FromInt(-1)); |
1622 a->GotoUnless(a->SmiEqual(a->StringIndexOfChar(context, replace_string, | 1619 a->GotoUnless(a->SmiEqual(a->StringIndexOfChar(context, replace_string, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1695 a->Bind(&if_matched); | 1692 a->Bind(&if_matched); |
1696 { | 1693 { |
1697 Node* result = ConstructNewResultFromMatchInfo(isolate, a, context, | 1694 Node* result = ConstructNewResultFromMatchInfo(isolate, a, context, |
1698 match_indices, string); | 1695 match_indices, string); |
1699 a->Return(result); | 1696 a->Return(result); |
1700 } | 1697 } |
1701 } | 1698 } |
1702 | 1699 |
1703 } // namespace internal | 1700 } // namespace internal |
1704 } // namespace v8 | 1701 } // namespace v8 |
OLD | NEW |