#ifndef PutByIdStatus_h
#define PutByIdStatus_h
#include <wtf/NotFound.h>
namespace JSC {
class CodeBlock;
class Identifier;
class Structure;
class StructureChain;
class PutByIdStatus {
public:
enum State {
NoInformation,
SimpleReplace,
SimpleTransition,
TakesSlowPath
};
PutByIdStatus()
: m_state(NoInformation)
, m_oldStructure(0)
, m_newStructure(0)
, m_structureChain(0)
, m_offset(notFound)
{
}
PutByIdStatus(
State state,
Structure* oldStructure,
Structure* newStructure,
StructureChain* structureChain,
size_t offset)
: m_state(state)
, m_oldStructure(oldStructure)
, m_newStructure(newStructure)
, m_structureChain(structureChain)
, m_offset(offset)
{
ASSERT((m_state == NoInformation || m_state == TakesSlowPath) == !m_oldStructure);
ASSERT((m_state != SimpleTransition) == !m_newStructure);
ASSERT((m_state != SimpleTransition) == !m_structureChain);
ASSERT((m_state == NoInformation || m_state == TakesSlowPath) == (m_offset == notFound));
}
static PutByIdStatus computeFor(CodeBlock*, unsigned bytecodeIndex, Identifier&);
State state() const { return m_state; }
bool isSet() const { return m_state != NoInformation; }
bool operator!() const { return m_state == NoInformation; }
bool isSimpleReplace() const { return m_state == SimpleReplace; }
bool isSimpleTransition() const { return m_state == SimpleTransition; }
bool takesSlowPath() const { return m_state == TakesSlowPath; }
Structure* oldStructure() const { return m_oldStructure; }
Structure* newStructure() const { return m_newStructure; }
StructureChain* structureChain() const { return m_structureChain; }
size_t offset() const { return m_offset; }
private:
static PutByIdStatus computeFromLLInt(CodeBlock*, unsigned bytecodeIndex, Identifier&);
State m_state;
Structure* m_oldStructure;
Structure* m_newStructure;
StructureChain* m_structureChain;
size_t m_offset;
};
}
#endif // PutByIdStatus_h