X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/4e4e5a6f2694187498445a6ac6f1634ce8141119..HEAD:/runtime/RegExpCache.h diff --git a/runtime/RegExpCache.h b/runtime/RegExpCache.h index 03b73ac..dd46ac6 100644 --- a/runtime/RegExpCache.h +++ b/runtime/RegExpCache.h @@ -27,29 +27,41 @@ #include "RegExp.h" #include "RegExpKey.h" -#include "UString.h" +#include "Strong.h" +#include "Weak.h" +#include "WeakInlines.h" +#include +#include #ifndef RegExpCache_h #define RegExpCache_h namespace JSC { -class RegExpCache { +class RegExpCache : private WeakHandleOwner { + WTF_MAKE_FAST_ALLOCATED; + + friend class RegExp; + typedef HashMap> RegExpCacheMap; + public: - PassRefPtr lookupOrCreate(const UString& patternString, const UString& flags); - PassRefPtr create(const UString& patternString, const UString& flags); - RegExpCache(JSGlobalData* globalData); + RegExpCache(VM* vm); + void invalidateCode(); private: - static const unsigned maxCacheablePatternLength = 256; - static const int maxCacheableEntries = 256; - - typedef HashMap > RegExpCacheMap; - RegExpKey patternKeyArray[maxCacheableEntries]; - RegExpCacheMap m_cacheMap; - JSGlobalData* m_globalData; - int m_nextKeyToEvict; - bool m_isFull; + + static const unsigned maxStrongCacheablePatternLength = 256; + + static const int maxStrongCacheableEntries = 32; + + virtual void finalize(Handle, void* context) override; + + RegExp* lookupOrCreate(const WTF::String& patternString, RegExpFlags); + void addToStrongCache(RegExp*); + RegExpCacheMap m_weakCache; // Holds all regular expressions currently live. + int m_nextEntryInStrongCache; + std::array, maxStrongCacheableEntries> m_strongCache; // Holds a select few regular expressions that have compiled and executed + VM* m_vm; }; } // namespace JSC