InterpreterInlines.h [plain text]
#pragma once
#include "CallFrameClosure.h"
#include "Exception.h"
#include "Instruction.h"
#include "Interpreter.h"
#include "JSCPtrTag.h"
#include "LLIntData.h"
#include "UnlinkedCodeBlock.h"
#include <wtf/UnalignedAccess.h>
namespace JSC {
inline Opcode Interpreter::getOpcode(OpcodeID id)
{
return LLInt::getOpcode(id);
}
inline OpcodeID Interpreter::getOpcodeID(Opcode opcode)
{
#if ENABLE(COMPUTED_GOTO_OPCODES)
ASSERT(isOpcode(opcode));
#if USE(LLINT_EMBEDDED_OPCODE_ID)
auto codePtr = MacroAssemblerCodePtr<BytecodePtrTag>::createFromExecutableAddress(opcode);
int32_t* opcodeIDAddress = codePtr.dataLocation<int32_t*>() - 1;
OpcodeID opcodeID = static_cast<OpcodeID>(WTF::unalignedLoad<int32_t>(opcodeIDAddress));
ASSERT(opcodeID < NUMBER_OF_BYTECODE_IDS);
return opcodeID;
#else
return opcodeIDTable().get(opcode);
#endif // USE(LLINT_EMBEDDED_OPCODE_ID)
#else // not ENABLE(COMPUTED_GOTO_OPCODES)
return opcode;
#endif
}
ALWAYS_INLINE JSValue Interpreter::execute(CallFrameClosure& closure)
{
VM& vm = *closure.vm;
auto throwScope = DECLARE_THROW_SCOPE(vm);
ASSERT(!vm.isCollectorBusyOnCurrentThread());
ASSERT(vm.currentThreadIsHoldingAPILock());
StackStats::CheckPoint stackCheckPoint;
VMTraps::Mask mask(VMTraps::NeedTermination, VMTraps::NeedWatchdogCheck);
if (UNLIKELY(vm.needTrapHandling(mask))) {
vm.handleTraps(closure.oldCallFrame, mask);
RETURN_IF_EXCEPTION(throwScope, throwScope.exception());
}
throwScope.release();
JSValue result = closure.functionExecutable->generatedJITCodeForCall()->execute(&vm, closure.protoCallFrame);
return checkedReturn(result);
}
}