Ignore:
Timestamp:
Apr 16, 2008, 12:08:03 PM (17 years ago)
Author:
[email protected]
Message:

2008-04-16 Kevin McCullough <[email protected]>

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):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/interpreter.cpp

    r30810 r31949  
    2828#include "Parser.h"
    2929#include "debugger.h"
     30#include <profiler/Profiler.h>
    3031#include <stdio.h>
    3132
     
    7172    int errLine;
    7273    UString errMsg;
     74
     75#if JAVASCRIPT_PROFILING
     76    Profiler::profiler()->willExecute(exec, sourceURL, startingLineNumber);
     77#endif
     78
    7379    RefPtr<ProgramNode> progNode = parser().parse<ProgramNode>(sourceURL, startingLineNumber, code, codeLength, &sourceId, &errLine, &errMsg);
    7480   
     
    104110        res = Completion(newExec.completionType(), value);
    105111    }
    106    
     112
     113#if JAVASCRIPT_PROFILING
     114        Profiler::profiler()->didExecute(exec, sourceURL, startingLineNumber);
     115#endif
     116
    107117    globalObject->decRecursion();
    108118   
Note: See TracChangeset for help on using the changeset viewer.