Changeset 44844 in webkit for trunk/JavaScriptCore/bytecode


Ignore:
Timestamp:
Jun 19, 2009, 12:10:49 AM (16 years ago)
Author:
[email protected]
Message:

Bug 26532: Native functions do not correctly unlink from optimised callsites when they're collected
<https://bugs.webkit.org/show_bug.cgi?id=26532> <rdar://problem/6625385>

Reviewed by Gavin "Viceroy of Venezuela" Barraclough.

We need to make sure that each native function instance correctly unlinks any references to it
when it is collected. Allowing this to happen required a few changes:

  • Every native function needs a codeblock to track the link information
  • To have this codeblock, every function now also needs its own functionbodynode so we no longer get to have a single shared instance.
  • Identifying a host function is now done by looking for CodeBlock::codeType() == NativeCode
Location:
trunk/JavaScriptCore/bytecode
Files:
2 edited

Legend:

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

    r44076 r44844  
    12661266}
    12671267
     1268CodeBlock::CodeBlock(ScopeNode* ownerNode)
     1269    : m_numCalleeRegisters(0)
     1270    , m_numConstants(0)
     1271    , m_numVars(0)
     1272    , m_numParameters(0)
     1273    , m_ownerNode(ownerNode)
     1274    , m_globalData(0)
     1275#ifndef NDEBUG
     1276    , m_instructionCount(0)
     1277#endif
     1278    , m_needsFullScopeChain(false)
     1279    , m_usesEval(false)
     1280    , m_isNumericCompareFunction(false)
     1281    , m_codeType(NativeCode)
     1282    , m_source(0)
     1283    , m_sourceOffset(0)
     1284    , m_exceptionInfo(0)
     1285{
     1286#if DUMP_CODE_BLOCK_STATISTICS
     1287    liveCodeBlockSet.add(this);
     1288#endif
     1289}
    12681290
    12691291CodeBlock::CodeBlock(ScopeNode* ownerNode, CodeType codeType, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset)
     
    13431365void CodeBlock::derefStructures(Instruction* vPC) const
    13441366{
     1367    ASSERT(m_codeType != NativeCode);
    13451368    Interpreter* interpreter = m_globalData->interpreter;
    13461369
     
    13881411void CodeBlock::refStructures(Instruction* vPC) const
    13891412{
     1413    ASSERT(m_codeType != NativeCode);
    13901414    Interpreter* interpreter = m_globalData->interpreter;
    13911415
     
    14421466void CodeBlock::reparseForExceptionInfoIfNecessary(CallFrame* callFrame)
    14431467{
     1468    ASSERT(m_codeType != NativeCode);
    14441469    if (m_exceptionInfo)
    14451470        return;
     
    15121537HandlerInfo* CodeBlock::handlerForBytecodeOffset(unsigned bytecodeOffset)
    15131538{
     1539    ASSERT(m_codeType != NativeCode);
    15141540    ASSERT(bytecodeOffset < m_instructionCount);
    15151541
     
    15301556int CodeBlock::lineNumberForBytecodeOffset(CallFrame* callFrame, unsigned bytecodeOffset)
    15311557{
     1558    ASSERT(m_codeType != NativeCode);
    15321559    ASSERT(bytecodeOffset < m_instructionCount);
    15331560
     
    15551582int CodeBlock::expressionRangeForBytecodeOffset(CallFrame* callFrame, unsigned bytecodeOffset, int& divot, int& startOffset, int& endOffset)
    15561583{
     1584    ASSERT(m_codeType != NativeCode);
    15571585    ASSERT(bytecodeOffset < m_instructionCount);
    15581586
     
    15941622bool CodeBlock::getByIdExceptionInfoForBytecodeOffset(CallFrame* callFrame, unsigned bytecodeOffset, OpcodeID& opcodeID)
    15951623{
     1624    ASSERT(m_codeType != NativeCode);
    15961625    ASSERT(bytecodeOffset < m_instructionCount);
    15971626
     
    16221651bool CodeBlock::functionRegisterForBytecodeOffset(unsigned bytecodeOffset, int& functionRegisterIndex)
    16231652{
     1653    ASSERT(m_codeType != NativeCode);
    16241654    ASSERT(bytecodeOffset < m_instructionCount);
    16251655
     
    16481678bool CodeBlock::hasGlobalResolveInstructionAtBytecodeOffset(unsigned bytecodeOffset)
    16491679{
     1680    ASSERT(m_codeType != NativeCode);
    16501681    if (m_globalResolveInstructions.isEmpty())
    16511682        return false;
     
    16681699bool CodeBlock::hasGlobalResolveInfoAtBytecodeOffset(unsigned bytecodeOffset)
    16691700{
     1701    ASSERT(m_codeType != NativeCode);
    16701702    if (m_globalResolveInfos.isEmpty())
    16711703        return false;
     
    16901722void CodeBlock::setJITCode(JITCode jitCode)
    16911723{
     1724    ASSERT(m_codeType != NativeCode);
    16921725    ownerNode()->setJITCode(jitCode);
    16931726#if !ENABLE(OPCODE_SAMPLING)
  • trunk/JavaScriptCore/bytecode/CodeBlock.h

    r44711 r44844  
    5050    class ExecState;
    5151
    52     enum CodeType { GlobalCode, EvalCode, FunctionCode };
     52    enum CodeType { GlobalCode, EvalCode, FunctionCode, NativeCode };
    5353
    5454    static ALWAYS_INLINE int missingThisObjectMarker() { return std::numeric_limits<int>::max(); }
     
    218218        friend class JIT;
    219219    public:
     220        CodeBlock(ScopeNode* ownerNode);
    220221        CodeBlock(ScopeNode* ownerNode, CodeType, PassRefPtr<SourceProvider>, unsigned sourceOffset);
    221222        ~CodeBlock();
     
    340341        CodeType codeType() const { return m_codeType; }
    341342
    342         SourceProvider* source() const { return m_source.get(); }
    343         unsigned sourceOffset() const { return m_sourceOffset; }
     343        SourceProvider* source() const { ASSERT(m_codeType != NativeCode); return m_source.get(); }
     344        unsigned sourceOffset() const { ASSERT(m_codeType != NativeCode); return m_sourceOffset; }
    344345
    345346        size_t numberOfJumpTargets() const { return m_jumpTargets.size(); }
     
    433434        SymbolTable& symbolTable() { return m_symbolTable; }
    434435
    435         EvalCodeCache& evalCodeCache() { createRareDataIfNecessary(); return m_rareData->m_evalCodeCache; }
     436        EvalCodeCache& evalCodeCache() { ASSERT(m_codeType != NativeCode); createRareDataIfNecessary(); return m_rareData->m_evalCodeCache; }
    436437
    437438        void shrinkToFit();
     
    457458        void createRareDataIfNecessary()
    458459        {
     460            ASSERT(m_codeType != NativeCode);
    459461            if (!m_rareData)
    460462                m_rareData.set(new RareData);
Note: See TracChangeset for help on using the changeset viewer.