X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/4e4e5a6f2694187498445a6ac6f1634ce8141119..14957cd040308e3eeec43d26bae5d76da13fcd85:/bytecode/EvalCodeCache.h?ds=sidebyside diff --git a/bytecode/EvalCodeCache.h b/bytecode/EvalCodeCache.h index 27c479d..1e181b9 100644 --- a/bytecode/EvalCodeCache.h +++ b/bytecode/EvalCodeCache.h @@ -41,35 +41,45 @@ namespace JSC { + class MarkStack; + typedef MarkStack SlotVisitor; + class EvalCodeCache { public: - PassRefPtr get(ExecState* exec, const UString& evalSource, ScopeChainNode* scopeChain, JSValue& exceptionValue) + EvalExecutable* get(ExecState* exec, ScriptExecutable* owner, bool inStrictContext, const UString& evalSource, ScopeChainNode* scopeChain, JSValue& exceptionValue) { - RefPtr evalExecutable; + EvalExecutable* evalExecutable = 0; - if (evalSource.size() < maxCacheableSourceLength && (*scopeChain->begin())->isVariableObject()) - evalExecutable = m_cacheMap.get(evalSource.rep()); + if (!inStrictContext && evalSource.length() < maxCacheableSourceLength && (*scopeChain->begin())->isVariableObject()) + evalExecutable = m_cacheMap.get(evalSource.impl()).get(); if (!evalExecutable) { - evalExecutable = EvalExecutable::create(exec, makeSource(evalSource)); + evalExecutable = EvalExecutable::create(exec, makeSource(evalSource), inStrictContext); exceptionValue = evalExecutable->compile(exec, scopeChain); if (exceptionValue) return 0; - if (evalSource.size() < maxCacheableSourceLength && (*scopeChain->begin())->isVariableObject() && m_cacheMap.size() < maxCacheEntries) - m_cacheMap.set(evalSource.rep(), evalExecutable); + if (!inStrictContext && evalSource.length() < maxCacheableSourceLength && (*scopeChain->begin())->isVariableObject() && m_cacheMap.size() < maxCacheEntries) + m_cacheMap.set(evalSource.impl(), WriteBarrier(exec->globalData(), owner, evalExecutable)); } - return evalExecutable.release(); + return evalExecutable; } bool isEmpty() const { return m_cacheMap.isEmpty(); } + void visitAggregate(SlotVisitor&); + + void clear() + { + m_cacheMap.clear(); + } + private: static const unsigned maxCacheableSourceLength = 256; static const int maxCacheEntries = 64; - typedef HashMap, RefPtr > EvalCacheMap; + typedef HashMap, WriteBarrier > EvalCacheMap; EvalCacheMap m_cacheMap; };