Ignore:
Timestamp:
Jun 22, 2010, 12:16:57 PM (15 years ago)
Author:
[email protected]
Message:

Adding regular expression caching to JavaScriptCore
https://bugs.webkit.org/show_bug.cgi?id=38142

Patch by Renata Hodovan <[email protected]> on 2010-06-22
Reviewed by Geoffrey Garen.

The cache is based on Round Robin eviction policy, and
can cache at most 256 character long regular expressions,
and at most 256 of them. These values can be changed at compile time.

(JSC::RegExpNode::emitBytecode):

  • runtime/JSGlobalData.cpp:

(JSC::JSGlobalData::JSGlobalData):
(JSC::JSGlobalData::~JSGlobalData):

  • runtime/JSGlobalData.h:

(JSC::JSGlobalData::regExpCache):

  • runtime/RegExpCache.cpp: Added.

(JSC::RegExpCache::lookupOrCreate):
(JSC::RegExpCache::create):
(JSC::RegExpCache::RegExpCache):

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

(JSC::constructRegExp):

  • runtime/RegExpKey.h: Added.

(JSC::RegExpKey::RegExpKey):
(JSC::RegExpKey::getFlagsValue):
(WTF::operator==):
(WTF::):

  • runtime/RegExpPrototype.cpp:

(JSC::regExpProtoFuncCompile):

  • runtime/StringPrototype.cpp:

(JSC::stringProtoFuncMatch):
(JSC::stringProtoFuncSearch):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/bytecompiler/NodesCodegen.cpp

    r60762 r61623  
    4040#include "Parser.h"
    4141#include "PropertyNameArray.h"
     42#include "RegExpCache.h"
    4243#include "RegExpObject.h"
    4344#include "SamplingTool.h"
     
    145146RegisterID* RegExpNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
    146147{
    147     RefPtr<RegExp> regExp = RegExp::create(generator.globalData(), m_pattern.ustring(), m_flags.ustring());
     148    RefPtr<RegExp> regExp = generator.globalData()->regExpCache()->lookupOrCreate(m_pattern.ustring(), m_flags.ustring());
    148149    if (!regExp->isValid())
    149150        return emitThrowError(generator, false, "Invalid regular expression: %s", regExp->errorMessage());
Note: See TracChangeset for help on using the changeset viewer.