author | Wolfgang Rosenauer <wr@rosenauer.org> |
Mon, 25 Jun 2012 22:09:15 +0200 | |
branch | firefox14 |
changeset 490 | be017dcbd7af |
parent 475 | b0df28e752fd |
permissions | -rw-r--r-- |
391 | 1 |
# HG changeset patch |
475
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
2 |
# Parent 831eeca7b7cfa9ae2458d9efafe168027259965f |
391 | 3 |
# User Landry Breuil <landry@openbsd.org> |
475
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
4 |
Bug 691898 - Use YARR regexp interpreter instead of PCRE on platforms where YARR JIT is not supported r=dmandelin |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
5 |
PCRE doesn't build anyway. |
378 | 6 |
|
7 |
diff --git a/js/src/Makefile.in b/js/src/Makefile.in |
|
8 |
--- a/js/src/Makefile.in |
|
9 |
+++ b/js/src/Makefile.in |
|
475
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
10 |
@@ -315,30 +315,33 @@ ifeq (mips, $(findstring mips,$(TARGET_C |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
11 |
CPPSRCS += TrampolineMIPS.cpp |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
12 |
endif |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
13 |
# |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
14 |
# END enclude sources for the method JIT |
386 | 15 |
############################################# |
16 |
||
475
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
17 |
endif |
378 | 18 |
|
475
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
19 |
-# For architectures without YARR JIT, PCRE is faster than the YARR |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
20 |
-# interpreter (bug 684559). |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
21 |
- |
401 | 22 |
ifeq (,$(filter arm% sparc %86 x86_64 mips%,$(TARGET_CPU))) |
378 | 23 |
|
24 |
-VPATH += $(srcdir)/yarr/pcre \ |
|
475
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
25 |
+VPATH += $(srcdir)/assembler \ |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
26 |
+ $(srcdir)/assembler/wtf \ |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
27 |
+ $(srcdir)/assembler/jit \ |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
28 |
+ $(srcdir)/yarr \ |
378 | 29 |
$(NULL) |
30 |
||
475
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
31 |
-CPPSRCS += \ |
378 | 32 |
- pcre_compile.cpp \ |
33 |
- pcre_exec.cpp \ |
|
34 |
- pcre_tables.cpp \ |
|
35 |
- pcre_xclass.cpp \ |
|
36 |
- pcre_ucp_searchfuncs.cpp \ |
|
475
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
37 |
+CPPSRCS += ExecutableAllocator.cpp \ |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
38 |
+ ExecutableAllocatorPosix.cpp \ |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
39 |
+ OSAllocatorOS2.cpp \ |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
40 |
+ OSAllocatorPosix.cpp \ |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
41 |
+ OSAllocatorWin.cpp \ |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
42 |
+ PageBlock.cpp \ |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
43 |
+ YarrInterpreter.cpp \ |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
44 |
+ YarrPattern.cpp \ |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
45 |
+ YarrSyntaxChecker.cpp \ |
378 | 46 |
$(NULL) |
47 |
else |
|
48 |
||
386 | 49 |
############################################### |
50 |
# BEGIN include sources for the Nitro assembler |
|
51 |
# |
|
52 |
||
53 |
ENABLE_YARR_JIT = 1 |
|
475
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
54 |
diff --git a/js/src/assembler/jit/ExecutableAllocator.h b/js/src/assembler/jit/ExecutableAllocator.h |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
55 |
--- a/js/src/assembler/jit/ExecutableAllocator.h |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
56 |
+++ b/js/src/assembler/jit/ExecutableAllocator.h |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
57 |
@@ -462,18 +462,16 @@ public: |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
58 |
: "r" (code), "r" (reinterpret_cast<char*>(code) + size) |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
59 |
: "r0", "r1", "r2"); |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
60 |
} |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
61 |
#elif WTF_CPU_SPARC |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
62 |
static void cacheFlush(void* code, size_t size) |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
63 |
{ |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
64 |
sync_instruction_memory((caddr_t)code, size); |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
65 |
} |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
66 |
-#else |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
67 |
- #error "The cacheFlush support is missing on this platform." |
401 | 68 |
#endif |
69 |
||
475
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
70 |
private: |
401 | 71 |
|
475
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
72 |
#if ENABLE_ASSEMBLER_WX_EXCLUSIVE |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
73 |
static void reprotectRegion(void*, size_t, ProtectionSetting); |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
74 |
#endif |
401 | 75 |
|
76 |
diff --git a/js/src/vm/RegExpObject-inl.h b/js/src/vm/RegExpObject-inl.h |
|
77 |
--- a/js/src/vm/RegExpObject-inl.h |
|
78 |
+++ b/js/src/vm/RegExpObject-inl.h |
|
79 |
@@ -132,26 +132,28 @@ RegExpObject::setMultiline(bool enabled) |
|
80 |
} |
|
81 |
||
82 |
inline void |
|
83 |
RegExpObject::setSticky(bool enabled) |
|
84 |
{ |
|
85 |
setSlot(STICKY_FLAG_SLOT, BooleanValue(enabled)); |
|
86 |
} |
|
87 |
||
88 |
+#if ENABLE_YARR_JIT |
|
89 |
/* This function should be deleted once bad Android platforms phase out. See bug 604774. */ |
|
90 |
inline bool |
|
91 |
detail::RegExpCode::isJITRuntimeEnabled(JSContext *cx) |
|
92 |
{ |
|
93 |
#if defined(ANDROID) && defined(JS_METHODJIT) |
|
94 |
return cx->methodJitEnabled; |
|
95 |
#else |
|
96 |
return true; |
|
97 |
#endif |
|
98 |
} |
|
99 |
+#endif |
|
100 |
||
101 |
inline bool |
|
102 |
RegExpToShared(JSContext *cx, JSObject &obj, RegExpGuard *g) |
|
103 |
{ |
|
104 |
JS_ASSERT(ObjectClassIs(obj, ESClass_RegExp, cx)); |
|
105 |
if (obj.isRegExp()) |
|
106 |
return obj.asRegExp().getShared(cx, g); |
|
107 |
return Proxy::regexp_toShared(cx, &obj, g); |
|
108 |
diff --git a/js/src/vm/RegExpObject.cpp b/js/src/vm/RegExpObject.cpp |
|
109 |
--- a/js/src/vm/RegExpObject.cpp |
|
110 |
+++ b/js/src/vm/RegExpObject.cpp |
|
475
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
111 |
@@ -163,17 +163,16 @@ MatchPairs::checkAgainst(size_t inputLen |
401 | 112 |
continue; |
113 |
JS_ASSERT(size_t(p.limit) <= inputLength); |
|
114 |
} |
|
115 |
#endif |
|
116 |
} |
|
117 |
||
118 |
/* detail::RegExpCode */ |
|
119 |
||
120 |
-#if ENABLE_YARR_JIT |
|
121 |
void |
|
122 |
RegExpCode::reportYarrError(JSContext *cx, TokenStream *ts, ErrorCode error) |
|
123 |
{ |
|
124 |
switch (error) { |
|
125 |
case JSC::Yarr::NoError: |
|
126 |
JS_NOT_REACHED("Called reportYarrError with value for no error"); |
|
127 |
return; |
|
128 |
#define COMPILE_EMSG(__code, __msg) \ |
|
475
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
129 |
@@ -195,73 +194,36 @@ RegExpCode::reportYarrError(JSContext *c |
401 | 130 |
COMPILE_EMSG(QuantifierTooLarge, JSMSG_BAD_QUANTIFIER); |
131 |
COMPILE_EMSG(EscapeUnterminated, JSMSG_TRAILING_SLASH); |
|
132 |
#undef COMPILE_EMSG |
|
133 |
default: |
|
134 |
JS_NOT_REACHED("Unknown Yarr error code"); |
|
135 |
} |
|
136 |
} |
|
137 |
||
138 |
-#else /* !ENABLE_YARR_JIT */ |
|
139 |
- |
|
140 |
-void |
|
141 |
-RegExpCode::reportPCREError(JSContext *cx, int error) |
|
142 |
-{ |
|
143 |
-#define REPORT(msg_) \ |
|
144 |
- JS_ReportErrorFlagsAndNumberUC(cx, JSREPORT_ERROR, js_GetErrorMessage, NULL, msg_); \ |
|
145 |
- return |
|
146 |
- switch (error) { |
|
147 |
- case -2: REPORT(JSMSG_REGEXP_TOO_COMPLEX); |
|
148 |
- case 0: JS_NOT_REACHED("Precondition violation: an error must have occurred."); |
|
149 |
- case 1: REPORT(JSMSG_TRAILING_SLASH); |
|
150 |
- case 2: REPORT(JSMSG_TRAILING_SLASH); |
|
151 |
- case 3: REPORT(JSMSG_REGEXP_TOO_COMPLEX); |
|
152 |
- case 4: REPORT(JSMSG_BAD_QUANTIFIER); |
|
153 |
- case 5: REPORT(JSMSG_BAD_QUANTIFIER); |
|
154 |
- case 6: REPORT(JSMSG_BAD_CLASS_RANGE); |
|
155 |
- case 7: REPORT(JSMSG_REGEXP_TOO_COMPLEX); |
|
156 |
- case 8: REPORT(JSMSG_BAD_CLASS_RANGE); |
|
157 |
- case 9: REPORT(JSMSG_BAD_QUANTIFIER); |
|
158 |
- case 10: REPORT(JSMSG_UNMATCHED_RIGHT_PAREN); |
|
159 |
- case 11: REPORT(JSMSG_REGEXP_TOO_COMPLEX); |
|
160 |
- case 12: REPORT(JSMSG_UNMATCHED_RIGHT_PAREN); |
|
161 |
- case 13: REPORT(JSMSG_REGEXP_TOO_COMPLEX); |
|
162 |
- case 14: REPORT(JSMSG_MISSING_PAREN); |
|
163 |
- case 15: REPORT(JSMSG_BAD_BACKREF); |
|
164 |
- case 16: REPORT(JSMSG_REGEXP_TOO_COMPLEX); |
|
165 |
- case 17: REPORT(JSMSG_REGEXP_TOO_COMPLEX); |
|
166 |
- default: |
|
167 |
- JS_NOT_REACHED("Precondition violation: unknown PCRE error code."); |
|
168 |
- } |
|
169 |
-#undef REPORT |
|
170 |
-} |
|
171 |
- |
|
172 |
-#endif /* ENABLE_YARR_JIT */ |
|
173 |
- |
|
174 |
bool |
|
475
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
175 |
RegExpCode::compile(JSContext *cx, JSLinearString &pattern, unsigned *parenCount, RegExpFlag flags) |
401 | 176 |
{ |
177 |
-#if ENABLE_YARR_JIT |
|
178 |
/* Parse the pattern. */ |
|
179 |
ErrorCode yarrError; |
|
180 |
YarrPattern yarrPattern(pattern, bool(flags & IgnoreCaseFlag), bool(flags & MultilineFlag), |
|
181 |
&yarrError); |
|
182 |
if (yarrError) { |
|
183 |
reportYarrError(cx, NULL, yarrError); |
|
184 |
return false; |
|
185 |
} |
|
186 |
*parenCount = yarrPattern.m_numSubpatterns; |
|
187 |
||
188 |
/* |
|
189 |
* The YARR JIT compiler attempts to compile the parsed pattern. If |
|
190 |
* it cannot, it informs us via |codeBlock.isFallBack()|, in which |
|
191 |
* case we have to bytecode compile it. |
|
192 |
*/ |
|
193 |
||
194 |
-#ifdef JS_METHODJIT |
|
195 |
+#if ENABLE_YARR_JIT && defined(JS_METHODJIT) |
|
196 |
if (isJITRuntimeEnabled(cx) && !yarrPattern.m_containsBackreferences) { |
|
197 |
JSC::ExecutableAllocator *execAlloc = cx->runtime->getExecutableAllocator(cx); |
|
198 |
if (!execAlloc) { |
|
199 |
js_ReportOutOfMemory(cx); |
|
200 |
return false; |
|
201 |
} |
|
202 |
||
203 |
JSGlobalData globalData(execAlloc); |
|
475
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
204 |
@@ -272,58 +234,41 @@ RegExpCode::compile(JSContext *cx, JSLin |
401 | 205 |
#endif |
206 |
||
207 |
WTF::BumpPointerAllocator *bumpAlloc = cx->runtime->getBumpPointerAllocator(cx); |
|
208 |
if (!bumpAlloc) { |
|
209 |
js_ReportOutOfMemory(cx); |
|
210 |
return false; |
|
211 |
} |
|
212 |
||
213 |
+#if ENABLE_YARR_JIT |
|
214 |
codeBlock.setFallBack(true); |
|
215 |
+#endif |
|
216 |
byteCode = byteCompile(yarrPattern, bumpAlloc).get(); |
|
217 |
return true; |
|
218 |
-#else /* !defined(ENABLE_YARR_JIT) */ |
|
219 |
- int error = 0; |
|
220 |
- compiled = jsRegExpCompile(pattern.chars(), pattern.length(), |
|
221 |
- ignoreCase() ? JSRegExpIgnoreCase : JSRegExpDoNotIgnoreCase, |
|
222 |
- multiline() ? JSRegExpMultiline : JSRegExpSingleLine, |
|
223 |
- parenCount, &error); |
|
224 |
- if (error) { |
|
225 |
- reportPCREError(cx, error); |
|
226 |
- return false; |
|
227 |
- } |
|
228 |
- return true; |
|
229 |
-#endif |
|
230 |
} |
|
231 |
||
232 |
RegExpRunStatus |
|
233 |
RegExpCode::execute(JSContext *cx, const jschar *chars, size_t length, size_t start, |
|
234 |
int *output, size_t outputCount) |
|
235 |
{ |
|
236 |
int result; |
|
237 |
#if ENABLE_YARR_JIT |
|
238 |
(void) cx; /* Unused. */ |
|
239 |
if (codeBlock.isFallBack()) |
|
240 |
result = JSC::Yarr::interpret(byteCode, chars, start, length, output); |
|
241 |
else |
|
242 |
result = JSC::Yarr::execute(codeBlock, chars, start, length, output); |
|
243 |
#else |
|
244 |
- result = jsRegExpExecute(cx, compiled, chars, length, start, output, outputCount); |
|
245 |
+ result = JSC::Yarr::interpret(byteCode, chars, start, length, output); |
|
246 |
#endif |
|
247 |
||
248 |
if (result == -1) |
|
249 |
return RegExpRunStatus_Success_NotFound; |
|
250 |
||
251 |
-#if !ENABLE_YARR_JIT |
|
252 |
- if (result < 0) { |
|
253 |
- reportPCREError(cx, result); |
|
254 |
- return RegExpRunStatus_Error; |
|
255 |
- } |
|
256 |
-#endif |
|
257 |
- |
|
258 |
JS_ASSERT(result >= 0); |
|
259 |
return RegExpRunStatus_Success; |
|
260 |
} |
|
261 |
||
262 |
/* RegExpObject */ |
|
263 |
||
264 |
static void |
|
265 |
regexp_trace(JSTracer *trc, JSObject *obj) |
|
266 |
diff --git a/js/src/vm/RegExpObject.h b/js/src/vm/RegExpObject.h |
|
267 |
--- a/js/src/vm/RegExpObject.h |
|
268 |
+++ b/js/src/vm/RegExpObject.h |
|
475
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
269 |
@@ -47,20 +47,18 @@ |
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
270 |
#include "jscntxt.h" |
401 | 271 |
#include "jsobj.h" |
272 |
||
273 |
#include "js/TemplateLib.h" |
|
274 |
||
275 |
#include "yarr/Yarr.h" |
|
276 |
#if ENABLE_YARR_JIT |
|
277 |
#include "yarr/YarrJIT.h" |
|
278 |
+#endif |
|
279 |
#include "yarr/YarrSyntaxChecker.h" |
|
280 |
-#else |
|
281 |
-#include "yarr/pcre/pcre.h" |
|
282 |
-#endif |
|
283 |
||
284 |
/* |
|
285 |
* JavaScript Regular Expressions |
|
286 |
* |
|
287 |
* There are several engine concepts associated with a single logical regexp: |
|
288 |
* |
|
289 |
* RegExpObject - The JS-visible object whose .[[Class]] equals "RegExp" |
|
290 |
* |
|
475
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
291 |
@@ -108,78 +106,61 @@ class RegExpObjectBuilder |
401 | 292 |
|
293 |
JSObject * |
|
294 |
CloneRegExpObject(JSContext *cx, JSObject *obj, JSObject *proto); |
|
295 |
||
296 |
namespace detail { |
|
297 |
||
298 |
class RegExpCode |
|
299 |
{ |
|
300 |
-#if ENABLE_YARR_JIT |
|
301 |
typedef JSC::Yarr::BytecodePattern BytecodePattern; |
|
302 |
typedef JSC::Yarr::ErrorCode ErrorCode; |
|
303 |
+ typedef JSC::Yarr::YarrPattern YarrPattern; |
|
304 |
+#if ENABLE_YARR_JIT |
|
305 |
typedef JSC::Yarr::JSGlobalData JSGlobalData; |
|
306 |
typedef JSC::Yarr::YarrCodeBlock YarrCodeBlock; |
|
307 |
- typedef JSC::Yarr::YarrPattern YarrPattern; |
|
308 |
||
309 |
/* Note: Native code is valid only if |codeBlock.isFallBack() == false|. */ |
|
310 |
YarrCodeBlock codeBlock; |
|
311 |
+#endif |
|
312 |
BytecodePattern *byteCode; |
|
313 |
-#else |
|
314 |
- JSRegExp *compiled; |
|
315 |
-#endif |
|
316 |
||
317 |
public: |
|
318 |
RegExpCode() |
|
319 |
: |
|
320 |
#if ENABLE_YARR_JIT |
|
321 |
codeBlock(), |
|
322 |
+#endif |
|
323 |
byteCode(NULL) |
|
324 |
-#else |
|
325 |
- compiled(NULL) |
|
326 |
-#endif |
|
327 |
{ } |
|
328 |
||
329 |
~RegExpCode() { |
|
330 |
#if ENABLE_YARR_JIT |
|
331 |
codeBlock.release(); |
|
332 |
+#endif |
|
333 |
if (byteCode) |
|
334 |
Foreground::delete_<BytecodePattern>(byteCode); |
|
335 |
-#else |
|
336 |
- if (compiled) |
|
337 |
- jsRegExpFree(compiled); |
|
338 |
-#endif |
|
339 |
} |
|
340 |
||
341 |
static bool checkSyntax(JSContext *cx, TokenStream *tokenStream, JSLinearString *source) { |
|
342 |
-#if ENABLE_YARR_JIT |
|
343 |
ErrorCode error = JSC::Yarr::checkSyntax(*source); |
|
344 |
if (error == JSC::Yarr::NoError) |
|
345 |
return true; |
|
346 |
||
347 |
reportYarrError(cx, tokenStream, error); |
|
348 |
return false; |
|
349 |
-#else |
|
350 |
-# error "Syntax checking not implemented for !ENABLE_YARR_JIT" |
|
351 |
-#endif |
|
352 |
} |
|
353 |
||
354 |
#if ENABLE_YARR_JIT |
|
355 |
static inline bool isJITRuntimeEnabled(JSContext *cx); |
|
356 |
+#endif |
|
357 |
static void reportYarrError(JSContext *cx, TokenStream *ts, JSC::Yarr::ErrorCode error); |
|
358 |
-#else |
|
359 |
- static void reportPCREError(JSContext *cx, int error); |
|
360 |
-#endif |
|
361 |
||
362 |
static size_t getOutputSize(size_t pairCount) { |
|
363 |
-#if ENABLE_YARR_JIT |
|
364 |
return pairCount * 2; |
|
365 |
-#else |
|
366 |
- return pairCount * 3; /* Should be x2, but PCRE has... needs. */ |
|
367 |
-#endif |
|
368 |
} |
|
369 |
||
475
b0df28e752fd
reenabled mozilla-yarr-pcre.patch
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
401
diff
changeset
|
370 |
bool compile(JSContext *cx, JSLinearString &pattern, unsigned *parenCount, RegExpFlag flags); |
401 | 371 |
|
372 |
||
373 |
RegExpRunStatus |
|
374 |
execute(JSContext *cx, const jschar *chars, size_t length, size_t start, |
|
375 |
int *output, size_t outputCount); |
|
378 | 376 |
diff --git a/js/src/yarr/wtfbridge.h b/js/src/yarr/wtfbridge.h |
377 |
--- a/js/src/yarr/wtfbridge.h |
|
378 |
+++ b/js/src/yarr/wtfbridge.h |
|
386 | 379 |
@@ -44,19 +44,17 @@ |
380 |
* WTF compatibility layer. This file provides various type and data |
|
381 |
* definitions for use by Yarr. |
|
382 |
*/ |
|
383 |
||
384 |
#include "jsstr.h" |
|
378 | 385 |
#include "jsprvtd.h" |
386 |
#include "vm/String.h" |
|
387 |
#include "assembler/wtf/Platform.h" |
|
388 |
-#if ENABLE_YARR_JIT |
|
389 |
#include "assembler/jit/ExecutableAllocator.h" |
|
390 |
-#endif |
|
391 |
||
392 |
namespace JSC { namespace Yarr { |
|
393 |
||
386 | 394 |
/* |
395 |
* Basic type definitions. |
|
396 |
*/ |
|
397 |
||
398 |
typedef jschar UChar; |