Ignore:
Timestamp:
Oct 8, 2009, 8:22:41 PM (16 years ago)
Author:
[email protected]
Message:

At long last, I pronounce the death of AllInOneFile.cpp.

Patch by Geoffrey Garen <[email protected]> on 2009-10-08
Reviewed by Maciej Stachowiak.

SunSpider reports a 1.01x speedup.

to compilation stages.

  • parser/Grammar.y:
  • parser/Lexer.cpp:
  • parser/Lexer.h:

(JSC::jscyylex):

  • runtime/ArrayConstructor.cpp:

(JSC::constructArrayWithSizeQuirk):

  • runtime/Collector.h:
  • runtime/JSCell.cpp:

(JSC::JSCell::operator new):

  • runtime/JSCell.h:

(JSC::JSCell::operator new):

  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::operator new):

  • runtime/JSNumberCell.h:

(JSC::JSNumberCell::operator new):

  • runtime/JSString.cpp:
  • runtime/JSString.h:

(JSC::jsString):
(JSC::jsSubstring):
(JSC::jsOwnedString):

  • runtime/RegExpConstructor.cpp:
  • runtime/RegExpConstructor.h:

(JSC::RegExpConstructorPrivate::RegExpConstructorPrivate):
(JSC::RegExpConstructorPrivate::lastOvector):
(JSC::RegExpConstructorPrivate::tempOvector):
(JSC::RegExpConstructorPrivate::changeLastOvector):
(JSC::RegExpConstructor::performMatch):

  • runtime/StringPrototype.cpp:

(JSC::stringProtoFuncMatch):

  • yarr/RegexJIT.cpp:
  • yarr/RegexJIT.h:

(JSC::Yarr::executeRegex): Inlined a few things that Shark said
were hot, on the presumption that AllInOneFile.cpp used to inline them
automatically.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/RegExpConstructor.h

    r48836 r49365  
    2323
    2424#include "InternalFunction.h"
     25#include "RegExp.h"
    2526#include <wtf/OwnPtr.h>
    2627
     
    3031    class RegExpPrototype;
    3132    struct RegExpConstructorPrivate;
     33
     34    struct RegExpConstructorPrivate : FastAllocBase {
     35        // Global search cache / settings
     36        RegExpConstructorPrivate()
     37            : lastNumSubPatterns(0)
     38            , multiline(false)
     39            , lastOvectorIndex(0)
     40        {
     41        }
     42
     43        const Vector<int, 32>& lastOvector() const { return ovector[lastOvectorIndex]; }
     44        Vector<int, 32>& lastOvector() { return ovector[lastOvectorIndex]; }
     45        Vector<int, 32>& tempOvector() { return ovector[lastOvectorIndex ? 0 : 1]; }
     46        void changeLastOvector() { lastOvectorIndex = lastOvectorIndex ? 0 : 1; }
     47
     48        UString input;
     49        UString lastInput;
     50        Vector<int, 32> ovector[2];
     51        unsigned lastNumSubPatterns : 30;
     52        bool multiline : 1;
     53        unsigned lastOvectorIndex : 1;
     54    };
    3255
    3356    class RegExpConstructor : public InternalFunction {
     
    79102    }
    80103
     104    /*
     105      To facilitate result caching, exec(), test(), match(), search(), and replace() dipatch regular
     106      expression matching through the performMatch function. We use cached results to calculate,
     107      e.g., RegExp.lastMatch and RegExp.leftParen.
     108    */
     109    inline void RegExpConstructor::performMatch(RegExp* r, const UString& s, int startOffset, int& position, int& length, int** ovector)
     110    {
     111        position = r->match(s, startOffset, &d->tempOvector());
     112
     113        if (ovector)
     114            *ovector = d->tempOvector().data();
     115
     116        if (position != -1) {
     117            ASSERT(!d->tempOvector().isEmpty());
     118
     119            length = d->tempOvector()[1] - d->tempOvector()[0];
     120
     121            d->input = s;
     122            d->lastInput = s;
     123            d->changeLastOvector();
     124            d->lastNumSubPatterns = r->numSubpatterns();
     125        }
     126    }
     127
    81128} // namespace JSC
    82129
Note: See TracChangeset for help on using the changeset viewer.