Ignore:
Timestamp:
Jun 24, 2008, 2:22:21 PM (17 years ago)
Author:
[email protected]
Message:

2008-06-24 Kevin McCullough <[email protected]>

Reviewed by Tim.

<rdar://problem/6031594> JSProfiler: Profiler goes into an infinite
loop sometimes.
<rdar://problem/6031603> JSProfiler: Profiler asserts in debug and
give the wrong times in release

Fixed two issues found by Tim in the same test.

  • profiler/Profile.cpp: (KJS::Profile::removeProfileStart): No longer take profile's time from all ancestors, but instead attribute it to its parent. Also add an Assert to ensure we only delete the child we mean to. (KJS::Profile::removeProfileEnd): Ditto for profileEnd. (KJS::Profile::didExecute): Cleaned up the execution order and correctly attribute all of the parent's time to the new node.
  • profiler/ProfileNode.cpp: If this node does not have a startTime it should not get a giant total time, but instead be 0. (KJS::ProfileNode::endAndRecordCall):
  • profiler/ProfileNode.h: (KJS::ProfileNode::removeChild): Should reset the sibling pointers since one of them has been removed.
File:
1 edited

Legend:

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

    r34712 r34778  
    100100        return;
    101101
    102     for (ProfileNode* currentParent = currentNode->parent(); currentParent; currentParent = currentParent->parent())
    103         currentParent->setTotalTime(currentParent->totalTime() - currentNode->totalTime());
    104 
     102    // Attribute the time of the node aobut to be removed to the self time of its parent
     103    currentNode->parent()->setSelfTime(currentNode->parent()->selfTime() + currentNode->totalTime());
     104
     105    ASSERT(currentNode->callIdentifier() == (currentNode->parent()->children()[0])->callIdentifier());
    105106    currentNode->parent()->removeChild(0);
    106107}
     
    115116        return;
    116117
    117     for (ProfileNode* currentParent = currentNode->parent(); currentParent; currentParent = currentParent->parent())
    118         currentParent->setTotalTime(currentParent->totalTime() - currentNode->totalTime());
    119 
     118    // Attribute the time of the node aobut to be removed to the self time of its parent
     119    currentNode->parent()->setSelfTime(currentNode->parent()->selfTime() + currentNode->totalTime());
     120
     121    ASSERT(currentNode->callIdentifier() == (currentNode->parent()->children()[currentNode->parent()->children().size() - 1])->callIdentifier());
    120122    currentNode->parent()->removeChild(currentNode->parent()->children().size() - 1);
    121123}
     
    139141        m_currentNode->setStartTime(m_head->startTime());
    140142        m_currentNode->didExecute();
    141         m_head->insertNode(m_currentNode.get());
    142143
    143144        if (m_stoppedProfiling) {
    144             m_currentNode->setTotalTime(m_currentNode->totalTime() + m_head->selfTime());
     145            m_currentNode->setTotalTime(m_head->totalTime());
     146            m_currentNode->setSelfTime(m_head->selfTime());
    145147            m_head->setSelfTime(0.0);
    146             m_currentNode->stopProfiling();
    147             m_currentNode = 0;
    148         } else
    149             m_currentNode = m_head;
     148        }
     149
     150        m_head->insertNode(m_currentNode.release());           
     151        m_currentNode = m_stoppedProfiling ? 0 : m_head;
    150152
    151153        return;
Note: See TracChangeset for help on using the changeset viewer.