X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/f9bf01c6616d5ddcf65b13b33cedf9e387ff7a63..12899fa232562c774004a3a9d7d3149944dec712:/profiler/ProfileNode.cpp diff --git a/profiler/ProfileNode.cpp b/profiler/ProfileNode.cpp index fb126b3..5b6a254 100644 --- a/profiler/ProfileNode.cpp +++ b/profiler/ProfileNode.cpp @@ -29,9 +29,11 @@ #include "config.h" #include "ProfileNode.h" -#include "Profiler.h" +#include "LegacyProfiler.h" #include #include +#include +#include #if OS(WINDOWS) #include @@ -44,7 +46,7 @@ namespace JSC { static double getCount() { #if OS(WINDOWS) - static LARGE_INTEGER frequency = {0}; + static LARGE_INTEGER frequency; if (!frequency.QuadPart) QueryPerformanceFrequency(&frequency); LARGE_INTEGER counter; @@ -55,8 +57,9 @@ static double getCount() #endif } -ProfileNode::ProfileNode(const CallIdentifier& callIdentifier, ProfileNode* headNode, ProfileNode* parentNode) - : m_callIdentifier(callIdentifier) +ProfileNode::ProfileNode(ExecState* callerCallFrame, const CallIdentifier& callIdentifier, ProfileNode* headNode, ProfileNode* parentNode) + : m_callerCallFrame(callerCallFrame) + , m_callIdentifier(callIdentifier) , m_head(headNode) , m_parent(parentNode) , m_nextSibling(0) @@ -71,8 +74,9 @@ ProfileNode::ProfileNode(const CallIdentifier& callIdentifier, ProfileNode* head startTimer(); } -ProfileNode::ProfileNode(ProfileNode* headNode, ProfileNode* nodeToCopy) - : m_callIdentifier(nodeToCopy->callIdentifier()) +ProfileNode::ProfileNode(ExecState* callerCallFrame, ProfileNode* headNode, ProfileNode* nodeToCopy) + : m_callerCallFrame(callerCallFrame) + , m_callIdentifier(nodeToCopy->callIdentifier()) , m_head(headNode) , m_parent(nodeToCopy->parent()) , m_nextSibling(0) @@ -86,7 +90,7 @@ ProfileNode::ProfileNode(ProfileNode* headNode, ProfileNode* nodeToCopy) { } -ProfileNode* ProfileNode::willExecute(const CallIdentifier& callIdentifier) +ProfileNode* ProfileNode::willExecute(ExecState* callerCallFrame, const CallIdentifier& callIdentifier) { for (StackIterator currentChild = m_children.begin(); currentChild != m_children.end(); ++currentChild) { if ((*currentChild)->callIdentifier() == callIdentifier) { @@ -95,7 +99,7 @@ ProfileNode* ProfileNode::willExecute(const CallIdentifier& callIdentifier) } } - RefPtr newChild = ProfileNode::create(callIdentifier, m_head ? m_head : this, this); // If this ProfileNode has no head it is the head. + RefPtr newChild = ProfileNode::create(callerCallFrame, callIdentifier, m_head ? m_head : this, this); // If this ProfileNode has no head it is the head. if (m_children.size()) m_children.last()->setNextSibling(newChild.get()); m_children.append(newChild.release()); @@ -290,14 +294,14 @@ void ProfileNode::debugPrintData(int indentLevel) const { // Print function names for (int i = 0; i < indentLevel; ++i) - printf(" "); + dataLogF(" "); - printf("Function Name %s %d SelfTime %.3fms/%.3f%% TotalTime %.3fms/%.3f%% VSelf %.3fms VTotal %.3fms Visible %s Next Sibling %s\n", - functionName().UTF8String().c_str(), + dataLogF("Function Name %s %d SelfTime %.3fms/%.3f%% TotalTime %.3fms/%.3f%% VSelf %.3fms VTotal %.3fms Visible %s Next Sibling %s\n", + functionName().utf8().data(), m_numberOfCalls, m_actualSelfTime, selfPercent(), m_actualTotalTime, totalPercent(), m_visibleSelfTime, m_visibleTotalTime, (m_visible ? "True" : "False"), - m_nextSibling ? m_nextSibling->functionName().UTF8String().c_str() : ""); + m_nextSibling ? m_nextSibling->functionName().utf8().data() : ""); ++indentLevel; @@ -309,20 +313,20 @@ void ProfileNode::debugPrintData(int indentLevel) const // print the profiled data in a format that matches the tool sample's output. double ProfileNode::debugPrintDataSampleStyle(int indentLevel, FunctionCallHashCount& countedFunctions) const { - printf(" "); + dataLogF(" "); // Print function names - const char* name = functionName().UTF8String().c_str(); + const char* name = functionName().utf8().data(); double sampleCount = m_actualTotalTime * 1000; if (indentLevel) { for (int i = 0; i < indentLevel; ++i) - printf(" "); + dataLogF(" "); - countedFunctions.add(functionName().rep()); + countedFunctions.add(functionName().impl()); - printf("%.0f %s\n", sampleCount ? sampleCount : 1, name); + dataLogF("%.0f %s\n", sampleCount ? sampleCount : 1, name); } else - printf("%s\n", name); + dataLogF("%s\n", name); ++indentLevel; @@ -334,11 +338,11 @@ double ProfileNode::debugPrintDataSampleStyle(int indentLevel, FunctionCallHashC sumOfChildrensCount *= 1000; // // Print remainder of samples to match sample's output if (sumOfChildrensCount < sampleCount) { - printf(" "); + dataLogF(" "); while (indentLevel--) - printf(" "); + dataLogF(" "); - printf("%.0f %s\n", sampleCount - sumOfChildrensCount, functionName().UTF8String().c_str()); + dataLogF("%.0f %s\n", sampleCount - sumOfChildrensCount, functionName().utf8().data()); } return m_actualTotalTime;