Ignore:
Timestamp:
Jul 27, 2010, 12:14:40 PM (15 years ago)
Author:
[email protected]
Message:

Bug 42621 - Add a bump allocator for the YARR interpreter

Reviewed by Oliver Hunt.

The regex engine requires lifo allocation, however currently uses the general purpose
malloc/free memory allocation. A simple bump pointer allocator should provide a lower
overhead allocation solution.

JavaScriptCore:

When using YARR interpreter, 15% progression on v8-regex.

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • runtime/JSGlobalData.h:
  • runtime/RegExp.cpp:

(JSC::RegExp::compile):

  • wtf/BumpPointerAllocator.h: Added.

(WTF::BumpPointerPool::ensureCapacity):
(WTF::BumpPointerPool::alloc):
(WTF::BumpPointerPool::dealloc):
(WTF::BumpPointerPool::operator new):
(WTF::BumpPointerPool::BumpPointerPool):
(WTF::BumpPointerPool::create):
(WTF::BumpPointerPool::shrink):
(WTF::BumpPointerPool::destroy):
(WTF::BumpPointerPool::ensureCapacityCrossPool):
(WTF::BumpPointerPool::deallocCrossPool):
(WTF::BumpPointerAllocator::BumpPointerAllocator):
(WTF::BumpPointerAllocator::~BumpPointerAllocator):
(WTF::BumpPointerAllocator::startAllocator):
(WTF::BumpPointerAllocator::stopAllocator):

  • yarr/RegexInterpreter.cpp:

(JSC::Yarr::Interpreter::allocDisjunctionContext):
(JSC::Yarr::Interpreter::freeDisjunctionContext):
(JSC::Yarr::Interpreter::allocParenthesesDisjunctionContext):
(JSC::Yarr::Interpreter::freeParenthesesDisjunctionContext):
(JSC::Yarr::Interpreter::interpret):
(JSC::Yarr::Interpreter::Interpreter):
(JSC::Yarr::ByteCompiler::compile):
(JSC::Yarr::byteCompileRegex):

  • yarr/RegexInterpreter.h:

(JSC::Yarr::BytecodePattern::BytecodePattern):

JavaScriptGlue:

  • ForwardingHeaders/wtf/BumpPointerAllocator.h: Added.

WebCore:

  • ForwardingHeaders/wtf/BumpPointerAllocator.h: Added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/yarr/RegexInterpreter.h

    r62677 r64146  
    3333#include <wtf/PassOwnPtr.h>
    3434#include <wtf/unicode/Unicode.h>
     35
     36namespace WTF {
     37class BumpPointerAllocator;
     38}
     39using WTF::BumpPointerAllocator;
    3540
    3641namespace JSC { namespace Yarr {
     
    294299
    295300struct BytecodePattern : FastAllocBase {
    296     BytecodePattern(PassOwnPtr<ByteDisjunction> body, Vector<ByteDisjunction*> allParenthesesInfo, RegexPattern& pattern)
     301    BytecodePattern(PassOwnPtr<ByteDisjunction> body, Vector<ByteDisjunction*> allParenthesesInfo, RegexPattern& pattern, BumpPointerAllocator* allocator)
    297302        : m_body(body)
    298303        , m_ignoreCase(pattern.m_ignoreCase)
    299304        , m_multiline(pattern.m_multiline)
     305        , m_allocator(allocator)
    300306    {
    301307        newlineCharacterClass = pattern.newlineCharacterClass();
     
    319325    bool m_ignoreCase;
    320326    bool m_multiline;
    321    
     327    // Each BytecodePattern is associated with a RegExp, each RegExp is associated
     328    // with a JSGlobalData.  Cache a pointer to out JSGlobalData's m_regexAllocator.
     329    BumpPointerAllocator* m_allocator;
     330
    322331    CharacterClass* newlineCharacterClass;
    323332    CharacterClass* wordcharCharacterClass;
     
    327336};
    328337
    329 PassOwnPtr<BytecodePattern> byteCompileRegex(const UString& pattern, unsigned& numSubpatterns, const char*& error, bool ignoreCase = false, bool multiline = false);
     338PassOwnPtr<BytecodePattern> byteCompileRegex(const UString& pattern, unsigned& numSubpatterns, const char*& error, BumpPointerAllocator*, bool ignoreCase = false, bool multiline = false);
    330339int interpretRegex(BytecodePattern* v_regex, const UChar* input, unsigned start, unsigned length, int* output);
    331340
Note: See TracChangeset for help on using the changeset viewer.