FTLSlowPathCallKey.h [plain text]
#pragma once
#if ENABLE(FTL_JIT)
#include "RegisterSet.h"
namespace JSC { namespace FTL {
class SlowPathCallKey {
public:
SlowPathCallKey()
: m_callTarget(0)
, m_offset(0)
{
}
SlowPathCallKey(
const RegisterSet& set, void* callTarget, const RegisterSet& argumentRegisters,
ptrdiff_t offset)
: m_usedRegisters(set)
, m_callTarget(callTarget)
, m_argumentRegisters(argumentRegisters)
, m_offset(offset)
{
}
const RegisterSet& usedRegisters() const { return m_usedRegisters; }
void* callTarget() const { return m_callTarget; }
const RegisterSet& argumentRegisters() const { return m_argumentRegisters; }
ptrdiff_t offset() const { return m_offset; }
SlowPathCallKey withCallTarget(void* callTarget)
{
return SlowPathCallKey(usedRegisters(), callTarget, argumentRegisters(), offset());
}
void dump(PrintStream&) const;
enum EmptyValueTag { EmptyValue };
enum DeletedValueTag { DeletedValue };
SlowPathCallKey(EmptyValueTag)
: m_usedRegisters(RegisterSet::EmptyValue)
, m_callTarget(0)
, m_offset(0)
{
}
SlowPathCallKey(DeletedValueTag)
: m_usedRegisters(RegisterSet::DeletedValue)
, m_callTarget(0)
, m_offset(0)
{
}
bool isEmptyValue() const { return m_usedRegisters.isEmptyValue(); }
bool isDeletedValue() const { return m_usedRegisters.isDeletedValue(); }
bool operator==(const SlowPathCallKey& other) const
{
return m_usedRegisters == other.m_usedRegisters
&& m_callTarget == other.m_callTarget
&& m_offset == other.m_offset;
}
unsigned hash() const
{
return m_usedRegisters.hash() + PtrHash<void*>::hash(m_callTarget) + m_offset;
}
private:
RegisterSet m_usedRegisters;
void* m_callTarget;
RegisterSet m_argumentRegisters;
ptrdiff_t m_offset;
};
struct SlowPathCallKeyHash {
static unsigned hash(const SlowPathCallKey& key) { return key.hash(); }
static bool equal(const SlowPathCallKey& a, const SlowPathCallKey& b) { return a == b; }
static const bool safeToCompareToEmptyOrDeleted = false;
};
} }
namespace WTF {
template<typename T> struct DefaultHash;
template<> struct DefaultHash<JSC::FTL::SlowPathCallKey> {
typedef JSC::FTL::SlowPathCallKeyHash Hash;
};
template<typename T> struct HashTraits;
template<> struct HashTraits<JSC::FTL::SlowPathCallKey> : public CustomHashTraits<JSC::FTL::SlowPathCallKey> { };
}
#endif // ENABLE(FTL_JIT)