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 | 10 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 CodeStubAssembler* a, | 85 CodeStubAssembler* a, |
86 compiler::Node* context, | 86 compiler::Node* context, |
87 compiler::Node* match_elements, | 87 compiler::Node* match_elements, |
88 compiler::Node* string) { | 88 compiler::Node* string) { |
89 typedef CodeStubAssembler::Variable Variable; | 89 typedef CodeStubAssembler::Variable Variable; |
90 typedef CodeStubAssembler::Label Label; | 90 typedef CodeStubAssembler::Label Label; |
91 typedef compiler::Node Node; | 91 typedef compiler::Node Node; |
92 | 92 |
93 Label out(a); | 93 Label out(a); |
94 | 94 |
95 Callable constructresult_callable = | |
96 CodeFactory::RegExpConstructResult(isolate); | |
97 | |
98 CodeStubAssembler::ParameterMode mode = CodeStubAssembler::INTPTR_PARAMETERS; | 95 CodeStubAssembler::ParameterMode mode = CodeStubAssembler::INTPTR_PARAMETERS; |
99 Node* const num_indices = a->SmiUntag(a->LoadFixedArrayElement( | 96 Node* const num_indices = a->SmiUntag(a->LoadFixedArrayElement( |
100 match_elements, a->IntPtrConstant(RegExpImpl::kLastCaptureCount), 0, | 97 match_elements, a->IntPtrConstant(RegExpImpl::kLastCaptureCount), 0, |
101 mode)); | 98 mode)); |
102 Node* const num_results = a->SmiTag(a->WordShr(num_indices, 1)); | 99 Node* const num_results = a->SmiTag(a->WordShr(num_indices, 1)); |
103 Node* const start = a->LoadFixedArrayElement( | 100 Node* const start = a->LoadFixedArrayElement( |
104 match_elements, a->IntPtrConstant(RegExpImpl::kFirstCapture), 0, mode); | 101 match_elements, a->IntPtrConstant(RegExpImpl::kFirstCapture), 0, mode); |
105 Node* const end = a->LoadFixedArrayElement( | 102 Node* const end = a->LoadFixedArrayElement( |
106 match_elements, a->IntPtrConstant(RegExpImpl::kFirstCapture + 1), 0, | 103 match_elements, a->IntPtrConstant(RegExpImpl::kFirstCapture + 1), 0, |
107 mode); | 104 mode); |
108 | 105 |
109 // Calculate the substring of the first match before creating the result array | 106 // Calculate the substring of the first match before creating the result array |
110 // to avoid an unnecessary write barrier storing the first result. | 107 // to avoid an unnecessary write barrier storing the first result. |
111 Node* const first = a->SubString(context, string, start, end); | 108 Node* const first = a->SubString(context, string, start, end); |
112 | 109 |
113 Node* const result = a->CallStub(constructresult_callable, context, | 110 Node* const result = |
114 num_results, start, string); | 111 a->AllocateRegExpResult(context, num_results, start, string); |
115 Node* const result_elements = a->LoadElements(result); | 112 Node* const result_elements = a->LoadElements(result); |
116 | 113 |
117 a->StoreFixedArrayElement(result_elements, a->IntPtrConstant(0), first, | 114 a->StoreFixedArrayElement(result_elements, a->IntPtrConstant(0), first, |
118 SKIP_WRITE_BARRIER); | 115 SKIP_WRITE_BARRIER); |
119 | 116 |
120 a->GotoIf(a->SmiEqual(num_results, a->SmiConstant(Smi::FromInt(1))), &out); | 117 a->GotoIf(a->SmiEqual(num_results, a->SmiConstant(Smi::FromInt(1))), &out); |
121 | 118 |
122 // Store all remaining captures. | 119 // Store all remaining captures. |
123 Node* const limit = | 120 Node* const limit = |
124 a->IntPtrAdd(a->IntPtrConstant(RegExpImpl::kFirstCapture), num_indices); | 121 a->IntPtrAdd(a->IntPtrConstant(RegExpImpl::kFirstCapture), num_indices); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 { | 285 { |
289 Node* result = ConstructNewResultFromMatchInfo(isolate, a, context, | 286 Node* result = ConstructNewResultFromMatchInfo(isolate, a, context, |
290 match_elements, string); | 287 match_elements, string); |
291 a->Return(result); | 288 a->Return(result); |
292 } | 289 } |
293 } | 290 } |
294 } | 291 } |
295 | 292 |
296 } // namespace internal | 293 } // namespace internal |
297 } // namespace v8 | 294 } // namespace v8 |
OLD | NEW |