Changeset 47405 in webkit for trunk/JavaScriptCore
- Timestamp:
- Aug 17, 2009, 6:05:37 PM (16 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r47404 r47405 1 2009-08-17 Mark Rowe <[email protected]> 2 3 Reviewed by Darin Adler. 4 5 Fix 300,000+ leaks seen during the regression tests. 6 7 EvalCodeCache::get was heap-allocating an EvalExecutable instance without adopting the initial reference. 8 While fixing this we noticed that EvalExecutable was a RefCounted type that was sometimes stack allocated. 9 To make this cleaner and to prevent clients from attempting to ref a stack-allocated instance, we move the 10 refcounting down to a new CacheableEvalExecutable class that derives from EvalExecutable. EvalCodeCache::get 11 now uses CacheableEvalExecutable::create and avoids the leak. 12 13 * bytecode/EvalCodeCache.h: 14 (JSC::EvalCodeCache::get): 15 * interpreter/Interpreter.cpp: 16 (JSC::Interpreter::callEval): 17 * runtime/Executable.h: 18 (JSC::CacheableEvalExecutable::create): 19 (JSC::CacheableEvalExecutable::CacheableEvalExecutable): 20 1 21 2009-08-17 Oliver Hunt <[email protected]> 2 22 -
trunk/JavaScriptCore/bytecode/EvalCodeCache.h
r47304 r47405 43 43 class EvalCodeCache { 44 44 public: 45 PassRefPtr< EvalExecutable> get(ExecState* exec, const UString& evalSource, ScopeChainNode* scopeChain, JSValue& exceptionValue)45 PassRefPtr<CacheableEvalExecutable> get(ExecState* exec, const UString& evalSource, ScopeChainNode* scopeChain, JSValue& exceptionValue) 46 46 { 47 RefPtr< EvalExecutable> evalExecutable;47 RefPtr<CacheableEvalExecutable> evalExecutable; 48 48 49 49 if (evalSource.size() < maxCacheableSourceLength && (*scopeChain->begin())->isVariableObject()) … … 51 51 52 52 if (!evalExecutable) { 53 evalExecutable = new EvalExecutable(makeSource(evalSource));53 evalExecutable = CacheableEvalExecutable::create(makeSource(evalSource)); 54 54 exceptionValue = evalExecutable->parse(exec); 55 55 if (exceptionValue) … … 75 75 static const int maxCacheEntries = 64; 76 76 77 typedef HashMap<RefPtr<UString::Rep>, RefPtr< EvalExecutable> > EvalCacheMap;77 typedef HashMap<RefPtr<UString::Rep>, RefPtr<CacheableEvalExecutable> > EvalCacheMap; 78 78 EvalCacheMap m_cacheMap; 79 79 }; -
trunk/JavaScriptCore/interpreter/Interpreter.cpp
r47304 r47405 351 351 if (JSValue parsedObject = preparser.tryLiteralParse()) 352 352 return parsedObject; 353 354 353 355 354 ScopeChainNode* scopeChain = callFrame->scopeChain(); 356 355 CodeBlock* codeBlock = callFrame->codeBlock(); 357 RefPtr< EvalExecutable> eval = codeBlock->evalCodeCache().get(callFrame, programSource, scopeChain, exceptionValue);356 RefPtr<CacheableEvalExecutable> eval = codeBlock->evalCodeCache().get(callFrame, programSource, scopeChain, exceptionValue); 358 357 359 358 JSValue result = jsUndefined(); -
trunk/JavaScriptCore/runtime/Executable.h
r47330 r47405 57 57 }; 58 58 59 class EvalExecutable : public TemplateExecutable<EvalNode, EvalCodeBlock> , public RefCounted<EvalExecutable>{59 class EvalExecutable : public TemplateExecutable<EvalNode, EvalCodeBlock> { 60 60 public: 61 61 EvalExecutable(const SourceCode& source) … … 65 65 66 66 JSObject* parse(ExecState* exec, bool allowDebug = true); 67 }; 68 69 class CacheableEvalExecutable : public EvalExecutable, public RefCounted<CacheableEvalExecutable> { 70 public: 71 static PassRefPtr<CacheableEvalExecutable> create(const SourceCode& source) { return adoptRef(new CacheableEvalExecutable(source)); } 72 73 private: 74 CacheableEvalExecutable(const SourceCode& source) 75 : EvalExecutable(source) 76 { 77 } 67 78 }; 68 79
Note:
See TracChangeset
for help on using the changeset viewer.