Changeset 34696 in webkit for trunk/JavaScriptCore/VM/Machine.cpp


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/VM/Machine.cpp

    r34684 r34696  
    672672    registerFileStack->popGlobalRegisterFile();
    673673
    674     if (*profiler)
     674    if (*profiler) {
    675675        (*profiler)->didExecute(exec, programNode->sourceURL(), programNode->lineNo());
     676        if (!m_reentryDepth)
     677            (*profiler)->didFinishAllExecution(exec);
     678    }
    676679
    677680    return result;
     
    730733    JSValue* result = privateExecute(Normal, &newExec, registerFile, r, scopeChain, newCodeBlock, exception);
    731734    m_reentryDepth--;
     735
     736    if (*profiler && !m_reentryDepth)
     737        (*profiler)->didFinishAllExecution(exec);
    732738
    733739    registerFile->shrink(oldSize);
     
    796802    registerFile->shrink(oldSize);
    797803
    798     if (*profiler)
     804    if (*profiler) {
    799805        (*profiler)->didExecute(exec, evalNode->sourceURL(), evalNode->lineNo());
     806        if (!m_reentryDepth)
     807            (*profiler)->didFinishAllExecution(exec);
     808    }
    800809
    801810    return result;
Note: See TracChangeset for help on using the changeset viewer.