Ignore:
Timestamp:
Oct 4, 2014, 2:55:58 PM (11 years ago)
Author:
Brian Burg
Message:

Unreviewed, rolling out r174319.

Causes assertions in fast/profiler tests. Needs nontrivial
investigation, will take offline.

Reverted changeset:

"Web Inspector: timelines should not count time elapsed while
paused in the debugger"
https://bugs.webkit.org/show_bug.cgi?id=136351
http://trac.webkit.org/changeset/174319

Location:
trunk/Source/JavaScriptCore/profiler
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/profiler/LegacyProfiler.cpp

    r174319 r174322  
    3333#include "CodeBlock.h"
    3434#include "CommonIdentifiers.h"
     35#include "DebuggerCallFrame.h"
    3536#include "InternalFunction.h"
    3637#include "JSFunction.h"
     
    5051static CallIdentifier createCallIdentifierFromFunctionImp(ExecState*, JSObject*, const String& defaultSourceURL, unsigned defaultLineNumber, unsigned defaultColumnNumber);
    5152
    52 LegacyProfiler* LegacyProfiler::s_sharedLegacyProfiler = nullptr;
     53LegacyProfiler* LegacyProfiler::s_sharedLegacyProfiler = 0;
    5354
    5455LegacyProfiler* LegacyProfiler::profiler()
     
    5758        s_sharedLegacyProfiler = new LegacyProfiler();
    5859    return s_sharedLegacyProfiler;
    59 }
    60 
    61 void LegacyProfiler::startProfiling(ExecState* exec, const String& title, PassRefPtr<Stopwatch> stopwatch)
     60}   
     61
     62void LegacyProfiler::startProfiling(ExecState* exec, const String& title)
    6263{
    6364    if (!exec)
     
    7576
    7677    exec->vm().setEnabledProfiler(this);
    77     RefPtr<ProfileGenerator> profileGenerator = ProfileGenerator::create(exec, title, ++ProfilesUID, stopwatch);
     78    RefPtr<ProfileGenerator> profileGenerator = ProfileGenerator::create(exec, title, ++ProfilesUID);
    7879    m_currentProfiles.append(profileGenerator);
    7980}
     
    8283{
    8384    if (!exec)
    84         return nullptr;
     85        return 0;
    8586
    8687    JSGlobalObject* origin = exec->lexicalGlobalObject();
     
    9495            if (!m_currentProfiles.size())
    9596                exec->vm().setEnabledProfiler(nullptr);
    96 
     97           
    9798            return returnProfile;
    9899        }
    99100    }
    100101
    101     return nullptr;
     102    return 0;
    102103}
    103104
     
    182183
    183184    callFunctionForProfilesWithGroup(std::bind(&ProfileGenerator::exceptionUnwind, std::placeholders::_1, handlerCallFrame, callIdentifier), m_currentProfiles, handlerCallFrame->lexicalGlobalObject()->profileGroup());
     185}
     186
     187void LegacyProfiler::didPause(PassRefPtr<DebuggerCallFrame> prpCallFrame)
     188{
     189    if (m_currentProfiles.isEmpty())
     190        return;
     191
     192    RefPtr<DebuggerCallFrame> callFrame = prpCallFrame;
     193    CallIdentifier callIdentifier = createCallIdentifier(callFrame->exec(), JSValue(), StringImpl::empty(), 0, 0);
     194
     195    callFunctionForProfilesWithGroup(std::bind(&ProfileGenerator::didPause, std::placeholders::_1, callFrame, callIdentifier), m_currentProfiles, callFrame->vmEntryGlobalObject()->profileGroup());
     196}
     197
     198void LegacyProfiler::didContinue(PassRefPtr<DebuggerCallFrame> prpCallFrame)
     199{
     200    if (m_currentProfiles.isEmpty())
     201        return;
     202
     203    RefPtr<DebuggerCallFrame> callFrame = prpCallFrame;
     204    CallIdentifier callIdentifier = createCallIdentifier(callFrame->exec(), JSValue(), StringImpl::empty(), 0, 0);
     205
     206    callFunctionForProfilesWithGroup(std::bind(&ProfileGenerator::didContinue, std::placeholders::_1, callFrame, callIdentifier), m_currentProfiles, callFrame->vmEntryGlobalObject()->profileGroup());
    184207}
    185208
  • trunk/Source/JavaScriptCore/profiler/LegacyProfiler.h

    r174319 r174322  
    3333#include <wtf/PassRefPtr.h>
    3434#include <wtf/RefPtr.h>
    35 #include <wtf/Stopwatch.h>
    3635#include <wtf/Vector.h>
    3736
    3837namespace JSC {
    3938
     39class DebuggerCallFrame;
    4040class ExecState;
     41class VM;
    4142class JSGlobalObject;
    4243class JSObject;
     
    4849    WTF_MAKE_FAST_ALLOCATED;
    4950public:
    50     JS_EXPORT_PRIVATE static LegacyProfiler* profiler();
     51    JS_EXPORT_PRIVATE static LegacyProfiler* profiler(); 
    5152    static CallIdentifier createCallIdentifier(ExecState*, JSValue, const WTF::String& sourceURL, unsigned defaultLineNumber, unsigned defaultColumnNumber);
    5253
    53     JS_EXPORT_PRIVATE void startProfiling(ExecState*, const WTF::String& title, PassRefPtr<Stopwatch>);
     54    JS_EXPORT_PRIVATE void startProfiling(ExecState*, const WTF::String& title);
    5455    JS_EXPORT_PRIVATE PassRefPtr<Profile> stopProfiling(ExecState*, const WTF::String& title);
    5556    void stopProfiling(JSGlobalObject*);
     
    6667    void exceptionUnwind(ExecState* handlerCallFrame);
    6768
     69    void didPause(PassRefPtr<DebuggerCallFrame>);
     70    void didContinue(PassRefPtr<DebuggerCallFrame>);
     71
    6872    const Vector<RefPtr<ProfileGenerator>>& currentProfiles() { return m_currentProfiles; };
    6973
  • trunk/Source/JavaScriptCore/profiler/ProfileGenerator.cpp

    r174319 r174322  
    2929#include "CallFrame.h"
    3030#include "CodeBlock.h"
     31#include "Debugger.h"
    3132#include "JSGlobalObject.h"
    3233#include "JSStringRef.h"
     
    4041namespace JSC {
    4142
    42 PassRefPtr<ProfileGenerator> ProfileGenerator::create(ExecState* exec, const String& title, unsigned uid, PassRefPtr<Stopwatch> stopwatch)
    43 {
    44     return adoptRef(new ProfileGenerator(exec, title, uid, stopwatch));
    45 }
    46 
    47 ProfileGenerator::ProfileGenerator(ExecState* exec, const String& title, unsigned uid, PassRefPtr<Stopwatch> stopwatch)
     43PassRefPtr<ProfileGenerator> ProfileGenerator::create(ExecState* exec, const String& title, unsigned uid)
     44{
     45    return adoptRef(new ProfileGenerator(exec, title, uid));
     46}
     47
     48ProfileGenerator::ProfileGenerator(ExecState* exec, const String& title, unsigned uid)
    4849    : m_origin(exec ? exec->lexicalGlobalObject() : nullptr)
    4950    , m_profileGroup(exec ? exec->lexicalGlobalObject()->profileGroup() : 0)
    50     , m_stopwatch(stopwatch)
     51    , m_debuggerPausedTimestamp(NAN)
    5152    , m_foundConsoleStartParent(false)
    5253    , m_suspended(false)
    5354{
     55    if (Debugger* debugger = exec->lexicalGlobalObject()->debugger())
     56        m_debuggerPausedTimestamp = debugger->isPaused() ? currentTime() : NAN;
     57
    5458    m_profile = Profile::create(title, uid);
    5559    m_currentNode = m_rootNode = m_profile->rootNode();
     
    115119
    116120    if (isnan(startTime))
    117         startTime = m_stopwatch->elapsedTime();
     121        startTime = currentTime();
     122
     123    // If the debugger is paused when beginning, then don't set the start time. It
     124    // will be fixed up when the debugger unpauses or the call entry ends.
     125    if (!isnan(m_debuggerPausedTimestamp))
     126        startTime = NAN;
    118127
    119128    node->appendCall(ProfileNode::Call(startTime));
     
    125134
    126135    ProfileNode::Call& last = node->lastCall();
     136
     137    // If the debugger is paused, ignore the interval that ends now.
     138    if (!isnan(m_debuggerPausedTimestamp) && !isnan(last.elapsedTime()))
     139        return;
     140
     141    // If paused and no time was accrued then the debugger was never unpaused. The call will
     142    // have no time accrued and appear to have started when the debugger was paused.
     143    if (!isnan(m_debuggerPausedTimestamp)) {
     144        last.setStartTime(m_debuggerPausedTimestamp);
     145        last.setElapsedTime(0.0);
     146        return;
     147    }
     148
     149    // Otherwise, add the interval ending now to elapsed time.
    127150    double previousElapsedTime = isnan(last.elapsedTime()) ? 0.0 : last.elapsedTime();
    128     double newlyElapsedTime = m_stopwatch->elapsedTime() - last.startTime();
     151    double newlyElapsedTime = currentTime() - last.startTime();
    129152    last.setElapsedTime(previousElapsedTime + newlyElapsedTime);
    130153}
     
    201224}
    202225
     226void ProfileGenerator::didPause(PassRefPtr<DebuggerCallFrame>, const CallIdentifier&)
     227{
     228    ASSERT(isnan(m_debuggerPausedTimestamp));
     229
     230    m_debuggerPausedTimestamp = currentTime();
     231
     232    for (ProfileNode* node = m_currentNode.get(); node != m_profile->rootNode(); node = node->parent()) {
     233        ProfileNode::Call& last = node->lastCall();
     234        ASSERT(!isnan(last.startTime()));
     235
     236        double previousElapsedTime = isnan(last.elapsedTime()) ? 0.0 : last.elapsedTime();
     237        double additionalElapsedTime = m_debuggerPausedTimestamp - last.startTime();
     238        last.setStartTime(NAN);
     239        last.setElapsedTime(previousElapsedTime + additionalElapsedTime);
     240    }
     241}
     242
     243void ProfileGenerator::didContinue(PassRefPtr<DebuggerCallFrame>, const CallIdentifier&)
     244{
     245    ASSERT(!isnan(m_debuggerPausedTimestamp));
     246
     247    for (ProfileNode* node = m_currentNode.get(); node != m_profile->rootNode(); node = node->parent())
     248        node->lastCall().setStartTime(m_debuggerPausedTimestamp);
     249
     250    m_debuggerPausedTimestamp = NAN;
     251}
     252
    203253void ProfileGenerator::stopProfiling()
    204254{
  • trunk/Source/JavaScriptCore/profiler/ProfileGenerator.h

    r174319 r174322  
    3030#include <wtf/RefCounted.h>
    3131#include <wtf/RefPtr.h>
    32 #include <wtf/Stopwatch.h>
    3332#include <wtf/text/WTFString.h>
    3433
     
    4443    class ProfileGenerator : public RefCounted<ProfileGenerator>  {
    4544    public:
    46         static PassRefPtr<ProfileGenerator> create(ExecState*, const WTF::String& title, unsigned uid, PassRefPtr<Stopwatch>);
     45        static PassRefPtr<ProfileGenerator> create(ExecState*, const WTF::String& title, unsigned uid);
    4746
    4847        // Members
     
    5655        void exceptionUnwind(ExecState* handlerCallFrame, const CallIdentifier&);
    5756
     57        void didPause(PassRefPtr<DebuggerCallFrame>, const CallIdentifier&);
     58        void didContinue(PassRefPtr<DebuggerCallFrame>, const CallIdentifier&);
     59
    5860        void setIsSuspended(bool suspended) { ASSERT(m_suspended != suspended); m_suspended = suspended; }
    5961
     
    6163
    6264    private:
    63         ProfileGenerator(ExecState*, const WTF::String& title, unsigned uid, PassRefPtr<Stopwatch>);
     65        ProfileGenerator(ExecState*, const WTF::String& title, unsigned uid);
    6466        void addParentForConsoleStart(ExecState*);
    6567
     
    7375        JSGlobalObject* m_origin;
    7476        unsigned m_profileGroup;
    75         RefPtr<Stopwatch> m_stopwatch;
     77        // Timestamp is set to NAN when the debugger is not currently paused.
     78        double m_debuggerPausedTimestamp;
    7679        RefPtr<ProfileNode> m_rootNode;
    7780        RefPtr<ProfileNode> m_currentNode;
Note: See TracChangeset for help on using the changeset viewer.