Line data Source code
1 : // Copyright 2017 the V8 project authors. All rights reserved.
2 : // Use of this source code is governed by a BSD-style license that can be
3 : // found in the LICENSE file.
4 :
5 : #ifndef V8_BUILTINS_BUILTINS_REGEXP_H_
6 : #define V8_BUILTINS_BUILTINS_REGEXP_H_
7 :
8 : #include "src/code-stub-assembler.h"
9 :
10 : namespace v8 {
11 : namespace internal {
12 :
13 : class RegExpBuiltinsAssembler : public CodeStubAssembler {
14 : public:
15 : explicit RegExpBuiltinsAssembler(compiler::CodeAssemblerState* state)
16 899 : : CodeStubAssembler(state) {}
17 :
18 : void BranchIfFastRegExp(Node* const context, Node* const object,
19 : Node* const map, Label* const if_isunmodified,
20 : Label* const if_ismodified);
21 :
22 : protected:
23 : // Allocate a RegExpResult with the given length (the number of captures,
24 : // including the match itself), index (the index where the match starts),
25 : // and input string. |length| and |index| are expected to be tagged, and
26 : // |input| must be a string.
27 : Node* AllocateRegExpResult(Node* context, Node* length, Node* index,
28 : Node* input);
29 :
30 : Node* FastLoadLastIndex(Node* regexp);
31 : Node* SlowLoadLastIndex(Node* context, Node* regexp);
32 : Node* LoadLastIndex(Node* context, Node* regexp, bool is_fastpath);
33 :
34 : void FastStoreLastIndex(Node* regexp, Node* value);
35 : void SlowStoreLastIndex(Node* context, Node* regexp, Node* value);
36 : void StoreLastIndex(Node* context, Node* regexp, Node* value,
37 : bool is_fastpath);
38 :
39 : // Loads {var_string_start} and {var_string_end} with the corresponding
40 : // offsets into the given {string_data}.
41 : void GetStringPointers(Node* const string_data, Node* const offset,
42 : Node* const last_index, Node* const string_length,
43 : String::Encoding encoding, Variable* var_string_start,
44 : Variable* var_string_end);
45 :
46 : // Low level logic around the actual call into pattern matching code.
47 : Node* RegExpExecInternal(Node* const context, Node* const regexp,
48 : Node* const string, Node* const last_index,
49 : Node* const match_info);
50 :
51 : Node* ConstructNewResultFromMatchInfo(Node* const context, Node* const regexp,
52 : Node* const match_info,
53 : Node* const string);
54 :
55 : Node* RegExpPrototypeExecBodyWithoutResult(Node* const context,
56 : Node* const regexp,
57 : Node* const string,
58 : Label* if_didnotmatch,
59 : const bool is_fastpath);
60 : Node* RegExpPrototypeExecBody(Node* const context, Node* const regexp,
61 : Node* const string, const bool is_fastpath);
62 :
63 : Node* ThrowIfNotJSReceiver(Node* context, Node* maybe_receiver,
64 : MessageTemplate::Template msg_template,
65 : char const* method_name);
66 :
67 : void BranchIfFastRegExp(Node* const context, Node* const object,
68 : Label* const if_isunmodified,
69 : Label* const if_ismodified);
70 :
71 : // Analogous to BranchIfFastRegExp, for use in asserts.
72 : Node* IsFastRegExp(Node* const context, Node* const object);
73 :
74 : // Performs fast path checks on the given object itself, but omits prototype
75 : // checks.
76 : Node* IsFastRegExpNoPrototype(Node* const context, Node* const object);
77 : Node* IsFastRegExpNoPrototype(Node* const context, Node* const object,
78 : Node* const map);
79 :
80 : void BranchIfFastRegExpResult(Node* const context, Node* const object,
81 : Label* if_isunmodified, Label* if_ismodified);
82 :
83 : Node* FlagsGetter(Node* const context, Node* const regexp, bool is_fastpath);
84 :
85 : Node* FastFlagGetter(Node* const regexp, JSRegExp::Flag flag);
86 : Node* SlowFlagGetter(Node* const context, Node* const regexp,
87 : JSRegExp::Flag flag);
88 : Node* FlagGetter(Node* const context, Node* const regexp, JSRegExp::Flag flag,
89 : bool is_fastpath);
90 : void FlagGetter(Node* context, Node* receiver, JSRegExp::Flag flag,
91 : int counter, const char* method_name);
92 :
93 : // Utility method, remove once dotall is unstaged.
94 : Node* IsDotAllEnabled(Isolate* isolate);
95 :
96 : Node* IsRegExp(Node* const context, Node* const maybe_receiver);
97 : Node* RegExpInitialize(Node* const context, Node* const regexp,
98 : Node* const maybe_pattern, Node* const maybe_flags);
99 :
100 : Node* RegExpExec(Node* context, Node* regexp, Node* string);
101 :
102 : Node* AdvanceStringIndex(Node* const string, Node* const index,
103 : Node* const is_unicode, bool is_fastpath);
104 :
105 : void RegExpPrototypeMatchBody(Node* const context, Node* const regexp,
106 : Node* const string, const bool is_fastpath);
107 :
108 : void RegExpPrototypeSearchBodyFast(Node* const context, Node* const regexp,
109 : Node* const string);
110 : void RegExpPrototypeSearchBodySlow(Node* const context, Node* const regexp,
111 : Node* const string);
112 :
113 : void RegExpPrototypeSplitBody(Node* const context, Node* const regexp,
114 : Node* const string, Node* const limit);
115 :
116 : Node* ReplaceGlobalCallableFastPath(Node* context, Node* regexp, Node* string,
117 : Node* replace_callable);
118 : Node* ReplaceSimpleStringFastPath(Node* context, Node* regexp, Node* string,
119 : Node* replace_string);
120 : };
121 :
122 : } // namespace internal
123 : } // namespace v8
124 :
125 : #endif // V8_BUILTINS_BUILTINS_REGEXP_H_
|