LLIntCallLinkInfo.h [plain text]
#pragma once
#include "JSCPtrTag.h"
#include "JSFunction.h"
#include "MacroAssemblerCodeRef.h"
#include <wtf/SentinelLinkedList.h>
namespace JSC {
struct Instruction;
class LLIntCallLinkInfo : public PackedRawSentinelNode<LLIntCallLinkInfo> {
public:
friend class LLIntOffsetsExtractor;
static constexpr uintptr_t unlinkedBit = 0x1;
LLIntCallLinkInfo() = default;
~LLIntCallLinkInfo()
{
if (isOnList())
remove();
}
bool isLinked() const { return !(m_calleeOrLastSeenCalleeWithLinkBit & unlinkedBit); }
void link(VM& vm, JSCell* owner, JSObject* callee, MacroAssemblerCodePtr<JSEntryPtrTag> codePtr)
{
if (isOnList())
remove();
m_calleeOrLastSeenCalleeWithLinkBit = bitwise_cast<uintptr_t>(callee);
vm.heap.writeBarrier(owner, callee);
m_machineCodeTarget = codePtr;
}
void unlink()
{
m_calleeOrLastSeenCalleeWithLinkBit |= unlinkedBit;
m_machineCodeTarget = MacroAssemblerCodePtr<JSEntryPtrTag>();
if (isOnList())
remove();
}
JSObject* callee() const
{
if (!isLinked())
return nullptr;
return bitwise_cast<JSObject*>(m_calleeOrLastSeenCalleeWithLinkBit);
}
JSObject* lastSeenCallee() const
{
return bitwise_cast<JSObject*>(m_calleeOrLastSeenCalleeWithLinkBit & ~unlinkedBit);
}
void clearLastSeenCallee()
{
m_calleeOrLastSeenCalleeWithLinkBit = unlinkedBit;
}
ArrayProfile m_arrayProfile;
private:
uintptr_t m_calleeOrLastSeenCalleeWithLinkBit { unlinkedBit };
MacroAssemblerCodePtr<JSEntryPtrTag> m_machineCodeTarget;
};
}