DFGExitProfile.cpp [plain text]
#include "config.h"
#include "DFGExitProfile.h"
#if ENABLE(DFG_JIT)
#include "CodeBlock.h"
#include "VMInlines.h"
namespace JSC { namespace DFG {
void FrequentExitSite::dump(PrintStream& out) const
{
out.print("bc#", m_bytecodeOffset, ": ", m_kind, "/", m_jitType);
}
ExitProfile::ExitProfile() { }
ExitProfile::~ExitProfile() { }
bool ExitProfile::add(const ConcurrentJSLocker&, CodeBlock* owner, const FrequentExitSite& site)
{
ASSERT(site.jitType() != ExitFromAnything);
CODEBLOCK_LOG_EVENT(owner, "frequentExit", (site));
if (Options::verboseExitProfile())
dataLog(pointerDump(owner), ": Adding exit site: ", site, "\n");
if (!m_frequentExitSites) {
m_frequentExitSites = std::make_unique<Vector<FrequentExitSite>>();
m_frequentExitSites->append(site);
return true;
}
for (unsigned i = 0; i < m_frequentExitSites->size(); ++i) {
if (m_frequentExitSites->at(i) == site)
return false;
}
m_frequentExitSites->append(site);
return true;
}
Vector<FrequentExitSite> ExitProfile::exitSitesFor(unsigned bytecodeIndex)
{
Vector<FrequentExitSite> result;
if (!m_frequentExitSites)
return result;
for (unsigned i = 0; i < m_frequentExitSites->size(); ++i) {
if (m_frequentExitSites->at(i).bytecodeOffset() == bytecodeIndex)
result.append(m_frequentExitSites->at(i));
}
return result;
}
bool ExitProfile::hasExitSite(const ConcurrentJSLocker&, const FrequentExitSite& site) const
{
if (!m_frequentExitSites)
return false;
for (unsigned i = m_frequentExitSites->size(); i--;) {
if (site.subsumes(m_frequentExitSites->at(i)))
return true;
}
return false;
}
QueryableExitProfile::QueryableExitProfile() { }
QueryableExitProfile::~QueryableExitProfile() { }
void QueryableExitProfile::initialize(const ConcurrentJSLocker&, const ExitProfile& profile)
{
if (!profile.m_frequentExitSites)
return;
for (unsigned i = 0; i < profile.m_frequentExitSites->size(); ++i)
m_frequentExitSites.add(profile.m_frequentExitSites->at(i));
}
} }
#endif