Ignore:
Timestamp:
Sep 7, 2010, 5:33:15 PM (15 years ago)
Author:
[email protected]
Message:

2010-09-07 Mihai Parparita <[email protected]>

Reviewed by Oliver Hunt.

pushState and replaceState do not clone RegExp objects correctly
https://bugs.webkit.org/show_bug.cgi?id=44718

Move internal representation of JSC::RegExp (which depends on wether
YARR and YARR_JIT is enabled) into RegExpRepresentation which can live
in the implementation only. This makes it feasible to use RegExp in
WebCore without bringing in all of YARR.

  • JavaScriptCore.exp: Export RegExp and RegExpObject functions that are needed inside WebCore's JSC bindings.
  • runtime/RegExp.cpp: (JSC::RegExpRepresentation::~RegExpRepresentation): (JSC::RegExp::RegExp): (JSC::RegExp::~RegExp): (JSC::RegExp::compile): (JSC::RegExp::match):
  • runtime/RegExp.h:

2010-09-07 Mihai Parparita <[email protected]>

Reviewed by Oliver Hunt.

pushState and replaceState do not clone RegExp objects correctly
https://bugs.webkit.org/show_bug.cgi?id=44718

Make RegExp test of pushstate-object-types.html actually test a RegExp
value with flags.

Also adds ImageData since it can be serialized as of r54646.

  • fast/loader/stateobjects/pushstate-object-types-expected.txt:
  • fast/loader/stateobjects/pushstate-object-types.html:

2010-09-07 Mihai Parparita <[email protected]>

Reviewed by Oliver Hunt.

pushState and replaceState do not clone RegExp objects correctly
https://bugs.webkit.org/show_bug.cgi?id=44718

Add RegExp support to the JSC implementation of SerializedScriptValue
(it stores the pattern and flags read from a RegExpObject, and creates
a new one on deserialization).

Tests: fast/loader/stateobjects/pushstate-object-types.html

  • ForwardingHeaders/runtime/RegExp.h: Added.
  • ForwardingHeaders/runtime/RegExpObject.h: Added.
  • bindings/js/SerializedScriptValue.cpp: (WebCore::CloneSerializer::dumpIfTerminal): (WebCore::CloneDeserializer::readTerminal):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/RegExp.cpp

    r66031 r66936  
    4747namespace JSC {
    4848
     49struct RegExpRepresentation {
     50#if ENABLE(YARR_JIT)
     51    Yarr::RegexCodeBlock m_regExpJITCode;
     52#elif ENABLE(YARR)
     53    OwnPtr<Yarr::BytecodePattern> m_regExpBytecode;
     54#else
     55    JSRegExp* m_regExp;
     56#endif
     57
     58#if !ENABLE(YARR)
     59    ~RegExpRepresentation()
     60    {
     61        jsRegExpFree(m_regExp);
     62    }
     63#endif
     64};
     65
    4966inline RegExp::RegExp(JSGlobalData* globalData, const UString& pattern, const UString& flags)
    5067    : m_pattern(pattern)
     
    5269    , m_constructionError(0)
    5370    , m_numSubpatterns(0)
     71    , m_representation(adoptPtr(new RegExpRepresentation))
    5472{
    5573    // NOTE: The global flag is handled on a case-by-case basis by functions like
     
    6684}
    6785
    68 #if !ENABLE(YARR)
    6986RegExp::~RegExp()
    7087{
    71     jsRegExpFree(m_regExp);
    72 }
    73 #endif
     88}
    7489
    7590PassRefPtr<RegExp> RegExp::create(JSGlobalData* globalData, const UString& pattern, const UString& flags)
     
    8398{
    8499#if ENABLE(YARR_JIT)
    85     Yarr::jitCompileRegex(globalData, m_regExpJITCode, m_pattern, m_numSubpatterns, m_constructionError, ignoreCase(), multiline());
    86 #else
    87     m_regExpBytecode = Yarr::byteCompileRegex(m_pattern, m_numSubpatterns, m_constructionError, &globalData->m_regexAllocator, ignoreCase(), multiline());
     100    Yarr::jitCompileRegex(globalData, m_representation->m_regExpJITCode, m_pattern, m_numSubpatterns, m_constructionError, ignoreCase(), multiline());
     101#else
     102    m_representation->m_regExpBytecode = Yarr::byteCompileRegex(m_pattern, m_numSubpatterns, m_constructionError, &globalData->m_regexAllocator, ignoreCase(), multiline());
    88103#endif
    89104}
     
    100115
    101116#if ENABLE(YARR_JIT)
    102     if (!!m_regExpJITCode) {
    103 #else
    104     if (m_regExpBytecode) {
     117    if (!!m_representation->m_regExpJITCode) {
     118#else
     119    if (m_representation->m_regExpBytecode) {
    105120#endif
    106121        int offsetVectorSize = (m_numSubpatterns + 1) * 3; // FIXME: should be 2 - but adding temporary fallback to pcre.
     
    120135
    121136#if ENABLE(YARR_JIT)
    122         int result = Yarr::executeRegex(m_regExpJITCode, s.characters(), startOffset, s.length(), offsetVector, offsetVectorSize);
    123 #else
    124         int result = Yarr::interpretRegex(m_regExpBytecode.get(), s.characters(), startOffset, s.length(), offsetVector);
     137        int result = Yarr::executeRegex(m_representation->m_regExpJITCode, s.characters(), startOffset, s.length(), offsetVector, offsetVectorSize);
     138#else
     139        int result = Yarr::interpretRegex(m_representation->m_regExpBytecode.get(), s.characters(), startOffset, s.length(), offsetVector);
    125140#endif
    126141
     
    145160void RegExp::compile(JSGlobalData*)
    146161{
    147     m_regExp = 0;
     162    m_representation->m_regExp = 0;
    148163    JSRegExpIgnoreCaseOption ignoreCaseOption = ignoreCase() ? JSRegExpIgnoreCase : JSRegExpDoNotIgnoreCase;
    149164    JSRegExpMultilineOption multilineOption = multiline() ? JSRegExpMultiline : JSRegExpSingleLine;
    150     m_regExp = jsRegExpCompile(reinterpret_cast<const UChar*>(m_pattern.characters()), m_pattern.length(), ignoreCaseOption, multilineOption, &m_numSubpatterns, &m_constructionError);
     165    m_representation->m_regExp = jsRegExpCompile(reinterpret_cast<const UChar*>(m_pattern.characters()), m_pattern.length(), ignoreCaseOption, multilineOption, &m_numSubpatterns, &m_constructionError);
    151166}
    152167
     
    161176        return -1;
    162177
    163     if (m_regExp) {
     178    if (m_representation->m_regExp) {
    164179        // Set up the offset vector for the result.
    165180        // First 2/3 used for result, the last third used by PCRE.
     
    176191        }
    177192
    178         int numMatches = jsRegExpExecute(m_regExp, reinterpret_cast<const UChar*>(s.characters()), s.length(), startOffset, offsetVector, offsetVectorSize);
     193        int numMatches = jsRegExpExecute(m_representation->m_regExp, reinterpret_cast<const UChar*>(s.characters()), s.length(), startOffset, offsetVector, offsetVectorSize);
    179194   
    180195        if (numMatches < 0) {
Note: See TracChangeset for help on using the changeset viewer.