2008-05-22 Kevin McCullough <kmccullough@apple.com>
authorkmccullough@apple.com <kmccullough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 May 2008 22:09:43 +0000 (22:09 +0000)
committerkmccullough@apple.com <kmccullough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 May 2008 22:09:43 +0000 (22:09 +0000)
commit2769cd10dd31ad00a73df9f2dd2fe01e7ba5b98c
treed9129dbef97172839bd3a0ffadb7e4e35eb22411
parente44c4ea11e0edc7f5c93f8e7c53450d61d8c278d
2008-05-22  Kevin McCullough  <kmccullough@apple.com>

        Reviewed by Sam.

        <rdar://problem/5951561> Turn on JavaScript Profiler
        Get basic JS profiling working.
        Even with this patch the profiler will not be compiled in because we do
        not know the extend, if any, of the performance regression it would cause
        when it is not in use. However with these changes, if the profiler were
        on, it would not crash and show good profiling data.

        * VM/Machine.cpp: Instrument the calls sites that are needed for profiling.
        (KJS::callEval):
        (KJS::Machine::unwindCallFrame):
        (KJS::Machine::execute):
        (KJS::Machine::privateExecute):
        * kjs/function.cpp: Ditto.
        (KJS::globalFuncEval):
        * kjs/interpreter.cpp: Ditto.
        (KJS::Interpreter::evaluate):
        * profiler/Profile.cpp:
        (KJS::Profile::willExecute):
        (KJS::Profile::didExecute): Because we do not get a good context when
        startProfiling is called it is possible that m_currentNode will be at the
        top of the known stack when a didExecute() is called.  What we then do is
        create a new node that represents the function being exited and insert
        it between the head and the currently known children, since they should
        be children of this new node.
        * profiler/ProfileNode.cpp:
        (KJS::ProfileNode::ProfileNode):
        (KJS::ProfileNode::willExecute): Rename the add function for consistency.
        (KJS::ProfileNode::addChild): Appends the child to this node but also
        sets the parent pointer of the children to this node.
        (KJS::ProfileNode::insertNode): Insert a node between this node and its
        children.  Also set the time for the new node since it is now exiting
        and we don't really know when it started.
        (KJS::ProfileNode::stopProfiling):
        (KJS::ProfileNode::startTimer):
        * profiler/ProfileNode.h:
        (KJS::CallIdentifier::toString): Added for debugging.
        (KJS::ProfileNode::setParent):
        (KJS::ProfileNode::setSelfTime): Fixed an old bug where we set the
        visibleTotalTime not the visibleSelfTime.
        (KJS::ProfileNode::children):
        (KJS::ProfileNode::toString): Added for debugging.
        * profiler/Profiler.cpp: remove unecessary calls.
        (KJS::Profiler::startProfiling):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@34036 268f45cc-cd09-0410-ab3c-d52691b4dbfc
JavaScriptCore/ChangeLog
JavaScriptCore/VM/Machine.cpp
JavaScriptCore/kjs/function.cpp
JavaScriptCore/kjs/interpreter.cpp
JavaScriptCore/profiler/Profile.cpp
JavaScriptCore/profiler/ProfileNode.cpp
JavaScriptCore/profiler/ProfileNode.h
JavaScriptCore/profiler/Profiler.cpp