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" |
| 6 |
5 #include "src/builtins/builtins-constructor.h" | 7 #include "src/builtins/builtins-constructor.h" |
6 #include "src/builtins/builtins-utils.h" | 8 #include "src/builtins/builtins-utils.h" |
7 #include "src/builtins/builtins.h" | 9 #include "src/builtins/builtins.h" |
8 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
9 #include "src/code-stub-assembler.h" | 11 #include "src/code-stub-assembler.h" |
10 #include "src/regexp/jsregexp.h" | 12 #include "src/regexp/jsregexp.h" |
11 #include "src/regexp/regexp-utils.h" | 13 #include "src/regexp/regexp-utils.h" |
12 #include "src/string-builder.h" | 14 #include "src/string-builder.h" |
13 | 15 |
14 namespace v8 { | 16 namespace v8 { |
15 namespace internal { | 17 namespace internal { |
16 | 18 |
17 typedef compiler::Node Node; | |
18 typedef CodeStubAssembler::ParameterMode ParameterMode; | 19 typedef CodeStubAssembler::ParameterMode ParameterMode; |
19 typedef compiler::CodeAssemblerState CodeAssemblerState; | |
20 | |
21 class RegExpBuiltinsAssembler : public CodeStubAssembler { | |
22 public: | |
23 explicit RegExpBuiltinsAssembler(CodeAssemblerState* state) | |
24 : CodeStubAssembler(state) {} | |
25 | |
26 protected: | |
27 Node* FastLoadLastIndex(Node* regexp); | |
28 Node* SlowLoadLastIndex(Node* context, Node* regexp); | |
29 Node* LoadLastIndex(Node* context, Node* regexp, bool is_fastpath); | |
30 | |
31 void FastStoreLastIndex(Node* regexp, Node* value); | |
32 void SlowStoreLastIndex(Node* context, Node* regexp, Node* value); | |
33 void StoreLastIndex(Node* context, Node* regexp, Node* value, | |
34 bool is_fastpath); | |
35 | |
36 Node* ConstructNewResultFromMatchInfo(Node* context, Node* match_info, | |
37 Node* string); | |
38 | |
39 Node* RegExpPrototypeExecBodyWithoutResult(Node* const context, | |
40 Node* const regexp, | |
41 Node* const string, | |
42 Label* if_didnotmatch, | |
43 const bool is_fastpath); | |
44 Node* RegExpPrototypeExecBody(Node* const context, Node* const regexp, | |
45 Node* const string, const bool is_fastpath); | |
46 | |
47 Node* ThrowIfNotJSReceiver(Node* context, Node* maybe_receiver, | |
48 MessageTemplate::Template msg_template, | |
49 char const* method_name); | |
50 | |
51 Node* IsInitialRegExpMap(Node* context, Node* map); | |
52 void BranchIfFastRegExp(Node* context, Node* map, Label* if_isunmodified, | |
53 Label* if_ismodified); | |
54 void BranchIfFastRegExpResult(Node* context, Node* map, | |
55 Label* if_isunmodified, Label* if_ismodified); | |
56 | |
57 Node* FlagsGetter(Node* const context, Node* const regexp, bool is_fastpath); | |
58 | |
59 Node* FastFlagGetter(Node* const regexp, JSRegExp::Flag flag); | |
60 Node* SlowFlagGetter(Node* const context, Node* const regexp, | |
61 JSRegExp::Flag flag); | |
62 Node* FlagGetter(Node* const context, Node* const regexp, JSRegExp::Flag flag, | |
63 bool is_fastpath); | |
64 void FlagGetter(JSRegExp::Flag flag, v8::Isolate::UseCounterFeature counter, | |
65 const char* method_name); | |
66 | |
67 Node* IsRegExp(Node* const context, Node* const maybe_receiver); | |
68 Node* RegExpInitialize(Node* const context, Node* const regexp, | |
69 Node* const maybe_pattern, Node* const maybe_flags); | |
70 | |
71 Node* RegExpExec(Node* context, Node* regexp, Node* string); | |
72 | |
73 Node* AdvanceStringIndex(Node* const string, Node* const index, | |
74 Node* const is_unicode); | |
75 | |
76 void RegExpPrototypeMatchBody(Node* const context, Node* const regexp, | |
77 Node* const string, const bool is_fastpath); | |
78 | |
79 void RegExpPrototypeSearchBodyFast(Node* const context, Node* const regexp, | |
80 Node* const string); | |
81 void RegExpPrototypeSearchBodySlow(Node* const context, Node* const regexp, | |
82 Node* const string); | |
83 | |
84 void RegExpPrototypeSplitBody(Node* const context, Node* const regexp, | |
85 Node* const string, Node* const limit); | |
86 | |
87 Node* ReplaceGlobalCallableFastPath(Node* context, Node* regexp, Node* string, | |
88 Node* replace_callable); | |
89 Node* ReplaceSimpleStringFastPath(Node* context, Node* regexp, Node* string, | |
90 Node* replace_string); | |
91 }; | |
92 | 20 |
93 // ----------------------------------------------------------------------------- | 21 // ----------------------------------------------------------------------------- |
94 // ES6 section 21.2 RegExp Objects | 22 // ES6 section 21.2 RegExp Objects |
95 | 23 |
96 Node* RegExpBuiltinsAssembler::FastLoadLastIndex(Node* regexp) { | 24 Node* RegExpBuiltinsAssembler::FastLoadLastIndex(Node* regexp) { |
97 // Load the in-object field. | 25 // Load the in-object field. |
98 static const int field_offset = | 26 static const int field_offset = |
99 JSRegExp::kSize + JSRegExp::kLastIndexFieldIndex * kPointerSize; | 27 JSRegExp::kSize + JSRegExp::kLastIndexFieldIndex * kPointerSize; |
100 return LoadObjectField(regexp, field_offset); | 28 return LoadObjectField(regexp, field_offset); |
101 } | 29 } |
(...skipping 2408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2510 Bind(&if_matched); | 2438 Bind(&if_matched); |
2511 { | 2439 { |
2512 Node* result = | 2440 Node* result = |
2513 ConstructNewResultFromMatchInfo(context, match_indices, string); | 2441 ConstructNewResultFromMatchInfo(context, match_indices, string); |
2514 Return(result); | 2442 Return(result); |
2515 } | 2443 } |
2516 } | 2444 } |
2517 | 2445 |
2518 } // namespace internal | 2446 } // namespace internal |
2519 } // namespace v8 | 2447 } // namespace v8 |
OLD | NEW |