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 946 : : 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 : Node* FastLoadLastIndex(Node* regexp);
24 : Node* SlowLoadLastIndex(Node* context, Node* regexp);
25 : Node* LoadLastIndex(Node* context, Node* regexp, bool is_fastpath);
26 :
27 : void FastStoreLastIndex(Node* regexp, Node* value);
28 : void SlowStoreLastIndex(Node* context, Node* regexp, Node* value);
29 : void StoreLastIndex(Node* context, Node* regexp, Node* value,
30 : bool is_fastpath);
31 :
32 : // Loads {var_string_start} and {var_string_end} with the corresponding
33 : // offsets into the given {string_data}.
34 : void GetStringPointers(Node* const string_data, Node* const offset,
35 : Node* const last_index, Node* const string_length,
36 : String::Encoding encoding, Variable* var_string_start,
37 : Variable* var_string_end);
38 :
39 : // Low level logic around the actual call into pattern matching code.
40 : Node* RegExpExecInternal(Node* const context, Node* const regexp,
41 : Node* const string, Node* const last_index,
42 : Node* const match_info);
43 :
44 : Node* ConstructNewResultFromMatchInfo(Node* const context, Node* const regexp,
45 : Node* const match_info,
46 : Node* const string);
47 :
48 : Node* RegExpPrototypeExecBodyWithoutResult(Node* const context,
49 : Node* const regexp,
50 : Node* const string,
51 : Label* if_didnotmatch,
52 : const bool is_fastpath);
53 : Node* RegExpPrototypeExecBody(Node* const context, Node* const regexp,
54 : Node* const string, const bool is_fastpath);
55 :
56 : Node* ThrowIfNotJSReceiver(Node* context, Node* maybe_receiver,
57 : MessageTemplate::Template msg_template,
58 : char const* method_name);
59 :
60 : void BranchIfFastRegExp(Node* const context, Node* const object,
61 : Label* const if_isunmodified,
62 : Label* const if_ismodified);
63 :
64 : // Analogous to BranchIfFastRegExp, for use in asserts.
65 : Node* IsFastRegExp(Node* const context, Node* const object);
66 :
67 : // Performs fast path checks on the given object itself, but omits prototype
68 : // checks.
69 : Node* IsFastRegExpNoPrototype(Node* const context, Node* const object);
70 : Node* IsFastRegExpNoPrototype(Node* const context, Node* const object,
71 : Node* const map);
72 :
73 : void BranchIfFastRegExpResult(Node* const context, Node* const object,
74 : Label* if_isunmodified, Label* if_ismodified);
75 :
76 : Node* FlagsGetter(Node* const context, Node* const regexp, bool is_fastpath);
77 :
78 : Node* FastFlagGetter(Node* const regexp, JSRegExp::Flag flag);
79 : Node* SlowFlagGetter(Node* const context, Node* const regexp,
80 : JSRegExp::Flag flag);
81 : Node* FlagGetter(Node* const context, Node* const regexp, JSRegExp::Flag flag,
82 : bool is_fastpath);
83 : void FlagGetter(Node* context, Node* receiver, JSRegExp::Flag flag,
84 : int counter, const char* method_name);
85 :
86 : // Utility method, remove once dotall is unstaged.
87 : Node* IsDotAllEnabled(Isolate* isolate);
88 :
89 : Node* IsRegExp(Node* const context, Node* const maybe_receiver);
90 : Node* RegExpInitialize(Node* const context, Node* const regexp,
91 : Node* const maybe_pattern, Node* const maybe_flags);
92 :
93 : Node* RegExpExec(Node* context, Node* regexp, Node* string);
94 :
95 : Node* AdvanceStringIndex(Node* const string, Node* const index,
96 : Node* const is_unicode, bool is_fastpath);
97 :
98 : void RegExpPrototypeMatchBody(Node* const context, Node* const regexp,
99 : Node* const string, const bool is_fastpath);
100 :
101 : void RegExpPrototypeSearchBodyFast(Node* const context, Node* const regexp,
102 : Node* const string);
103 : void RegExpPrototypeSearchBodySlow(Node* const context, Node* const regexp,
104 : Node* const string);
105 :
106 : void RegExpPrototypeSplitBody(Node* const context, Node* const regexp,
107 : Node* const string, Node* const limit);
108 :
109 : Node* ReplaceGlobalCallableFastPath(Node* context, Node* regexp, Node* string,
110 : Node* replace_callable);
111 : Node* ReplaceSimpleStringFastPath(Node* context, Node* regexp, Node* string,
112 : Node* replace_string);
113 : };
114 :
115 : } // namespace internal
116 : } // namespace v8
117 :
118 : #endif // V8_BUILTINS_BUILTINS_REGEXP_H_
|