2008-04-16 Kevin McCullough <kmccullough@apple.com>
authorkmccullough@apple.com <kmccullough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Apr 2008 19:08:03 +0000 (19:08 +0000)
committerkmccullough@apple.com <kmccullough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Apr 2008 19:08:03 +0000 (19:08 +0000)
commit38347afa51f68bfc75ab40c343c3af19b8f7cdfd
tree13a20b819c3f626822136a8268acdb2a17be5249
parent3a156ac30ef0b8fb5c42a74b3d4aebf7acd42cc6
2008-04-16  Kevin McCullough  <kmccullough@apple.com>

        Reviewed by Sam and Geoff.

        -<rdar://problem/5770054> JavaScript profiler (10928)
        Inital profiler prototype

        * GNUmakefile.am: Added new files to project
        * JavaScriptCore.pri: Ditto
        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Ditto
        * JavaScriptCore.xcodeproj/project.pbxproj: Ditto
        * JavaScriptCoreSources.bkl: Ditto
        * kjs/config.h: Put compiling flag in here.
        * kjs/function.cpp: Instrument calling the function eval().
        (KJS::eval):
        * kjs/interpreter.cpp: Instrument evaluating global scopes.
        (KJS::Interpreter::evaluate):
        * kjs/object.cpp: Instrument JS function calls.
        (KJS::JSObject::call):
        * profiler: Added.
        * profiler/FunctionCallProfile.cpp: Added.
        (KJS::FunctionCallProfile::FunctionCallProfile):
        (KJS::FunctionCallProfile::~FunctionCallProfile):
        (KJS::FunctionCallProfile::willExecute): Call right before the JS function or executing context is executed to start the profiler's timer.
        (KJS::FunctionCallProfile::didExecute): Call right after the JS function or executing context is executed to stop the profiler's timer.
        (KJS::FunctionCallProfile::addChild): Add a child to the current FunctionCallProfile if it isn't already a child of the current FunctionalCallProfile.
        (KJS::FunctionCallProfile::findChild): Return the child that matches the given name if there is one.
        (KJS::FunctionCallProfile::printDataSampleStyle): Print the current profiled information in a format that matches sample's output.
        * profiler/FunctionCallProfile.h: Added.
        (KJS::FunctionCallProfile::FunctionCallProfile):
        (KJS::FunctionCallProfile::~FunctionCallProfile):
        (KJS::FunctionCallProfile::functionName):
        (KJS::FunctionCallProfile::microSecs):
        * profiler/Profiler.cpp: Added.
        (KJS::Profiler::profiler):
        (KJS::Profiler::sharedProfiler): Return global singleton (may change due to multi-threading concerns)
        (KJS::Profiler::startProfiling): Don't start collecting profiling information until the user starts the profiler. Also don't clear old prfiled data until the profiler is restarted.
        (KJS::Profiler::stopProfiling): Stop collecting profile information.
        (KJS::Profiler::willExecute): Same as above.
        (KJS::Profiler::didExecute): Same as above.
        (KJS::Profiler::insertStackNamesInTree): Follow the stack of the given names and if a sub-stack is not in the current tree, add it.
        (KJS::Profiler::getStackNames): Get the names from the different passed in parameters and order them as a stack.
        (KJS::Profiler::getFunctionName): Get the function name from the given parameter.
        (KJS::Profiler::printDataSampleStyle): Print the current profiled information in a format that matches sample's output.
        (KJS::Profiler::debugLog):
        * profiler/Profiler.h: Added.
        (KJS::Profiler::Profiler):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@31949 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
JavaScriptCore/ChangeLog
JavaScriptCore/GNUmakefile.am
JavaScriptCore/JavaScriptCore.pri
JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj
JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
JavaScriptCore/JavaScriptCoreSources.bkl
JavaScriptCore/kjs/config.h
JavaScriptCore/kjs/function.cpp
JavaScriptCore/kjs/interpreter.cpp
JavaScriptCore/kjs/object.cpp
JavaScriptCore/profiler/FunctionCallProfile.cpp [new file with mode: 0644]
JavaScriptCore/profiler/FunctionCallProfile.h [new file with mode: 0644]
JavaScriptCore/profiler/Profiler.cpp [new file with mode: 0644]
JavaScriptCore/profiler/Profiler.h [new file with mode: 0644]