Changeset 38311 in webkit for trunk/JavaScriptCore/VM/CodeBlock.h
- Timestamp:
- Nov 11, 2008, 12:06:11 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/VM/CodeBlock.h
r38291 r38311 31 31 #define CodeBlock_h 32 32 33 #include "EvalCodeCache.h" 33 34 #include "Instruction.h" 34 35 #include "JSGlobalObject.h" 35 36 #include "Nodes.h" 36 #include "Parser.h"37 37 #include "RegExp.h" 38 #include "SourceCode.h"39 38 #include "UString.h" 40 39 #include <wtf/RefPtr.h> … … 212 211 }; 213 212 214 class EvalCodeCache {215 public:216 PassRefPtr<EvalNode> get(ExecState* exec, const UString& evalSource, ScopeChainNode* scopeChain, JSValue*& exceptionValue)217 {218 RefPtr<EvalNode> evalNode;219 220 if (evalSource.size() < maxCacheableSourceLength && (*scopeChain->begin())->isVariableObject())221 evalNode = cacheMap.get(evalSource.rep());222 223 if (!evalNode) {224 int errLine;225 UString errMsg;226 227 SourceCode source = makeSource(evalSource);228 evalNode = exec->globalData().parser->parse<EvalNode>(exec, exec->dynamicGlobalObject()->debugger(), source, &errLine, &errMsg);229 if (evalNode) {230 if (evalSource.size() < maxCacheableSourceLength && (*scopeChain->begin())->isVariableObject() && cacheMap.size() < maxCacheEntries)231 cacheMap.set(evalSource.rep(), evalNode);232 } else {233 exceptionValue = Error::create(exec, SyntaxError, errMsg, errLine, source.provider()->asID(), NULL);234 return 0;235 }236 }237 238 return evalNode.release();239 }240 241 private:242 static const int maxCacheableSourceLength = 256;243 static const int maxCacheEntries = 64;244 245 HashMap<RefPtr<UString::Rep>, RefPtr<EvalNode> > cacheMap;246 };247 248 213 struct CodeBlock { 249 214 CodeBlock(ScopeNode* ownerNode, CodeType codeType, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset)
Note:
See TracChangeset
for help on using the changeset viewer.