Changeset 173262 in webkit for trunk/Source/JavaScriptCore/profiler/ProfileNode.cpp
- Timestamp:
- Sep 4, 2014, 10:00:22 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/profiler/ProfileNode.cpp
r173199 r173262 43 43 , m_callIdentifier(callIdentifier) 44 44 , m_parent(parentNode) 45 #ifndef NDEBUG 45 46 , m_nextSibling(nullptr) 46 { 47 startTimer(); 47 #endif 48 { 48 49 } 49 50 … … 52 53 , m_callIdentifier(nodeToCopy->callIdentifier()) 53 54 , m_parent(nodeToCopy->parent()) 55 , m_calls(nodeToCopy->calls()) 56 #ifndef NDEBUG 54 57 , m_nextSibling(nullptr) 55 , m_calls(nodeToCopy->calls()) 56 { 57 } 58 59 ProfileNode* ProfileNode::willExecute(ExecState* callerCallFrame, const CallIdentifier& callIdentifier) 60 { 61 for (StackIterator currentChild = m_children.begin(); currentChild != m_children.end(); ++currentChild) { 62 if ((*currentChild)->callIdentifier() == callIdentifier) { 63 (*currentChild)->startTimer(); 64 return (*currentChild).get(); 65 } 66 } 67 68 RefPtr<ProfileNode> newChild = ProfileNode::create(callerCallFrame, callIdentifier, this); 69 if (m_children.size()) 70 m_children.last()->setNextSibling(newChild.get()); 71 m_children.append(newChild.release()); 72 return m_children.last().get(); 73 } 74 75 ProfileNode* ProfileNode::didExecute() 76 { 77 endAndRecordCall(); 78 return m_parent; 58 #endif 59 { 79 60 } 80 61 … … 83 64 RefPtr<ProfileNode> child = prpChild; 84 65 child->setParent(this); 66 #ifndef NDEBUG 85 67 if (m_children.size()) 86 68 m_children.last()->setNextSibling(child.get()); 69 #endif 87 70 m_children.append(child.release()); 88 71 } … … 100 83 } 101 84 102 resetChildrensSiblings(); 103 } 104 105 void ProfileNode::insertNode(PassRefPtr<ProfileNode> prpNode) 85 #ifndef NDEBUG 86 size_t size = m_children.size(); 87 for (size_t i = 0; i < size; ++i) 88 m_children[i]->setNextSibling(i + 1 == size ? nullptr : m_children[i + 1].get()); 89 #endif 90 } 91 92 void ProfileNode::spliceNode(PassRefPtr<ProfileNode> prpNode) 106 93 { 107 94 RefPtr<ProfileNode> node = prpNode; … … 114 101 } 115 102 116 void ProfileNode::stopProfiling() 117 { 118 ASSERT(!m_calls.isEmpty()); 119 120 if (isnan(m_calls.last().totalTime())) 121 endAndRecordCall(); 122 } 123 103 #ifndef NDEBUG 124 104 ProfileNode* ProfileNode::traverseNextNodePostOrder() const 125 105 { … … 132 112 } 133 113 134 void ProfileNode::endAndRecordCall()135 {136 Call& last = lastCall();137 ASSERT(isnan(last.totalTime()));138 139 last.setTotalTime(currentTime() - last.startTime());140 }141 142 void ProfileNode::startTimer()143 {144 m_calls.append(Call(currentTime()));145 }146 147 void ProfileNode::resetChildrensSiblings()148 {149 unsigned size = m_children.size();150 for (unsigned i = 0; i < size; ++i)151 m_children[i]->setNextSibling(i + 1 == size ? 0 : m_children[i + 1].get());152 }153 154 #ifndef NDEBUG155 114 void ProfileNode::debugPrint() 156 115 { … … 188 147 dataLogF("Function Name %s %zu SelfTime %.3fms/%.3f%% TotalTime %.3fms/%.3f%% Next Sibling %s\n", 189 148 functionName().utf8().data(), 190 numberOfCalls(), nodeSelfTime, nodeSelfTime / rootTotalTime * 100.0, nodeTotalTime, nodeTotalTime / rootTotalTime * 100.0,149 m_calls.size(), nodeSelfTime, nodeSelfTime / rootTotalTime * 100.0, nodeTotalTime, nodeTotalTime / rootTotalTime * 100.0, 191 150 m_nextSibling ? m_nextSibling->functionName().utf8().data() : ""); 192 151
Note:
See TracChangeset
for help on using the changeset viewer.