DFGDesiredGlobalProperty.h [plain text]
#pragma once
#if ENABLE(DFG_JIT)
#include "DumpContext.h"
#include <wtf/HashMap.h>
#include <wtf/PrintStream.h>
namespace JSC {
class JSGlobalObject;
namespace DFG {
class DesiredGlobalProperty {
public:
DesiredGlobalProperty() = default;
DesiredGlobalProperty(JSGlobalObject* globalObject, unsigned identifierNumber)
: m_globalObject(globalObject)
, m_identifierNumber(identifierNumber)
{
}
DesiredGlobalProperty(WTF::HashTableDeletedValueType)
: m_globalObject(nullptr)
, m_identifierNumber(UINT_MAX)
{
}
JSGlobalObject* globalObject() const { return m_globalObject; }
unsigned identifierNumber() const { return m_identifierNumber; }
bool operator==(const DesiredGlobalProperty& other) const
{
return m_globalObject == other.m_globalObject && m_identifierNumber == other.m_identifierNumber;
}
bool operator!=(const DesiredGlobalProperty& other) const
{
return !(*this == other);
}
bool isHashTableDeletedValue() const
{
return !m_globalObject && m_identifierNumber == UINT_MAX;
}
unsigned hash() const
{
return WTF::PtrHash<JSGlobalObject*>::hash(m_globalObject) + m_identifierNumber * 7;
}
void dumpInContext(PrintStream& out, DumpContext*) const
{
out.print(m_identifierNumber, " for ", RawPointer(m_globalObject));
}
void dump(PrintStream& out) const
{
dumpInContext(out, nullptr);
}
private:
JSGlobalObject* m_globalObject { nullptr };
unsigned m_identifierNumber { 0 };
};
struct DesiredGlobalPropertyHash {
static unsigned hash(const DesiredGlobalProperty& key) { return key.hash(); }
static bool equal(const DesiredGlobalProperty& a, const DesiredGlobalProperty& b) { return a == b; }
static const bool safeToCompareToEmptyOrDeleted = true;
};
} }
namespace WTF {
template<typename T> struct DefaultHash;
template<> struct DefaultHash<JSC::DFG::DesiredGlobalProperty> {
typedef JSC::DFG::DesiredGlobalPropertyHash Hash;
};
template<typename T> struct HashTraits;
template<> struct HashTraits<JSC::DFG::DesiredGlobalProperty> : SimpleClassHashTraits<JSC::DFG::DesiredGlobalProperty> { };
}
#endif // ENABLE(DFG_JIT)