Changeset 41842 in webkit for trunk/JavaScriptCore/wrec


Ignore:
Timestamp:
Mar 19, 2009, 1:32:49 PM (16 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2009-03-19 Geoffrey Garen <[email protected]>

Reviewed by Sam Weinig.


Fixed <rdar://problem/6603562> REGRESSION (Safari 4): regular expression
pattern size limit lower than Safari 3.2, other browsers, breaks SAP (14873)


Bumped the pattern size limit to 1MB, and standardized it between PCRE
and WREC. (Empirical testing says that we can easily compile a 1MB regular
expression without risking a hang. Other browsers support bigger regular
expressions, but also hang.)


SunSpider reports no change.


I started with a patch posted to Bugzilla by Erik Corry ([email protected]).


  • pcre/pcre_internal.h: (put3ByteValue): (get3ByteValue): (put3ByteValueAndAdvance): (putLinkValueAllowZero): (getLinkValueAllowZero): Made PCRE's "LINK_SIZE" (the number of bytes used to record jumps between bytecodes) 3, to accomodate larger potential jumps. Bumped PCRE's "MAX_PATTERN_SIZE" to 1MB. (Technically, at this LINK_SIZE, we can support even larger patterns, but we risk a hang during compilation, and it's not clear that such large patterns are important on the web.)
  • wrec/WREC.cpp: (JSC::WREC::Generator::compileRegExp): Match PCRE's maximum pattern size, to avoid quirks between platforms.

LayoutTests:

2009-03-19 Geoffrey Garen <[email protected]>

Reviewed by Sam Weinig.


Made two layout tests less agressive, to accomodate a change I made
for <rdar://problem/6603562> REGRESSION (Safari 4): regular expression
pattern size limit lower than Safari 3.2, other browsers, breaks SAP (14873)

  • fast/js/regexp-charclass-crash-expected.txt:
  • fast/js/regexp-charclass-crash.html: Explicitly limit the number of iterations in the test loop. Otherwise, regular expression engines supporting very long patterns take a very very very long time to run this test.
  • fast/js/resources/regexp-overflow.js: Made the "too big" regexp in this test even bigger, to match our new limit.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wrec/WREC.cpp

    r41168 r41842  
    4141namespace JSC { namespace WREC {
    4242
    43 // Patterns longer than this can hang the compiler.
    44 static const int MaxPatternSize = (1 << 13);
    45 
    4643CompiledRegExp Generator::compileRegExp(JSGlobalData* globalData, const UString& pattern, unsigned* numSubpatterns_ptr, const char** error_ptr, RefPtr<ExecutablePool>& pool, bool ignoreCase, bool multiline)
    4744{
    48     if (pattern.size() > MaxPatternSize) {
     45    if (pattern.size() > MAX_PATTERN_SIZE) {
    4946        *error_ptr = "regular expression too large";
    5047        return 0;
Note: See TracChangeset for help on using the changeset viewer.