2018-09-13 00:29:04 +00:00
|
|
|
|
|
|
|
#include "jitintern.h"
|
|
|
|
|
|
|
|
void JitCompiler::EmitTEST()
|
|
|
|
{
|
|
|
|
int i = (int)(ptrdiff_t)(pc - sfunc->Code);
|
|
|
|
cc.cmp(regD[A], BC);
|
2018-10-12 04:14:27 +00:00
|
|
|
cc.jne(GetLabel(i + 2));
|
2018-09-13 00:29:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void JitCompiler::EmitTESTN()
|
|
|
|
{
|
|
|
|
int bc = BC;
|
|
|
|
int i = (int)(ptrdiff_t)(pc - sfunc->Code);
|
|
|
|
cc.cmp(regD[A], -bc);
|
2018-10-12 04:14:27 +00:00
|
|
|
cc.jne(GetLabel(i + 2));
|
2018-09-13 00:29:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void JitCompiler::EmitJMP()
|
|
|
|
{
|
|
|
|
auto dest = pc + JMPOFS(pc) + 1;
|
|
|
|
int i = (int)(ptrdiff_t)(dest - sfunc->Code);
|
2018-10-12 04:14:27 +00:00
|
|
|
cc.jmp(GetLabel(i));
|
2018-09-13 00:29:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void JitCompiler::EmitIJMP()
|
|
|
|
{
|
2018-09-17 19:52:21 +00:00
|
|
|
// This uses the whole function as potential jump targets. Can the range be reduced?
|
|
|
|
|
|
|
|
int i = (int)(ptrdiff_t)(pc - sfunc->Code);
|
2018-10-07 07:02:28 +00:00
|
|
|
auto val = newTempInt32();
|
2018-09-17 19:52:21 +00:00
|
|
|
cc.mov(val, regD[A]);
|
|
|
|
cc.add(val, i + (int)BCs + 1);
|
|
|
|
|
|
|
|
int size = sfunc->CodeSize;
|
|
|
|
for (i = 0; i < size; i++)
|
|
|
|
{
|
|
|
|
if (sfunc->Code[i].op == OP_JMP)
|
|
|
|
{
|
|
|
|
int target = i + JMPOFS(&sfunc->Code[i]) + 1;
|
|
|
|
|
|
|
|
cc.cmp(val, i);
|
2018-10-12 04:14:27 +00:00
|
|
|
cc.je(GetLabel(target));
|
2018-09-17 19:52:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// This should never happen. It means we are jumping to something that is not a JMP instruction!
|
|
|
|
EmitThrowException(X_OTHER);
|
2018-09-13 00:29:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void JitCompiler::EmitVTBL()
|
|
|
|
{
|
2018-11-10 21:48:20 +00:00
|
|
|
auto label = EmitThrowExceptionLabel(X_READ_NIL);
|
2018-09-13 00:29:04 +00:00
|
|
|
cc.test(regA[B], regA[B]);
|
2018-11-10 21:48:20 +00:00
|
|
|
cc.jz(label);
|
2018-09-13 00:29:04 +00:00
|
|
|
|
2018-10-07 07:02:28 +00:00
|
|
|
auto result = newResultIntPtr();
|
2018-09-17 10:00:25 +00:00
|
|
|
auto call = CreateCall<VMFunction*, DObject*, int>([](DObject *o, int c) -> VMFunction* {
|
2018-09-13 00:29:04 +00:00
|
|
|
auto p = o->GetClass();
|
|
|
|
assert(c < (int)p->Virtuals.Size());
|
|
|
|
return p->Virtuals[c];
|
2018-09-17 10:00:25 +00:00
|
|
|
});
|
2018-10-07 04:29:54 +00:00
|
|
|
call->setRet(0, result);
|
2018-09-14 22:28:34 +00:00
|
|
|
call->setArg(0, regA[B]);
|
2018-09-13 00:29:04 +00:00
|
|
|
call->setArg(1, asmjit::Imm(C));
|
2018-10-07 04:29:54 +00:00
|
|
|
cc.mov(regA[A], result);
|
2018-09-13 00:29:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void JitCompiler::EmitSCOPE()
|
|
|
|
{
|
2018-11-10 21:48:20 +00:00
|
|
|
auto label = EmitThrowExceptionLabel(X_READ_NIL);
|
2018-09-13 00:29:04 +00:00
|
|
|
cc.test(regA[A], regA[A]);
|
2018-11-10 21:48:20 +00:00
|
|
|
cc.jz(label);
|
2018-09-13 00:29:04 +00:00
|
|
|
|
2018-10-07 07:02:28 +00:00
|
|
|
auto f = newTempIntPtr();
|
2018-09-18 16:13:53 +00:00
|
|
|
cc.mov(f, asmjit::imm_ptr(konsta[C].v));
|
2018-09-13 00:29:04 +00:00
|
|
|
|
|
|
|
typedef int(*FuncPtr)(DObject*, VMFunction*, int);
|
2018-10-09 14:30:55 +00:00
|
|
|
auto call = CreateCall<void, DObject*, VMFunction*, int>([](DObject *o, VMFunction *f, int b) {
|
2018-09-13 00:29:04 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
FScopeBarrier::ValidateCall(o->GetClass(), f, b - 1);
|
|
|
|
}
|
2018-10-07 18:38:08 +00:00
|
|
|
catch (...)
|
2018-09-13 00:29:04 +00:00
|
|
|
{
|
2018-10-09 14:30:55 +00:00
|
|
|
VMThrowException(std::current_exception());
|
2018-09-13 00:29:04 +00:00
|
|
|
}
|
2018-09-17 10:00:25 +00:00
|
|
|
});
|
2018-09-13 00:29:04 +00:00
|
|
|
call->setArg(0, regA[A]);
|
|
|
|
call->setArg(1, f);
|
|
|
|
call->setArg(2, asmjit::Imm(B));
|
|
|
|
}
|
|
|
|
|
|
|
|
void JitCompiler::EmitRET()
|
|
|
|
{
|
|
|
|
using namespace asmjit;
|
|
|
|
if (B == REGT_NIL)
|
|
|
|
{
|
2018-10-09 01:37:11 +00:00
|
|
|
EmitPopFrame();
|
2018-10-07 07:02:28 +00:00
|
|
|
X86Gp vReg = newTempInt32();
|
2018-09-13 00:29:04 +00:00
|
|
|
cc.mov(vReg, 0);
|
|
|
|
cc.ret(vReg);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int a = A;
|
|
|
|
int retnum = a & ~RET_FINAL;
|
|
|
|
|
2018-10-07 07:02:28 +00:00
|
|
|
X86Gp reg_retnum = newTempInt32();
|
|
|
|
X86Gp location = newTempIntPtr();
|
2018-09-13 00:29:04 +00:00
|
|
|
Label L_endif = cc.newLabel();
|
|
|
|
|
|
|
|
cc.mov(reg_retnum, retnum);
|
2018-09-14 22:12:12 +00:00
|
|
|
cc.cmp(reg_retnum, numret);
|
|
|
|
cc.jge(L_endif);
|
2018-09-13 00:29:04 +00:00
|
|
|
|
|
|
|
cc.mov(location, x86::ptr(ret, retnum * sizeof(VMReturn)));
|
|
|
|
|
|
|
|
int regtype = B;
|
|
|
|
int regnum = C;
|
|
|
|
switch (regtype & REGT_TYPE)
|
|
|
|
{
|
|
|
|
case REGT_INT:
|
|
|
|
if (regtype & REGT_KONST)
|
|
|
|
cc.mov(x86::dword_ptr(location), konstd[regnum]);
|
|
|
|
else
|
|
|
|
cc.mov(x86::dword_ptr(location), regD[regnum]);
|
|
|
|
break;
|
|
|
|
case REGT_FLOAT:
|
|
|
|
if (regtype & REGT_KONST)
|
|
|
|
{
|
2018-10-07 07:02:28 +00:00
|
|
|
auto tmp = newTempInt64();
|
2018-09-13 00:29:04 +00:00
|
|
|
if (regtype & REGT_MULTIREG3)
|
|
|
|
{
|
|
|
|
cc.mov(tmp, (((int64_t *)konstf)[regnum]));
|
|
|
|
cc.mov(x86::qword_ptr(location), tmp);
|
|
|
|
|
|
|
|
cc.mov(tmp, (((int64_t *)konstf)[regnum + 1]));
|
|
|
|
cc.mov(x86::qword_ptr(location, 8), tmp);
|
|
|
|
|
|
|
|
cc.mov(tmp, (((int64_t *)konstf)[regnum + 2]));
|
|
|
|
cc.mov(x86::qword_ptr(location, 16), tmp);
|
|
|
|
}
|
|
|
|
else if (regtype & REGT_MULTIREG2)
|
|
|
|
{
|
|
|
|
cc.mov(tmp, (((int64_t *)konstf)[regnum]));
|
|
|
|
cc.mov(x86::qword_ptr(location), tmp);
|
|
|
|
|
|
|
|
cc.mov(tmp, (((int64_t *)konstf)[regnum + 1]));
|
|
|
|
cc.mov(x86::qword_ptr(location, 8), tmp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cc.mov(tmp, (((int64_t *)konstf)[regnum]));
|
|
|
|
cc.mov(x86::qword_ptr(location), tmp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (regtype & REGT_MULTIREG3)
|
|
|
|
{
|
|
|
|
cc.movsd(x86::qword_ptr(location), regF[regnum]);
|
|
|
|
cc.movsd(x86::qword_ptr(location, 8), regF[regnum + 1]);
|
|
|
|
cc.movsd(x86::qword_ptr(location, 16), regF[regnum + 2]);
|
|
|
|
}
|
|
|
|
else if (regtype & REGT_MULTIREG2)
|
|
|
|
{
|
|
|
|
cc.movsd(x86::qword_ptr(location), regF[regnum]);
|
|
|
|
cc.movsd(x86::qword_ptr(location, 8), regF[regnum + 1]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cc.movsd(x86::qword_ptr(location), regF[regnum]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case REGT_STRING:
|
2018-09-14 17:20:31 +00:00
|
|
|
{
|
2018-10-07 07:02:28 +00:00
|
|
|
auto ptr = newTempIntPtr();
|
2018-09-14 17:20:31 +00:00
|
|
|
cc.mov(ptr, ret);
|
2018-09-14 21:38:57 +00:00
|
|
|
cc.add(ptr, (int)(retnum * sizeof(VMReturn)));
|
2018-09-17 10:00:25 +00:00
|
|
|
auto call = CreateCall<void, VMReturn*, FString*>([](VMReturn* ret, FString* str) -> void {
|
|
|
|
ret->SetString(*str);
|
|
|
|
});
|
2018-09-14 17:20:31 +00:00
|
|
|
call->setArg(0, ptr);
|
|
|
|
if (regtype & REGT_KONST) call->setArg(1, asmjit::imm_ptr(&konsts[regnum]));
|
|
|
|
else call->setArg(1, regS[regnum]);
|
2018-09-13 00:29:04 +00:00
|
|
|
break;
|
2018-09-14 17:20:31 +00:00
|
|
|
}
|
2018-09-13 00:29:04 +00:00
|
|
|
case REGT_POINTER:
|
2018-10-07 18:55:06 +00:00
|
|
|
if (cc.is64Bit())
|
|
|
|
{
|
|
|
|
if (regtype & REGT_KONST)
|
|
|
|
cc.mov(x86::qword_ptr(location), asmjit::imm_ptr(konsta[regnum].v));
|
|
|
|
else
|
|
|
|
cc.mov(x86::qword_ptr(location), regA[regnum]);
|
|
|
|
}
|
2018-09-13 00:29:04 +00:00
|
|
|
else
|
2018-10-07 18:55:06 +00:00
|
|
|
{
|
|
|
|
if (regtype & REGT_KONST)
|
|
|
|
cc.mov(x86::dword_ptr(location), asmjit::imm_ptr(konsta[regnum].v));
|
|
|
|
else
|
|
|
|
cc.mov(x86::dword_ptr(location), regA[regnum]);
|
|
|
|
}
|
2018-09-13 00:29:04 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (a & RET_FINAL)
|
|
|
|
{
|
|
|
|
cc.add(reg_retnum, 1);
|
2018-10-09 01:37:11 +00:00
|
|
|
EmitPopFrame();
|
2018-09-13 00:29:04 +00:00
|
|
|
cc.ret(reg_retnum);
|
|
|
|
}
|
|
|
|
|
|
|
|
cc.bind(L_endif);
|
|
|
|
if (a & RET_FINAL)
|
2018-10-09 01:37:11 +00:00
|
|
|
{
|
|
|
|
EmitPopFrame();
|
2018-09-13 00:29:04 +00:00
|
|
|
cc.ret(numret);
|
2018-10-09 01:37:11 +00:00
|
|
|
}
|
2018-09-13 00:29:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void JitCompiler::EmitRETI()
|
|
|
|
{
|
|
|
|
using namespace asmjit;
|
|
|
|
|
|
|
|
int a = A;
|
|
|
|
int retnum = a & ~RET_FINAL;
|
|
|
|
|
2018-10-07 07:02:28 +00:00
|
|
|
X86Gp reg_retnum = newTempInt32();
|
|
|
|
X86Gp location = newTempIntPtr();
|
2018-09-13 00:29:04 +00:00
|
|
|
Label L_endif = cc.newLabel();
|
|
|
|
|
|
|
|
cc.mov(reg_retnum, retnum);
|
2018-09-14 22:12:12 +00:00
|
|
|
cc.cmp(reg_retnum, numret);
|
|
|
|
cc.jge(L_endif);
|
2018-09-13 00:29:04 +00:00
|
|
|
|
|
|
|
cc.mov(location, x86::ptr(ret, retnum * sizeof(VMReturn)));
|
|
|
|
cc.mov(x86::dword_ptr(location), BCs);
|
|
|
|
|
|
|
|
if (a & RET_FINAL)
|
|
|
|
{
|
|
|
|
cc.add(reg_retnum, 1);
|
2018-10-09 01:37:11 +00:00
|
|
|
EmitPopFrame();
|
2018-09-13 00:29:04 +00:00
|
|
|
cc.ret(reg_retnum);
|
|
|
|
}
|
|
|
|
|
|
|
|
cc.bind(L_endif);
|
|
|
|
if (a & RET_FINAL)
|
2018-10-09 01:37:11 +00:00
|
|
|
{
|
|
|
|
EmitPopFrame();
|
2018-09-13 00:29:04 +00:00
|
|
|
cc.ret(numret);
|
2018-10-09 01:37:11 +00:00
|
|
|
}
|
2018-09-13 00:29:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void JitCompiler::EmitNEW()
|
|
|
|
{
|
2018-10-07 07:02:28 +00:00
|
|
|
auto result = newResultIntPtr();
|
2018-10-09 14:30:55 +00:00
|
|
|
auto call = CreateCall<DObject*, PClass*, int>([](PClass *cls, int c) -> DObject* {
|
2018-09-13 00:29:04 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
if (!cls->ConstructNative)
|
|
|
|
{
|
|
|
|
ThrowAbortException(X_OTHER, "Class %s requires native construction", cls->TypeName.GetChars());
|
|
|
|
}
|
|
|
|
else if (cls->bAbstract)
|
|
|
|
{
|
|
|
|
ThrowAbortException(X_OTHER, "Cannot instantiate abstract class %s", cls->TypeName.GetChars());
|
|
|
|
}
|
|
|
|
else if (cls->IsDescendantOf(NAME_Actor)) // Creating actors here must be outright prohibited
|
|
|
|
{
|
|
|
|
ThrowAbortException(X_OTHER, "Cannot create actors with 'new'");
|
|
|
|
}
|
|
|
|
|
|
|
|
// [ZZ] validate readonly and between scope construction
|
|
|
|
if (c) FScopeBarrier::ValidateNew(cls, c - 1);
|
|
|
|
return cls->CreateNew();
|
|
|
|
}
|
2018-10-07 18:38:08 +00:00
|
|
|
catch (...)
|
2018-09-13 00:29:04 +00:00
|
|
|
{
|
2018-10-09 14:30:55 +00:00
|
|
|
VMThrowException(std::current_exception());
|
2018-09-13 00:29:04 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
2018-09-17 10:00:25 +00:00
|
|
|
});
|
2018-09-13 00:29:04 +00:00
|
|
|
call->setRet(0, result);
|
|
|
|
call->setArg(0, regA[B]);
|
|
|
|
call->setArg(1, asmjit::Imm(C));
|
|
|
|
|
|
|
|
cc.mov(regA[A], result);
|
|
|
|
}
|
|
|
|
|
|
|
|
void JitCompiler::EmitNEW_K()
|
|
|
|
{
|
|
|
|
PClass *cls = (PClass*)konsta[B].v;
|
2018-11-10 18:52:41 +00:00
|
|
|
auto regcls = newTempIntPtr();
|
|
|
|
cc.mov(regcls, asmjit::imm_ptr(cls));
|
|
|
|
|
|
|
|
if (!cls->ConstructNative || cls->bAbstract || cls->IsDescendantOf(NAME_Actor))
|
2018-09-13 00:29:04 +00:00
|
|
|
{
|
2018-11-10 18:52:41 +00:00
|
|
|
auto call = CreateCall<void, PClass*, int>([](PClass *cls, int c) {
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if (!cls->ConstructNative)
|
|
|
|
{
|
|
|
|
ThrowAbortException(X_OTHER, "Class %s requires native construction", cls->TypeName.GetChars());
|
|
|
|
}
|
|
|
|
else if (cls->bAbstract)
|
|
|
|
{
|
|
|
|
ThrowAbortException(X_OTHER, "Cannot instantiate abstract class %s", cls->TypeName.GetChars());
|
|
|
|
}
|
|
|
|
else // if (cls->IsDescendantOf(NAME_Actor)) // Creating actors here must be outright prohibited
|
|
|
|
{
|
|
|
|
ThrowAbortException(X_OTHER, "Cannot create actors with 'new'");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
VMThrowException(std::current_exception());
|
|
|
|
}
|
|
|
|
});
|
|
|
|
call->setArg(0, regcls);
|
2018-09-13 00:29:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-10-07 07:02:28 +00:00
|
|
|
auto result = newResultIntPtr();
|
2018-10-09 14:30:55 +00:00
|
|
|
auto call = CreateCall<DObject*, PClass*, int>([](PClass *cls, int c) -> DObject* {
|
2018-09-13 00:29:04 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
if (c) FScopeBarrier::ValidateNew(cls, c - 1);
|
|
|
|
return cls->CreateNew();
|
|
|
|
}
|
2018-10-07 18:38:08 +00:00
|
|
|
catch (...)
|
2018-09-13 00:29:04 +00:00
|
|
|
{
|
2018-10-09 14:30:55 +00:00
|
|
|
VMThrowException(std::current_exception());
|
2018-09-13 00:29:04 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
2018-09-17 10:00:25 +00:00
|
|
|
});
|
2018-09-13 00:29:04 +00:00
|
|
|
call->setRet(0, result);
|
|
|
|
call->setArg(0, regcls);
|
|
|
|
call->setArg(1, asmjit::Imm(C));
|
|
|
|
|
|
|
|
cc.mov(regA[A], result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void JitCompiler::EmitTHROW()
|
|
|
|
{
|
|
|
|
EmitThrowException(EVMAbortException(BC));
|
|
|
|
}
|
|
|
|
|
|
|
|
void JitCompiler::EmitBOUND()
|
|
|
|
{
|
2018-11-10 21:48:20 +00:00
|
|
|
auto cursor = cc.getCursor();
|
2018-11-10 18:52:41 +00:00
|
|
|
auto label = cc.newLabel();
|
2018-11-10 21:48:20 +00:00
|
|
|
cc.bind(label);
|
2018-11-10 18:52:41 +00:00
|
|
|
auto call = CreateCall<void, VMScriptFunction *, VMOP *, int, int>(&JitCompiler::ThrowArrayOutOfBounds);
|
|
|
|
call->setArg(0, asmjit::imm_ptr(sfunc));
|
|
|
|
call->setArg(1, asmjit::imm_ptr(pc));
|
|
|
|
call->setArg(2, regD[A]);
|
|
|
|
call->setArg(3, asmjit::imm(BC));
|
2018-11-10 21:48:20 +00:00
|
|
|
cc.setCursor(cursor);
|
2018-11-10 18:52:41 +00:00
|
|
|
|
2018-11-10 21:48:20 +00:00
|
|
|
cc.cmp(regD[A], (int)BC);
|
|
|
|
cc.jae(label);
|
2018-09-13 00:29:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void JitCompiler::EmitBOUND_K()
|
|
|
|
{
|
2018-11-10 21:48:20 +00:00
|
|
|
auto cursor = cc.getCursor();
|
2018-11-10 18:52:41 +00:00
|
|
|
auto label = cc.newLabel();
|
2018-11-10 21:48:20 +00:00
|
|
|
cc.bind(label);
|
2018-11-10 18:52:41 +00:00
|
|
|
auto call = CreateCall<void, VMScriptFunction *, VMOP *, int, int>(&JitCompiler::ThrowArrayOutOfBounds);
|
|
|
|
call->setArg(0, asmjit::imm_ptr(sfunc));
|
|
|
|
call->setArg(1, asmjit::imm_ptr(pc));
|
|
|
|
call->setArg(2, regD[A]);
|
|
|
|
call->setArg(3, asmjit::imm(konstd[BC]));
|
2018-11-10 21:48:20 +00:00
|
|
|
cc.setCursor(cursor);
|
2018-11-10 18:52:41 +00:00
|
|
|
|
2018-11-10 21:48:20 +00:00
|
|
|
cc.cmp(regD[A], (int)konstd[BC]);
|
|
|
|
cc.jae(label);
|
2018-09-13 00:29:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void JitCompiler::EmitBOUND_R()
|
|
|
|
{
|
2018-11-10 21:48:20 +00:00
|
|
|
auto cursor = cc.getCursor();
|
2018-11-10 18:52:41 +00:00
|
|
|
auto label = cc.newLabel();
|
2018-11-10 21:48:20 +00:00
|
|
|
cc.bind(label);
|
2018-11-10 18:52:41 +00:00
|
|
|
auto call = CreateCall<void, VMScriptFunction *, VMOP *, int, int>(&JitCompiler::ThrowArrayOutOfBounds);
|
|
|
|
call->setArg(0, asmjit::imm_ptr(sfunc));
|
|
|
|
call->setArg(1, asmjit::imm_ptr(pc));
|
|
|
|
call->setArg(2, regD[A]);
|
|
|
|
call->setArg(3, regD[B]);
|
2018-11-10 21:48:20 +00:00
|
|
|
cc.setCursor(cursor);
|
2018-11-10 18:52:41 +00:00
|
|
|
|
2018-11-10 21:48:20 +00:00
|
|
|
cc.cmp(regD[A], regD[B]);
|
|
|
|
cc.jae(label);
|
2018-11-10 18:52:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void JitCompiler::ThrowArrayOutOfBounds(VMScriptFunction *func, VMOP *line, int index, int size)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2018-11-10 18:56:54 +00:00
|
|
|
if (index >= size)
|
2018-11-10 18:52:41 +00:00
|
|
|
{
|
|
|
|
ThrowAbortException(X_ARRAY_OUT_OF_BOUNDS, "Max.index = %u, current index = %u\n", size, index);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ThrowAbortException(X_ARRAY_OUT_OF_BOUNDS, "Negative current index = %i\n", index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
VMThrowException(std::current_exception());
|
|
|
|
}
|
2018-09-13 00:29:04 +00:00
|
|
|
}
|