Ignore:
Timestamp:
Jul 7, 2008, 11:12:09 AM (17 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2008-07-07 Kevin McCullough <[email protected]>

Reviewed by Darin.

When the profiler is running it gathers information and creates a
Profile. After it finishes the Profile can be sorted and have other
data refinements run over it. Both of these were done in the same class
before. Now I split the gathering operations into a new class called
ProfileGenerator.

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • profiler/Profile.cpp: Removed code related to the gather stage of a Profile's creation. (KJS::Profile::create): (KJS::Profile::Profile):
  • profiler/Profile.h: Ditto. (KJS::Profile::title): (KJS::Profile::callTree): (KJS::Profile::setHead):
  • profiler/ProfileGenerator.cpp: Added. This is the class that will handle the stage of creating a Profile. Once the Profile is finished being created, this class goes away. (KJS::ProfileGenerator::create): (KJS::ProfileGenerator::ProfileGenerator): (KJS::ProfileGenerator::title): (KJS::ProfileGenerator::willExecute): (KJS::ProfileGenerator::didExecute): (KJS::ProfileGenerator::stopProfiling): (KJS::ProfileGenerator::didFinishAllExecution): (KJS::ProfileGenerator::removeProfileStart): (KJS::ProfileGenerator::removeProfileEnd):
  • profiler/ProfileGenerator.h: Added. (KJS::ProfileGenerator::profile): (KJS::ProfileGenerator::originatingGlobalExec): (KJS::ProfileGenerator::pageGroupIdentifier): (KJS::ProfileGenerator::client): (KJS::ProfileGenerator::stoppedProfiling):
  • profiler/Profiler.cpp: Now operates with the ProfileGenerator instead of the Profile. (KJS::Profiler::startProfiling): (KJS::Profiler::stopProfiling): (KJS::Profiler::didFinishAllExecution): It is here that the Profile is handed off to its client and the Profile Generator is no longer needed. (KJS::dispatchFunctionToProfiles): (KJS::Profiler::willExecute): (KJS::Profiler::didExecute):
  • profiler/Profiler.h: Cleaned up the includes and subsequently the forward declarations. Also use the new ProfileGenerator. (KJS::ProfilerClient::~ProfilerClient): (KJS::Profiler::currentProfiles):
  • profiler/TreeProfile.cpp: Use Profile's new interface. (KJS::TreeProfile::create): (KJS::TreeProfile::TreeProfile):
  • profiler/TreeProfile.h:

WebCore:

2008-07-07 Kevin McCullough <[email protected]>

Reviewed by Darin.

Because profiler.h no longer #includes profile.h we need to explicitly
include it in console.cpp.

  • page/Console.cpp:
File:
1 edited

Legend:

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

    r35037 r35039  
    3434#include "JSGlobalObject.h"
    3535#include "Profile.h"
     36#include "ProfileGenerator.h"
    3637#include "ProfileNode.h"
    3738#include <stdio.h>
     
    6465    ExecState* globalExec = exec->lexicalGlobalObject()->globalExec();
    6566    for (size_t i = 0; i < m_currentProfiles.size(); ++i) {
    66         Profile* profile = m_currentProfiles[i].get();
    67         if (!profile->stoppedProfiling() && profile->originatingGlobalExec() == globalExec && profile->title() == title)
     67        ProfileGenerator* profileGenerator = m_currentProfiles[i].get();
     68        if (!profileGenerator->stoppedProfiling() && profileGenerator->originatingGlobalExec() == globalExec && profileGenerator->title() == title)
    6869            return;
    6970    }
    7071
    7172    s_sharedEnabledProfilerReference = this;
    72     RefPtr<Profile> profile = Profile::create(title, globalExec, exec->lexicalGlobalObject()->pageGroupIdentifier(), client);
    73     m_currentProfiles.append(profile);
     73    RefPtr<ProfileGenerator> profileGenerator = ProfileGenerator::create(title, globalExec, exec->lexicalGlobalObject()->pageGroupIdentifier(), client);
     74    m_currentProfiles.append(profileGenerator);
    7475}
    7576
     
    7879    ExecState* globalExec = exec->lexicalGlobalObject()->globalExec();
    7980    for (ptrdiff_t i = m_currentProfiles.size() - 1; i >= 0; --i) {
    80         Profile* profile = m_currentProfiles[i].get();
    81         if (!profile->stoppedProfiling() && profile->originatingGlobalExec() == globalExec && (title.isNull() || profile->title() == title))
     81        ProfileGenerator* profileGenerator = m_currentProfiles[i].get();
     82        if (!profileGenerator->stoppedProfiling() && profileGenerator->originatingGlobalExec() == globalExec && (title.isNull() || profileGenerator->title() == title))
    8283            m_currentProfiles[i]->stopProfiling();
    8384    }
     
    8889    ExecState* globalExec = exec->lexicalGlobalObject()->globalExec();
    8990    for (ptrdiff_t i = m_currentProfiles.size() - 1; i >= 0; --i) {
    90         Profile* profile = m_currentProfiles[i].get();
    91         if (profile->originatingGlobalExec() == globalExec && profile->didFinishAllExecution()) {
    92             PassRefPtr<Profile> prpProfile = m_currentProfiles[i].release();       
     91        ProfileGenerator* profileGenerator = m_currentProfiles[i].get();
     92        if (profileGenerator->originatingGlobalExec() == globalExec && profileGenerator->didFinishAllExecution()) {
     93            PassRefPtr<ProfileGenerator> prpProfileGenerator = m_currentProfiles[i].release();
    9394            m_currentProfiles.remove(i);
    9495
     
    9697                s_sharedEnabledProfilerReference = 0;
    9798
    98             if (ProfilerClient* client = prpProfile->client())
    99                 client->finishedProfiling(prpProfile);
     99            if (ProfilerClient* client = prpProfileGenerator->client())
     100                client->finishedProfiling(prpProfileGenerator->profile());
    100101        }
    101102    }
    102103}
    103104
    104 static inline void dispatchFunctionToProfiles(const Vector<RefPtr<Profile> >& profiles, Profile::ProfileFunction function, const CallIdentifier& callIdentifier, unsigned currentPageGroupIdentifier)
     105static inline void dispatchFunctionToProfiles(const Vector<RefPtr<ProfileGenerator> >& profiles, ProfileGenerator::ProfileFunction function, const CallIdentifier& callIdentifier, unsigned currentPageGroupIdentifier)
    105106{
    106107    for (size_t i = 0; i < profiles.size(); ++i) {
     
    114115    ASSERT(!m_currentProfiles.isEmpty());
    115116
    116     dispatchFunctionToProfiles(m_currentProfiles, &Profile::willExecute, createCallIdentifier(calledFunction), exec->lexicalGlobalObject()->pageGroupIdentifier());
     117    dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::willExecute, createCallIdentifier(calledFunction), exec->lexicalGlobalObject()->pageGroupIdentifier());
    117118}
    118119
     
    123124    CallIdentifier callIdentifier = createCallIdentifier(sourceURL, startingLineNumber);
    124125
    125     dispatchFunctionToProfiles(m_currentProfiles, &Profile::willExecute, callIdentifier, exec->lexicalGlobalObject()->pageGroupIdentifier());
     126    dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::willExecute, callIdentifier, exec->lexicalGlobalObject()->pageGroupIdentifier());
    126127}
    127128
     
    130131    ASSERT(!m_currentProfiles.isEmpty());
    131132
    132     dispatchFunctionToProfiles(m_currentProfiles, &Profile::didExecute, createCallIdentifier(calledFunction), exec->lexicalGlobalObject()->pageGroupIdentifier());
     133    dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::didExecute, createCallIdentifier(calledFunction), exec->lexicalGlobalObject()->pageGroupIdentifier());
    133134}
    134135
     
    137138    ASSERT(!m_currentProfiles.isEmpty());
    138139
    139     dispatchFunctionToProfiles(m_currentProfiles, &Profile::didExecute, createCallIdentifier(sourceURL, startingLineNumber), exec->lexicalGlobalObject()->pageGroupIdentifier());
     140    dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::didExecute, createCallIdentifier(sourceURL, startingLineNumber), exec->lexicalGlobalObject()->pageGroupIdentifier());
    140141}
    141142
Note: See TracChangeset for help on using the changeset viewer.