LazyOperandValueProfile.cpp [plain text]
#include "config.h"
#include "LazyOperandValueProfile.h"
#if ENABLE(VALUE_PROFILER)
#include "Operations.h"
namespace JSC {
CompressedLazyOperandValueProfileHolder::CompressedLazyOperandValueProfileHolder() { }
CompressedLazyOperandValueProfileHolder::~CompressedLazyOperandValueProfileHolder() { }
void CompressedLazyOperandValueProfileHolder::computeUpdatedPredictions(OperationInProgress operation)
{
if (!m_data)
return;
for (unsigned i = 0; i < m_data->size(); ++i)
m_data->at(i).computeUpdatedPrediction(operation);
}
LazyOperandValueProfile* CompressedLazyOperandValueProfileHolder::add(
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(
CompressedLazyOperandValueProfileHolder& holder)
: m_holder(holder)
{
if (!m_holder.m_data)
return;
LazyOperandValueProfile::List& data = *m_holder.m_data;
for (unsigned i = 0; i < data.size(); ++i)
m_map.add(data[i].key(), &data[i]);
}
LazyOperandValueProfileParser::~LazyOperandValueProfileParser() { }
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 LazyOperandValueProfileKey& key) const
{
LazyOperandValueProfile* profile = getIfPresent(key);
if (!profile)
return SpecNone;
return profile->computeUpdatedPrediction();
}
}
#endif // ENABLE(VALUE_PROFILER)