Ignore:
Timestamp:
Sep 2, 2014, 9:58:55 PM (11 years ago)
Author:
Brian Burg
Message:

LegacyProfiler: remove redundant ProfileNode members and other cleanup
https://bugs.webkit.org/show_bug.cgi?id=136380

Reviewed by Timothy Hatcher.

Source/JavaScriptCore:

ProfileNode's selfTime and totalTime members are redundant and only used
for dumping profile data from debug-only code. Remove the members and compute
the same data on-demand when necessary using a postorder traversal functor.

Remove ProfileNode.head since it is only used to calculate percentages for
dumped profile data. This can be explicitly passed around when needed.

Rename Profile.head to Profile.rootNode, and other various renamings.

Rearrange some header includes so that touching LegacyProfiler-related headers
will no longer cause a full rebuild.

  • inspector/JSConsoleClient.cpp: Add header include.
  • inspector/agents/InspectorProfilerAgent.cpp:

(Inspector::InspectorProfilerAgent::buildProfileInspectorObject):

  • inspector/protocol/Profiler.json: Remove unused Profile.idleTime member.
  • jit/JIT.h: Remove header include.
  • jit/JITCode.h: Remove header include.
  • jit/JITOperations.cpp: Sort and add header include.
  • llint/LLIntSlowPaths.cpp: Sort and add header include.
  • profiler/Profile.cpp: Rename the debug dumping functions. Move the node

postorder traversal code to ProfileNode so we can traverse any subtree.
(JSC::Profile::Profile):
(JSC::Profile::debugPrint):
(JSC::Profile::debugPrintSampleStyle):
(JSC::Profile::forEach): Deleted.
(JSC::Profile::debugPrintData): Deleted.
(JSC::Profile::debugPrintDataSampleStyle): Deleted.

  • profiler/Profile.h:
  • profiler/ProfileGenerator.cpp:

(JSC::ProfileGenerator::ProfileGenerator):
(JSC::AddParentForConsoleStartFunctor::AddParentForConsoleStartFunctor):
(JSC::AddParentForConsoleStartFunctor::operator()):
(JSC::ProfileGenerator::addParentForConsoleStart):
(JSC::ProfileGenerator::didExecute):
(JSC::StopProfilingFunctor::operator()):
(JSC::ProfileGenerator::stopProfiling):
(JSC::ProfileGenerator::removeProfileStart):
(JSC::ProfileGenerator::removeProfileEnd):

  • profiler/ProfileGenerator.h:
  • profiler/ProfileNode.cpp:

(JSC::ProfileNode::ProfileNode):
(JSC::ProfileNode::willExecute):
(JSC::ProfileNode::removeChild):
(JSC::ProfileNode::stopProfiling):
(JSC::ProfileNode::endAndRecordCall):
(JSC::ProfileNode::debugPrint):
(JSC::ProfileNode::debugPrintSampleStyle):
(JSC::ProfileNode::debugPrintRecursively):
(JSC::ProfileNode::debugPrintSampleStyleRecursively):
(JSC::ProfileNode::debugPrintData): Deleted.
(JSC::ProfileNode::debugPrintDataSampleStyle): Deleted.

  • profiler/ProfileNode.h: Calculate per-node self and total times using a postorder traversal.

The forEachNodePostorder functor traverses the subtree rooted at |this|.
(JSC::ProfileNode::create):
(JSC::ProfileNode::calls):
(JSC::ProfileNode::forEachNodePostorder):
(JSC::CalculateProfileSubtreeDataFunctor::returnValue):
(JSC::CalculateProfileSubtreeDataFunctor::operator()):
(JSC::ProfileNode::head): Deleted.
(JSC::ProfileNode::setHead): Deleted.
(JSC::ProfileNode::totalTime): Deleted.
(JSC::ProfileNode::setTotalTime): Deleted.
(JSC::ProfileNode::selfTime): Deleted.
(JSC::ProfileNode::setSelfTime): Deleted.
(JSC::ProfileNode::totalPercent): Deleted.
(JSC::ProfileNode::selfPercent): Deleted.

  • runtime/ConsoleClient.h: Remove header include.

Source/WebCore:

Remove Profile.idleTime, rename head to rootNode, and remove ProfileNode members.

Covered by existing tests.

  • inspector/ScriptProfile.idl:
  • inspector/ScriptProfileNode.idl:
  • inspector/TimelineRecordFactory.cpp:

Source/WebInspectorUI:

Remove unused Profile.idleTime member.

  • UserInterface/Models/Profile.js:

(WebInspector.Profile.prototype.get idleTime): Deleted.

  • UserInterface/Models/ScriptTimelineRecord.js:

(WebInspector.ScriptTimelineRecord.prototype._initializeProfileFromPayload):

LayoutTests:

Renamed Profile.head to Profile.rootNode.

  • fast/profiler/resources/profiler-test-JS-resources.js:

(printHeavyProfilesDataWithoutTime):
(printProfilesDataWithoutTime):

File:
1 edited

Legend:

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

    r173120 r173199  
    4040    : m_title(title)
    4141    , m_uid(uid)
    42     , m_idleTime(0)
    4342{
    4443    // FIXME: When multi-threading is supported this will be a vector and calls
    4544    // into the profiler will need to know which thread it is executing on.
    46     m_head = ProfileNode::create(0, CallIdentifier(ASCIILiteral("Thread_1"), String(), 0, 0), 0, 0);
     45    m_rootNode = ProfileNode::create(nullptr, CallIdentifier(ASCIILiteral("Thread_1"), String(), 0, 0), nullptr);
    4746}
    4847
     
    5150}
    5251
    53 void Profile::forEach(void (ProfileNode::*function)())
     52#ifndef NDEBUG
     53void Profile::debugPrint()
    5454{
    55     ProfileNode* currentNode = m_head->firstChild();
    56     for (ProfileNode* nextNode = currentNode; nextNode; nextNode = nextNode->firstChild())
    57         currentNode = nextNode;
     55    CalculateProfileSubtreeDataFunctor functor;
     56    m_rootNode->forEachNodePostorder(functor);
     57    ProfileNode::ProfileSubtreeData data = functor.returnValue();
    5858
    59     if (!currentNode)
    60         currentNode = m_head.get();
    61 
    62     ProfileNode* endNode = m_head->traverseNextNodePostOrder();
    63     while (currentNode && currentNode != endNode) {
    64         (currentNode->*function)();
    65         currentNode = currentNode->traverseNextNodePostOrder();
    66     }
    67 }
    68 
    69 #ifndef NDEBUG
    70 void Profile::debugPrintData() const
    71 {
    7259    dataLogF("Call graph:\n");
    73     m_head->debugPrintData(0);
     60    m_rootNode->debugPrintRecursively(0, data);
    7461}
    7562
     
    8168}
    8269
    83 void Profile::debugPrintDataSampleStyle() const
     70void Profile::debugPrintSampleStyle()
    8471{
    8572    typedef Vector<NameCountPair> NameCountPairVector;
    8673
     74    CalculateProfileSubtreeDataFunctor functor;
     75    m_rootNode->forEachNodePostorder(functor);
     76    ProfileNode::ProfileSubtreeData data = functor.returnValue();
     77
    8778    FunctionCallHashCount countedFunctions;
    8879    dataLogF("Call graph:\n");
    89     m_head->debugPrintDataSampleStyle(0, countedFunctions);
     80    m_rootNode->debugPrintSampleStyleRecursively(0, countedFunctions, data);
    9081
    9182    dataLogF("\nTotal number in stack:\n");
Note: See TracChangeset for help on using the changeset viewer.