Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 402471
Collapse All | Expand All

(-)a/js/src/Makefile.in (-8 / +13 lines)
Lines 416-430 CPPSRCS += checks.cc \ Link Here
416
416
417
ifeq (,$(filter arm% sparc %86 x86_64,$(TARGET_CPU)))
417
ifeq (,$(filter arm% sparc %86 x86_64,$(TARGET_CPU)))
418
418
419
VPATH +=        $(srcdir)/yarr/pcre \
419
VPATH +=        $(srcdir)/assembler \
420
                $(srcdir)/assembler/wtf \
421
                $(srcdir)/yarr \
420
		$(NULL)
422
		$(NULL)
421
423
422
CPPSRCS += \
424
CPPSRCS += \
423
                pcre_compile.cpp \
425
                Assertions.cpp \
424
                pcre_exec.cpp \
426
                OSAllocatorOS2.cpp \
425
                pcre_tables.cpp \
427
                OSAllocatorPosix.cpp \
426
                pcre_xclass.cpp \
428
                OSAllocatorWin.cpp \
427
                pcre_ucp_searchfuncs.cpp \
429
                PageBlock.cpp \
430
                YarrInterpreter.cpp \
431
                YarrPattern.cpp \
432
                YarrSyntaxChecker.cpp \
428
		$(NULL)
433
		$(NULL)
429
else
434
else
430
435
Lines 1015-1024 endif Link Here
1015
# Needed to "configure" it correctly.  Unfortunately these
1020
# Needed to "configure" it correctly.  Unfortunately these
1016
# flags wind up being applied to all code in js/src, not just
1021
# flags wind up being applied to all code in js/src, not just
1017
# the code in js/src/assembler.
1022
# the code in js/src/assembler.
1018
CXXFLAGS += -DUSE_SYSTEM_MALLOC=1 -DENABLE_ASSEMBLER=1
1023
CXXFLAGS += -DUSE_SYSTEM_MALLOC=1
1019
1024
1020
ifneq (,$(ENABLE_YARR_JIT)$(ENABLE_TRACEJIT)$(ENABLE_METHODJIT))
1025
ifneq (,$(ENABLE_YARR_JIT)$(ENABLE_TRACEJIT)$(ENABLE_METHODJIT))
1021
CXXFLAGS +=  -DENABLE_JIT=1
1026
CXXFLAGS +=  -DENABLE_JIT=1 -DENABLE_ASSEMBLER=1
1022
endif
1027
endif
1023
1028
1024
INCLUDES +=	-I$(srcdir)/assembler -I$(srcdir)/yarr
1029
INCLUDES +=	-I$(srcdir)/assembler -I$(srcdir)/yarr
(-)a/js/src/vm/RegExpObject-inl.h (-22 / +6 lines)
Lines 327-332 RegExpPrivate::create(JSContext *cx, JSString *source, RegExpFlag flags, TokenSt Link Here
327
    return RetType(self);
327
    return RetType(self);
328
}
328
}
329
329
330
#if ENABLE_YARR_JIT
330
/* This function should be deleted once bad Android platforms phase out. See bug 604774. */
331
/* This function should be deleted once bad Android platforms phase out. See bug 604774. */
331
inline bool
332
inline bool
332
RegExpPrivateCode::isJITRuntimeEnabled(JSContext *cx)
333
RegExpPrivateCode::isJITRuntimeEnabled(JSContext *cx)
Lines 337-348 RegExpPrivateCode::isJITRuntimeEnabled(JSContext *cx) Link Here
337
    return true;
338
    return true;
338
#endif
339
#endif
339
}
340
}
341
#endif
340
342
341
inline bool
343
inline bool
342
RegExpPrivateCode::compile(JSContext *cx, JSLinearString &pattern, TokenStream *ts,
344
RegExpPrivateCode::compile(JSContext *cx, JSLinearString &pattern, TokenStream *ts,
343
                           uintN *parenCount, RegExpFlag flags)
345
                           uintN *parenCount, RegExpFlag flags)
344
{
346
{
345
#if ENABLE_YARR_JIT
346
    /* Parse the pattern. */
347
    /* Parse the pattern. */
347
    ErrorCode yarrError;
348
    ErrorCode yarrError;
348
    YarrPattern yarrPattern(pattern, bool(flags & IgnoreCaseFlag), bool(flags & MultilineFlag),
349
    YarrPattern yarrPattern(pattern, bool(flags & IgnoreCaseFlag), bool(flags & MultilineFlag),
Lines 359-365 RegExpPrivateCode::compile(JSContext *cx, JSLinearString &pattern, TokenStream * Link Here
359
     * case we have to bytecode compile it.
360
     * case we have to bytecode compile it.
360
     */
361
     */
361
362
362
#ifdef JS_METHODJIT
363
#if ENABLE_YARR_JIT && defined(JS_METHODJIT)
363
    if (isJITRuntimeEnabled(cx) && !yarrPattern.m_containsBackreferences) {
364
    if (isJITRuntimeEnabled(cx) && !yarrPattern.m_containsBackreferences) {
364
        if (!cx->compartment->ensureJaegerCompartmentExists(cx))
365
        if (!cx->compartment->ensureJaegerCompartmentExists(cx))
365
            return false;
366
            return false;
Lines 371-391 RegExpPrivateCode::compile(JSContext *cx, JSLinearString &pattern, TokenStream * Link Here
371
    }
372
    }
372
#endif
373
#endif
373
374
375
#if ENABLE_YARR_JIT
374
    codeBlock.setFallBack(true);
376
    codeBlock.setFallBack(true);
377
#endif
375
    byteCode = byteCompile(yarrPattern, cx->compartment->regExpAllocator).get();
378
    byteCode = byteCompile(yarrPattern, cx->compartment->regExpAllocator).get();
376
    return true;
379
    return true;
377
#else /* !defined(ENABLE_YARR_JIT) */
378
    int error = 0;
379
    compiled = jsRegExpCompile(pattern.chars(), pattern.length(),
380
                  ignoreCase() ? JSRegExpIgnoreCase : JSRegExpDoNotIgnoreCase,
381
                  multiline() ? JSRegExpMultiline : JSRegExpSingleLine,
382
                  parenCount, &error);
383
    if (error) {
384
        reportPCREError(cx, error);
385
        return false;
386
    }
387
    return true;
388
#endif
389
}
380
}
390
381
391
inline bool
382
inline bool
Lines 431-449 RegExpPrivateCode::execute(JSContext *cx, const jschar *chars, size_t start, siz Link Here
431
    else
422
    else
432
        result = JSC::Yarr::execute(codeBlock, chars, start, length, output);
423
        result = JSC::Yarr::execute(codeBlock, chars, start, length, output);
433
#else
424
#else
434
    result = jsRegExpExecute(cx, compiled, chars, length, start, output, outputCount);
425
    result = JSC::Yarr::interpret(byteCode, chars, start, length, output);
435
#endif
426
#endif
436
427
437
    if (result == -1)
428
    if (result == -1)
438
        return Success_NotFound;
429
        return Success_NotFound;
439
430
440
#if !ENABLE_YARR_JIT
441
    if (result < 0) {
442
        reportPCREError(cx, result);
443
        return Error;
444
    }
445
#endif
446
447
    JS_ASSERT(result >= 0);
431
    JS_ASSERT(result >= 0);
448
    return Success;
432
    return Success;
449
}
433
}
(-)a/js/src/vm/RegExpObject.cpp (-36 lines)
Lines 251-257 Class js::RegExpClass = { Link Here
251
    NULL                     /* trace */
251
    NULL                     /* trace */
252
};
252
};
253
253
254
#if ENABLE_YARR_JIT
255
void
254
void
256
RegExpPrivateCode::reportYarrError(JSContext *cx, TokenStream *ts, ErrorCode error)
255
RegExpPrivateCode::reportYarrError(JSContext *cx, TokenStream *ts, ErrorCode error)
257
{
256
{
Lines 283-323 RegExpPrivateCode::reportYarrError(JSContext *cx, TokenStream *ts, ErrorCode err Link Here
283
    }
282
    }
284
}
283
}
285
284
286
#else /* !ENABLE_YARR_JIT */
287
288
void
289
RegExpPrivateCode::reportPCREError(JSContext *cx, int error)
290
{
291
#define REPORT(msg_) \
292
    JS_ReportErrorFlagsAndNumberUC(cx, JSREPORT_ERROR, js_GetErrorMessage, NULL, msg_); \
293
    return
294
    switch (error) {
295
      case -2: REPORT(JSMSG_REGEXP_TOO_COMPLEX);
296
      case 0: JS_NOT_REACHED("Precondition violation: an error must have occurred."); 
297
      case 1: REPORT(JSMSG_TRAILING_SLASH);
298
      case 2: REPORT(JSMSG_TRAILING_SLASH); 
299
      case 3: REPORT(JSMSG_REGEXP_TOO_COMPLEX);
300
      case 4: REPORT(JSMSG_BAD_QUANTIFIER);
301
      case 5: REPORT(JSMSG_BAD_QUANTIFIER);
302
      case 6: REPORT(JSMSG_BAD_CLASS_RANGE);
303
      case 7: REPORT(JSMSG_REGEXP_TOO_COMPLEX);
304
      case 8: REPORT(JSMSG_BAD_CLASS_RANGE);
305
      case 9: REPORT(JSMSG_BAD_QUANTIFIER);
306
      case 10: REPORT(JSMSG_UNMATCHED_RIGHT_PAREN);
307
      case 11: REPORT(JSMSG_REGEXP_TOO_COMPLEX);
308
      case 12: REPORT(JSMSG_UNMATCHED_RIGHT_PAREN);
309
      case 13: REPORT(JSMSG_REGEXP_TOO_COMPLEX);
310
      case 14: REPORT(JSMSG_MISSING_PAREN);
311
      case 15: REPORT(JSMSG_BAD_BACKREF);
312
      case 16: REPORT(JSMSG_REGEXP_TOO_COMPLEX);
313
      case 17: REPORT(JSMSG_REGEXP_TOO_COMPLEX);
314
      default:
315
        JS_NOT_REACHED("Precondition violation: unknown PCRE error code.");
316
    }
317
#undef REPORT
318
}
319
#endif /* ENABLE_YARR_JIT */
320
321
bool
285
bool
322
js::ParseRegExpFlags(JSContext *cx, JSString *flagStr, RegExpFlag *flagsOut)
286
js::ParseRegExpFlags(JSContext *cx, JSString *flagStr, RegExpFlag *flagsOut)
323
{
287
{
(-)a/js/src/vm/RegExpObject.h (-21 / +6 lines)
Lines 49-56 Link Here
49
#include "yarr/Yarr.h"
49
#include "yarr/Yarr.h"
50
#if ENABLE_YARR_JIT
50
#if ENABLE_YARR_JIT
51
#include "yarr/YarrJIT.h"
51
#include "yarr/YarrJIT.h"
52
#else
53
#include "yarr/pcre/pcre.h"
54
#endif
52
#endif
55
53
56
namespace js {
54
namespace js {
Lines 153-200 ResetRegExpObject(JSContext *cx, AlreadyIncRefed<RegExpPrivate> rep); Link Here
153
/* Abstracts away the gross |RegExpPrivate| backend details. */
151
/* Abstracts away the gross |RegExpPrivate| backend details. */
154
class RegExpPrivateCode
152
class RegExpPrivateCode
155
{
153
{
156
#if ENABLE_YARR_JIT
157
    typedef JSC::Yarr::BytecodePattern BytecodePattern;
154
    typedef JSC::Yarr::BytecodePattern BytecodePattern;
158
    typedef JSC::Yarr::ErrorCode ErrorCode;
155
    typedef JSC::Yarr::ErrorCode ErrorCode;
156
    typedef JSC::Yarr::YarrPattern YarrPattern;
157
#if ENABLE_YARR_JIT
159
    typedef JSC::Yarr::JSGlobalData JSGlobalData;
158
    typedef JSC::Yarr::JSGlobalData JSGlobalData;
160
    typedef JSC::Yarr::YarrCodeBlock YarrCodeBlock;
159
    typedef JSC::Yarr::YarrCodeBlock YarrCodeBlock;
161
    typedef JSC::Yarr::YarrPattern YarrPattern;
162
160
163
    /* Note: Native code is valid only if |codeBlock.isFallBack() == false|. */
161
    /* Note: Native code is valid only if |codeBlock.isFallBack() == false|. */
164
    YarrCodeBlock   codeBlock;
162
    YarrCodeBlock   codeBlock;
165
    BytecodePattern *byteCode;
166
#else
167
    JSRegExp        *compiled;
168
#endif
163
#endif
164
    BytecodePattern *byteCode;
169
165
170
  public:
166
  public:
171
    RegExpPrivateCode()
167
    RegExpPrivateCode()
172
      :
168
      :
173
#if ENABLE_YARR_JIT
169
#if ENABLE_YARR_JIT
174
        codeBlock(),
170
        codeBlock(),
175
        byteCode(NULL)
176
#else
177
        compiled(NULL)
178
#endif
171
#endif
172
        byteCode(NULL)
179
    { }
173
    { }
180
174
181
    ~RegExpPrivateCode() {
175
    ~RegExpPrivateCode() {
182
#if ENABLE_YARR_JIT
176
#if ENABLE_YARR_JIT
183
        codeBlock.release();
177
        codeBlock.release();
178
#endif
184
        if (byteCode)
179
        if (byteCode)
185
            Foreground::delete_<BytecodePattern>(byteCode);
180
            Foreground::delete_<BytecodePattern>(byteCode);
186
#else
187
        if (compiled)
188
            jsRegExpFree(compiled);
189
#endif
190
    }
181
    }
191
182
192
#if ENABLE_YARR_JIT
183
#if ENABLE_YARR_JIT
193
    static inline bool isJITRuntimeEnabled(JSContext *cx);
184
    static inline bool isJITRuntimeEnabled(JSContext *cx);
194
    void reportYarrError(JSContext *cx, TokenStream *ts, JSC::Yarr::ErrorCode error);
195
#else
196
    void reportPCREError(JSContext *cx, int error);
197
#endif
185
#endif
186
    void reportYarrError(JSContext *cx, TokenStream *ts, JSC::Yarr::ErrorCode error);
198
187
199
    inline bool compile(JSContext *cx, JSLinearString &pattern, TokenStream *ts, uintN *parenCount,
188
    inline bool compile(JSContext *cx, JSLinearString &pattern, TokenStream *ts, uintN *parenCount,
200
                        RegExpFlag flags);
189
                        RegExpFlag flags);
Lines 205-215 class RegExpPrivateCode Link Here
205
                                 int *output, size_t outputCount);
194
                                 int *output, size_t outputCount);
206
195
207
    static size_t getOutputSize(size_t pairCount) {
196
    static size_t getOutputSize(size_t pairCount) {
208
#if ENABLE_YARR_JIT
209
        return pairCount * 2;
197
        return pairCount * 2;
210
#else
211
        return pairCount * 3; /* Should be x2, but PCRE has... needs. */
212
#endif
213
    }
198
    }
214
};
199
};
215
200
(-)a/js/src/yarr/wtfbridge.h (-2 lines)
Lines 49-57 Link Here
49
#include "jsprvtd.h"
49
#include "jsprvtd.h"
50
#include "vm/String.h"
50
#include "vm/String.h"
51
#include "assembler/wtf/Platform.h"
51
#include "assembler/wtf/Platform.h"
52
#if ENABLE_YARR_JIT
53
#include "assembler/jit/ExecutableAllocator.h"
52
#include "assembler/jit/ExecutableAllocator.h"
54
#endif
55
53
56
namespace JSC { namespace Yarr {
54
namespace JSC { namespace Yarr {
57
55

Return to bug 402471