Changeset 47405 in webkit for trunk/JavaScriptCore/runtime


Ignore:
Timestamp:
Aug 17, 2009, 6:05:37 PM (16 years ago)
Author:
[email protected]
Message:

Fix 300,000+ leaks seen during the regression tests.

Reviewed by Darin Adler.

EvalCodeCache::get was heap-allocating an EvalExecutable instance without adopting the initial reference.
While fixing this we noticed that EvalExecutable was a RefCounted type that was sometimes stack allocated.
To make this cleaner and to prevent clients from attempting to ref a stack-allocated instance, we move the
refcounting down to a new CacheableEvalExecutable class that derives from EvalExecutable. EvalCodeCache::get
now uses CacheableEvalExecutable::create and avoids the leak.

  • bytecode/EvalCodeCache.h:

(JSC::EvalCodeCache::get):

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::callEval):

  • runtime/Executable.h:

(JSC::CacheableEvalExecutable::create):
(JSC::CacheableEvalExecutable::CacheableEvalExecutable):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/Executable.h

    r47330 r47405  
    5757    };
    5858
    59     class EvalExecutable : public TemplateExecutable<EvalNode, EvalCodeBlock>, public RefCounted<EvalExecutable> {
     59    class EvalExecutable : public TemplateExecutable<EvalNode, EvalCodeBlock> {
    6060    public:
    6161        EvalExecutable(const SourceCode& source)
     
    6565
    6666        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        }
    6778    };
    6879
Note: See TracChangeset for help on using the changeset viewer.