LazyOperandValueProfile.cpp [plain text]
#include "config.h"
#include "LazyOperandValueProfile.h"
#include "JSCInlines.h"
namespace JSC {
CompressedLazyOperandValueProfileHolder::CompressedLazyOperandValueProfileHolder() { }
CompressedLazyOperandValueProfileHolder::~CompressedLazyOperandValueProfileHolder() { }
void CompressedLazyOperandValueProfileHolder::computeUpdatedPredictions(const ConcurrentJITLocker& locker)
{
if (!m_data)
return;
for (unsigned i = 0; i < m_data->size(); ++i)
m_data->at(i).computeUpdatedPrediction(locker);
}
LazyOperandValueProfile* CompressedLazyOperandValueProfileHolder::add(
const ConcurrentJITLocker&, const LazyOperandValueProfileKey& key)
{
if (!m_data)
m_data = adoptPtr(new LazyOperandValueProfile::List());
else {
for (unsigned i = 0; i < m_data->size(); ++i) {
if (m_data->at(i).key() == key)
return &m_data->at(i);
}
}
m_data->append(LazyOperandValueProfile(key));
return &m_data->last();
}
LazyOperandValueProfileParser::LazyOperandValueProfileParser() { }
LazyOperandValueProfileParser::~LazyOperandValueProfileParser() { }
void LazyOperandValueProfileParser::initialize(
const ConcurrentJITLocker&, CompressedLazyOperandValueProfileHolder& holder)
{
ASSERT(m_map.isEmpty());
if (!holder.m_data)
return;
LazyOperandValueProfile::List& data = *holder.m_data;
for (unsigned i = 0; i < data.size(); ++i)
m_map.add(data[i].key(), &data[i]);
}
LazyOperandValueProfile* LazyOperandValueProfileParser::getIfPresent(
const LazyOperandValueProfileKey& key) const
{
HashMap<LazyOperandValueProfileKey, LazyOperandValueProfile*>::const_iterator iter =
m_map.find(key);
if (iter == m_map.end())
return 0;
return iter->value;
}
SpeculatedType LazyOperandValueProfileParser::prediction(
const ConcurrentJITLocker& locker, const LazyOperandValueProfileKey& key) const
{
LazyOperandValueProfile* profile = getIfPresent(key);
if (!profile)
return SpecNone;
return profile->computeUpdatedPrediction(locker);
}
}