Ignore:
Timestamp:
May 22, 2008, 3:09:43 PM (17 years ago)
Author:
[email protected]
Message:

2008-05-22 Kevin McCullough <[email protected]>

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

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/profiler/Profiler.cpp

    r34013 r34036  
    4444static const char* AnonymousFunction = "(anonymous function)";
    4545
    46 static void getCallIdentifiers(ExecState*, Vector<CallIdentifier>& callIdentifiers);
    4746static CallIdentifier createCallIdentifier(JSObject*);
    4847static CallIdentifier createCallIdentifier(const UString& sourceURL, int startingLineNumber);
     
    7877    RefPtr<Profile> profile = Profile::create(title, globalExec, exec->lexicalGlobalObject()->pageGroupIdentifier());
    7978    m_currentProfiles.append(profile);
    80 
    81     // Update the profile with the current call identifiers that started the profiling.
    82     Vector<CallIdentifier> callIdentifiers;
    83     getCallIdentifiers(exec, callIdentifiers);
    84     for (unsigned i = 0; i< callIdentifiers.size(); ++i)
    85         profile->willExecute(callIdentifiers[i]);
    8679}
    8780
     
    161154}
    162155
    163 void getCallIdentifiers(ExecState*, Vector<CallIdentifier>&)
    164 {
    165     ASSERT_NOT_REACHED();
    166 #if 0
    167     for (ExecState* currentState = exec; currentState; currentState = currentState->callingExecState()) {
    168         if (FunctionImp* functionImp = currentState->function())
    169             getCallIdentifierFromFunctionImp(functionImp, callIdentifiers);
    170         else if (ScopeNode* scopeNode = currentState->scopeNode())
    171             callIdentifiers.append(CallIdentifier(GlobalCodeExecution, scopeNode->sourceURL(), (scopeNode->lineNo() + 1)) );   // FIXME: Why is the line number always off by one?
    172     }
    173 #endif
    174 }
    175 
    176156CallIdentifier createCallIdentifier(JSObject* calledFunction)
    177157{
Note: See TracChangeset for help on using the changeset viewer.