diff options
author | Andrei Popescu <andreip@google.com> | 2009-08-19 14:09:30 +0100 |
---|---|---|
committer | Andrei Popescu <andreip@google.com> | 2009-08-19 14:09:30 +0100 |
commit | 058ccc7ba0a4d59b9f6e92808332aa9895425fc7 (patch) | |
tree | 276aad5a2bbc2fd7d65d21bfca42c9de88b3dd20 /JavaScriptCore/bytecode/EvalCodeCache.h | |
parent | 2796dd1bf3b4b01e7e1d96ea91bd3a212f647579 (diff) | |
download | external_webkit-058ccc7ba0a4d59b9f6e92808332aa9895425fc7.zip external_webkit-058ccc7ba0a4d59b9f6e92808332aa9895425fc7.tar.gz external_webkit-058ccc7ba0a4d59b9f6e92808332aa9895425fc7.tar.bz2 |
Revert "Merge WebKit r47420"
This reverts commit d227fc870c7a697500a3c900c31baf05fb9a8524.
Diffstat (limited to 'JavaScriptCore/bytecode/EvalCodeCache.h')
-rw-r--r-- | JavaScriptCore/bytecode/EvalCodeCache.h | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/JavaScriptCore/bytecode/EvalCodeCache.h b/JavaScriptCore/bytecode/EvalCodeCache.h index c486e42..986525c 100644 --- a/JavaScriptCore/bytecode/EvalCodeCache.h +++ b/JavaScriptCore/bytecode/EvalCodeCache.h @@ -29,7 +29,6 @@ #ifndef EvalCodeCache_h #define EvalCodeCache_h -#include "Executable.h" #include "JSGlobalObject.h" #include "Nodes.h" #include "Parser.h" @@ -42,33 +41,44 @@ namespace JSC { class EvalCodeCache { public: - PassRefPtr<CacheableEvalExecutable> get(ExecState* exec, const UString& evalSource, ScopeChainNode* scopeChain, JSValue& exceptionValue) + PassRefPtr<EvalNode> get(ExecState* exec, const UString& evalSource, ScopeChainNode* scopeChain, JSValue& exceptionValue) { - RefPtr<CacheableEvalExecutable> evalExecutable; + RefPtr<EvalNode> evalNode; if (evalSource.size() < maxCacheableSourceLength && (*scopeChain->begin())->isVariableObject()) - evalExecutable = m_cacheMap.get(evalSource.rep()); + evalNode = m_cacheMap.get(evalSource.rep()); - if (!evalExecutable) { - evalExecutable = CacheableEvalExecutable::create(makeSource(evalSource)); - exceptionValue = evalExecutable->parse(exec); - if (exceptionValue) + if (!evalNode) { + int errorLine; + UString errorMessage; + + SourceCode source = makeSource(evalSource); + evalNode = exec->globalData().parser->parse<EvalNode>(exec, exec->dynamicGlobalObject()->debugger(), source, &errorLine, &errorMessage); + if (evalNode) { + if (evalSource.size() < maxCacheableSourceLength && (*scopeChain->begin())->isVariableObject() && m_cacheMap.size() < maxCacheEntries) + m_cacheMap.set(evalSource.rep(), evalNode); + } else { + exceptionValue = Error::create(exec, SyntaxError, errorMessage, errorLine, source.provider()->asID(), 0); return 0; - - if (evalSource.size() < maxCacheableSourceLength && (*scopeChain->begin())->isVariableObject() && m_cacheMap.size() < maxCacheEntries) - m_cacheMap.set(evalSource.rep(), evalExecutable); + } } - return evalExecutable.release(); + return evalNode.release(); } bool isEmpty() const { return m_cacheMap.isEmpty(); } + void markAggregate(MarkStack& markStack) + { + EvalCacheMap::iterator end = m_cacheMap.end(); + for (EvalCacheMap::iterator ptr = m_cacheMap.begin(); ptr != end; ++ptr) + ptr->second->markAggregate(markStack); + } private: static const int maxCacheableSourceLength = 256; static const int maxCacheEntries = 64; - typedef HashMap<RefPtr<UString::Rep>, RefPtr<CacheableEvalExecutable> > EvalCacheMap; + typedef HashMap<RefPtr<UString::Rep>, RefPtr<EvalNode> > EvalCacheMap; EvalCacheMap m_cacheMap; }; |