void Profiler::stopProfiling(ExecState* exec, const UString& title) { ExecState* globalExec = exec->lexicalGlobalObject()->globalExec(); for (ptrdiff_t i = m_currentProfiles.size() - 1; i >= 0; --i) { ProfileGenerator* profileGenerator = m_currentProfiles[i].get(); if (!profileGenerator->stoppedProfiling() && profileGenerator->originatingGlobalExec() == globalExec && (title.isNull() || profileGenerator->title() == title)) m_currentProfiles[i]->stopProfiling(); } }
void Profiler::startProfiling(ExecState* exec, const UString& title) { // Check if we currently have a Profile for this global ExecState and title. // If so return early and don't create a new Profile. ExecState* globalExec = exec ? exec->lexicalGlobalObject()->globalExec() : 0; for (size_t i = 0; i < m_currentProfiles.size(); ++i) { ProfileGenerator* profileGenerator = m_currentProfiles[i].get(); if (profileGenerator->originatingGlobalExec() == globalExec && profileGenerator->title() == title) return; } s_sharedEnabledProfilerReference = this; RefPtr<ProfileGenerator> profileGenerator = ProfileGenerator::create(title, exec, ++ProfilesUID); m_currentProfiles.append(profileGenerator); }
void Profiler::didFinishAllExecution(ExecState* exec) { ExecState* globalExec = exec->lexicalGlobalObject()->globalExec(); for (ptrdiff_t i = m_currentProfiles.size() - 1; i >= 0; --i) { ProfileGenerator* profileGenerator = m_currentProfiles[i].get(); if (profileGenerator->originatingGlobalExec() == globalExec && profileGenerator->didFinishAllExecution()) { PassRefPtr<ProfileGenerator> prpProfileGenerator = m_currentProfiles[i].release(); m_currentProfiles.remove(i); if (!m_currentProfiles.size()) s_sharedEnabledProfilerReference = 0; if (ProfilerClient* client = prpProfileGenerator->client()) client->finishedProfiling(prpProfileGenerator->profile()); } } }
PassRefPtr<Profile> Profiler::stopProfiling(ExecState* exec, const UString& title) { ExecState* globalExec = exec ? exec->lexicalGlobalObject()->globalExec() : 0; for (ptrdiff_t i = m_currentProfiles.size() - 1; i >= 0; --i) { ProfileGenerator* profileGenerator = m_currentProfiles[i].get(); if (profileGenerator->originatingGlobalExec() == globalExec && (title.isNull() || profileGenerator->title() == title)) { profileGenerator->stopProfiling(); RefPtr<Profile> returnProfile = profileGenerator->profile(); m_currentProfiles.remove(i); if (!m_currentProfiles.size()) s_sharedEnabledProfilerReference = 0; return returnProfile; } } return 0; }