Ignore:
Timestamp:
Jun 25, 2008, 2:44:42 PM (17 years ago)
Author:
[email protected]
Message:

Fixes an ASSERT in the profiler when starting multiple profiles
with the same name inside the same function/program.

Reviewed by Kevin McCullough.

  • profiler/Profile.cpp: (KJS::Profile::Profile): Initialize m_stoppedCallDepth to zero. (KJS::Profile::stopProfiling): Set the current node to the parent, because we are in a call that will not get a didExecute call. (KJS::Profile::removeProfile): Increment m_stoppedCallDepth to account for didExecute not being called for profile. (KJS::Profile::willExecute): Increment m_stoppedCallDepth if stopped. (KJS::Profile::didExecute): Decrement m_stoppedCallDepth if stopped and greater than zero, and return early.
  • profiler/Profile.h: Added stoppedProfiling().
  • profiler/Profiler.cpp: (KJS::Profiler::findProfile): Removed. (KJS::Profiler::startProfiling): Don't return early for stopped profiles. (KJS::Profiler::stopProfiling): Skipp stopped profiles. (KJS::Profiler::didFinishAllExecution): Code clean-up.
  • profiler/Profiler.h: Removed findProfile.
File:
1 edited

Legend:

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

    r34696 r34800  
    5656    return s_sharedProfiler;
    5757}   
    58    
    59 Profile* Profiler::findProfile(ExecState* exec, const UString& title) const
    60 {
    61     ExecState* globalExec = exec->lexicalGlobalObject()->globalExec();
    62     for (size_t i = 0; i < m_currentProfiles.size(); ++i)
    63         if (m_currentProfiles[i]->originatingGlobalExec() == globalExec && (title.isNull() || m_currentProfiles[i]->title() == title))
    64             return m_currentProfiles[i].get();
    65     return 0;
    66 }
    6758
    6859void Profiler::startProfiling(ExecState* exec, const UString& title, ProfilerClient* client)
     
    7364    // If so return early and don't create a new Profile.
    7465    ExecState* globalExec = exec->lexicalGlobalObject()->globalExec();
    75     for (size_t i = 0; i < m_currentProfiles.size(); ++i)
    76         if (m_currentProfiles[i]->originatingGlobalExec() == globalExec && m_currentProfiles[i]->title() == title)
     66    for (size_t i = 0; i < m_currentProfiles.size(); ++i) {
     67        Profile* profile = m_currentProfiles[i].get();
     68        if (!profile->stoppedProfiling() && profile->originatingGlobalExec() == globalExec && profile->title() == title)
    7769            return;
     70    }
     71
    7872    s_sharedEnabledProfilerReference = this;
    7973    RefPtr<Profile> profile = Profile::create(title, globalExec, exec->lexicalGlobalObject()->pageGroupIdentifier(), client);
     
    8579    ExecState* globalExec = exec->lexicalGlobalObject()->globalExec();
    8680    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))
     81        Profile* profile = m_currentProfiles[i].get();
     82        if (!profile->stoppedProfiling() && profile->originatingGlobalExec() == globalExec && (title.isNull() || profile->title() == title))
    8883            m_currentProfiles[i]->stopProfiling();
    8984    }
     
    9489    ExecState* globalExec = exec->lexicalGlobalObject()->globalExec();
    9590    for (ptrdiff_t i = m_currentProfiles.size() - 1; i >= 0; --i) {
    96         if (m_currentProfiles[i]->originatingGlobalExec() == globalExec && m_currentProfiles[i]->didFinishAllExecution()) {
     91        Profile* profile = m_currentProfiles[i].get();
     92        if (profile->originatingGlobalExec() == globalExec && profile->didFinishAllExecution()) {
    9793            PassRefPtr<Profile> prpProfile = m_currentProfiles[i].release();       
    9894            m_currentProfiles.remove(i);
Note: See TracChangeset for help on using the changeset viewer.