DFGPropertyTypeKey.h [plain text]
#pragma once
#if ENABLE(DFG_JIT)
#include "Structure.h"
#include <wtf/HashMap.h>
namespace JSC { namespace DFG {
class PropertyTypeKey {
public:
PropertyTypeKey()
: m_structure(nullptr)
, m_uid(nullptr)
{
}
PropertyTypeKey(Structure* structure, UniquedStringImpl* uid)
: m_structure(structure)
, m_uid(uid)
{
}
PropertyTypeKey(WTF::HashTableDeletedValueType)
: m_structure(nullptr)
, m_uid(deletedUID())
{
}
explicit operator bool() const { return m_structure && m_uid; }
Structure* structure() const { return m_structure; }
UniquedStringImpl* uid() const { return m_uid; }
bool operator==(const PropertyTypeKey& other) const
{
return m_structure == other.m_structure
&& m_uid == other.m_uid;
}
bool operator!=(const PropertyTypeKey& other) const
{
return !(*this == other);
}
unsigned hash() const
{
return WTF::PtrHash<Structure*>::hash(m_structure) + WTF::PtrHash<UniquedStringImpl*>::hash(m_uid);
}
bool isHashTableDeletedValue() const
{
return !m_structure && m_uid == deletedUID();
}
void dumpInContext(PrintStream& out, DumpContext* context) const
{
out.print(pointerDumpInContext(m_structure, context), "+", m_uid);
}
void dump(PrintStream& out) const
{
dumpInContext(out, nullptr);
}
private:
static UniquedStringImpl* deletedUID()
{
return bitwise_cast<UniquedStringImpl*>(static_cast<intptr_t>(1));
}
Structure* m_structure;
UniquedStringImpl* m_uid;
};
struct PropertyTypeKeyHash {
static unsigned hash(const PropertyTypeKey& key) { return key.hash(); }
static bool equal(const PropertyTypeKey& a, const PropertyTypeKey& b) { return a == b; }
static const bool safeToCompareToEmptyOrDeleted = true;
};
} }
namespace WTF {
template<typename T> struct DefaultHash;
template<> struct DefaultHash<JSC::DFG::PropertyTypeKey> {
typedef JSC::DFG::PropertyTypeKeyHash Hash;
};
template<typename T> struct HashTraits;
template<> struct HashTraits<JSC::DFG::PropertyTypeKey> : SimpleClassHashTraits<JSC::DFG::PropertyTypeKey> {
static const bool emptyValueIsZero = false;
};
}
#endif // ENABLE(DFG_JIT)