⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 98398 in webkit


Ignore:
Timestamp:
Oct 25, 2011, 2:56:31 PM (15 years ago)
Author:
fpizlo@apple.com
Message:

Tiered compilation may introduce dangling pointers in constant buffers
https://bugs.webkit.org/show_bug.cgi?id=70854

Reviewed by Oliver Hunt.

Tiered compilation now copies constant buffers, which fixes the regression in
https://bugs.webkit.org/show_bug.cgi?id=70246. No new tests because this
regression relies on a subtle interleaving of optimized compilation and garbage
collection, and cannot be reproduced in a simple test.

This also adds some new debug support, which was used to fix this bug and is
likely to be useful in the future.

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::copyDataFrom):
(JSC::CodeBlock::usesOpcode):

  • bytecode/CodeBlock.h:
  • dfg/DFGGraph.cpp:

(JSC::DFG::Graph::dump):

Location:
trunk/Source/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r98383 r98398  
     12011-10-25  Filip Pizlo  <fpizlo@apple.com>
     2
     3        Tiered compilation may introduce dangling pointers in constant buffers
     4        https://bugs.webkit.org/show_bug.cgi?id=70854
     5
     6        Reviewed by Oliver Hunt.
     7       
     8        Tiered compilation now copies constant buffers, which fixes the regression in
     9        https://bugs.webkit.org/show_bug.cgi?id=70246. No new tests because this
     10        regression relies on a subtle interleaving of optimized compilation and garbage
     11        collection, and cannot be reproduced in a simple test.
     12       
     13        This also adds some new debug support, which was used to fix this bug and is
     14        likely to be useful in the future.
     15
     16        * bytecode/CodeBlock.cpp:
     17        (JSC::CodeBlock::copyDataFrom):
     18        (JSC::CodeBlock::usesOpcode):
     19        * bytecode/CodeBlock.h:
     20        * dfg/DFGGraph.cpp:
     21        (JSC::DFG::Graph::dump):
     22
    1232011-10-25  Mark Hahnenberg  <mhahnenberg@apple.com>
    224
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r98179 r98398  
    18291829    replaceExistingEntries(m_functionDecls, alternative->m_functionDecls);
    18301830    replaceExistingEntries(m_functionExprs, alternative->m_functionExprs);
     1831    if (!!m_rareData && !!alternative->m_rareData)
     1832        replaceExistingEntries(m_rareData->m_constantBuffers, alternative->m_rareData->m_constantBuffers);
    18311833}
    18321834
     
    20032005#endif
    20042006
     2007#ifndef NDEBUG
     2008bool CodeBlock::usesOpcode(OpcodeID opcodeID)
     2009{
     2010    Interpreter* interpreter = globalData()->interpreter;
     2011    Instruction* instructionsBegin = instructions().begin();
     2012    unsigned instructionCount = instructions().size();
     2013   
     2014    for (unsigned bytecodeOffset = 0; bytecodeOffset < instructionCount; ) {
     2015        switch (interpreter->getOpcodeID(instructionsBegin[bytecodeOffset].u.opcode)) {
     2016#define DEFINE_OP(curOpcode, length)        \
     2017        case curOpcode:                     \
     2018            if (curOpcode == opcodeID)      \
     2019                return true;                \
     2020            bytecodeOffset += length;       \
     2021            break;
     2022            FOR_EACH_OPCODE_ID(DEFINE_OP)
     2023#undef DEFINE_OP
     2024        default:
     2025            ASSERT_NOT_REACHED();
     2026            break;
     2027        }
     2028    }
     2029   
     2030    return false;
     2031}
     2032#endif
     2033
    20052034} // namespace JSC
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.h

    r98220 r98398  
    391391        void discardBytecode() { m_instructions.clear(); }
    392392
     393#ifndef NDEBUG
     394        bool usesOpcode(OpcodeID);
     395#endif
     396
    393397        unsigned instructionCount() { return m_instructionCount; }
    394398        void setInstructionCount(unsigned instructionCount) { m_instructionCount = instructionCount; }
  • trunk/Source/JavaScriptCore/dfg/DFGGraph.cpp

    r98179 r98398  
    223223        hasPrinted = true;
    224224    }
     225    if (node.hasConstantBuffer() && codeBlock) {
     226        if (hasPrinted)
     227            printf(", ");
     228        printf("%u:[", node.startConstant());
     229        for (unsigned i = 0; i < node.numConstants(); ++i) {
     230            if (i)
     231                printf(", ");
     232            printf("%s", codeBlock->constantBuffer(node.startConstant())[i].description());
     233        }
     234        printf("]");
     235        hasPrinted = true;
     236    }
    225237    if (op == JSConstant) {
    226238        printf("%s$%u", hasPrinted ? ", " : "", node.constantNumber());
Note: See TracChangeset for help on using the changeset viewer.