Changeset 36267 in webkit for trunk/JavaScriptCore/VM/CodeBlock.h
- Timestamp:
- Sep 8, 2008, 5:17:33 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/VM/CodeBlock.h
r36263 r36267 34 34 #include "JSGlobalObject.h" 35 35 #include "nodes.h" 36 #include "Parser.h" 36 37 #include "SourceRange.h" 37 38 #include "ustring.h" … … 128 129 } 129 130 #endif 131 }; 132 133 class EvalCodeCache { 134 public: 135 PassRefPtr<EvalNode> get(ExecState* exec, const UString& evalSource, ScopeChainNode* scopeChain, JSValue*& exceptionValue) 136 { 137 RefPtr<EvalNode> evalNode; 138 139 if (evalSource.size() < maxCacheableSourceLength && (*scopeChain->begin())->isVariableObject()) 140 evalNode = cacheMap.get(evalSource.rep()); 141 142 if (!evalNode) { 143 int sourceId; 144 int errLine; 145 UString errMsg; 146 147 evalNode = exec->parser()->parse<EvalNode>(exec, UString(), 1, UStringSourceProvider::create(evalSource), &sourceId, &errLine, &errMsg); 148 if (evalNode) { 149 if (evalSource.size() < maxCacheableSourceLength && (*scopeChain->begin())->isVariableObject() && cacheMap.size() < maxCacheEntries) 150 cacheMap.set(evalSource.rep(), evalNode); 151 } else { 152 exceptionValue = Error::create(exec, SyntaxError, errMsg, errLine, sourceId, NULL); 153 return 0; 154 } 155 } 156 157 return evalNode.release(); 158 } 159 160 private: 161 static const int maxCacheableSourceLength = 256; 162 static const int maxCacheEntries = 64; 163 164 HashMap<RefPtr<UString::Rep>, RefPtr<EvalNode> > cacheMap; 130 165 }; 131 166 … … 208 243 #endif 209 244 245 EvalCodeCache evalCodeCache; 246 210 247 private: 211 248 #if !defined(NDEBUG) || ENABLE(SAMPLING_TOOL) 212 249 void dump(ExecState*, const Vector<Instruction>::const_iterator& begin, Vector<Instruction>::const_iterator&) const; 213 250 #endif 251 214 252 }; 215 253
Note:
See TracChangeset
for help on using the changeset viewer.