Ignore:
Timestamp:
Jun 20, 2008, 12:36:10 PM (17 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2008-06-20 Kevin McCullough <[email protected]>

Reviewed by Tim.

<rdar://problem/5958770> JSProfiler: Time incorrectly given to (idle)
if profiling is started and finished within the same function. (19230)

  • Now we profile one more stack frame up from the last frame to allocate the time spent in it, if it exists.
  • JavaScriptCore.exp:
  • VM/Machine.cpp: We need to let the profiler know when the JS program has finished since that is what will actually stop the profiler instead of just calling stopProfiling(). (KJS::Machine::execute):
  • profiler/Profile.cpp: (KJS::Profile::create): Moved from Profile.h since it was getting pretty long. (KJS::Profile::Profile): We now have a client, which is a listener who we will return this profile to, once it has actually finished. (KJS::Profile::stopProfiling): Instead of fully stopping the profiler here, we set the flag and keep it profiling in the background. (KJS::Profile::didFinishAllExecution): This is where the profiler actually finishes and creates the (idle) node if one should be made. (KJS::Profile::removeProfileStart): Don't use m_currentNode since it is needed by the profiler as it runs silently in the background. (KJS::Profile::removeProfileEnd): Ditto. (KJS::Profile::willExecute): Don't profile new functions if we have stopped profiling. (KJS::Profile::didExecute): Only record one more return as all the remaining time will be attributed to that function. (KJS::Profile::setupCurrentNodeAsStopped): Sets the current node's time.
  • profiler/Profile.h: Added functions and variables for the above changes. (KJS::Profile::client):
  • profiler/ProfileNode.h: (KJS::CallIdentifier::toString): Debug method.
  • profiler/Profiler.cpp: Added support for the ProfilerClient. (KJS::Profiler::startProfiling): (KJS::Profiler::stopProfiling): No longer return sthe profile. (KJS::Profiler::didFinishAllExecution): Now returns the profile to the client instead of stopProfiling.
  • profiler/Profiler.h: (KJS::ProfilerClient::~ProfilerClient): Clients will implement this interface.

WebCore:

2008-06-20 Kevin McCullough <[email protected]>

Reviewed by Tim.

<rdar://problem/5958770> JSProfiler: Time incorrectly given to (idle)
if profiling is started and finished within the same function. (19230)

  • Now we profile one more stack frame up from the last frame to allocate the time spent in it, if it exists.
  • page/Console.cpp:
  • manual-tests/inspector/profiler-test-start-and-stop-profiling-in-the-same-function.html: Added. (WebCore::Console::profile): When stating the profiler give a client for the callback of when the profile actually finishes. (WebCore::Console::profileEnd): No longer needs to handle the return of the profile object since it will be retruned in the client's callback. (WebCore::Console::finishedProfiling): Implemenet the ProfileClient callback method.
  • page/Console.h: Inherit from the ProfileClient.
  • page/InspectorController.cpp: (WebCore::InspectorController::startUserInitiatedProfiling): Use the client callback. (WebCore::InspectorController::stopUserInitiatedProfiling): Does not need to handle the profile being returned as it is now handled by the client callback. (WebCore::InspectorController::finishedProfiling): Implement the ProfileClient callback method.
  • page/InspectorController.h: Inherit from the ProfileClient.
File:
1 edited

Legend:

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

    r34581 r34696  
    6666}
    6767
    68 void Profiler::startProfiling(ExecState* exec, const UString& title)
     68void Profiler::startProfiling(ExecState* exec, const UString& title, ProfilerClient* client)
    6969{
    7070    ASSERT_ARG(exec, exec);
     
    7777            return;
    7878    s_sharedEnabledProfilerReference = this;
    79     RefPtr<Profile> profile = Profile::create(title, globalExec, exec->lexicalGlobalObject()->pageGroupIdentifier());
     79    RefPtr<Profile> profile = Profile::create(title, globalExec, exec->lexicalGlobalObject()->pageGroupIdentifier(), client);
    8080    m_currentProfiles.append(profile);
    8181}
    8282
    83 PassRefPtr<Profile> Profiler::stopProfiling(ExecState* exec, const UString& title)
     83void Profiler::stopProfiling(ExecState* exec, const UString& title)
    8484{
    8585    ExecState* globalExec = exec->lexicalGlobalObject()->globalExec();
    8686    for (ptrdiff_t i = m_currentProfiles.size() - 1; i >= 0; --i) {
    87         if (m_currentProfiles[i]->originatingGlobalExec() == globalExec && (title.isNull() || m_currentProfiles[i]->title() == title)) {
     87        if (m_currentProfiles[i]->originatingGlobalExec() == globalExec && (title.isNull() || m_currentProfiles[i]->title() == title))
    8888            m_currentProfiles[i]->stopProfiling();
     89    }
     90}
    8991
    90             PassRefPtr<Profile> prpProfile = m_currentProfiles[i].release();
     92void Profiler::didFinishAllExecution(ExecState* exec)
     93{
     94    ExecState* globalExec = exec->lexicalGlobalObject()->globalExec();
     95    for (ptrdiff_t i = m_currentProfiles.size() - 1; i >= 0; --i) {
     96        if (m_currentProfiles[i]->originatingGlobalExec() == globalExec && m_currentProfiles[i]->didFinishAllExecution()) {
     97            PassRefPtr<Profile> prpProfile = m_currentProfiles[i].release();       
    9198            m_currentProfiles.remove(i);
     99
    92100            if (!m_currentProfiles.size())
    93101                s_sharedEnabledProfilerReference = 0;
    94             return prpProfile;
     102
     103            if (ProfilerClient* client = prpProfile->client())
     104                client->finishedProfiling(prpProfile);
    95105        }
    96106    }
    97 
    98     return 0;
    99107}
    100108
Note: See TracChangeset for help on using the changeset viewer.