Debian Codegraph @

src/3rdparty/javascriptcore/JavaScriptCore/yarr/RegexJIT.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 2009 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26 #include "config.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/config.h`/
27 #include "RegexJIT.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/yarr/RegexJIT.h`/
28
29 #include "ASCIICType.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/ASCIICType.h`/
30 #include "JSGlobalData.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSGlobalData.h`/
31 #include "LinkBuffer.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/assembler/LinkBuffer.h`/
32 #include "MacroAssembler.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/assembler/MacroAssembler.h`/
33 #include "RegexCompiler.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/yarr/RegexCompiler.h`/
34
35 #include "pcre.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/pcre/pcre.h`/ // temporary, remove when fallback is removed.
36
37 #if ENABLEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:57:9`!(YARR_JIT)
38
39 using namespace WTFcxx . . $ `<built-in>:467:9`!;
40
41 namespace JSCcxx . . $ `<built-in>:463:9`! { namespace Yarrcxx . . $ QTJSC/Yarr/ {
42
43
44 class RegexGeneratorcxx . . $ QTJSC/Yarr/RegexGenerator# : private MacroAssemblercxx . . $ QTJSC/MacroAssembler# {
45 friend void jitCompileRegexcxx . . $ QTJSC/Yarr/jitCompileRegex(eb7cf78519d4005a).(JSGlobalDatacxx . . $ QTJSC/JSGlobalData#* globalData, RegexCodeBlockcxx . . $ QTJSC/Yarr/RegexCodeBlock#& jitObject, const UStringcxx . . $ QTJSC/UString#& pattern, unsigned& numSubpatterns, const char*& error, bool ignoreCase, bool multiline);
46
47 #if CPUcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:44:9`!(ARM)
48 static const RegisterID input = ARMRegisters::r0;
49 static const RegisterID index = ARMRegisters::r1;
50 static const RegisterID length = ARMRegisters::r2;
51 static const RegisterID output = ARMRegisters::r4;
52
53 static const RegisterID regT0 = ARMRegisters::r5;
54 static const RegisterID regT1 = ARMRegisters::r6;
55
56 static const RegisterID returnRegister = ARMRegisters::r0;
57 #elif CPUcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:44:9`!(X86)
58 static const RegisterID input = X86Registers::eax;
59 static const RegisterID index = X86Registers::edx;
60 static const RegisterID length = X86Registers::ecx;
61 static const RegisterID output = X86Registers::edi;
62
63 static const RegisterID regT0 = X86Registers::ebx;
64 static const RegisterID regT1 = X86Registers::esi;
65
66 static const RegisterID returnRegister = X86Registers::eax;
67 #elif CPUcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:44:9`!(X86_64)
68 static const RegisterID inputcxx . . $ QTJSC/Yarr/RegexGenerator#input. = X86Registerscxx . . $ QTJSC/X86Registers/::edicxx . . $ QTJSC/X86Registers/edi.;
69 static const RegisterID indexcxx . . $ QTJSC/Yarr/RegexGenerator#index. = X86Registerscxx . . $ QTJSC/X86Registers/::esicxx . . $ QTJSC/X86Registers/esi.;
70 static const RegisterID lengthcxx . . $ QTJSC/Yarr/RegexGenerator#length. = X86Registerscxx . . $ QTJSC/X86Registers/::edxcxx . . $ QTJSC/X86Registers/edx.;
71 static const RegisterID outputcxx . . $ QTJSC/Yarr/RegexGenerator#output. = X86Registerscxx . . $ QTJSC/X86Registers/::ecxcxx . . $ QTJSC/X86Registers/ecx.;
72
73 static const RegisterID regT0cxx . . $ QTJSC/Yarr/RegexGenerator#regT0. = X86Registerscxx . . $ QTJSC/X86Registers/::eaxcxx . . $ QTJSC/X86Registers/eax.;
74 static const RegisterID regT1cxx . . $ QTJSC/Yarr/RegexGenerator#regT1. = X86Registerscxx . . $ QTJSC/X86Registers/::ebxcxx . . $ QTJSC/X86Registers/ebx.;
75
76 static const RegisterID returnRegistercxx . . $ QTJSC/Yarr/RegexGenerator#returnRegister. = X86Registerscxx . . $ QTJSC/X86Registers/::eaxcxx . . $ QTJSC/X86Registers/eax.;
77 #endif
78
79 void optimizeAlternativecxx . . $ QTJSC/Yarr/RegexGenerator#optimizeAlternative(8a910acb71f34a04).(PatternAlternativecxx . . $ QTJSC/Yarr/PatternAlternative#* alternative)
80 {
81 if (!alternative->m_terms.size())
82 return;
83
84 for (unsigned i = 0; i <cxx . . $ QTJSC/`operator<`(11610d830df66bbf). alternative->m_terms.size() - 1; ++i) {
85 PatternTermcxx . . $ QTJSC/Yarr/PatternTerm#& term = alternative->m_terms[i];
86 PatternTermcxx . . $ QTJSC/Yarr/PatternTerm#& nextTerm = alternative->m_terms[i + 1];
87
88 if ((term.typecxx . . $ QTJSC/Yarr/PatternTerm#type. == PatternTermcxx . . $ QTJSC/Yarr/PatternTerm#::TypeCharacterClasscxx . . $ QTJSC/Yarr/PatternTerm#TypeCharacterClass.)
89 && (term.quantityTypecxx . . $ QTJSC/Yarr/PatternTerm#quantityType. == QuantifierFixedCountcxx . . $ QTJSC/Yarr/QuantifierFixedCount.)
90 && (nextTerm.typecxx . . $ QTJSC/Yarr/PatternTerm#type. == PatternTermcxx . . $ QTJSC/Yarr/PatternTerm#::TypePatternCharactercxx . . $ QTJSC/Yarr/PatternTerm#TypePatternCharacter.)
91 && (nextTerm.quantityTypecxx . . $ QTJSC/Yarr/PatternTerm#quantityType. == QuantifierFixedCountcxx . . $ QTJSC/Yarr/QuantifierFixedCount.)) {
92 PatternTermcxx . . $ QTJSC/Yarr/PatternTerm# termCopy = term;
93 alternative->m_terms[i] = nextTerm;
94 alternative->m_terms[i + 1] = termCopy;
95 }
96 }
97 }
98
99 void matchCharacterClassRangecxx . . $ QTJSC/Yarr/RegexGenerator#matchCharacterClassRange(ff78681ca62791e1).(RegisterID character, JumpList& failures, JumpList& matchDest, const CharacterRangecxx . . $ QTJSC/Yarr/CharacterRange#* ranges, unsigned count, unsigned* matchIndex, const UCharcxx . . $ UChar#* matches, unsigned matchCount)
100 {
101 do {
102 // pick which range we're going to generate
103 int which = count >> 1;
104 char lo = ranges[which].begincxx . . $ QTJSC/Yarr/CharacterRange#begin.;
105 char hi = ranges[which].endcxx . . $ QTJSC/Yarr/CharacterRange#end.;
106
107 // check if there are any ranges or matches below lo. If not, just jl to failure -
108 // if there is anything else to check, check that first, if it falls through jmp to failure.
109 if ((*matchIndex < matchCount) && (matches[*matchIndex] < lo)) {
110 Jump loOrAbove = branch32(GreaterThanOrEqual, character, Imm32((unsigned short)lo));
111
112 // generate code for all ranges before this one
113 if (which)
114 matchCharacterClassRange(character, failures, matchDest, ranges, which, matchIndex, matches, matchCount);
115
116 while ((*matchIndex < matchCount) && (matches[*matchIndex] < lo)) {
117 matchDest.append(branch32(Equal, character, Imm32((unsigned short)matches[*matchIndex])));
118 ++*matchIndex;
119 }
120 failures.append(jump());
121
122 loOrAbove.link(this);
123 } else if (which) {
124 Jump loOrAbove = branch32(GreaterThanOrEqual, character, Imm32((unsigned short)lo));
125
126 matchCharacterClassRange(character, failures, matchDest, ranges, which, matchIndex, matches, matchCount);
127 failures.append(jump());
128
129 loOrAbove.link(this);
130 } else
131 failures.append(branch32(LessThan, character, Imm32((unsigned short)lo)));
132
133 while ((*matchIndex < matchCount) && (matches[*matchIndex] <= hi))
134 ++*matchIndex;
135
136 matchDest.append(branch32(LessThanOrEqual, character, Imm32((unsigned short)hi)));
137 // fall through to here, the value is above hi.
138
139 // shuffle along & loop around if there are any more matches to handle.
140 unsigned next = which + 1;
141 ranges += next;
142 count -= next;
143 } while (count);
144 }
145
146 void matchCharacterClasscxx . . $ QTJSC/Yarr/RegexGenerator#matchCharacterClass(1bac102ca8275cdc).(RegisterID character, JumpList& matchDest, const CharacterClasscxx . . $ QTJSC/Yarr/CharacterClass#* charClass)
147 {
148 Jump unicodeFail;
149 if (charClass->m_matchesUnicode.size() || charClass->m_rangesUnicode.size()) {
150 Jump isAscii = branch32(LessThanOrEqual, character, Imm32(0x7f));
151
152 if (charClass->m_matchesUnicode.size()) {
153 for (unsigned i = 0; i <cxx . . $ QTJSC/`operator<`(11610d830df66bbf). charClass->m_matchesUnicode.size(); ++i) {
154 UCharcxx . . $ UChar# ch = charClass->m_matchesUnicode[i];
155 matchDest.append(branch32(Equal, character, Imm32(ch)));
156 }
157 }
158
159 if (charClass->m_rangesUnicode.size()) {
160 for (unsigned i = 0; i <cxx . . $ QTJSC/`operator<`(11610d830df66bbf). charClass->m_rangesUnicode.size(); ++i) {
161 UCharcxx . . $ UChar# lo = charClass->m_rangesUnicode[i].begin;
162 UCharcxx . . $ UChar# hi = charClass->m_rangesUnicode[i].end;
163
164 Jump below = branch32(LessThan, character, Imm32(lo));
165 matchDest.append(branch32(LessThanOrEqual, character, Imm32(hi)));
166 below.link(this);
167 }
168 }
169
170 unicodeFail = jump();
171 isAscii.link(this);
172 }
173
174 if (charClass->m_ranges.size()) {
175 unsigned matchIndex = 0;
176 JumpList failures;
177 matchCharacterClassRange(character, failures, matchDest, charClass->m_ranges.begin(), charClass->m_ranges.size(), &matchIndex, charClass->m_matches.begin(), charClass->m_matches.size());
178 while (matchIndex <cxx . . $ QTJSC/`operator<`(11610d830df66bbf). charClass->m_matches.size())
179 matchDest.append(branch32(Equal, character, Imm32((unsigned short)charClass->m_matches[matchIndex++])));
180
181 failures.link(this);
182 } else if (charClass->m_matches.size()) {
183 // optimization: gather 'a','A' etc back together, can mask & test once.
184 Vector<char> matchesAZaz;
185
186 for (unsigned i = 0; i <cxx . . $ QTJSC/`operator<`(11610d830df66bbf). charClass->m_matches.size(); ++i) {
187 char ch = charClass->m_matches[i];
188 if (m_patterncxx . . $ QTJSC/Yarr/RegexGenerator#m_pattern..m_ignoreCasecxx . . $ QTJSC/Yarr/RegexPattern#m_ignoreCase.) {
189 if (isASCIILowercxx . . $ isASCIILower(b5fd09639b7a0261).(ch)) {
190 matchesAZaz.append(ch);
191 continue;
192 }
193 if (isASCIIUppercxx . . $ isASCIIUpper(b5fd09639b7a0261).(ch))
194 continue;
195 }
196 matchDest.append(branch32(Equal, character, Imm32((unsigned short)ch)));
197 }
198
199 if (unsigned countAZaz = matchesAZaz.size()) {
200 or32(Imm32(32), character);
201 for (unsigned i = 0; i < countAZaz; ++i)
202 matchDest.append(branch32(Equal, character, Imm32(matchesAZaz[i])));
203 }
204 }
205
206 if (charClass->m_matchesUnicode.size() || charClass->m_rangesUnicode.size())
207 unicodeFail.link(this);
208 }
209
210 // Jumps if input not available; will have (incorrectly) incremented already!
211 Jump jumpIfNoAvailableInputcxx . . $ QTJSC/Yarr/RegexGenerator#jumpIfNoAvailableInput(4c679297bf94b9eb).(unsigned countToCheck)
212 {
213 add32(Imm32(countToCheck), index);
214 return branch32(Above, index, length);
215 }
216
217 Jump jumpIfAvailableInputcxx . . $ QTJSC/Yarr/RegexGenerator#jumpIfAvailableInput(4c679297bf94b9eb).(unsigned countToCheck)
218 {
219 add32(Imm32(countToCheck), index);
220 return branch32(BelowOrEqual, index, length);
221 }
222
223 Jump checkInputcxx . . $ QTJSC/Yarr/RegexGenerator#checkInput(b126dc7c1de90089).()
224 {
225 return branch32(BelowOrEqual, index, length);
226 }
227
228 Jump atEndOfInputcxx . . $ QTJSC/Yarr/RegexGenerator#atEndOfInput(b126dc7c1de90089).()
229 {
230 return branch32(Equal, index, length);
231 }
232
233 Jump notAtEndOfInputcxx . . $ QTJSC/Yarr/RegexGenerator#notAtEndOfInput(b126dc7c1de90089).()
234 {
235 return branch32(NotEqual, index, length);
236 }
237
238 Jump jumpIfCharEqualscxx . . $ QTJSC/Yarr/RegexGenerator#jumpIfCharEquals(3727f65dc41d151e).(UCharcxx . . $ UChar# ch, int inputPosition)
239 {
240 return branch16(Equal, BaseIndex(input, index, TimesTwo, inputPosition * sizeof(UChar)), Imm32(ch));
241 }
242
243 Jump jumpIfCharNotEqualscxx . . $ QTJSC/Yarr/RegexGenerator#jumpIfCharNotEquals(3727f65dc41d151e).(UCharcxx . . $ UChar# ch, int inputPosition)
244 {
245 return branch16(NotEqual, BaseIndex(input, index, TimesTwo, inputPosition * sizeof(UChar)), Imm32(ch));
246 }
247
248 void readCharactercxx . . $ QTJSC/Yarr/RegexGenerator#readCharacter(3e454b8ccf442868).(int inputPosition, RegisterID reg)
249 {
250 load16(BaseIndex(input, index, TimesTwo, inputPosition * sizeof(UChar)), reg);
251 }
252
253 void storeToFramecxx . . $ QTJSC/Yarr/RegexGenerator#storeToFrame(c8dafc4a64bf4a1c).(RegisterID reg, unsigned frameLocation)
254 {
255 poke(reg, frameLocation);
256 }
257
258 void storeToFramecxx . . $ QTJSC/Yarr/RegexGenerator#storeToFrame(c8dafc4a64bf4a1c).(Imm32 imm, unsigned frameLocation)
259 {
260 poke(imm, frameLocation);
261 }
262
263 DataLabelPtr storeToFrameWithPatchcxx . . $ QTJSC/Yarr/RegexGenerator#storeToFrameWithPatch(4c679297bf94b9eb).(unsigned frameLocation)
264 {
265 return storePtrWithPatch(ImmPtr(0), Address(stackPointerRegister, frameLocation * sizeof(void*)));
266 }
267
268 void loadFromFramecxx . . $ QTJSC/Yarr/RegexGenerator#loadFromFrame(3d89109e85ced1be).(unsigned frameLocation, RegisterID reg)
269 {
270 peek(reg, frameLocation);
271 }
272
273 void loadFromFrameAndJumpcxx . . $ QTJSC/Yarr/RegexGenerator#loadFromFrameAndJump(cb2f890c2fdad230).(unsigned frameLocation)
274 {
275 jump(Address(stackPointerRegister, frameLocation * sizeof(void*)));
276 }
277
278 struct AlternativeBacktrackRecordcxx . . $ QTJSC/Yarr/RegexGenerator#AlternativeBacktrackRecord# {
279 DataLabelPtr dataLabelcxx . . $ QTJSC/Yarr/RegexGenerator#AlternativeBacktrackRecord#dataLabel.;
280 Label backtrackLocationcxx . . $ QTJSC/Yarr/RegexGenerator#AlternativeBacktrackRecord#backtrackLocation.;
281
282 AlternativeBacktrackRecordcxx . . $ QTJSC/Yarr/RegexGenerator#AlternativeBacktrackRecord#AlternativeBacktrackRecord(3e454b8ccf442868).(DataLabelPtr dataLabel, Label backtrackLocation)
283 : dataLabel(dataLabel)
284 , backtrackLocation(backtrackLocation)
285 {
286 }
287 };
288
289 struct TermGenerationStatecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState# {
290 TermGenerationStatecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#TermGenerationState(b0c648ccdd6384da).(PatternDisjunctioncxx . . $ QTJSC/Yarr/PatternDisjunction#* disjunction, unsigned checkedTotal)
291 : disjunctioncxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#disjunction.(disjunction)
292 , checkedTotalcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#checkedTotal.(checkedTotal)
293 {
294 }
295
296 void resetAlternativecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#resetAlternative(49f6e7a06ebc5aa8).()
297 {
298 isBackTrackGeneratedcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#isBackTrackGenerated. = false;
299 altcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#alt. = 0;
300 }
301 bool alternativeValidcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#alternativeValid(c9857a73d68e59ba).()
302 {
303 return altcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#alt. <cxx . . $ QTJSC/`operator<`(11610d830df66bbf). disjunctioncxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#disjunction.->m_alternatives.size();
304 }
305 void nextAlternativecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#nextAlternative(49f6e7a06ebc5aa8).()
306 {
307 ++altcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#alt.;
308 }
309 PatternAlternativecxx . . $ QTJSC/Yarr/PatternAlternative#* alternativecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#alternative(b7c439e3c6b41127).()
310 {
311 return disjunctioncxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#disjunction.->m_alternatives[altcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#alt.];
312 }
313
314 void resetTermcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#resetTerm(49f6e7a06ebc5aa8).()
315 {
316 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(alternativeValid());
317 tcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#t. = 0;
318 }
319 bool termValidcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#termValid(c9857a73d68e59ba).()
320 {
321 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(alternativeValid());
322 return tcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#t. <cxx . . $ QTJSC/`operator<`(11610d830df66bbf). alternativecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#alternative(b7c439e3c6b41127).()->m_terms.size();
323 }
324 void nextTermcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#nextTerm(49f6e7a06ebc5aa8).()
325 {
326 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(alternativeValid());
327 ++tcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#t.;
328 }
329 PatternTermcxx . . $ QTJSC/Yarr/PatternTerm#& termcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#term(6889087f3753b497).()
330 {
331 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(alternativeValid());
332 return alternativecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#alternative(b7c439e3c6b41127).()->m_terms[tcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#t.];
333 }
334
335 PatternTermcxx . . $ QTJSC/Yarr/PatternTerm#& lookaheadTermcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#lookaheadTerm(6889087f3753b497).()
336 {
337 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(alternativeValid());
338 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!((t + 1) < alternative()->m_terms.size());
339 return alternativecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#alternative(b7c439e3c6b41127).()->m_terms[tcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#t. + 1];
340 }
341 bool isSinglePatternCharacterLookaheadTermcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#isSinglePatternCharacterLookaheadTerm(c9857a73d68e59ba).()
342 {
343 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(alternativeValid());
344 return ((tcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#t. + 1) <cxx . . $ QTJSC/`operator<`(11610d830df66bbf). alternativecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#alternative(b7c439e3c6b41127).()->m_terms.size())
345 && (lookaheadTermcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#lookaheadTerm(6889087f3753b497).().typecxx . . $ QTJSC/Yarr/PatternTerm#type. == PatternTermcxx . . $ QTJSC/Yarr/PatternTerm#::TypePatternCharactercxx . . $ QTJSC/Yarr/PatternTerm#TypePatternCharacter.)
346 && (lookaheadTermcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#lookaheadTerm(6889087f3753b497).().quantityTypecxx . . $ QTJSC/Yarr/PatternTerm#quantityType. == QuantifierFixedCountcxx . . $ QTJSC/Yarr/QuantifierFixedCount.)
347 && (lookaheadTermcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#lookaheadTerm(6889087f3753b497).().quantityCountcxx . . $ QTJSC/Yarr/PatternTerm#quantityCount. == 1);
348 }
349
350 int inputOffsetcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#inputOffset(b126dc7c1de90089).()
351 {
352 return termcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#term(6889087f3753b497).().inputPositioncxx . . $ QTJSC/Yarr/PatternTerm#inputPosition. - checkedTotalcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#checkedTotal.;
353 }
354
355 void jumpToBacktrackcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#jumpToBacktrack(4cc9cd2ff46d0d64).(Jump jump, MacroAssemblercxx . . $ QTJSC/MacroAssembler#* masm)
356 {
357 if (isBackTrackGeneratedcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#isBackTrackGenerated.)
358 jump.linkTo(backtrackLabel, masm);
359 else
360 backTrackJumps.append(jump);
361 }
362 void jumpToBacktrackcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#jumpToBacktrack(878f8ae67a8a5e02).(JumpList& jumps, MacroAssemblercxx . . $ QTJSC/MacroAssembler#* masm)
363 {
364 if (isBackTrackGeneratedcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#isBackTrackGenerated.)
365 jumps.linkTo(backtrackLabel, masm);
366 else
367 backTrackJumps.append(jumps);
368 }
369 bool plantJumpToBacktrackIfExistscxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#plantJumpToBacktrackIfExists(818b5ecfd2e19450).(MacroAssemblercxx . . $ QTJSC/MacroAssembler#* masm)
370 {
371 if (isBackTrackGeneratedcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#isBackTrackGenerated.) {
372 masm->jump(backtrackLabel);
373 return true;
374 }
375 return false;
376 }
377 void addBacktrackJumpcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#addBacktrackJump(d4f767463ce0a6b3).(Jump jump)
378 {
379 backTrackJumps.append(jump);
380 }
381 void setBacktrackGeneratedcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#setBacktrackGenerated(d4f767463ce0a6b3).(Label label)
382 {
383 isBackTrackGeneratedcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#isBackTrackGenerated. = true;
384 backtrackLabel = label;
385 }
386 void linkAlternativeBacktrackscxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#linkAlternativeBacktracks(c2b519253ca5229d).(MacroAssemblercxx . . $ QTJSC/MacroAssembler#* masm)
387 {
388 isBackTrackGeneratedcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#isBackTrackGenerated. = false;
389 backTrackJumps.link(masm);
390 }
391 void linkAlternativeBacktracksTocxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#linkAlternativeBacktracksTo(4cc9cd2ff46d0d64).(Label label, MacroAssemblercxx . . $ QTJSC/MacroAssembler#* masm)
392 {
393 isBackTrackGeneratedcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#isBackTrackGenerated. = false;
394 backTrackJumps.linkTo(label, masm);
395 }
396 void propagateBacktrackingFromcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#propagateBacktrackingFrom(e617cdc665ce5193).(TermGenerationStatecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#& nestedParenthesesState, MacroAssemblercxx . . $ QTJSC/MacroAssembler#* masm)
397 {
398 jumpToBacktrack(nestedParenthesesState.backTrackJumps, masm);
399 if (nestedParenthesesState.isBackTrackGenerated)
400 setBacktrackGenerated(nestedParenthesesState.backtrackLabel);
401 }
402
403 PatternDisjunctioncxx . . $ QTJSC/Yarr/PatternDisjunction#* disjunctioncxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#disjunction.;
404 int checkedTotalcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#checkedTotal.;
405 private:
406 unsigned altcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#alt.;
407 unsigned tcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#t.;
408 JumpList backTrackJumpscxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#backTrackJumps.;
409 Label backtrackLabelcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#backtrackLabel.;
410 bool isBackTrackGeneratedcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#isBackTrackGenerated.;
411 };
412
413 void generateAssertionBOLcxx . . $ QTJSC/Yarr/RegexGenerator#generateAssertionBOL(f680d07b789f7bcb).(TermGenerationStatecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#& state)
414 {
415 PatternTermcxx . . $ QTJSC/Yarr/PatternTerm#& term = state.termcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#term(6889087f3753b497).();
416
417 if (m_patterncxx . . $ QTJSC/Yarr/RegexGenerator#m_pattern..m_multilinecxx . . $ QTJSC/Yarr/RegexPattern#m_multiline.) {
418 const RegisterID character = regT0;
419
420 JumpList matchDest;
421 if (!term.inputPositioncxx . . $ QTJSC/Yarr/PatternTerm#inputPosition.)
422 matchDest.append(branch32(Equal, index, Imm32(state.checkedTotal)));
423
424 readCharacter(state.inputOffset() - 1, character);
425 matchCharacterClass(character, matchDest, m_pattern.newlineCharacterClass());
426 state.jumpToBacktrack(jump(), this);
427
428 matchDest.link(this);
429 } else {
430 // Erk, really should poison out these alternatives early. :-/
431 if (term.inputPositioncxx . . $ QTJSC/Yarr/PatternTerm#inputPosition.)
432 state.jumpToBacktrack(jump(), this);
433 else
434 state.jumpToBacktrack(branch32(NotEqual, index, Imm32(state.checkedTotal)), this);
435 }
436 }
437
438 void generateAssertionEOLcxx . . $ QTJSC/Yarr/RegexGenerator#generateAssertionEOL(f680d07b789f7bcb).(TermGenerationStatecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#& state)
439 {
440 PatternTermcxx . . $ QTJSC/Yarr/PatternTerm#& term = state.termcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#term(6889087f3753b497).();
441
442 if (m_patterncxx . . $ QTJSC/Yarr/RegexGenerator#m_pattern..m_multilinecxx . . $ QTJSC/Yarr/RegexPattern#m_multiline.) {
443 const RegisterID character = regT0;
444
445 JumpList matchDest;
446 if (term.inputPositioncxx . . $ QTJSC/Yarr/PatternTerm#inputPosition. == state.checkedTotalcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#checkedTotal.)
447 matchDest.append(atEndOfInput());
448
449 readCharacter(state.inputOffset(), character);
450 matchCharacterClass(character, matchDest, m_pattern.newlineCharacterClass());
451 state.jumpToBacktrack(jump(), this);
452
453 matchDest.link(this);
454 } else {
455 if (term.inputPositioncxx . . $ QTJSC/Yarr/PatternTerm#inputPosition. == state.checkedTotalcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#checkedTotal.)
456 state.jumpToBacktrack(notAtEndOfInput(), this);
457 // Erk, really should poison out these alternatives early. :-/
458 else
459 state.jumpToBacktrack(jump(), this);
460 }
461 }
462
463 // Also falls though on nextIsNotWordChar.
464 void matchAssertionWordcharcxx . . $ QTJSC/Yarr/RegexGenerator#matchAssertionWordchar(f6cdca3f2c1c42a1).(TermGenerationStatecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#& state, JumpList& nextIsWordChar, JumpList& nextIsNotWordChar)
465 {
466 const RegisterID character = regT0;
467 PatternTermcxx . . $ QTJSC/Yarr/PatternTerm#& term = state.termcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#term(6889087f3753b497).();
468
469 if (term.inputPositioncxx . . $ QTJSC/Yarr/PatternTerm#inputPosition. == state.checkedTotalcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#checkedTotal.)
470 nextIsNotWordChar.append(atEndOfInput());
471
472 readCharacter(state.inputOffset(), character);
473 matchCharacterClass(character, nextIsWordChar, m_pattern.wordcharCharacterClass());
474 }
475
476 void generateAssertionWordBoundarycxx . . $ QTJSC/Yarr/RegexGenerator#generateAssertionWordBoundary(f680d07b789f7bcb).(TermGenerationStatecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#& state)
477 {
478 const RegisterID character = regT0;
479 PatternTermcxx . . $ QTJSC/Yarr/PatternTerm#& term = state.termcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#term(6889087f3753b497).();
480
481 Jump atBegin;
482 JumpList matchDest;
483 if (!term.inputPosition)
484 atBegin = branch32(Equal, index, Imm32(state.checkedTotal));
485 readCharacter(state.inputOffset() - 1, character);
486 matchCharacterClass(character, matchDest, m_pattern.wordcharCharacterClass());
487 if (!term.inputPositioncxx . . $ QTJSC/Yarr/PatternTerm#inputPosition.)
488 atBegin.link(this);
489
490 // We fall through to here if the last character was not a wordchar.
491 JumpList nonWordCharThenWordChar;
492 JumpList nonWordCharThenNonWordChar;
493 if (term.invertOrCapturecxx . . $ QTJSC/Yarr/PatternTerm#invertOrCapture.) {
494 matchAssertionWordchar(state, nonWordCharThenNonWordChar, nonWordCharThenWordChar);
495 nonWordCharThenWordChar.append(jump());
496 } else {
497 matchAssertionWordchar(state, nonWordCharThenWordChar, nonWordCharThenNonWordChar);
498 nonWordCharThenNonWordChar.append(jump());
499 }
500 state.jumpToBacktrack(nonWordCharThenNonWordChar, this);
501
502 // We jump here if the last character was a wordchar.
503 matchDest.link(this);
504 JumpList wordCharThenWordChar;
505 JumpList wordCharThenNonWordChar;
506 if (term.invertOrCapturecxx . . $ QTJSC/Yarr/PatternTerm#invertOrCapture.) {
507 matchAssertionWordchar(state, wordCharThenNonWordChar, wordCharThenWordChar);
508 wordCharThenWordChar.append(jump());
509 } else {
510 matchAssertionWordchar(state, wordCharThenWordChar, wordCharThenNonWordChar);
511 // This can fall-though!
512 }
513
514 state.jumpToBacktrack(wordCharThenWordChar, this);
515
516 nonWordCharThenWordChar.link(this);
517 wordCharThenNonWordChar.link(this);
518 }
519
520 void generatePatternCharacterSinglecxx . . $ QTJSC/Yarr/RegexGenerator#generatePatternCharacterSingle(f680d07b789f7bcb).(TermGenerationStatecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#& state)
521 {
522 const RegisterID character = regT0;
523 UCharcxx . . $ UChar# ch = state.termcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#term(6889087f3753b497).().patternCharactercxx . . $ QTJSC/Yarr/PatternTerm#$anonymous_type_0#patternCharacter.;
524
525 if (m_patterncxx . . $ QTJSC/Yarr/RegexGenerator#m_pattern..m_ignoreCasecxx . . $ QTJSC/Yarr/RegexPattern#m_ignoreCase. && isASCIIAlphacxx . . $ isASCIIAlpha(3c978dac0e5ee2ad).(ch)) {
526 readCharacter(state.inputOffset(), character);
527 or32(Imm32(32), character);
528 state.jumpToBacktrack(branch32(NotEqual, character, Imm32(Unicode::toLower(ch))), this);
529 } else {
530 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(!m_pattern.m_ignoreCase || (Unicode::toLower(ch) == Unicode::toUpper(ch)));
531 state.jumpToBacktrack(jumpIfCharNotEquals(ch, state.inputOffset()), this);
532 }
533 }
534
535 void generatePatternCharacterPaircxx . . $ QTJSC/Yarr/RegexGenerator#generatePatternCharacterPair(f680d07b789f7bcb).(TermGenerationStatecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#& state)
536 {
537 const RegisterID character = regT0;
538 UCharcxx . . $ UChar# ch1 = state.termcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#term(6889087f3753b497).().patternCharactercxx . . $ QTJSC/Yarr/PatternTerm#$anonymous_type_0#patternCharacter.;
539 UCharcxx . . $ UChar# ch2 = state.lookaheadTermcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#lookaheadTerm(6889087f3753b497).().patternCharactercxx . . $ QTJSC/Yarr/PatternTerm#$anonymous_type_0#patternCharacter.;
540
541 int mask = 0;
542 int chPair = ch1 | (ch2 << 16);
543
544 if (m_patterncxx . . $ QTJSC/Yarr/RegexGenerator#m_pattern..m_ignoreCasecxx . . $ QTJSC/Yarr/RegexPattern#m_ignoreCase.) {
545 if (isASCIIAlphacxx . . $ isASCIIAlpha(3c978dac0e5ee2ad).(ch1))
546 mask |= 32;
547 if (isASCIIAlphacxx . . $ isASCIIAlpha(3c978dac0e5ee2ad).(ch2))
548 mask |= 32 << 16;
549 }
550
551 if (mask) {
552 load32WithUnalignedHalfWords(BaseIndex(input, index, TimesTwo, state.inputOffset() * sizeof(UChar)), character);
553 or32(Imm32(mask), character);
554 state.jumpToBacktrack(branch32(NotEqual, character, Imm32(chPair | mask)), this);
555 } else
556 state.jumpToBacktrack(branch32WithUnalignedHalfWords(NotEqual, BaseIndex(input, index, TimesTwo, state.inputOffset() * sizeof(UChar)), Imm32(chPair)), this);
557 }
558
559 void generatePatternCharacterFixedcxx . . $ QTJSC/Yarr/RegexGenerator#generatePatternCharacterFixed(f680d07b789f7bcb).(TermGenerationStatecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#& state)
560 {
561 const RegisterID character = regT0;
562 const RegisterID countRegister = regT1;
563 PatternTermcxx . . $ QTJSC/Yarr/PatternTerm#& term = state.termcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#term(6889087f3753b497).();
564 UCharcxx . . $ UChar# ch = term.patternCharactercxx . . $ QTJSC/Yarr/PatternTerm#$anonymous_type_0#patternCharacter.;
565
566 move(index, countRegister);
567 sub32(Imm32(term.quantityCount), countRegister);
568
569 Label loop(this);
570 if (m_patterncxx . . $ QTJSC/Yarr/RegexGenerator#m_pattern..m_ignoreCasecxx . . $ QTJSC/Yarr/RegexPattern#m_ignoreCase. && isASCIIAlphacxx . . $ isASCIIAlpha(3c978dac0e5ee2ad).(ch)) {
571 load16(BaseIndex(input, countRegister, TimesTwo, (state.inputOffset() + term.quantityCount) * sizeof(UChar)), character);
572 or32(Imm32(32), character);
573 state.jumpToBacktrack(branch32(NotEqual, character, Imm32(Unicode::toLower(ch))), this);
574 } else {
575 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(!m_pattern.m_ignoreCase || (Unicode::toLower(ch) == Unicode::toUpper(ch)));
576 state.jumpToBacktrack(branch16(NotEqual, BaseIndex(input, countRegister, TimesTwo, (state.inputOffset() + term.quantityCount) * sizeof(UChar)), Imm32(ch)), this);
577 }
578 add32(Imm32(1), countRegister);
579 branch32(NotEqual, countRegister, index).linkTo(loop, this);
580 }
581
582 void generatePatternCharacterGreedycxx . . $ QTJSC/Yarr/RegexGenerator#generatePatternCharacterGreedy(f680d07b789f7bcb).(TermGenerationStatecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#& state)
583 {
584 const RegisterID character = regT0;
585 const RegisterID countRegister = regT1;
586 PatternTermcxx . . $ QTJSC/Yarr/PatternTerm#& term = state.termcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#term(6889087f3753b497).();
587 UCharcxx . . $ UChar# ch = term.patternCharactercxx . . $ QTJSC/Yarr/PatternTerm#$anonymous_type_0#patternCharacter.;
588
589 move(Imm32(0), countRegister);
590
591 JumpList failures;
592 Label loop(this);
593 failures.append(atEndOfInput());
594 if (m_patterncxx . . $ QTJSC/Yarr/RegexGenerator#m_pattern..m_ignoreCasecxx . . $ QTJSC/Yarr/RegexPattern#m_ignoreCase. && isASCIIAlphacxx . . $ isASCIIAlpha(3c978dac0e5ee2ad).(ch)) {
595 readCharacter(state.inputOffset(), character);
596 or32(Imm32(32), character);
597 failures.append(branch32(NotEqual, character, Imm32(Unicode::toLower(ch))));
598 } else {
599 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(!m_pattern.m_ignoreCase || (Unicode::toLower(ch) == Unicode::toUpper(ch)));
600 failures.append(jumpIfCharNotEquals(ch, state.inputOffset()));
601 }
602 add32(Imm32(1), countRegister);
603 add32(Imm32(1), index);
604 branch32(NotEqual, countRegister, Imm32(term.quantityCount)).linkTo(loop, this);
605 failures.append(jump());
606
607 Label backtrackBegin(this);
608 loadFromFrame(term.frameLocation, countRegister);
609 state.jumpToBacktrack(branchTest32(Zero, countRegister), this);
610 sub32(Imm32(1), countRegister);
611 sub32(Imm32(1), index);
612
613 failures.link(this);
614
615 storeToFrame(countRegister, term.frameLocation);
616
617 state.setBacktrackGenerated(backtrackBegin);
618 }
619
620 void generatePatternCharacterNonGreedycxx . . $ QTJSC/Yarr/RegexGenerator#generatePatternCharacterNonGreedy(f680d07b789f7bcb).(TermGenerationStatecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#& state)
621 {
622 const RegisterID character = regT0;
623 const RegisterID countRegister = regT1;
624 PatternTermcxx . . $ QTJSC/Yarr/PatternTerm#& term = state.termcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#term(6889087f3753b497).();
625 UCharcxx . . $ UChar# ch = term.patternCharactercxx . . $ QTJSC/Yarr/PatternTerm#$anonymous_type_0#patternCharacter.;
626
627 move(Imm32(0), countRegister);
628
629 Jump firstTimeDoNothing = jump();
630
631 Label hardFail(this);
632 sub32(countRegister, index);
633 state.jumpToBacktrack(jump(), this);
634
635 Label backtrackBegin(this);
636 loadFromFrame(term.frameLocation, countRegister);
637
638 atEndOfInput().linkTo(hardFail, this);
639 branch32(Equal, countRegister, Imm32(term.quantityCount), hardFail);
640 if (m_patterncxx . . $ QTJSC/Yarr/RegexGenerator#m_pattern..m_ignoreCasecxx . . $ QTJSC/Yarr/RegexPattern#m_ignoreCase. && isASCIIAlphacxx . . $ isASCIIAlpha(3c978dac0e5ee2ad).(ch)) {
641 readCharacter(state.inputOffset(), character);
642 or32(Imm32(32), character);
643 branch32(NotEqual, character, Imm32(Unicode::toLower(ch))).linkTo(hardFail, this);
644 } else {
645 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(!m_pattern.m_ignoreCase || (Unicode::toLower(ch) == Unicode::toUpper(ch)));
646 jumpIfCharNotEquals(ch, state.inputOffset()).linkTo(hardFail, this);
647 }
648
649 add32(Imm32(1), countRegister);
650 add32(Imm32(1), index);
651
652 firstTimeDoNothing.link(this);
653 storeToFrame(countRegister, term.frameLocation);
654
655 state.setBacktrackGenerated(backtrackBegin);
656 }
657
658 void generateCharacterClassSinglecxx . . $ QTJSC/Yarr/RegexGenerator#generateCharacterClassSingle(f680d07b789f7bcb).(TermGenerationStatecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#& state)
659 {
660 const RegisterID character = regT0;
661 PatternTermcxx . . $ QTJSC/Yarr/PatternTerm#& term = state.termcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#term(6889087f3753b497).();
662
663 JumpList matchDest;
664 readCharacter(state.inputOffset(), character);
665 matchCharacterClass(character, matchDest, term.characterClass);
666
667 if (term.invertOrCapturecxx . . $ QTJSC/Yarr/PatternTerm#invertOrCapture.)
668 state.jumpToBacktrack(matchDest, this);
669 else {
670 state.jumpToBacktrack(jump(), this);
671 matchDest.link(this);
672 }
673 }
674
675 void generateCharacterClassFixedcxx . . $ QTJSC/Yarr/RegexGenerator#generateCharacterClassFixed(f680d07b789f7bcb).(TermGenerationStatecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#& state)
676 {
677 const RegisterID character = regT0;
678 const RegisterID countRegister = regT1;
679 PatternTermcxx . . $ QTJSC/Yarr/PatternTerm#& term = state.termcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#term(6889087f3753b497).();
680
681 move(index, countRegister);
682 sub32(Imm32(term.quantityCount), countRegister);
683
684 Label loop(this);
685 JumpList matchDest;
686 load16(BaseIndex(input, countRegister, TimesTwo, (state.inputOffset() + term.quantityCount) * sizeof(UChar)), character);
687 matchCharacterClass(character, matchDest, term.characterClass);
688
689 if (term.invertOrCapturecxx . . $ QTJSC/Yarr/PatternTerm#invertOrCapture.)
690 state.jumpToBacktrack(matchDest, this);
691 else {
692 state.jumpToBacktrack(jump(), this);
693 matchDest.link(this);
694 }
695
696 add32(Imm32(1), countRegister);
697 branch32(NotEqual, countRegister, index).linkTo(loop, this);
698 }
699
700 void generateCharacterClassGreedycxx . . $ QTJSC/Yarr/RegexGenerator#generateCharacterClassGreedy(f680d07b789f7bcb).(TermGenerationStatecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#& state)
701 {
702 const RegisterID character = regT0;
703 const RegisterID countRegister = regT1;
704 PatternTermcxx . . $ QTJSC/Yarr/PatternTerm#& term = state.termcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#term(6889087f3753b497).();
705
706 move(Imm32(0), countRegister);
707
708 JumpList failures;
709 Label loop(this);
710 failures.append(atEndOfInput());
711
712 if (term.invertOrCapturecxx . . $ QTJSC/Yarr/PatternTerm#invertOrCapture.) {
713 readCharacter(state.inputOffset(), character);
714 matchCharacterClass(character, failures, term.characterClass);
715 } else {
716 JumpList matchDest;
717 readCharacter(state.inputOffset(), character);
718 matchCharacterClass(character, matchDest, term.characterClass);
719 failures.append(jump());
720 matchDest.link(this);
721 }
722
723 add32(Imm32(1), countRegister);
724 add32(Imm32(1), index);
725 branch32(NotEqual, countRegister, Imm32(term.quantityCount)).linkTo(loop, this);
726 failures.append(jump());
727
728 Label backtrackBegin(this);
729 loadFromFrame(term.frameLocation, countRegister);
730 state.jumpToBacktrack(branchTest32(Zero, countRegister), this);
731 sub32(Imm32(1), countRegister);
732 sub32(Imm32(1), index);
733
734 failures.link(this);
735
736 storeToFrame(countRegister, term.frameLocation);
737
738 state.setBacktrackGenerated(backtrackBegin);
739 }
740
741 void generateCharacterClassNonGreedycxx . . $ QTJSC/Yarr/RegexGenerator#generateCharacterClassNonGreedy(f680d07b789f7bcb).(TermGenerationStatecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#& state)
742 {
743 const RegisterID character = regT0;
744 const RegisterID countRegister = regT1;
745 PatternTermcxx . . $ QTJSC/Yarr/PatternTerm#& term = state.termcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#term(6889087f3753b497).();
746
747 move(Imm32(0), countRegister);
748
749 Jump firstTimeDoNothing = jump();
750
751 Label hardFail(this);
752 sub32(countRegister, index);
753 state.jumpToBacktrack(jump(), this);
754
755 Label backtrackBegin(this);
756 loadFromFrame(term.frameLocation, countRegister);
757
758 atEndOfInput().linkTo(hardFail, this);
759 branch32(Equal, countRegister, Imm32(term.quantityCount), hardFail);
760
761 JumpList matchDest;
762 readCharacter(state.inputOffset(), character);
763 matchCharacterClass(character, matchDest, term.characterClass);
764
765 if (term.invertOrCapturecxx . . $ QTJSC/Yarr/PatternTerm#invertOrCapture.)
766 matchDest.linkTo(hardFail, this);
767 else {
768 jump(hardFail);
769 matchDest.link(this);
770 }
771
772 add32(Imm32(1), countRegister);
773 add32(Imm32(1), index);
774
775 firstTimeDoNothing.link(this);
776 storeToFrame(countRegister, term.frameLocation);
777
778 state.setBacktrackGenerated(backtrackBegin);
779 }
780
781 void generateParenthesesDisjunctioncxx . . $ QTJSC/Yarr/RegexGenerator#generateParenthesesDisjunction(3965959b85f0a527).(PatternTermcxx . . $ QTJSC/Yarr/PatternTerm#& parenthesesTerm, TermGenerationStatecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#& state, unsigned alternativeFrameLocation)
782 {
783 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!((parenthesesTerm.type == PatternTerm::TypeParenthesesSubpattern) || (parenthesesTerm.type == PatternTerm::TypeParentheticalAssertion));
784 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(parenthesesTerm.quantityCount == 1);
785
786 PatternDisjunctioncxx . . $ QTJSC/Yarr/PatternDisjunction#* disjunction = parenthesesTerm.parenthesescxx . . $ QTJSC/Yarr/PatternTerm#$anonymous_type_0#parentheses..disjunctioncxx . . $ QTJSC/Yarr/PatternTerm#$anonymous_type_0#$anonymous_type_1#disjunction.;
787 unsigned preCheckedCount = ((parenthesesTerm.quantityTypecxx . . $ QTJSC/Yarr/PatternTerm#quantityType. == QuantifierFixedCountcxx . . $ QTJSC/Yarr/QuantifierFixedCount.) && (parenthesesTerm.typecxx . . $ QTJSC/Yarr/PatternTerm#type. != PatternTermcxx . . $ QTJSC/Yarr/PatternTerm#::TypeParentheticalAssertioncxx . . $ QTJSC/Yarr/PatternTerm#TypeParentheticalAssertion.)) ? disjunction->m_minimumSizecxx . . $ QTJSC/Yarr/PatternDisjunction#m_minimumSize. : 0;
788
789 if (disjunction->m_alternatives.size() ==cxx . . $ QTJSC/`operator==`(e9142ab59ce7dac8). 1) {
790 state.resetAlternativecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#resetAlternative(49f6e7a06ebc5aa8).();
791 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(state.alternativeValid());
792 PatternAlternativecxx . . $ QTJSC/Yarr/PatternAlternative#* alternative = state.alternativecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#alternative(b7c439e3c6b41127).();
793 optimizeAlternativecxx . . $ QTJSC/Yarr/RegexGenerator#optimizeAlternative(8a910acb71f34a04).(alternative);
794
795 int countToCheck = alternative->m_minimumSizecxx . . $ QTJSC/Yarr/PatternAlternative#m_minimumSize. - preCheckedCount;
796 if (countToCheck) {
797 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!((parenthesesTerm.type == PatternTerm::TypeParentheticalAssertion) || (parenthesesTerm.quantityType != QuantifierFixedCount));
798
799 // FIXME: This is quite horrible. The call to 'plantJumpToBacktrackIfExists'
800 // will be forced to always trampoline into here, just to decrement the index.
801 // Ick.
802 Jump skip = jump();
803
804 Label backtrackBegin(this);
805 sub32(Imm32(countToCheck), index);
806 state.addBacktrackJump(jump());
807
808 skip.link(this);
809
810 state.setBacktrackGenerated(backtrackBegin);
811
812 state.jumpToBacktrack(jumpIfNoAvailableInput(countToCheck), this);
813 state.checkedTotalcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#checkedTotal. += countToCheck;
814 }
815
816 for (state.resetTermcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#resetTerm(49f6e7a06ebc5aa8).(); state.termValidcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#termValid(c9857a73d68e59ba).(); state.nextTermcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#nextTerm(49f6e7a06ebc5aa8).())
817 generateTermcxx . . $ QTJSC/Yarr/RegexGenerator#generateTerm(f680d07b789f7bcb).(state);
818
819 state.checkedTotalcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#checkedTotal. -= countToCheck;
820 } else {
821 JumpList successes;
822
823 for (state.resetAlternativecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#resetAlternative(49f6e7a06ebc5aa8).(); state.alternativeValidcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#alternativeValid(c9857a73d68e59ba).(); state.nextAlternativecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#nextAlternative(49f6e7a06ebc5aa8).()) {
824
825 PatternAlternativecxx . . $ QTJSC/Yarr/PatternAlternative#* alternative = state.alternativecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#alternative(b7c439e3c6b41127).();
826 optimizeAlternativecxx . . $ QTJSC/Yarr/RegexGenerator#optimizeAlternative(8a910acb71f34a04).(alternative);
827
828 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(alternative->m_minimumSize >= preCheckedCount);
829 int countToCheck = alternative->m_minimumSizecxx . . $ QTJSC/Yarr/PatternAlternative#m_minimumSize. - preCheckedCount;
830 if (countToCheck) {
831 state.addBacktrackJump(jumpIfNoAvailableInput(countToCheck));
832 state.checkedTotalcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#checkedTotal. += countToCheck;
833 }
834
835 for (state.resetTermcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#resetTerm(49f6e7a06ebc5aa8).(); state.termValidcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#termValid(c9857a73d68e59ba).(); state.nextTermcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#nextTerm(49f6e7a06ebc5aa8).())
836 generateTermcxx . . $ QTJSC/Yarr/RegexGenerator#generateTerm(f680d07b789f7bcb).(state);
837
838 // Matched an alternative.
839 DataLabelPtr dataLabel = storeToFrameWithPatch(alternativeFrameLocation);
840 successes.append(jump());
841
842 // Alternative did not match.
843 Label backtrackLocation(this);
844
845 // Can we backtrack the alternative? - if so, do so. If not, just fall through to the next one.
846 state.plantJumpToBacktrackIfExistscxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#plantJumpToBacktrackIfExists(818b5ecfd2e19450).(this);
847
848 state.linkAlternativeBacktrackscxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#linkAlternativeBacktracks(c2b519253ca5229d).(this);
849
850 if (countToCheck) {
851 sub32(Imm32(countToCheck), index);
852 state.checkedTotalcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#checkedTotal. -= countToCheck;
853 }
854
855 m_backtrackRecords.append(AlternativeBacktrackRecord(dataLabel, backtrackLocation));
856 }
857 // We fall through to here when the last alternative fails.
858 // Add a backtrack out of here for the parenthese handling code to link up.
859 state.addBacktrackJump(jump());
860
861 // Generate a trampoline for the parens code to backtrack to, to retry the
862 // next alternative.
863 state.setBacktrackGenerated(label());
864 loadFromFrameAndJumpcxx . . $ QTJSC/Yarr/RegexGenerator#loadFromFrameAndJump(cb2f890c2fdad230).(alternativeFrameLocation);
865
866 // FIXME: both of the above hooks are a little inefficient, in that you
867 // may end up trampolining here, just to trampoline back out to the
868 // parentheses code, or vice versa. We can probably eliminate a jump
869 // by restructuring, but coding this way for now for simplicity during
870 // development.
871
872 successes.link(this);
873 }
874 }
875
876 void generateParenthesesSinglecxx . . $ QTJSC/Yarr/RegexGenerator#generateParenthesesSingle(f680d07b789f7bcb).(TermGenerationStatecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#& state)
877 {
878 const RegisterID indexTemporary = regT0;
879 PatternTermcxx . . $ QTJSC/Yarr/PatternTerm#& term = state.termcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#term(6889087f3753b497).();
880 PatternDisjunctioncxx . . $ QTJSC/Yarr/PatternDisjunction#* disjunction = term.parenthesescxx . . $ QTJSC/Yarr/PatternTerm#$anonymous_type_0#parentheses..disjunctioncxx . . $ QTJSC/Yarr/PatternTerm#$anonymous_type_0#$anonymous_type_1#disjunction.;
881 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(term.quantityCount == 1);
882
883 unsigned preCheckedCount = ((term.quantityCountcxx . . $ QTJSC/Yarr/PatternTerm#quantityCount. == 1) && (term.quantityTypecxx . . $ QTJSC/Yarr/PatternTerm#quantityType. == QuantifierFixedCountcxx . . $ QTJSC/Yarr/QuantifierFixedCount.)) ? disjunction->m_minimumSizecxx . . $ QTJSC/Yarr/PatternDisjunction#m_minimumSize. : 0;
884
885 unsigned parenthesesFrameLocation = term.frameLocationcxx . . $ QTJSC/Yarr/PatternTerm#frameLocation.;
886 unsigned alternativeFrameLocation = parenthesesFrameLocation;
887 if (term.quantityTypecxx . . $ QTJSC/Yarr/PatternTerm#quantityType. != QuantifierFixedCountcxx . . $ QTJSC/Yarr/QuantifierFixedCount.)
888 alternativeFrameLocation += RegexStackSpaceForBackTrackInfoParenthesesOncecxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/yarr/RegexPattern.h:44:9`!;
889
890 // optimized case - no capture & no quantifier can be handled in a light-weight manner.
891 if (!term.invertOrCapturecxx . . $ QTJSC/Yarr/PatternTerm#invertOrCapture. && (term.quantityTypecxx . . $ QTJSC/Yarr/PatternTerm#quantityType. == QuantifierFixedCountcxx . . $ QTJSC/Yarr/QuantifierFixedCount.)) {
892 TermGenerationStatecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState# parenthesesStatecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#TermGenerationState(b0c648ccdd6384da).(disjunction, state.checkedTotalcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#checkedTotal.);
893 generateParenthesesDisjunctioncxx . . $ QTJSC/Yarr/RegexGenerator#generateParenthesesDisjunction(3965959b85f0a527).(state.termcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#term(6889087f3753b497).(), parenthesesState, alternativeFrameLocation);
894 // this expects that any backtracks back out of the parentheses will be in the
895 // parenthesesState's backTrackJumps vector, and that if they need backtracking
896 // they will have set an entry point on the parenthesesState's backtrackLabel.
897 state.propagateBacktrackingFromcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#propagateBacktrackingFrom(e617cdc665ce5193).(parenthesesState, this);
898 } else {
899 Jump nonGreedySkipParentheses;
900 Label nonGreedyTryParentheses;
901 if (term.quantityTypecxx . . $ QTJSC/Yarr/PatternTerm#quantityType. == QuantifierGreedycxx . . $ QTJSC/Yarr/QuantifierGreedy.)
902 storeToFrame(Imm32(1), parenthesesFrameLocation);
903 else if (term.quantityTypecxx . . $ QTJSC/Yarr/PatternTerm#quantityType. == QuantifierNonGreedycxx . . $ QTJSC/Yarr/QuantifierNonGreedy.) {
904 storeToFrame(Imm32(0), parenthesesFrameLocation);
905 nonGreedySkipParentheses = jump();
906 nonGreedyTryParentheses = label();
907 storeToFrame(Imm32(1), parenthesesFrameLocation);
908 }
909
910 // store the match start index
911 if (term.invertOrCapturecxx . . $ QTJSC/Yarr/PatternTerm#invertOrCapture.) {
912 int inputOffset = state.inputOffsetcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#inputOffset(b126dc7c1de90089).() - preCheckedCount;
913 if (inputOffset) {
914 move(index, indexTemporary);
915 add32(Imm32(inputOffset), indexTemporary);
916 store32(indexTemporary, Address(output, (term.parentheses.subpatternId << 1) * sizeof(int)));
917 } else
918 store32(index, Address(output, (term.parentheses.subpatternId << 1) * sizeof(int)));
919 }
920
921 // generate the body of the parentheses
922 TermGenerationStatecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState# parenthesesStatecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#TermGenerationState(b0c648ccdd6384da).(disjunction, state.checkedTotalcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#checkedTotal.);
923 generateParenthesesDisjunctioncxx . . $ QTJSC/Yarr/RegexGenerator#generateParenthesesDisjunction(3965959b85f0a527).(state.termcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#term(6889087f3753b497).(), parenthesesState, alternativeFrameLocation);
924
925 // store the match end index
926 if (term.invertOrCapturecxx . . $ QTJSC/Yarr/PatternTerm#invertOrCapture.) {
927 int inputOffset = state.inputOffsetcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#inputOffset(b126dc7c1de90089).();
928 if (inputOffset) {
929 move(index, indexTemporary);
930 add32(Imm32(state.inputOffset()), indexTemporary);
931 store32(indexTemporary, Address(output, ((term.parentheses.subpatternId << 1) + 1) * sizeof(int)));
932 } else
933 store32(index, Address(output, ((term.parentheses.subpatternId << 1) + 1) * sizeof(int)));
934 }
935 Jump success = jump();
936
937 // A failure AFTER the parens jumps here
938 Label backtrackFromAfterParens(this);
939
940 if (term.quantityTypecxx . . $ QTJSC/Yarr/PatternTerm#quantityType. == QuantifierGreedycxx . . $ QTJSC/Yarr/QuantifierGreedy.) {
941 // If this is zero we have now tested with both with and without the parens.
942 loadFromFrame(parenthesesFrameLocation, indexTemporary);
943 state.jumpToBacktrack(branchTest32(Zero, indexTemporary), this);
944 } else if (term.quantityTypecxx . . $ QTJSC/Yarr/PatternTerm#quantityType. == QuantifierNonGreedycxx . . $ QTJSC/Yarr/QuantifierNonGreedy.) {
945 // If this is zero we have now tested with both with and without the parens.
946 loadFromFrame(parenthesesFrameLocation, indexTemporary);
947 branchTest32(Zero, indexTemporary).linkTo(nonGreedyTryParentheses, this);
948 }
949
950 parenthesesState.plantJumpToBacktrackIfExistscxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#plantJumpToBacktrackIfExists(818b5ecfd2e19450).(this);
951 // A failure WITHIN the parens jumps here
952 parenthesesState.linkAlternativeBacktrackscxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#linkAlternativeBacktracks(c2b519253ca5229d).(this);
953 if (term.invertOrCapturecxx . . $ QTJSC/Yarr/PatternTerm#invertOrCapture.) {
954 store32(Imm32(-1), Address(output, (term.parentheses.subpatternId << 1) * sizeof(int)));
955 store32(Imm32(-1), Address(output, ((term.parentheses.subpatternId << 1) + 1) * sizeof(int)));
956 }
957
958 if (term.quantityTypecxx . . $ QTJSC/Yarr/PatternTerm#quantityType. == QuantifierGreedycxx . . $ QTJSC/Yarr/QuantifierGreedy.)
959 storeToFrame(Imm32(0), parenthesesFrameLocation);
960 else
961 state.jumpToBacktrack(jump(), this);
962
963 state.setBacktrackGenerated(backtrackFromAfterParens);
964 if (term.quantityTypecxx . . $ QTJSC/Yarr/PatternTerm#quantityType. == QuantifierNonGreedycxx . . $ QTJSC/Yarr/QuantifierNonGreedy.)
965 nonGreedySkipParentheses.link(this);
966 success.link(this);
967 }
968 }
969
970 void generateParentheticalAssertioncxx . . $ QTJSC/Yarr/RegexGenerator#generateParentheticalAssertion(f680d07b789f7bcb).(TermGenerationStatecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#& state)
971 {
972 PatternTermcxx . . $ QTJSC/Yarr/PatternTerm#& term = state.termcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#term(6889087f3753b497).();
973 PatternDisjunctioncxx . . $ QTJSC/Yarr/PatternDisjunction#* disjunction = term.parenthesescxx . . $ QTJSC/Yarr/PatternTerm#$anonymous_type_0#parentheses..disjunctioncxx . . $ QTJSC/Yarr/PatternTerm#$anonymous_type_0#$anonymous_type_1#disjunction.;
974 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(term.quantityCount == 1);
975 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(term.quantityType == QuantifierFixedCount);
976
977 unsigned parenthesesFrameLocation = term.frameLocationcxx . . $ QTJSC/Yarr/PatternTerm#frameLocation.;
978 unsigned alternativeFrameLocation = parenthesesFrameLocation + RegexStackSpaceForBackTrackInfoParentheticalAssertioncxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/yarr/RegexPattern.h:43:9`!;
979
980 int countCheckedAfterAssertion = state.checkedTotalcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#checkedTotal. - term.inputPositioncxx . . $ QTJSC/Yarr/PatternTerm#inputPosition.;
981
982 if (term.invertOrCapturecxx . . $ QTJSC/Yarr/PatternTerm#invertOrCapture.) {
983 // Inverted case
984 storeToFrame(index, parenthesesFrameLocation);
985
986 state.checkedTotalcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#checkedTotal. -= countCheckedAfterAssertion;
987 if (countCheckedAfterAssertion)
988 sub32(Imm32(countCheckedAfterAssertion), index);
989
990 TermGenerationStatecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState# parenthesesStatecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#TermGenerationState(b0c648ccdd6384da).(disjunction, state.checkedTotalcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#checkedTotal.);
991 generateParenthesesDisjunctioncxx . . $ QTJSC/Yarr/RegexGenerator#generateParenthesesDisjunction(3965959b85f0a527).(state.termcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#term(6889087f3753b497).(), parenthesesState, alternativeFrameLocation);
992 // Success! - which means - Fail!
993 loadFromFrame(parenthesesFrameLocation, index);
994 state.jumpToBacktrack(jump(), this);
995
996 // And fail means success.
997 parenthesesState.linkAlternativeBacktrackscxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#linkAlternativeBacktracks(c2b519253ca5229d).(this);
998 loadFromFrame(parenthesesFrameLocation, index);
999
1000 state.checkedTotalcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#checkedTotal. += countCheckedAfterAssertion;
1001 } else {
1002 // Normal case
1003 storeToFrame(index, parenthesesFrameLocation);
1004
1005 state.checkedTotalcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#checkedTotal. -= countCheckedAfterAssertion;
1006 if (countCheckedAfterAssertion)
1007 sub32(Imm32(countCheckedAfterAssertion), index);
1008
1009 TermGenerationStatecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState# parenthesesStatecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#TermGenerationState(b0c648ccdd6384da).(disjunction, state.checkedTotalcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#checkedTotal.);
1010 generateParenthesesDisjunctioncxx . . $ QTJSC/Yarr/RegexGenerator#generateParenthesesDisjunction(3965959b85f0a527).(state.termcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#term(6889087f3753b497).(), parenthesesState, alternativeFrameLocation);
1011 // Success! - which means - Success!
1012 loadFromFrame(parenthesesFrameLocation, index);
1013 Jump success = jump();
1014
1015 parenthesesState.linkAlternativeBacktrackscxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#linkAlternativeBacktracks(c2b519253ca5229d).(this);
1016 loadFromFrame(parenthesesFrameLocation, index);
1017 state.jumpToBacktrack(jump(), this);
1018
1019 success.link(this);
1020
1021 state.checkedTotalcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#checkedTotal. += countCheckedAfterAssertion;
1022 }
1023 }
1024
1025 void generateTermcxx . . $ QTJSC/Yarr/RegexGenerator#generateTerm(f680d07b789f7bcb).(TermGenerationStatecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#& state)
1026 {
1027 PatternTermcxx . . $ QTJSC/Yarr/PatternTerm#& term = state.termcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#term(6889087f3753b497).();
1028
1029 switch (term.typecxx . . $ QTJSC/Yarr/PatternTerm#type.) {
1030 case PatternTermcxx . . $ QTJSC/Yarr/PatternTerm#::TypeAssertionBOLcxx . . $ QTJSC/Yarr/PatternTerm#TypeAssertionBOL.:
1031 generateAssertionBOLcxx . . $ QTJSC/Yarr/RegexGenerator#generateAssertionBOL(f680d07b789f7bcb).(state);
1032 break;
1033
1034 case PatternTermcxx . . $ QTJSC/Yarr/PatternTerm#::TypeAssertionEOLcxx . . $ QTJSC/Yarr/PatternTerm#TypeAssertionEOL.:
1035 generateAssertionEOLcxx . . $ QTJSC/Yarr/RegexGenerator#generateAssertionEOL(f680d07b789f7bcb).(state);
1036 break;
1037
1038 case PatternTermcxx . . $ QTJSC/Yarr/PatternTerm#::TypeAssertionWordBoundarycxx . . $ QTJSC/Yarr/PatternTerm#TypeAssertionWordBoundary.:
1039 generateAssertionWordBoundarycxx . . $ QTJSC/Yarr/RegexGenerator#generateAssertionWordBoundary(f680d07b789f7bcb).(state);
1040 break;
1041
1042 case PatternTermcxx . . $ QTJSC/Yarr/PatternTerm#::TypePatternCharactercxx . . $ QTJSC/Yarr/PatternTerm#TypePatternCharacter.:
1043 switch (term.quantityTypecxx . . $ QTJSC/Yarr/PatternTerm#quantityType.) {
1044 case QuantifierFixedCountcxx . . $ QTJSC/Yarr/QuantifierFixedCount.:
1045 if (term.quantityCountcxx . . $ QTJSC/Yarr/PatternTerm#quantityCount. == 1) {
1046 if (state.isSinglePatternCharacterLookaheadTermcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#isSinglePatternCharacterLookaheadTerm(c9857a73d68e59ba).() && (state.lookaheadTermcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#lookaheadTerm(6889087f3753b497).().inputPositioncxx . . $ QTJSC/Yarr/PatternTerm#inputPosition. == (term.inputPositioncxx . . $ QTJSC/Yarr/PatternTerm#inputPosition. + 1))) {
1047 generatePatternCharacterPaircxx . . $ QTJSC/Yarr/RegexGenerator#generatePatternCharacterPair(f680d07b789f7bcb).(state);
1048 state.nextTermcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#nextTerm(49f6e7a06ebc5aa8).();
1049 } else
1050 generatePatternCharacterSinglecxx . . $ QTJSC/Yarr/RegexGenerator#generatePatternCharacterSingle(f680d07b789f7bcb).(state);
1051 } else
1052 generatePatternCharacterFixedcxx . . $ QTJSC/Yarr/RegexGenerator#generatePatternCharacterFixed(f680d07b789f7bcb).(state);
1053 break;
1054 case QuantifierGreedycxx . . $ QTJSC/Yarr/QuantifierGreedy.:
1055 generatePatternCharacterGreedycxx . . $ QTJSC/Yarr/RegexGenerator#generatePatternCharacterGreedy(f680d07b789f7bcb).(state);
1056 break;
1057 case QuantifierNonGreedycxx . . $ QTJSC/Yarr/QuantifierNonGreedy.:
1058 generatePatternCharacterNonGreedycxx . . $ QTJSC/Yarr/RegexGenerator#generatePatternCharacterNonGreedy(f680d07b789f7bcb).(state);
1059 break;
1060 }
1061 break;
1062
1063 case PatternTermcxx . . $ QTJSC/Yarr/PatternTerm#::TypeCharacterClasscxx . . $ QTJSC/Yarr/PatternTerm#TypeCharacterClass.:
1064 switch (term.quantityTypecxx . . $ QTJSC/Yarr/PatternTerm#quantityType.) {
1065 case QuantifierFixedCountcxx . . $ QTJSC/Yarr/QuantifierFixedCount.:
1066 if (term.quantityCountcxx . . $ QTJSC/Yarr/PatternTerm#quantityCount. == 1)
1067 generateCharacterClassSinglecxx . . $ QTJSC/Yarr/RegexGenerator#generateCharacterClassSingle(f680d07b789f7bcb).(state);
1068 else
1069 generateCharacterClassFixedcxx . . $ QTJSC/Yarr/RegexGenerator#generateCharacterClassFixed(f680d07b789f7bcb).(state);
1070 break;
1071 case QuantifierGreedycxx . . $ QTJSC/Yarr/QuantifierGreedy.:
1072 generateCharacterClassGreedycxx . . $ QTJSC/Yarr/RegexGenerator#generateCharacterClassGreedy(f680d07b789f7bcb).(state);
1073 break;
1074 case QuantifierNonGreedycxx . . $ QTJSC/Yarr/QuantifierNonGreedy.:
1075 generateCharacterClassNonGreedycxx . . $ QTJSC/Yarr/RegexGenerator#generateCharacterClassNonGreedy(f680d07b789f7bcb).(state);
1076 break;
1077 }
1078 break;
1079
1080 case PatternTermcxx . . $ QTJSC/Yarr/PatternTerm#::TypeBackReferencecxx . . $ QTJSC/Yarr/PatternTerm#TypeBackReference.:
1081 m_generationFailedcxx . . $ QTJSC/Yarr/RegexGenerator#m_generationFailed. = true;
1082 break;
1083
1084 case PatternTermcxx . . $ QTJSC/Yarr/PatternTerm#::TypeForwardReferencecxx . . $ QTJSC/Yarr/PatternTerm#TypeForwardReference.:
1085 break;
1086
1087 case PatternTermcxx . . $ QTJSC/Yarr/PatternTerm#::TypeParenthesesSubpatterncxx . . $ QTJSC/Yarr/PatternTerm#TypeParenthesesSubpattern.:
1088 if ((term.quantityCountcxx . . $ QTJSC/Yarr/PatternTerm#quantityCount. == 1) && !term.parenthesescxx . . $ QTJSC/Yarr/PatternTerm#$anonymous_type_0#parentheses..isCopycxx . . $ QTJSC/Yarr/PatternTerm#$anonymous_type_0#$anonymous_type_1#isCopy.)
1089 generateParenthesesSinglecxx . . $ QTJSC/Yarr/RegexGenerator#generateParenthesesSingle(f680d07b789f7bcb).(state);
1090 else
1091 m_generationFailedcxx . . $ QTJSC/Yarr/RegexGenerator#m_generationFailed. = true;
1092 break;
1093
1094 case PatternTermcxx . . $ QTJSC/Yarr/PatternTerm#::TypeParentheticalAssertioncxx . . $ QTJSC/Yarr/PatternTerm#TypeParentheticalAssertion.:
1095 generateParentheticalAssertioncxx . . $ QTJSC/Yarr/RegexGenerator#generateParentheticalAssertion(f680d07b789f7bcb).(state);
1096 break;
1097 }
1098 }
1099
1100 void generateDisjunctioncxx . . $ QTJSC/Yarr/RegexGenerator#generateDisjunction(55f44b0c7819c50).(PatternDisjunctioncxx . . $ QTJSC/Yarr/PatternDisjunction#* disjunction)
1101 {
1102 TermGenerationStatecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState# statecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#TermGenerationState(b0c648ccdd6384da).(disjunction, 0);
1103 state.resetAlternativecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#resetAlternative(49f6e7a06ebc5aa8).();
1104
1105 // Plant a check to see if there is sufficient input available to run the first alternative.
1106 // Jumping back to the label 'firstAlternative' will get to this check, jumping to
1107 // 'firstAlternativeInputChecked' will jump directly to matching the alternative having
1108 // skipped this check.
1109
1110 Label firstAlternative(this);
1111
1112 // check availability for the next alternative
1113 int countCheckedForCurrentAlternative = 0;
1114 int countToCheckForFirstAlternative = 0;
1115 bool hasShorterAlternatives = false;
1116 JumpList notEnoughInputForPreviousAlternative;
1117
1118 if (state.alternativeValidcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#alternativeValid(c9857a73d68e59ba).()) {
1119 PatternAlternativecxx . . $ QTJSC/Yarr/PatternAlternative#* alternative = state.alternativecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#alternative(b7c439e3c6b41127).();
1120 countToCheckForFirstAlternative = alternative->m_minimumSizecxx . . $ QTJSC/Yarr/PatternAlternative#m_minimumSize.;
1121 state.checkedTotalcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#checkedTotal. += countToCheckForFirstAlternative;
1122 if (countToCheckForFirstAlternative)
1123 notEnoughInputForPreviousAlternative.append(jumpIfNoAvailableInput(countToCheckForFirstAlternative));
1124 countCheckedForCurrentAlternative = countToCheckForFirstAlternative;
1125 }
1126
1127 Label firstAlternativeInputChecked(this);
1128
1129 while (state.alternativeValidcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#alternativeValid(c9857a73d68e59ba).()) {
1130 // Track whether any alternatives are shorter than the first one.
1131 hasShorterAlternatives = hasShorterAlternatives || (countCheckedForCurrentAlternative < countToCheckForFirstAlternative);
1132
1133 PatternAlternativecxx . . $ QTJSC/Yarr/PatternAlternative#* alternative = state.alternativecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#alternative(b7c439e3c6b41127).();
1134 optimizeAlternativecxx . . $ QTJSC/Yarr/RegexGenerator#optimizeAlternative(8a910acb71f34a04).(alternative);
1135
1136 for (state.resetTermcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#resetTerm(49f6e7a06ebc5aa8).(); state.termValidcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#termValid(c9857a73d68e59ba).(); state.nextTermcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#nextTerm(49f6e7a06ebc5aa8).())
1137 generateTermcxx . . $ QTJSC/Yarr/RegexGenerator#generateTerm(f680d07b789f7bcb).(state);
1138
1139 // If we get here, the alternative matched.
1140 if (m_pattern.m_body->m_callFrameSize)
1141 addPtr(Imm32(m_pattern.m_body->m_callFrameSize * sizeof(void*)), stackPointerRegister);
1142
1143 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(index != returnRegister);
1144 if (m_patterncxx . . $ QTJSC/Yarr/RegexGenerator#m_pattern..m_bodycxx . . $ QTJSC/Yarr/RegexPattern#m_body.->m_hasFixedSizecxx . . $ QTJSC/Yarr/PatternDisjunction#m_hasFixedSize.) {
1145 move(index, returnRegister);
1146 if (alternative->m_minimumSize)
1147 sub32(Imm32(alternative->m_minimumSize), returnRegister);
1148 } else
1149 popcxx . . $ QTJSC/MacroAssembler#pop(49f6e7a06ebc5aa8).(returnRegister);
1150 store32(index, Address(output, 4));
1151 store32(returnRegister, output);
1152
1153 generateReturncxx . . $ QTJSC/Yarr/RegexGenerator#generateReturn(49f6e7a06ebc5aa8).();
1154
1155 state.nextAlternativecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#nextAlternative(49f6e7a06ebc5aa8).();
1156
1157 // if there are any more alternatives, plant the check for input before looping.
1158 if (state.alternativeValidcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#alternativeValid(c9857a73d68e59ba).()) {
1159 PatternAlternativecxx . . $ QTJSC/Yarr/PatternAlternative#* nextAlternative = state.alternativecxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#alternative(b7c439e3c6b41127).();
1160 int countToCheckForNextAlternative = nextAlternative->m_minimumSizecxx . . $ QTJSC/Yarr/PatternAlternative#m_minimumSize.;
1161
1162 if (countCheckedForCurrentAlternative > countToCheckForNextAlternative) { // CASE 1: current alternative was longer than the next one.
1163 // If we get here, there the last input checked failed.
1164 notEnoughInputForPreviousAlternative.link(this);
1165
1166 // Check if sufficent input available to run the next alternative
1167 notEnoughInputForPreviousAlternative.append(jumpIfNoAvailableInput(countToCheckForNextAlternative - countCheckedForCurrentAlternative));
1168 // We are now in the correct state to enter the next alternative; this add is only required
1169 // to mirror and revert operation of the sub32, just below.
1170 add32(Imm32(countCheckedForCurrentAlternative - countToCheckForNextAlternative), index);
1171
1172 // If we get here, there the last input checked passed.
1173 state.linkAlternativeBacktrackscxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#linkAlternativeBacktracks(c2b519253ca5229d).(this);
1174 // No need to check if we can run the next alternative, since it is shorter -
1175 // just update index.
1176 sub32(Imm32(countCheckedForCurrentAlternative - countToCheckForNextAlternative), index);
1177 } else if (countCheckedForCurrentAlternative < countToCheckForNextAlternative) { // CASE 2: next alternative is longer than the current one.
1178 // If we get here, there the last input checked failed.
1179 // If there is insufficient input to run the current alternative, and the next alternative is longer,
1180 // then there is definitely not enough input to run it - don't even check. Just adjust index, as if
1181 // we had checked.
1182 notEnoughInputForPreviousAlternative.link(this);
1183 add32(Imm32(countToCheckForNextAlternative - countCheckedForCurrentAlternative), index);
1184 notEnoughInputForPreviousAlternative.append(jump());
1185
1186 // The next alternative is longer than the current one; check the difference.
1187 state.linkAlternativeBacktrackscxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#linkAlternativeBacktracks(c2b519253ca5229d).(this);
1188 notEnoughInputForPreviousAlternative.append(jumpIfNoAvailableInput(countToCheckForNextAlternative - countCheckedForCurrentAlternative));
1189 } else { // CASE 3: Both alternatives are the same length.
1190 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(countCheckedForCurrentAlternative == countToCheckForNextAlternative);
1191
1192 // If the next alterative is the same length as this one, then no need to check the input -
1193 // if there was sufficent input to run the current alternative then there is sufficient
1194 // input to run the next one; if not, there isn't.
1195 state.linkAlternativeBacktrackscxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#linkAlternativeBacktracks(c2b519253ca5229d).(this);
1196 }
1197
1198 state.checkedTotalcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#checkedTotal. -= countCheckedForCurrentAlternative;
1199 countCheckedForCurrentAlternative = countToCheckForNextAlternative;
1200 state.checkedTotalcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#checkedTotal. += countCheckedForCurrentAlternative;
1201 }
1202 }
1203
1204 // If we get here, all Alternatives failed...
1205
1206 state.checkedTotalcxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#checkedTotal. -= countCheckedForCurrentAlternative;
1207
1208 // How much more input need there be to be able to retry from the first alternative?
1209 // examples:
1210 // /yarr_jit/ or /wrec|pcre/
1211 // In these examples we need check for one more input before looping.
1212 // /yarr_jit|pcre/
1213 // In this case we need check for 5 more input to loop (+4 to allow for the first alterative
1214 // being four longer than the last alternative checked, and another +1 to effectively move
1215 // the start position along by one).
1216 // /yarr|rules/ or /wrec|notsomuch/
1217 // In these examples, provided that there was sufficient input to have just been matching for
1218 // the second alternative we can loop without checking for available input (since the second
1219 // alternative is longer than the first). In the latter example we need to decrement index
1220 // (by 4) so the start position is only progressed by 1 from the last iteration.
1221 int incrementForNextIter = (countToCheckForFirstAlternative - countCheckedForCurrentAlternative) + 1;
1222
1223 // First, deal with the cases where there was sufficient input to try the last alternative.
1224 if (incrementForNextIter > 0) // We need to check for more input anyway, fall through to the checking below.
1225 state.linkAlternativeBacktrackscxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#linkAlternativeBacktracks(c2b519253ca5229d).(this);
1226 else if (m_patterncxx . . $ QTJSC/Yarr/RegexGenerator#m_pattern..m_bodycxx . . $ QTJSC/Yarr/RegexPattern#m_body.->m_hasFixedSizecxx . . $ QTJSC/Yarr/PatternDisjunction#m_hasFixedSize. && !incrementForNextIter) // No need to update anything, link these backtracks straight to the to pof the loop!
1227 state.linkAlternativeBacktracksTo(firstAlternativeInputChecked, this);
1228 else { // no need to check the input, but we do have some bookkeeping to do first.
1229 state.linkAlternativeBacktrackscxx . . $ QTJSC/Yarr/RegexGenerator#TermGenerationState#linkAlternativeBacktracks(c2b519253ca5229d).(this);
1230
1231 // Where necessary update our preserved start position.
1232 if (!m_patterncxx . . $ QTJSC/Yarr/RegexGenerator#m_pattern..m_bodycxx . . $ QTJSC/Yarr/RegexPattern#m_body.->m_hasFixedSizecxx . . $ QTJSC/Yarr/PatternDisjunction#m_hasFixedSize.) {
1233 move(index, regT0);
1234 sub32(Imm32(countCheckedForCurrentAlternative - 1), regT0);
1235 poke(regT0, m_pattern.m_body->m_callFrameSize);
1236 }
1237
1238 // Update index if necessary, and loop (without checking).
1239 if (incrementForNextIter)
1240 add32(Imm32(incrementForNextIter), index);
1241 jump().linkTo(firstAlternativeInputChecked, this);
1242 }
1243
1244 notEnoughInputForPreviousAlternative.link(this);
1245 // Update our idea of the start position, if we're tracking this.
1246 if (!m_patterncxx . . $ QTJSC/Yarr/RegexGenerator#m_pattern..m_bodycxx . . $ QTJSC/Yarr/RegexPattern#m_body.->m_hasFixedSizecxx . . $ QTJSC/Yarr/PatternDisjunction#m_hasFixedSize.) {
1247 if (countCheckedForCurrentAlternative - 1) {
1248 move(index, regT0);
1249 sub32(Imm32(countCheckedForCurrentAlternative - 1), regT0);
1250 poke(regT0, m_pattern.m_body->m_callFrameSize);
1251 } else
1252 poke(index, m_pattern.m_body->m_callFrameSize);
1253 }
1254 // Check if there is sufficent input to run the first alternative again.
1255 jumpIfAvailableInput(incrementForNextIter).linkTo(firstAlternativeInputChecked, this);
1256 // No - insufficent input to run the first alteranative, are there any other alternatives we
1257 // might need to check? If so, the last check will have left the index incremented by
1258 // (countToCheckForFirstAlternative + 1), so we need test whether countToCheckForFirstAlternative
1259 // LESS input is available, to have the effect of just progressing the start position by 1
1260 // from the last iteration. If this check passes we can just jump up to the check associated
1261 // with the first alternative in the loop. This is a bit sad, since we'll end up trying the
1262 // first alternative again, and this check will fail (otherwise the check planted just above
1263 // here would have passed). This is a bit sad, however it saves trying to do something more
1264 // complex here in compilation, and in the common case we should end up coallescing the checks.
1265 //
1266 // FIXME: a nice improvement here may be to stop trying to match sooner, based on the least
1267 // of the minimum-alternative-lengths. E.g. if I have two alternatives of length 200 and 150,
1268 // and a string of length 100, we'll end up looping index from 0 to 100, checking whether there
1269 // is sufficient input to run either alternative (constantly failing). If there had been only
1270 // one alternative, or if the shorter alternative had come first, we would have terminated
1271 // immediately. :-/
1272 if (hasShorterAlternatives)
1273 jumpIfAvailableInput(-countToCheckForFirstAlternative).linkTo(firstAlternative, this);
1274 // index will now be a bit garbled (depending on whether 'hasShorterAlternatives' is true,
1275 // it has either been incremented by 1 or by (countToCheckForFirstAlternative + 1) ...
1276 // but since we're about to return a failure this doesn't really matter!)
1277
1278 unsigned frameSize = m_patterncxx . . $ QTJSC/Yarr/RegexGenerator#m_pattern..m_bodycxx . . $ QTJSC/Yarr/RegexPattern#m_body.->m_callFrameSizecxx . . $ QTJSC/Yarr/PatternDisjunction#m_callFrameSize.;
1279 if (!m_patterncxx . . $ QTJSC/Yarr/RegexGenerator#m_pattern..m_bodycxx . . $ QTJSC/Yarr/RegexPattern#m_body.->m_hasFixedSizecxx . . $ QTJSC/Yarr/PatternDisjunction#m_hasFixedSize.)
1280 ++frameSize;
1281 if (frameSize)
1282 addPtr(Imm32(frameSize * sizeof(void*)), stackPointerRegister);
1283
1284 move(Imm32(-1), returnRegister);
1285
1286 generateReturncxx . . $ QTJSC/Yarr/RegexGenerator#generateReturn(49f6e7a06ebc5aa8).();
1287 }
1288
1289 void generateEntercxx . . $ QTJSC/Yarr/RegexGenerator#generateEnter(49f6e7a06ebc5aa8).()
1290 {
1291 #if CPUcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:44:9`!(X86_64)
1292 push(X86Registers::ebp);
1293 move(stackPointerRegister, X86Registers::ebp);
1294 push(X86Registers::ebx);
1295 #elif CPU(X86)
1296 push(X86Registers::ebp);
1297 move(stackPointerRegister, X86Registers::ebp);
1298 // TODO: do we need spill registers to fill the output pointer if there are no sub captures?
1299 push(X86Registers::ebx);
1300 push(X86Registers::edi);
1301 push(X86Registers::esi);
1302 // load output into edi (2 = saved ebp + return address).
1303 #if COMPILER(MSVC)
1304 loadPtr(Address(X86Registers::ebp, 2 * sizeof(void*)), input);
1305 loadPtr(Address(X86Registers::ebp, 3 * sizeof(void*)), index);
1306 loadPtr(Address(X86Registers::ebp, 4 * sizeof(void*)), length);
1307 loadPtr(Address(X86Registers::ebp, 5 * sizeof(void*)), output);
1308 #else
1309 loadPtr(Address(X86Registers::ebp, 2 * sizeof(void*)), output);
1310 #endif
1311 #elif CPU(ARM)
1312 push(ARMRegisters::r4);
1313 push(ARMRegisters::r5);
1314 push(ARMRegisters::r6);
1315 #if CPU(ARM_TRADITIONAL)
1316 push(ARMRegisters::r8); // scratch register
1317 #endif
1318 move(ARMRegisters::r3, output);
1319 #endif
1320 }
1321
1322 void generateReturncxx . . $ QTJSC/Yarr/RegexGenerator#generateReturn(49f6e7a06ebc5aa8).()
1323 {
1324 #if CPUcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:44:9`!(X86_64)
1325 popcxx . . $ QTJSC/MacroAssembler#pop(49f6e7a06ebc5aa8).(X86Registerscxx . . $ QTJSC/X86Registers/::ebxcxx . . $ QTJSC/X86Registers/ebx.);
1326 popcxx . . $ QTJSC/MacroAssembler#pop(49f6e7a06ebc5aa8).(X86Registerscxx . . $ QTJSC/X86Registers/::ebpcxx . . $ QTJSC/X86Registers/ebp.);
1327 #elif CPU(X86)
1328 pop(X86Registers::esi);
1329 pop(X86Registers::edi);
1330 pop(X86Registers::ebx);
1331 pop(X86Registers::ebp);
1332 #elif CPU(ARM)
1333 #if CPU(ARM_TRADITIONAL)
1334 pop(ARMRegisters::r8); // scratch register
1335 #endif
1336 pop(ARMRegisters::r6);
1337 pop(ARMRegisters::r5);
1338 pop(ARMRegisters::r4);
1339 #endif
1340 retcxx . . $ QTJSC/MacroAssemblerX86Common#ret(49f6e7a06ebc5aa8).();
1341 }
1342
1343 public:
1344 RegexGeneratorcxx . . $ QTJSC/Yarr/RegexGenerator#RegexGenerator(42309c613cd95058).(RegexPatterncxx . . $ QTJSC/Yarr/RegexPattern#& pattern)
1345 : m_patterncxx . . $ QTJSC/Yarr/RegexGenerator#m_pattern.(pattern)
1346 , m_generationFailedcxx . . $ QTJSC/Yarr/RegexGenerator#m_generationFailed.(false)
1347 {
1348 }
1349
1350 void generatecxx . . $ QTJSC/Yarr/RegexGenerator#generate(49f6e7a06ebc5aa8).()
1351 {
1352 generateEntercxx . . $ QTJSC/Yarr/RegexGenerator#generateEnter(49f6e7a06ebc5aa8).();
1353
1354 // TODO: do I really want this on the stack?
1355 if (!m_pattern.m_body->m_hasFixedSize)
1356 push(index);
1357
1358 if (m_pattern.m_body->m_callFrameSize)
1359 subPtr(Imm32(m_pattern.m_body->m_callFrameSize * sizeof(void*)), stackPointerRegister);
1360
1361 generateDisjunctioncxx . . $ QTJSC/Yarr/RegexGenerator#generateDisjunction(55f44b0c7819c50).(m_patterncxx . . $ QTJSC/Yarr/RegexGenerator#m_pattern..m_bodycxx . . $ QTJSC/Yarr/RegexPattern#m_body.);
1362 }
1363
1364 void compilecxx . . $ QTJSC/Yarr/RegexGenerator#compile(bb8dce9a83f5c37).(JSGlobalDatacxx . . $ QTJSC/JSGlobalData#* globalData, RegexCodeBlockcxx . . $ QTJSC/Yarr/RegexCodeBlock#& jitObject)
1365 {
1366 generatecxx . . $ QTJSC/Yarr/RegexGenerator#generate(49f6e7a06ebc5aa8).();
1367
1368 LinkBuffercxx . . $ QTJSC/LinkBuffer# patchBuffer(this, globalData->executableAllocator.poolForSize(size()));
1369
1370 for (unsigned i = 0; i < m_backtrackRecords.size(); ++i)
1371 patchBuffer.patchcxx . . $ QTJSC/LinkBuffer#patch(6ca3d68f5c5f0975).(m_backtrackRecords[i].dataLabel, patchBuffer.locationOfcxx . . $ QTJSC/LinkBuffer#locationOf(9c800df4b359ec60).(m_backtrackRecords[i].backtrackLocation));
1372
1373 jitObject.set(patchBuffer.finalizeCodecxx . . $ QTJSC/LinkBuffer#finalizeCode(8e7195db0ad7251e).());
1374 }
1375
1376 bool generationFailedcxx . . $ QTJSC/Yarr/RegexGenerator#generationFailed(c9857a73d68e59ba).()
1377 {
1378 return m_generationFailedcxx . . $ QTJSC/Yarr/RegexGenerator#m_generationFailed.;
1379 }
1380
1381 private:
1382 RegexPatterncxx . . $ QTJSC/Yarr/RegexPattern#& m_patterncxx . . $ QTJSC/Yarr/RegexGenerator#m_pattern.;
1383 Vector<AlternativeBacktrackRecord> m_backtrackRecordscxx . . $ QTJSC/Yarr/RegexGenerator#m_backtrackRecords.;
1384 bool m_generationFailedcxx . . $ QTJSC/Yarr/RegexGenerator#m_generationFailed.;
1385 };
1386
1387 void jitCompileRegexcxx . . $ QTJSC/Yarr/jitCompileRegex(eb7cf78519d4005a).(JSGlobalDatacxx . . $ QTJSC/JSGlobalData#* globalData, RegexCodeBlockcxx . . $ QTJSC/Yarr/RegexCodeBlock#& jitObject, const UStringcxx . . $ QTJSC/UString#& patternString, unsigned& numSubpatterns, const char*& error, bool ignoreCase, bool multiline)
1388 {
1389 RegexPatterncxx . . $ QTJSC/Yarr/RegexPattern# patterncxx . . $ QTJSC/Yarr/RegexPattern#RegexPattern(b0b38cda41d4ede4).(ignoreCase, multiline);
1390
1391 if ((error = compileRegexcxx . . $ QTJSC/Yarr/compileRegex(d85ba63b80712db2).(patternString, pattern)))
1392 return;
1393
1394 numSubpatterns = pattern.m_numSubpatternscxx . . $ QTJSC/Yarr/RegexPattern#m_numSubpatterns.;
1395
1396 RegexGeneratorcxx . . $ QTJSC/Yarr/RegexGenerator# generatorcxx . . $ QTJSC/Yarr/RegexGenerator#RegexGenerator(42309c613cd95058).(pattern);
1397 generator.compilecxx . . $ QTJSC/Yarr/RegexGenerator#compile(bb8dce9a83f5c37).(globalData, jitObject);
1398
1399 if (generator.generationFailedcxx . . $ QTJSC/Yarr/RegexGenerator#generationFailed(c9857a73d68e59ba).()) {
1400 JSRegExpIgnoreCaseOptioncxx . . $ JSRegExpIgnoreCaseOption# ignoreCaseOption = ignoreCase ? JSRegExpIgnoreCasecxx . . $ JSRegExpIgnoreCase. : JSRegExpDoNotIgnoreCasecxx . . $ JSRegExpDoNotIgnoreCase.;
1401 JSRegExpMultilineOptioncxx . . $ JSRegExpMultilineOption# multilineOption = multiline ? JSRegExpMultilinecxx . . $ JSRegExpMultiline. : JSRegExpSingleLinecxx . . $ JSRegExpSingleLine.;
1402 jitObject.setFallbackcxx . . $ QTJSC/Yarr/RegexCodeBlock#setFallback(5352636f5a3848ef).(jsRegExpCompilecxx . . $ jsRegExpCompile(1cd3b9fc8507aa50).(reinterpret_cast<const UCharcxx . . $ UChar#*>(patternString.datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).()), patternString.sizecxx . . $ QTJSC/UString#size(455f465bc33b4cdf).(), ignoreCaseOption, multilineOption, &numSubpatterns, &error));
1403 }
1404 }
1405
1406 }}
1407
1408 #endif
1409
1410
1411
1412
1413