Ignore:
Timestamp:
Jun 25, 2008, 2:44:42 PM (17 years ago)
Author:
[email protected]
Message:

Fixes an ASSERT in the profiler when starting multiple profiles
with the same name inside the same function/program.

Reviewed by Kevin McCullough.

  • profiler/Profile.cpp: (KJS::Profile::Profile): Initialize m_stoppedCallDepth to zero. (KJS::Profile::stopProfiling): Set the current node to the parent, because we are in a call that will not get a didExecute call. (KJS::Profile::removeProfile): Increment m_stoppedCallDepth to account for didExecute not being called for profile. (KJS::Profile::willExecute): Increment m_stoppedCallDepth if stopped. (KJS::Profile::didExecute): Decrement m_stoppedCallDepth if stopped and greater than zero, and return early.
  • profiler/Profile.h: Added stoppedProfiling().
  • profiler/Profiler.cpp: (KJS::Profiler::findProfile): Removed. (KJS::Profiler::startProfiling): Don't return early for stopped profiles. (KJS::Profiler::stopProfiling): Skipp stopped profiles. (KJS::Profiler::didFinishAllExecution): Code clean-up.
  • profiler/Profiler.h: Removed findProfile.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/profiler/Profile.cpp

    r34778 r34800  
    4747    , m_originatingGlobalExec(originatingGlobalExec)
    4848    , m_pageGroupIdentifier(pageGroupIdentifier)
     49    , m_stoppedCallDepth(0)
    4950    , m_client(client)
    5051    , m_stoppedProfiling(false)
     
    6263    removeProfileEnd();
    6364
    64     // Already at the head, set m_currentNode to prevent
    65     // didExecute from recording more nodes.
    66     if (m_currentNode == m_head)
    67         m_currentNode = 0;
     65    ASSERT(m_currentNode);
     66
     67    // Set the current node to the parent, because we are in a call that
     68    // will not get didExecute call.
     69    m_currentNode = m_currentNode->parent();
    6870
    6971    m_stoppedProfiling = true;
     
    100102        return;
    101103
     104    // Increment m_stoppedCallDepth to account for didExecute not being called for console.profile.
     105    ++m_stoppedCallDepth;
     106
    102107    // Attribute the time of the node aobut to be removed to the self time of its parent
    103108    currentNode->parent()->setSelfTime(currentNode->parent()->selfTime() + currentNode->totalTime());
     
    125130void Profile::willExecute(const CallIdentifier& callIdentifier)
    126131{
    127     if (m_stoppedProfiling)
    128         return;
     132    if (m_stoppedProfiling) {
     133        ++m_stoppedCallDepth;
     134        return;
     135    }
    129136
    130137    ASSERT(m_currentNode);
     
    136143    if (!m_currentNode)
    137144        return;
     145
     146    if (m_stoppedProfiling && m_stoppedCallDepth > 0) {
     147        --m_stoppedCallDepth;
     148        return;
     149    }
    138150
    139151    if (m_currentNode == m_head) {
     
    154166    }
    155167
    156     if (m_stoppedProfiling) {
    157         m_currentNode = m_currentNode->parent();
    158         return;
    159     }
    160 
    161     m_currentNode = m_currentNode->didExecute();
     168    // Set m_currentNode to the parent (which didExecute returns). If stopped, just set the
     169    // m_currentNode to the parent and don't call didExecute.
     170    m_currentNode = m_stoppedProfiling ? m_currentNode->parent() : m_currentNode->didExecute();
    162171}
    163172
Note: See TracChangeset for help on using the changeset viewer.