X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/1df5f87f1309a8daa30dabdee855f48ae40d14ab..6fe7ccc865dc7d7541b93c5bcaf6368d2c98a174:/bytecode/EvalCodeCache.h?ds=inline diff --git a/bytecode/EvalCodeCache.h b/bytecode/EvalCodeCache.h index 1e181b9..fba1d32 100644 --- a/bytecode/EvalCodeCache.h +++ b/bytecode/EvalCodeCache.h @@ -41,27 +41,36 @@ namespace JSC { - class MarkStack; - typedef MarkStack SlotVisitor; + class SlotVisitor; class EvalCodeCache { public: - EvalExecutable* get(ExecState* exec, ScriptExecutable* owner, bool inStrictContext, const UString& evalSource, ScopeChainNode* scopeChain, JSValue& exceptionValue) + EvalExecutable* tryGet(bool inStrictContext, const UString& evalSource, ScopeChainNode* scopeChain) { - EvalExecutable* evalExecutable = 0; - if (!inStrictContext && evalSource.length() < maxCacheableSourceLength && (*scopeChain->begin())->isVariableObject()) - evalExecutable = m_cacheMap.get(evalSource.impl()).get(); - - if (!evalExecutable) { - evalExecutable = EvalExecutable::create(exec, makeSource(evalSource), inStrictContext); - exceptionValue = evalExecutable->compile(exec, scopeChain); - if (exceptionValue) - return 0; + return m_cacheMap.get(evalSource.impl()).get(); + return 0; + } + + EvalExecutable* getSlow(ExecState* exec, ScriptExecutable* owner, bool inStrictContext, const UString& evalSource, ScopeChainNode* scopeChain, JSValue& exceptionValue) + { + EvalExecutable* evalExecutable = EvalExecutable::create(exec, makeSource(evalSource), inStrictContext); + exceptionValue = evalExecutable->compile(exec, scopeChain); + if (exceptionValue) + return 0; + + if (!inStrictContext && evalSource.length() < maxCacheableSourceLength && (*scopeChain->begin())->isVariableObject() && m_cacheMap.size() < maxCacheEntries) + m_cacheMap.set(evalSource.impl(), WriteBarrier(exec->globalData(), owner, evalExecutable)); + + return evalExecutable; + } + + EvalExecutable* get(ExecState* exec, ScriptExecutable* owner, bool inStrictContext, const UString& evalSource, ScopeChainNode* scopeChain, JSValue& exceptionValue) + { + EvalExecutable* evalExecutable = tryGet(inStrictContext, evalSource, scopeChain); - if (!inStrictContext && evalSource.length() < maxCacheableSourceLength && (*scopeChain->begin())->isVariableObject() && m_cacheMap.size() < maxCacheEntries) - m_cacheMap.set(evalSource.impl(), WriteBarrier(exec->globalData(), owner, evalExecutable)); - } + if (!evalExecutable) + evalExecutable = getSlow(exec, owner, inStrictContext, evalSource, scopeChain, exceptionValue); return evalExecutable; }