Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(409)

Side by Side Diff: src/builtins/builtins-regexp.cc

Issue 2409513003: [regexp] Port remaining JS functions in regexp.js (Closed)
Patch Set: Rebaseline bytecode expectations Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/builtins/builtins.h ('k') | src/contexts.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1637 matching lines...) Expand 10 before | Expand all | Expand 10 after
1648 } 1648 }
1649 1649
1650 a->Bind(&runtime); 1650 a->Bind(&runtime);
1651 { 1651 {
1652 Node* const result = a->CallRuntime(Runtime::kRegExpReplace, context, 1652 Node* const result = a->CallRuntime(Runtime::kRegExpReplace, context,
1653 receiver, string, replace_value); 1653 receiver, string, replace_value);
1654 a->Return(result); 1654 a->Return(result);
1655 } 1655 }
1656 } 1656 }
1657 1657
1658 namespace {
1659
1660 // TODO(jgruber): Replace this with a FixedArray.
1661 compiler::Node* GetInternalMatchInfo(CodeStubAssembler* a,
1662 compiler::Node* context) {
1663 typedef compiler::Node Node;
1664
1665 const ElementsKind elements_kind = FAST_ELEMENTS;
1666 Node* const native_context = a->LoadNativeContext(context);
1667 Node* const array_map =
1668 a->LoadJSArrayElementsMap(elements_kind, native_context);
1669 Node* const capacity = a->IntPtrConstant(RegExpImpl::kLastMatchOverhead + 2);
1670 Node* const allocation_site = nullptr;
1671
1672 Node* const smi_zero = a->SmiConstant(Smi::kZero);
1673
1674 return a->AllocateJSArray(elements_kind, array_map, capacity, smi_zero,
1675 allocation_site,
1676 CodeStubAssembler::INTPTR_PARAMETERS);
1677 }
1678
1679 } // namespace
1680
1681 // Simple string matching functionality for internal use which does not modify
1682 // the last match info.
1683 void Builtins::Generate_RegExpInternalMatch(CodeStubAssembler* a) {
1684 typedef CodeStubAssembler::Label Label;
1685 typedef compiler::Node Node;
1686
1687 Isolate* const isolate = a->isolate();
1688
1689 Node* const regexp = a->Parameter(1);
1690 Node* const string = a->Parameter(2);
1691 Node* const context = a->Parameter(5);
1692
1693 Node* const null = a->NullConstant();
1694 Node* const smi_zero = a->SmiConstant(Smi::FromInt(0));
1695 Node* const internal_match_info = GetInternalMatchInfo(a, context);
1696
1697 Callable exec_callable = CodeFactory::RegExpExec(isolate);
1698 Node* const match_indices = a->CallStub(
1699 exec_callable, context, regexp, string, smi_zero, internal_match_info);
1700
1701 Label if_matched(a), if_didnotmatch(a);
1702 a->Branch(a->WordEqual(match_indices, null), &if_didnotmatch, &if_matched);
1703
1704 a->Bind(&if_didnotmatch);
1705 a->Return(null);
1706
1707 a->Bind(&if_matched);
1708 {
1709 Node* const match_elements = a->LoadElements(match_indices);
1710 Node* result = ConstructNewResultFromMatchInfo(isolate, a, context,
1711 match_elements, string);
1712 a->Return(result);
1713 }
1714 }
1715
1658 } // namespace internal 1716 } // namespace internal
1659 } // namespace v8 1717 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins/builtins.h ('k') | src/contexts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698