DFGAbstractValueClobberEpoch.h [plain text]
#pragma once
#if ENABLE(DFG_JIT)
#include "DFGEpoch.h"
#include "DFGStructureClobberState.h"
#include <wtf/PrintStream.h>
namespace JSC { namespace DFG {
class AbstractValueClobberEpoch {
public:
AbstractValueClobberEpoch()
{
}
static AbstractValueClobberEpoch first(StructureClobberState clobberState)
{
AbstractValueClobberEpoch result;
result.m_value = Epoch::first().toUnsigned() << epochShift;
switch (clobberState) {
case StructuresAreWatched:
result.m_value |= watchedFlag;
break;
case StructuresAreClobbered:
break;
}
return result;
}
void clobber()
{
m_value += step;
m_value &= ~watchedFlag;
}
void observeInvalidationPoint()
{
m_value |= watchedFlag;
}
bool operator==(const AbstractValueClobberEpoch& other) const
{
return m_value == other.m_value;
}
bool operator!=(const AbstractValueClobberEpoch& other) const
{
return !(*this == other);
}
StructureClobberState structureClobberState() const
{
return m_value & watchedFlag ? StructuresAreWatched : StructuresAreClobbered;
}
Epoch clobberEpoch() const
{
return Epoch::fromUnsigned(m_value >> epochShift);
}
void dump(PrintStream&) const;
private:
static constexpr unsigned step = 2;
static constexpr unsigned watchedFlag = 1;
static constexpr unsigned epochShift = 1;
unsigned m_value { 0 };
};
} }
#endif // ENABLE(DFG_JIT)