Ignore:
Timestamp:
Mar 28, 2012, 3:18:20 PM (13 years ago)
Author:
[email protected]
Message:

Yarr: if we're not using the output array, don't populate it!
https://bugs.webkit.org/show_bug.cgi?id=82519

Reviewed by Sam Weinig.

../JavaScriptCore:

Add a new variant of the match method to RegExp that returns a MatchResult,
and modify YarrJIT to be able to compile code that doesn't use an output vector.

This is a 3% progression on v8-regexp.

  • JavaScriptCore.xcodeproj/project.pbxproj:
    • Moved MatchResult into its own header.
  • assembler/AbstractMacroAssembler.h:
    • Added missing include.
  • runtime/MatchResult.h: Added.

(MatchResult::MatchResult):
(MatchResult):
(MatchResult::failed):
(MatchResult::operator bool):
(MatchResult::empty):

  • Moved MatchResult into its own header.
  • runtime/RegExp.cpp:

(JSC::RegExp::compile):
(JSC::RegExp::compileIfNecessary):
(JSC::RegExp::match):

  • Changed due to execute & representation changes.

(JSC::RegExp::compileMatchOnly):
(JSC::RegExp::compileIfNecessaryMatchOnly):

  • Added helper to compile MatchOnly code.

(JSC::RegExp::invalidateCode):
(JSC::RegExp::matchCompareWithInterpreter):
(JSC::RegExp::printTraceData):

  • Changed due representation changes.
  • runtime/RegExp.h:

(RegExp):
(JSC::RegExp::hasCode):

  • Made YarrCodeBlock a member.
  • runtime/RegExpConstructor.h:

(RegExpConstructor):
(JSC::RegExpConstructor::performMatch):

  • Added no-ovector form.
  • runtime/RegExpMatchesArray.cpp:

(JSC::RegExpMatchesArray::reifyAllProperties):

  • Match now takes a reference to ovector, not a pointer.
  • runtime/RegExpObject.h:

(JSC):

  • Moved MatchResult into its own header.
  • runtime/StringPrototype.cpp:

(JSC::stringProtoFuncSplit):

  • Match now takes a reference to ovector, not a pointer.
  • testRegExp.cpp:

(testOneRegExp):

  • Match now takes a reference to ovector, not a pointer.
  • yarr/YarrJIT.cpp:

(Yarr):
(YarrGenerator):
(JSC::Yarr::YarrGenerator::initCallFrame):
(JSC::Yarr::YarrGenerator::removeCallFrame):
(JSC::Yarr::YarrGenerator::setSubpatternStart):
(JSC::Yarr::YarrGenerator::setSubpatternEnd):
(JSC::Yarr::YarrGenerator::clearSubpatternStart):
(JSC::Yarr::YarrGenerator::setMatchStart):
(JSC::Yarr::YarrGenerator::getMatchStart):

  • Added helper functions to intermediate access to output.

(JSC::Yarr::YarrGenerator::generateDotStarEnclosure):
(JSC::Yarr::YarrGenerator::generate):
(JSC::Yarr::YarrGenerator::backtrack):
(JSC::Yarr::YarrGenerator::generateEnter):
(JSC::Yarr::YarrGenerator::compile):

  • Changed to use the new helpers, only generate subpatterns if IncludeSubpatterns.

(JSC::Yarr::jitCompile):

  • Needs to template of MatchOnly or IncludeSubpatterns.
  • yarr/YarrJIT.h:

(YarrCodeBlock):
(JSC::Yarr::YarrCodeBlock::set8BitCode):
(JSC::Yarr::YarrCodeBlock::set16BitCode):
(JSC::Yarr::YarrCodeBlock::has8BitCodeMatchOnly):
(JSC::Yarr::YarrCodeBlock::has16BitCodeMatchOnly):
(JSC::Yarr::YarrCodeBlock::set8BitCodeMatchOnly):
(JSC::Yarr::YarrCodeBlock::set16BitCodeMatchOnly):
(JSC::Yarr::YarrCodeBlock::execute):
(JSC::Yarr::YarrCodeBlock::clear):

  • Added a second set of CodeRefs, so that we can compile RexExps with/without subpattern matching.

../WebCore:

  • ForwardingHeaders/runtime/MatchResult.h: Added.
  • ForwardingHeaders/yarr/YarrJIT.h: Added.
    • Added forwarding headers.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/RegExp.h

    r106189 r112454  
    2323#define RegExp_h
    2424
     25#include "ExecutableAllocator.h"
     26#include "MatchResult.h"
     27#include "RegExpKey.h"
     28#include "Structure.h"
    2529#include "UString.h"
    26 #include "ExecutableAllocator.h"
    27 #include "Structure.h"
    28 #include "RegExpKey.h"
    2930#include "yarr/Yarr.h"
    3031#include <wtf/Forward.h>
    3132#include <wtf/RefCounted.h>
     33
     34#if ENABLE(YARR_JIT)
     35#include "yarr/YarrJIT.h"
     36#endif
    3237
    3338namespace JSC {
     
    5459        const char* errorMessage() const { return m_constructionError; }
    5560
    56         JS_EXPORT_PRIVATE int match(JSGlobalData&, const UString&, unsigned startOffset, Vector<int, 32>* ovector = 0);
     61        JS_EXPORT_PRIVATE int match(JSGlobalData&, const UString&, unsigned startOffset, Vector<int, 32>& ovector);
     62        MatchResult match(JSGlobalData&, const UString&, unsigned startOffset);
    5763        unsigned numSubpatterns() const { return m_numSubpatterns; }
    5864
    5965        bool hasCode()
    6066        {
    61             return m_representation;
     67            return m_state != NotCompiled;
    6268        }
    6369
     
    96102        void compileIfNecessary(JSGlobalData&, Yarr::YarrCharSize);
    97103
     104        void compileMatchOnly(JSGlobalData*, Yarr::YarrCharSize);
     105        void compileIfNecessaryMatchOnly(JSGlobalData&, Yarr::YarrCharSize);
     106
    98107#if ENABLE(YARR_JIT_DEBUG)
    99108        void matchCompareWithInterpreter(const UString&, int startOffset, int* offsetVector, int jitResult);
     
    109118#endif
    110119
    111         OwnPtr<RegExpRepresentation> m_representation;
     120#if ENABLE(YARR_JIT)
     121        Yarr::YarrCodeBlock m_regExpJITCode;
     122#endif
     123        OwnPtr<Yarr::BytecodePattern> m_regExpBytecode;
    112124    };
    113125
Note: See TracChangeset for help on using the changeset viewer.