#pragma once
#include "CodeBlock.h"
#include "Register.h"
#include "StackAlignment.h"
#include <wtf/ForbidHeapAllocation.h>
namespace JSC {
struct JS_EXPORT_PRIVATE ProtoCallFrame {
WTF_FORBID_HEAP_ALLOCATION;
public:
static constexpr unsigned numberOfRegisters { 4 };
Register codeBlockValue;
Register calleeValue;
Register argCountAndCodeOriginValue;
Register thisArg;
uint32_t paddedArgCount;
bool hasArityMismatch;
JSValue *args;
JSGlobalObject* globalObject;
inline void init(CodeBlock*, JSGlobalObject*, JSObject*, JSValue, int, JSValue* otherArgs = nullptr);
inline CodeBlock* codeBlock() const;
inline void setCodeBlock(CodeBlock*);
inline JSObject* callee() const;
inline void setCallee(JSObject*);
void setGlobalObject(JSGlobalObject* object)
{
globalObject = object;
}
int argumentCountIncludingThis() const { return argCountAndCodeOriginValue.payload(); }
int argumentCount() const { return argumentCountIncludingThis() - 1; }
void setArgumentCountIncludingThis(int count) { argCountAndCodeOriginValue.payload() = count; }
void setPaddedArgCount(uint32_t argCount) { paddedArgCount = argCount; }
void clearCurrentVPC() { argCountAndCodeOriginValue.tag() = 0; }
JSValue thisValue() const { return thisArg.Register::jsValue(); }
void setThisValue(JSValue value) { thisArg = value; }
bool needArityCheck() { return hasArityMismatch; }
JSValue argument(size_t argumentIndex)
{
ASSERT(static_cast<int>(argumentIndex) < argumentCount());
return args[argumentIndex];
}
void setArgument(size_t argumentIndex, JSValue value)
{
ASSERT(static_cast<int>(argumentIndex) < argumentCount());
args[argumentIndex] = value;
}
};
}