Ignore:
Timestamp:
Sep 3, 2008, 10:35:42 AM (17 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2008-09-02 Kevin McCullough <[email protected]>

Reviewed by Darin and Tim.

Remove most of the "zombie" mode from the profiler. Next we will need
to remove the client callback mechanism in profiles.

  • This simplifies the code, leverages the recent changes I've made in getting line numbers from SquirrelFish, and is a slight speed improvement on SunSpider.
  • Also the "zombie" mode was a constant source of odd edge cases and obscure bugs so it's good to remove since all of its issues may not have been found.
  • API/JSProfilerPrivate.cpp: No need to call didFinishAllExecution() any more. (JSEndProfiling):
  • JavaScriptCore.exp: Export the new signature of retrieveLastCaller()
  • VM/Machine.cpp: (KJS::Machine::execute): No need to call didFinishAllExecution() any more. (KJS::Machine::retrieveCaller): Now operates on InternalFunctions now since the RegisterFile is no longer guaranteeded to store only JSFunctions (KJS::Machine::retrieveLastCaller): Now also retrieve the function's name (KJS::Machine::callFrame): A result of changing retrieveCaller()
  • VM/Machine.h:
  • VM/Register.h:
  • kjs/JSGlobalObject.cpp: (KJS::JSGlobalObject::~JSGlobalObject):
  • kjs/nodes.h:
  • profiler/ProfileGenerator.cpp: (KJS::ProfileGenerator::create): Now pass the original exec and get the global exec and client when necessary. We need the original exec so we can have the stack frame where profiling started. (KJS::ProfileGenerator::ProfileGenerator): ditto. (KJS::ProfileGenerator::addParentForConsoleStart): This is where the parent to star of the profile is added, if there is one. (KJS::ProfileGenerator::willExecute): Remove uglyness! (KJS::ProfileGenerator::didExecute): Ditto! (KJS::ProfileGenerator::stopProfiling): (KJS::ProfileGenerator::removeProfileStart): Use a better way to find and remove the function we are looking for. (KJS::ProfileGenerator::removeProfileEnd): Ditto.
  • profiler/ProfileGenerator.h: (KJS::ProfileGenerator::client):
  • profiler/ProfileNode.cpp: (KJS::ProfileNode::removeChild): Add a better way to remove a child from a ProfileNode. (KJS::ProfileNode::stopProfiling): (KJS::ProfileNode::debugPrintData): Modified a debug-only diagnostic function to be sane.
  • profiler/ProfileNode.h:
  • profiler/Profiler.cpp: Change to pass the original exec state. (KJS::Profiler::startProfiling): (KJS::Profiler::stopProfiling): (KJS::Profiler::willExecute): (KJS::Profiler::didExecute): (KJS::Profiler::createCallIdentifier):
  • profiler/Profiler.h:

WebCore:

2008-09-03 Kevin McCullough <[email protected]>

Reviewed by Darin and Tim.

Remove most of the "zombie" mode from the profiler. Next we will need
to remove the client callback mechanism in profiles.

  • These changes are a result of changes to JSCore.
  • manual-tests/inspector/profiler-test-nested-start-and-stop-profiler.html:
  • page/Console.cpp: (WebCore::retrieveLastCaller): (WebCore::Console::profileEnd):
  • page/InspectorController.cpp: (WebCore::InspectorController::stopUserInitiatedProfiling):
File:
1 edited

Legend:

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

    r35807 r36058  
    4545static unsigned ProfilesUID = 0;
    4646
    47 static CallIdentifier createCallIdentifier(ExecState*, JSObject*);
    48 static CallIdentifier createCallIdentifier(ExecState*, const UString& sourceURL, int startingLineNumber);
    4947static CallIdentifier createCallIdentifierFromFunctionImp(ExecState*, JSFunction*);
    5048
     
    6866    for (size_t i = 0; i < m_currentProfiles.size(); ++i) {
    6967        ProfileGenerator* profileGenerator = m_currentProfiles[i].get();
    70         if (!profileGenerator->stoppedProfiling() && profileGenerator->originatingGlobalExec() == globalExec && profileGenerator->title() == title)
     68        if (profileGenerator->originatingGlobalExec() == globalExec && profileGenerator->title() == title)
    7169            return;
    7270    }
    7371
    7472    s_sharedEnabledProfilerReference = this;
    75     RefPtr<ProfileGenerator> profileGenerator = ProfileGenerator::create(title, globalExec, exec->lexicalGlobalObject()->profileGroup(), client, ++ProfilesUID);
     73    RefPtr<ProfileGenerator> profileGenerator = ProfileGenerator::create(title, exec, client, ++ProfilesUID);
    7674    m_currentProfiles.append(profileGenerator);
    7775}
     
    8280    for (ptrdiff_t i = m_currentProfiles.size() - 1; i >= 0; --i) {
    8381        ProfileGenerator* profileGenerator = m_currentProfiles[i].get();
    84         if (!profileGenerator->stoppedProfiling() && profileGenerator->originatingGlobalExec() == globalExec && (title.isNull() || profileGenerator->title() == title))
    85             m_currentProfiles[i]->stopProfiling();
    86     }
    87 }
    88 
    89 void Profiler::didFinishAllExecution(ExecState* exec)
    90 {
    91     ExecState* globalExec = exec->lexicalGlobalObject()->globalExec();
    92     for (ptrdiff_t i = m_currentProfiles.size() - 1; i >= 0; --i) {
    93         ProfileGenerator* profileGenerator = m_currentProfiles[i].get();
    94         if (profileGenerator->originatingGlobalExec() == globalExec && profileGenerator->didFinishAllExecution()) {
     82        if (profileGenerator->originatingGlobalExec() == globalExec && (title.isNull() || profileGenerator->title() == title)) {
    9583            PassRefPtr<ProfileGenerator> prpProfileGenerator = m_currentProfiles[i].release();
    9684            m_currentProfiles.remove(i);
     
    9987                s_sharedEnabledProfilerReference = 0;
    10088
     89
     90            prpProfileGenerator->stopProfiling();
    10191            if (ProfilerClient* client = prpProfileGenerator->client())
    10292                client->finishedProfiling(prpProfileGenerator->profile());
     
    117107    ASSERT(!m_currentProfiles.isEmpty());
    118108
    119     dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::willExecute, createCallIdentifier(exec, calledFunction), exec->lexicalGlobalObject()->profileGroup());
     109    dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::willExecute, createCallIdentifier(exec, calledFunction, "", 0), exec->lexicalGlobalObject()->profileGroup());
    120110}
    121111
     
    124114    ASSERT(!m_currentProfiles.isEmpty());
    125115
    126     CallIdentifier callIdentifier = createCallIdentifier(exec, sourceURL, startingLineNumber);
     116    CallIdentifier callIdentifier = createCallIdentifier(exec, 0, sourceURL, startingLineNumber);
    127117
    128118    dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::willExecute, callIdentifier, exec->lexicalGlobalObject()->profileGroup());
     
    133123    ASSERT(!m_currentProfiles.isEmpty());
    134124
    135     dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::didExecute, createCallIdentifier(exec, calledFunction), exec->lexicalGlobalObject()->profileGroup());
     125    dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::didExecute, createCallIdentifier(exec, calledFunction, "", 0), exec->lexicalGlobalObject()->profileGroup());
    136126}
    137127
     
    140130    ASSERT(!m_currentProfiles.isEmpty());
    141131
    142     dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::didExecute, createCallIdentifier(exec, sourceURL, startingLineNumber), exec->lexicalGlobalObject()->profileGroup());
     132    dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::didExecute, createCallIdentifier(exec, 0, sourceURL, startingLineNumber), exec->lexicalGlobalObject()->profileGroup());
    143133}
    144134
    145 CallIdentifier createCallIdentifier(ExecState* exec, JSObject* calledFunction)
     135CallIdentifier Profiler::createCallIdentifier(ExecState* exec, JSObject* calledFunction, const UString& defaultSourceURL, int defaultLineNumber)
    146136{
     137    if (!calledFunction)
     138        return CallIdentifier(GlobalCodeExecution, defaultSourceURL, defaultLineNumber);
     139
    147140    if (calledFunction->inherits(&JSFunction::info))
    148141        return createCallIdentifierFromFunctionImp(exec, static_cast<JSFunction*>(calledFunction));
    149142    if (calledFunction->inherits(&InternalFunction::info))
    150         return CallIdentifier(static_cast<InternalFunction*>(calledFunction)->name(exec), "", 0);
     143        return CallIdentifier(static_cast<InternalFunction*>(calledFunction)->name(exec), defaultSourceURL, defaultLineNumber);
    151144
    152145    UString name = "(" + calledFunction->className() + " object)";
    153     return CallIdentifier(name, 0, 0);
    154 }
    155 
    156 CallIdentifier createCallIdentifier(ExecState*, const UString& sourceURL, int startingLineNumber)
    157 {
    158     return CallIdentifier(GlobalCodeExecution, sourceURL, startingLineNumber);
     146    return CallIdentifier(name, defaultSourceURL, defaultLineNumber);
    159147}
    160148
Note: See TracChangeset for help on using the changeset viewer.