X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/14957cd040308e3eeec43d26bae5d76da13fcd85..refs/heads/master:/bytecode/EvalCodeCache.h diff --git a/bytecode/EvalCodeCache.h b/bytecode/EvalCodeCache.h index 1e181b9..b0e5aac 100644 --- a/bytecode/EvalCodeCache.h +++ b/bytecode/EvalCodeCache.h @@ -10,7 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * 3. Neither the name of Apple Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -31,38 +31,34 @@ #include "Executable.h" #include "JSGlobalObject.h" -#include "Nodes.h" -#include "Parser.h" +#include "Options.h" #include "SourceCode.h" -#include "UString.h" #include #include #include 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 String& evalSource, JSScope* scope) { - 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; - - if (!inStrictContext && evalSource.length() < maxCacheableSourceLength && (*scopeChain->begin())->isVariableObject() && m_cacheMap.size() < maxCacheEntries) - m_cacheMap.set(evalSource.impl(), WriteBarrier(exec->globalData(), owner, evalExecutable)); - } + if (!inStrictContext && evalSource.length() < Options::maximumEvalCacheableSourceLength() && scope->begin()->isVariableObject()) + return m_cacheMap.get(evalSource.impl()).get(); + return 0; + } + + EvalExecutable* getSlow(ExecState* exec, ScriptExecutable* owner, bool inStrictContext, ThisTDZMode thisTDZMode, const String& evalSource, JSScope* scope) + { + EvalExecutable* evalExecutable = EvalExecutable::create(exec, makeSource(evalSource), inStrictContext, thisTDZMode); + if (!evalExecutable) + return 0; + if (!inStrictContext && evalSource.length() < Options::maximumEvalCacheableSourceLength() && scope->begin()->isVariableObject() && m_cacheMap.size() < maxCacheEntries) + m_cacheMap.set(evalSource.impl(), WriteBarrier(exec->vm(), owner, evalExecutable)); + return evalExecutable; } @@ -76,10 +72,9 @@ namespace JSC { } private: - static const unsigned maxCacheableSourceLength = 256; static const int maxCacheEntries = 64; - typedef HashMap, WriteBarrier > EvalCacheMap; + typedef HashMap, WriteBarrier> EvalCacheMap; EvalCacheMap m_cacheMap; };