Ignore:
Timestamp:
Aug 21, 2009, 12:48:59 AM (16 years ago)
Author:
[email protected]
Message:

Browser hangs on opening Web Inspector.
https://bugs.webkit.org/show_bug.cgi?id=28438

Reviewed by Maciej Stachowiak.

Code generation needs to be able to walk the entire scopechain in some
cases, however the symbol table used by activations was a member of the
codeblock. Following recompilation this may no longer exist, leading
to a crash or hang on lookup.

We fix this by introducing a refcounted SymbolTable subclass, SharedSymbolTable,
for the CodeBlocks used by function code. This allows activations to
maintain ownership of a copy of the symbol table even after recompilation so
they can continue to work.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/bytecode/CodeBlock.h

    r47597 r47627  
    262262        friend class JIT;
    263263    protected:
    264         CodeBlock(ExecutableBase* ownerExecutable, CodeType, PassRefPtr<SourceProvider>, unsigned sourceOffset);
     264        CodeBlock(ExecutableBase* ownerExecutable, CodeType, PassRefPtr<SourceProvider>, unsigned sourceOffset, SymbolTable* symbolTable);
    265265    public:
    266         ~CodeBlock();
     266        virtual ~CodeBlock();
    267267
    268268        void markAggregate(MarkStack&);
     
    467467
    468468
    469         SymbolTable& symbolTable() { return m_symbolTable; }
     469        SymbolTable* symbolTable() { return m_symbolTable; }
     470        SharedSymbolTable* sharedSymbolTable() { ASSERT(m_codeType == FunctionCode); return static_cast<SharedSymbolTable*>(m_symbolTable); }
    470471
    471472        EvalCodeCache& evalCodeCache() { createRareDataIfNecessary(); return m_rareData->m_evalCodeCache; }
     
    531532        Vector<RefPtr<FunctionExecutable> > m_functionExprs;
    532533
    533         SymbolTable m_symbolTable;
     534        SymbolTable* m_symbolTable;
    534535
    535536        OwnPtr<ExceptionInfo> m_exceptionInfo;
     
    561562    public:
    562563        GlobalCodeBlock(ExecutableBase* ownerExecutable, CodeType codeType, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset, JSGlobalObject* globalObject)
    563             : CodeBlock(ownerExecutable, codeType, sourceProvider, sourceOffset)
     564            : CodeBlock(ownerExecutable, codeType, sourceProvider, sourceOffset, &m_unsharedSymbolTable)
    564565            , m_globalObject(globalObject)
    565566        {
     
    577578    private:
    578579        JSGlobalObject* m_globalObject; // For program and eval nodes, the global object that marks the constant pool.
     580        SymbolTable m_unsharedSymbolTable;
    579581    };
    580582
     
    612614    class FunctionCodeBlock : public CodeBlock {
    613615    public:
     616        // Rather than using the usual RefCounted::create idiom for SharedSymbolTable we just use new
     617        // as we need to initialise the CodeBlock before we could initialise any RefPtr to hold the shared
     618        // symbol table, so we just pass as a raw pointer with a ref count of 1.  We then manually deref
     619        // in the destructor.
    614620        FunctionCodeBlock(FunctionExecutable* ownerExecutable, CodeType codeType, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset)
    615             : CodeBlock(ownerExecutable, codeType, sourceProvider, sourceOffset)
    616         {
     621            : CodeBlock(ownerExecutable, codeType, sourceProvider, sourceOffset, new SharedSymbolTable)
     622        {
     623        }
     624        ~FunctionCodeBlock()
     625        {
     626            sharedSymbolTable()->deref();
    617627        }
    618628    };
Note: See TracChangeset for help on using the changeset viewer.