Changeset 173264 in webkit


Ignore:
Timestamp:
Sep 4, 2014 10:21:39 AM (10 years ago)
Author:
Brian Burg
Message:

Web Inspector: the profiler should not accrue time to nodes while the debugger is paused
https://bugs.webkit.org/show_bug.cgi?id=136352

Reviewed by Timothy Hatcher.

Hook up pause/continue events to the LegacyProfiler and any active
ProfilerGenerators. If the debugger is paused, all intervening call
entries will be created with totalTime as 0.0.

  • inspector/ScriptDebugServer.cpp:

(Inspector::ScriptDebugServer::handlePause):

  • profiler/LegacyProfiler.cpp: Move from typedef'd callbacks to using

std::function. This allows callbacks to take different argument types.

(JSC::callFunctionForProfilesWithGroup):
(JSC::LegacyProfiler::willExecute):
(JSC::LegacyProfiler::didExecute):
(JSC::LegacyProfiler::exceptionUnwind):
(JSC::LegacyProfiler::didPause):
(JSC::LegacyProfiler::didContinue):
(JSC::dispatchFunctionToProfiles): Deleted.

  • profiler/LegacyProfiler.h:
  • profiler/ProfileGenerator.cpp:

(JSC::ProfileGenerator::ProfileGenerator):
(JSC::ProfileGenerator::endCallEntry):
(JSC::ProfileGenerator::didExecute): Deleted.

  • profiler/ProfileGenerator.h:

(JSC::ProfileGenerator::didPause):
(JSC::ProfileGenerator::didContinue):

Location:
trunk/Source/JavaScriptCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r173263 r173264  
     12014-09-04  Brian J. Burg  <burg@cs.washington.edu>
     2
     3        Web Inspector: the profiler should not accrue time to nodes while the debugger is paused
     4        https://bugs.webkit.org/show_bug.cgi?id=136352
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        Hook up pause/continue events to the LegacyProfiler and any active
     9        ProfilerGenerators. If the debugger is paused, all intervening call
     10        entries will be created with totalTime as 0.0.
     11
     12        * inspector/ScriptDebugServer.cpp:
     13        (Inspector::ScriptDebugServer::handlePause):
     14        * profiler/LegacyProfiler.cpp: Move from typedef'd callbacks to using
     15        std::function. This allows callbacks to take different argument types.
     16
     17        (JSC::callFunctionForProfilesWithGroup):
     18        (JSC::LegacyProfiler::willExecute):
     19        (JSC::LegacyProfiler::didExecute):
     20        (JSC::LegacyProfiler::exceptionUnwind):
     21        (JSC::LegacyProfiler::didPause):
     22        (JSC::LegacyProfiler::didContinue):
     23        (JSC::dispatchFunctionToProfiles): Deleted.
     24        * profiler/LegacyProfiler.h:
     25        * profiler/ProfileGenerator.cpp:
     26        (JSC::ProfileGenerator::ProfileGenerator):
     27        (JSC::ProfileGenerator::endCallEntry):
     28        (JSC::ProfileGenerator::didExecute): Deleted.
     29        * profiler/ProfileGenerator.h:
     30        (JSC::ProfileGenerator::didPause):
     31        (JSC::ProfileGenerator::didContinue):
     32
    1332014-09-04  Commit Queue  <commit-queue@webkit.org>
    234
  • trunk/Source/JavaScriptCore/inspector/ScriptDebugServer.cpp

    r173100 r173264  
    3939#include "JSLock.h"
    4040#include "JavaScriptCallFrame.h"
     41#include "LegacyProfiler.h"
    4142#include "ScriptValue.h"
    4243#include "SourceProvider.h"
     
    317318{
    318319    dispatchFunctionToListeners(&ScriptDebugServer::dispatchDidPause, vmEntryGlobalObject);
     320    LegacyProfiler::profiler()->didPause(currentDebuggerCallFrame());
    319321    didPause(vmEntryGlobalObject);
    320322
     
    323325
    324326    didContinue(vmEntryGlobalObject);
     327    LegacyProfiler::profiler()->didContinue(currentDebuggerCallFrame());
    325328    dispatchFunctionToListeners(&ScriptDebugServer::dispatchDidContinue, vmEntryGlobalObject);
    326329}
  • trunk/Source/JavaScriptCore/profiler/LegacyProfiler.cpp

    r171204 r173264  
    3333#include "CodeBlock.h"
    3434#include "CommonIdentifiers.h"
     35#include "DebuggerCallFrame.h"
    3536#include "InternalFunction.h"
    3637#include "JSFunction.h"
     
    115116}
    116117
    117 static inline void dispatchFunctionToProfiles(ExecState* callerOrHandlerCallFrame, const Vector<RefPtr<ProfileGenerator>>& profiles, ProfileGenerator::ProfileFunction function, const CallIdentifier& callIdentifier, unsigned currentProfileTargetGroup)
    118 {
    119     for (size_t i = 0; i < profiles.size(); ++i) {
    120         if (profiles[i]->profileGroup() == currentProfileTargetGroup || !profiles[i]->origin())
    121             (profiles[i].get()->*function)(callerOrHandlerCallFrame, callIdentifier);
     118static inline void callFunctionForProfilesWithGroup(std::function<void(ProfileGenerator*)> callback, const Vector<RefPtr<ProfileGenerator>>& profiles, unsigned targetProfileGroup)
     119{
     120    for (const RefPtr<ProfileGenerator>& profile : profiles) {
     121        if (profile->profileGroup() == targetProfileGroup || !profile->origin())
     122            callback(profile.get());
    122123    }
    123124}
     
    127128    ASSERT(!m_currentProfiles.isEmpty());
    128129
    129     dispatchFunctionToProfiles(callerCallFrame, m_currentProfiles, &ProfileGenerator::willExecute, createCallIdentifier(callerCallFrame, function, StringImpl::empty(), 0, 0), callerCallFrame->lexicalGlobalObject()->profileGroup());
     130    CallIdentifier callIdentifier = createCallIdentifier(callerCallFrame, function, StringImpl::empty(), 0, 0);
     131
     132    callFunctionForProfilesWithGroup(std::bind(&ProfileGenerator::willExecute, std::placeholders::_1, callerCallFrame, callIdentifier), m_currentProfiles, callerCallFrame->lexicalGlobalObject()->profileGroup());
    130133}
    131134
     
    136139    CallIdentifier callIdentifier = createCallIdentifier(callerCallFrame, JSValue(), sourceURL, startingLineNumber, startingColumnNumber);
    137140
    138     dispatchFunctionToProfiles(callerCallFrame, m_currentProfiles, &ProfileGenerator::willExecute, callIdentifier, callerCallFrame->lexicalGlobalObject()->profileGroup());
     141    callFunctionForProfilesWithGroup(std::bind(&ProfileGenerator::willExecute, std::placeholders::_1, callerCallFrame, callIdentifier), m_currentProfiles, callerCallFrame->lexicalGlobalObject()->profileGroup());
    139142}
    140143
     
    143146    ASSERT(!m_currentProfiles.isEmpty());
    144147
    145     dispatchFunctionToProfiles(callerCallFrame, m_currentProfiles, &ProfileGenerator::didExecute, createCallIdentifier(callerCallFrame, function, StringImpl::empty(), 0, 0), callerCallFrame->lexicalGlobalObject()->profileGroup());
     148    CallIdentifier callIdentifier = createCallIdentifier(callerCallFrame, function, StringImpl::empty(), 0, 0);
     149
     150    callFunctionForProfilesWithGroup(std::bind(&ProfileGenerator::didExecute, std::placeholders::_1, callerCallFrame, callIdentifier), m_currentProfiles, callerCallFrame->lexicalGlobalObject()->profileGroup());
    146151}
    147152
     
    150155    ASSERT(!m_currentProfiles.isEmpty());
    151156
    152     dispatchFunctionToProfiles(callerCallFrame, m_currentProfiles, &ProfileGenerator::didExecute, createCallIdentifier(callerCallFrame, JSValue(), sourceURL, startingLineNumber, startingColumnNumber), callerCallFrame->lexicalGlobalObject()->profileGroup());
     157    CallIdentifier callIdentifier = createCallIdentifier(callerCallFrame, JSValue(), sourceURL, startingLineNumber, startingColumnNumber);
     158
     159    callFunctionForProfilesWithGroup(std::bind(&ProfileGenerator::didExecute, std::placeholders::_1, callerCallFrame, callIdentifier), m_currentProfiles, callerCallFrame->lexicalGlobalObject()->profileGroup());
    153160}
    154161
     
    157164    ASSERT(!m_currentProfiles.isEmpty());
    158165
    159     dispatchFunctionToProfiles(handlerCallFrame, m_currentProfiles, &ProfileGenerator::exceptionUnwind, createCallIdentifier(handlerCallFrame, JSValue(), StringImpl::empty(), 0, 0), handlerCallFrame->lexicalGlobalObject()->profileGroup());
     166    CallIdentifier callIdentifier = createCallIdentifier(handlerCallFrame, JSValue(), StringImpl::empty(), 0, 0);
     167
     168    callFunctionForProfilesWithGroup(std::bind(&ProfileGenerator::exceptionUnwind, std::placeholders::_1, handlerCallFrame, callIdentifier), m_currentProfiles, handlerCallFrame->lexicalGlobalObject()->profileGroup());
     169}
     170
     171void LegacyProfiler::didPause(PassRefPtr<DebuggerCallFrame> prpCallFrame)
     172{
     173    if (m_currentProfiles.isEmpty())
     174        return;
     175
     176    RefPtr<DebuggerCallFrame> callFrame = prpCallFrame;
     177    CallIdentifier callIdentifier = createCallIdentifier(callFrame->exec(), JSValue(), StringImpl::empty(), 0, 0);
     178
     179    callFunctionForProfilesWithGroup(std::bind(&ProfileGenerator::didPause, std::placeholders::_1, callFrame, callIdentifier), m_currentProfiles, callFrame->vmEntryGlobalObject()->profileGroup());
     180}
     181
     182void LegacyProfiler::didContinue(PassRefPtr<DebuggerCallFrame> prpCallFrame)
     183{
     184    if (m_currentProfiles.isEmpty())
     185        return;
     186
     187    RefPtr<DebuggerCallFrame> callFrame = prpCallFrame;
     188    CallIdentifier callIdentifier = createCallIdentifier(callFrame->exec(), JSValue(), StringImpl::empty(), 0, 0);
     189
     190    callFunctionForProfilesWithGroup(std::bind(&ProfileGenerator::didContinue, std::placeholders::_1, callFrame, callIdentifier), m_currentProfiles, callFrame->vmEntryGlobalObject()->profileGroup());
    160191}
    161192
  • trunk/Source/JavaScriptCore/profiler/LegacyProfiler.h

    r165676 r173264  
    3737namespace JSC {
    3838
     39class DebuggerCallFrame;
    3940class ExecState;
    4041class VM;
     
    6263    void exceptionUnwind(ExecState* handlerCallFrame);
    6364
     65    void didPause(PassRefPtr<DebuggerCallFrame>);
     66    void didContinue(PassRefPtr<DebuggerCallFrame>);
     67
    6468    const Vector<RefPtr<ProfileGenerator>>& currentProfiles() { return m_currentProfiles; };
    6569
  • trunk/Source/JavaScriptCore/profiler/ProfileGenerator.cpp

    r173262 r173264  
    2929#include "CallFrame.h"
    3030#include "CodeBlock.h"
     31#include "Debugger.h"
    3132#include "JSGlobalObject.h"
    3233#include "JSStringRef.h"
     
    4950    , m_profileGroup(exec ? exec->lexicalGlobalObject()->profileGroup() : 0)
    5051    , m_foundConsoleStartParent(false)
    51 {
     52    , m_debuggerPaused(false)
     53{
     54    if (Debugger* debugger = exec->lexicalGlobalObject()->debugger())
     55        m_debuggerPaused = debugger->isPaused();
     56
    5257    m_profile = Profile::create(title, uid);
    5358    m_currentNode = m_rootNode = m_profile->rootNode();
     
    124129    ASSERT(isnan(last.totalTime()));
    125130
    126     last.setTotalTime(currentTime() - last.startTime());
     131    last.setTotalTime(m_debuggerPaused ? 0.0 : currentTime() - last.startTime());
    127132}
    128133
  • trunk/Source/JavaScriptCore/profiler/ProfileGenerator.h

    r173262 r173264  
    3434namespace JSC {
    3535
     36    class DebuggerCallFrame;
    3637    class ExecState;
    3738    class JSGlobalObject;
     
    5354        void didExecute(ExecState* callerCallFrame, const CallIdentifier&);
    5455        void exceptionUnwind(ExecState* handlerCallFrame, const CallIdentifier&);
     56
     57        void didPause(PassRefPtr<DebuggerCallFrame>, const CallIdentifier&) { m_debuggerPaused = true; }
     58        void didContinue(PassRefPtr<DebuggerCallFrame>, const CallIdentifier&) { m_debuggerPaused = false; }
    5559
    5660        void stopProfiling();
     
    7478        RefPtr<ProfileNode> m_currentNode;
    7579        bool m_foundConsoleStartParent;
     80        bool m_debuggerPaused;
    7681    };
    7782
Note: See TracChangeset for help on using the changeset viewer.