#include "config.h"
#include "JITExceptions.h"
#include "CallFrame.h"
#include "CatchScope.h"
#include "CodeBlock.h"
#include "Disassembler.h"
#include "Interpreter.h"
#include "JSCInlines.h"
#include "JSCJSValue.h"
#include "LLIntData.h"
#include "LLIntOpcode.h"
#include "LLIntThunks.h"
#include "Opcode.h"
#include "ShadowChicken.h"
#include "VM.h"
namespace JSC {
void genericUnwind(VM* vm, ExecState* callFrame, UnwindStart unwindStart)
{
auto scope = DECLARE_CATCH_SCOPE(*vm);
if (Options::breakOnThrow()) {
CodeBlock* codeBlock = callFrame->codeBlock();
if (codeBlock)
dataLog("In call frame ", RawPointer(callFrame), " for code block ", *codeBlock, "\n");
else
dataLog("In call frame ", RawPointer(callFrame), " with null CodeBlock\n");
CRASH();
}
ExecState* shadowChickenTopFrame = callFrame;
if (unwindStart == UnwindFromCallerFrame) {
VMEntryFrame* topVMEntryFrame = vm->topVMEntryFrame;
shadowChickenTopFrame = callFrame->callerFrame(topVMEntryFrame);
}
vm->shadowChicken().log(*vm, shadowChickenTopFrame, ShadowChicken::Packet::throwPacket());
Exception* exception = scope.exception();
RELEASE_ASSERT(exception);
HandlerInfo* handler = vm->interpreter->unwind(*vm, callFrame, exception, unwindStart);
void* catchRoutine;
Instruction* catchPCForInterpreter = 0;
if (handler) {
if (!JITCode::isOptimizingJIT(callFrame->codeBlock()->jitType()))
catchPCForInterpreter = &callFrame->codeBlock()->instructions()[handler->target];
#if ENABLE(JIT)
catchRoutine = handler->nativeCode.executableAddress();
#else
catchRoutine = catchPCForInterpreter->u.pointer;
#endif
} else
catchRoutine = LLInt::getCodePtr(handleUncaughtException);
ASSERT(bitwise_cast<uintptr_t>(callFrame) < bitwise_cast<uintptr_t>(vm->topVMEntryFrame));
vm->callFrameForCatch = callFrame;
vm->targetMachinePCForThrow = catchRoutine;
vm->targetInterpreterPCForThrow = catchPCForInterpreter;
RELEASE_ASSERT(catchRoutine);
}
void genericUnwind(VM* vm, ExecState* callFrame)
{
genericUnwind(vm, callFrame, UnwindFromCurrentFrame);
}
}