Changeset 63675 in webkit


Ignore:
Timestamp:
Jul 19, 2010 10:19:16 AM (14 years ago)
Author:
Darin Adler
Message:

2010-07-16 Darin Adler <Darin Adler>

Reviewed by Sam Weinig.

Use OwnPtr for CodeBlock objects
https://bugs.webkit.org/show_bug.cgi?id=42490

  • runtime/Executable.cpp: (JSC::EvalExecutable::EvalExecutable): Moved this here and made it non-inline. Eliminated the code that used to initialize the raw pointer since it's now an OwnPtr. (JSC::EvalExecutable::~EvalExecutable): Removed the explicit delete here. (JSC::ProgramExecutable::ProgramExecutable): Ditto. (JSC::ProgramExecutable::~ProgramExecutable): Ditto. (JSC::FunctionExecutable::FunctionExecutable): Ditto. (JSC::FunctionExecutable::~FunctionExecutable): Ditto. (JSC::EvalExecutable::compileInternal): Added use of adoptPtr and get. (JSC::ProgramExecutable::compileInternal): Ditto. (JSC::FunctionExecutable::compileForCallInternal): Ditto. (JSC::FunctionExecutable::compileForConstructInternal): Ditto. (JSC::FunctionExecutable::recompile): Use clear instead of delete followed by assignment of 0.
  • runtime/Executable.h: Moved constructors to the cpp file and changed raw pointers to OwnPtr.
Location:
trunk/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r63651 r63675  
     12010-07-16  Darin Adler  <darin@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        Use OwnPtr for CodeBlock objects
     6        https://bugs.webkit.org/show_bug.cgi?id=42490
     7
     8        * runtime/Executable.cpp:
     9        (JSC::EvalExecutable::EvalExecutable): Moved this here and made it non-inline.
     10        Eliminated the code that used to initialize the raw pointer since it's now
     11        an OwnPtr.
     12        (JSC::EvalExecutable::~EvalExecutable): Removed the explicit delete here.
     13        (JSC::ProgramExecutable::ProgramExecutable): Ditto.
     14        (JSC::ProgramExecutable::~ProgramExecutable): Ditto.
     15        (JSC::FunctionExecutable::FunctionExecutable): Ditto.
     16        (JSC::FunctionExecutable::~FunctionExecutable): Ditto.
     17        (JSC::EvalExecutable::compileInternal): Added use of adoptPtr and get.
     18        (JSC::ProgramExecutable::compileInternal): Ditto.
     19        (JSC::FunctionExecutable::compileForCallInternal): Ditto.
     20        (JSC::FunctionExecutable::compileForConstructInternal): Ditto.
     21        (JSC::FunctionExecutable::recompile): Use clear instead of delete followed
     22        by assignment of 0.
     23
     24        * runtime/Executable.h: Moved constructors to the cpp file and changed
     25        raw pointers to OwnPtr.
     26
    1272010-07-19  Lucas De Marchi  <lucas.demarchi@profusion.mobi>
    228
  • trunk/JavaScriptCore/runtime/Executable.cpp

    r63267 r63675  
    4646}
    4747
     48EvalExecutable::EvalExecutable(ExecState* exec, const SourceCode& source)
     49    : ScriptExecutable(exec, source)
     50{
     51}
     52
    4853EvalExecutable::~EvalExecutable()
    4954{
    50     delete m_evalCodeBlock;
     55}
     56
     57ProgramExecutable::ProgramExecutable(ExecState* exec, const SourceCode& source)
     58    : ScriptExecutable(exec, source)
     59{
    5160}
    5261
    5362ProgramExecutable::~ProgramExecutable()
    5463{
    55     delete m_programCodeBlock;
     64}
     65
     66FunctionExecutable::FunctionExecutable(JSGlobalData* globalData, const Identifier& name, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, int firstLine, int lastLine)
     67    : ScriptExecutable(globalData, source)
     68    , m_numVariables(0)
     69    , m_forceUsesArguments(forceUsesArguments)
     70    , m_parameters(parameters)
     71    , m_name(name)
     72    , m_symbolTable(0)
     73{
     74    m_firstLine = firstLine;
     75    m_lastLine = lastLine;
     76}
     77
     78FunctionExecutable::FunctionExecutable(ExecState* exec, const Identifier& name, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, int firstLine, int lastLine)
     79    : ScriptExecutable(exec, source)
     80    , m_numVariables(0)
     81    , m_forceUsesArguments(forceUsesArguments)
     82    , m_parameters(parameters)
     83    , m_name(name)
     84    , m_symbolTable(0)
     85{
     86    m_firstLine = firstLine;
     87    m_lastLine = lastLine;
    5688}
    5789
    5890FunctionExecutable::~FunctionExecutable()
    5991{
    60     delete m_codeBlockForCall;
    61     delete m_codeBlockForConstruct;
    6292}
    6393
     
    78108
    79109    ASSERT(!m_evalCodeBlock);
    80     m_evalCodeBlock = new EvalCodeBlock(this, globalObject, source().provider(), scopeChain.localDepth());
    81     OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(evalNode.get(), globalObject->debugger(), scopeChain, m_evalCodeBlock->symbolTable(), m_evalCodeBlock)));
     110    m_evalCodeBlock = adoptPtr(new EvalCodeBlock(this, globalObject, source().provider(), scopeChain.localDepth()));
     111    OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(evalNode.get(), globalObject->debugger(), scopeChain, m_evalCodeBlock->symbolTable(), m_evalCodeBlock.get())));
    82112    generator->generate();
    83113   
     
    86116#if ENABLE(JIT)
    87117    if (exec->globalData().canUseJIT()) {
    88         m_jitCodeForCall = JIT::compile(scopeChainNode->globalData, m_evalCodeBlock);
     118        m_jitCodeForCall = JIT::compile(scopeChainNode->globalData, m_evalCodeBlock.get());
    89119#if !ENABLE(OPCODE_SAMPLING)
    90120        if (!BytecodeGenerator::dumpsGeneratedCode())
     
    126156    JSGlobalObject* globalObject = scopeChain.globalObject();
    127157   
    128     m_programCodeBlock = new ProgramCodeBlock(this, GlobalCode, globalObject, source().provider());
    129     OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(programNode.get(), globalObject->debugger(), scopeChain, &globalObject->symbolTable(), m_programCodeBlock)));
     158    m_programCodeBlock = adoptPtr(new ProgramCodeBlock(this, GlobalCode, globalObject, source().provider()));
     159    OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(programNode.get(), globalObject->debugger(), scopeChain, &globalObject->symbolTable(), m_programCodeBlock.get())));
    130160    generator->generate();
    131161
     
    134164#if ENABLE(JIT)
    135165    if (exec->globalData().canUseJIT()) {
    136         m_jitCodeForCall = JIT::compile(scopeChainNode->globalData, m_programCodeBlock);
     166        m_jitCodeForCall = JIT::compile(scopeChainNode->globalData, m_programCodeBlock.get());
    137167#if !ENABLE(OPCODE_SAMPLING)
    138168        if (!BytecodeGenerator::dumpsGeneratedCode())
     
    163193
    164194    ASSERT(!m_codeBlockForCall);
    165     m_codeBlockForCall = new FunctionCodeBlock(this, FunctionCode, source().provider(), source().startOffset(), false);
    166     OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(body.get(), globalObject->debugger(), scopeChain, m_codeBlockForCall->symbolTable(), m_codeBlockForCall)));
     195    m_codeBlockForCall = adoptPtr(new FunctionCodeBlock(this, FunctionCode, source().provider(), source().startOffset(), false));
     196    OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(body.get(), globalObject->debugger(), scopeChain, m_codeBlockForCall->symbolTable(), m_codeBlockForCall.get())));
    167197    generator->generate();
    168198    m_numParametersForCall = m_codeBlockForCall->m_numParameters;
     
    175205#if ENABLE(JIT)
    176206    if (exec->globalData().canUseJIT()) {
    177         m_jitCodeForCall = JIT::compile(scopeChainNode->globalData, m_codeBlockForCall, &m_jitCodeForCallWithArityCheck);
     207        m_jitCodeForCall = JIT::compile(scopeChainNode->globalData, m_codeBlockForCall.get(), &m_jitCodeForCallWithArityCheck);
    178208#if !ENABLE(OPCODE_SAMPLING)
    179209        if (!BytecodeGenerator::dumpsGeneratedCode())
     
    204234
    205235    ASSERT(!m_codeBlockForConstruct);
    206     m_codeBlockForConstruct = new FunctionCodeBlock(this, FunctionCode, source().provider(), source().startOffset(), true);
    207     OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(body.get(), globalObject->debugger(), scopeChain, m_codeBlockForConstruct->symbolTable(), m_codeBlockForConstruct)));
     236    m_codeBlockForConstruct = adoptPtr(new FunctionCodeBlock(this, FunctionCode, source().provider(), source().startOffset(), true));
     237    OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(body.get(), globalObject->debugger(), scopeChain, m_codeBlockForConstruct->symbolTable(), m_codeBlockForConstruct.get())));
    208238    generator->generate();
    209239    m_numParametersForConstruct = m_codeBlockForConstruct->m_numParameters;
     
    216246#if ENABLE(JIT)
    217247    if (exec->globalData().canUseJIT()) {
    218         m_jitCodeForConstruct = JIT::compile(scopeChainNode->globalData, m_codeBlockForConstruct, &m_jitCodeForConstructWithArityCheck);
     248        m_jitCodeForConstruct = JIT::compile(scopeChainNode->globalData, m_codeBlockForConstruct.get(), &m_jitCodeForConstructWithArityCheck);
    219249#if !ENABLE(OPCODE_SAMPLING)
    220250        if (!BytecodeGenerator::dumpsGeneratedCode())
     
    299329void FunctionExecutable::recompile(ExecState*)
    300330{
    301     delete m_codeBlockForCall;
    302     m_codeBlockForCall = 0;
    303     delete m_codeBlockForConstruct;
    304     m_codeBlockForConstruct = 0;
     331    m_codeBlockForCall.clear();
     332    m_codeBlockForConstruct.clear();
    305333    m_numParametersForCall = NUM_PARAMETERS_NOT_COMPILED;
    306334    m_numParametersForConstruct = NUM_PARAMETERS_NOT_COMPILED;
  • trunk/JavaScriptCore/runtime/Executable.h

    r63404 r63675  
    221221
    222222    private:
    223         EvalExecutable(ExecState* exec, const SourceCode& source)
    224             : ScriptExecutable(exec, source)
    225             , m_evalCodeBlock(0)
    226         {
    227         }
     223        EvalExecutable(ExecState*, const SourceCode&);
    228224
    229225        JSObject* compileInternal(ExecState*, ScopeChainNode*);
     
    231227        virtual PassOwnPtr<ExceptionInfo> reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*);
    232228
    233         EvalCodeBlock* m_evalCodeBlock;
     229        OwnPtr<EvalCodeBlock> m_evalCodeBlock;
    234230    };
    235231
     
    268264
    269265    private:
    270         ProgramExecutable(ExecState* exec, const SourceCode& source)
    271             : ScriptExecutable(exec, source)
    272             , m_programCodeBlock(0)
    273         {
    274         }
     266        ProgramExecutable(ExecState*, const SourceCode&);
    275267
    276268        JSObject* compileInternal(ExecState*, ScopeChainNode*);
     
    278270        virtual PassOwnPtr<ExceptionInfo> reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*);
    279271
    280         ProgramCodeBlock* m_programCodeBlock;
     272        OwnPtr<ProgramCodeBlock> m_programCodeBlock;
    281273    };
    282274
     
    359351
    360352        void recompile(ExecState*);
    361         void markAggregate(MarkStack& markStack);
     353        void markAggregate(MarkStack&);
    362354        static PassRefPtr<FunctionExecutable> fromGlobalCode(const Identifier&, ExecState*, Debugger*, const SourceCode&, JSObject** exception);
    363355
    364356    private:
    365         FunctionExecutable(JSGlobalData* globalData, const Identifier& name, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, int firstLine, int lastLine)
    366             : ScriptExecutable(globalData, source)
    367             , m_numVariables(0)
    368             , m_forceUsesArguments(forceUsesArguments)
    369             , m_parameters(parameters)
    370             , m_codeBlockForCall(0)
    371             , m_codeBlockForConstruct(0)
    372             , m_name(name)
    373             , m_symbolTable(0)
    374         {
    375             m_firstLine = firstLine;
    376             m_lastLine = lastLine;
    377         }
    378 
    379         FunctionExecutable(ExecState* exec, const Identifier& name, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, int firstLine, int lastLine)
    380             : ScriptExecutable(exec, source)
    381             , m_numVariables(0)
    382             , m_forceUsesArguments(forceUsesArguments)
    383             , m_parameters(parameters)
    384             , m_codeBlockForCall(0)
    385             , m_codeBlockForConstruct(0)
    386             , m_name(name)
    387             , m_symbolTable(0)
    388         {
    389             m_firstLine = firstLine;
    390             m_lastLine = lastLine;
    391         }
     357        FunctionExecutable(JSGlobalData*, const Identifier& name, const SourceCode&, bool forceUsesArguments, FunctionParameters*, int firstLine, int lastLine);
     358        FunctionExecutable(ExecState*, const Identifier& name, const SourceCode&, bool forceUsesArguments, FunctionParameters*, int firstLine, int lastLine);
    392359
    393360        JSObject* compileForCallInternal(ExecState*, ScopeChainNode*);
     
    400367
    401368        RefPtr<FunctionParameters> m_parameters;
    402         FunctionCodeBlock* m_codeBlockForCall;
    403         FunctionCodeBlock* m_codeBlockForConstruct;
     369        OwnPtr<FunctionCodeBlock> m_codeBlockForCall;
     370        OwnPtr<FunctionCodeBlock> m_codeBlockForConstruct;
    404371        Identifier m_name;
    405372        SharedSymbolTable* m_symbolTable;
Note: See TracChangeset for help on using the changeset viewer.