- fix VM native calls containing strings and enable them again

This commit is contained in:
Magnus Norddahl 2018-12-03 21:58:01 +01:00 committed by drfrag
parent 6090e5ec24
commit 9e432c0c9f
2 changed files with 35 additions and 26 deletions

View file

@ -360,13 +360,17 @@ void JitCompiler::EmitNativeCall(VMNativeFunction *target)
call->setArg(slot, regS[bc]);
break;
case REGT_STRING | REGT_KONST:
call->setArg(slot, imm_ptr(&konsts[bc]));
tmp = newTempIntPtr();
cc.mov(tmp, imm_ptr(&konsts[bc]));
call->setArg(slot, tmp);
break;
case REGT_POINTER:
call->setArg(slot, regA[bc]);
break;
case REGT_POINTER | REGT_KONST:
call->setArg(slot, asmjit::imm_ptr(konsta[bc].v));
tmp = newTempIntPtr();
cc.mov(tmp, imm_ptr(konsta[bc].v));
call->setArg(slot, tmp);
break;
case REGT_FLOAT:
call->setArg(slot, regF[bc]);
@ -442,6 +446,13 @@ void JitCompiler::EmitNativeCall(VMNativeFunction *target)
CheckVMFrame();
if ((type & REGT_TYPE) == REGT_STRING)
{
// For strings we already have them on the stack and got named registers for them.
call->setArg(numparams + i - startret, regS[regnum]);
}
else
{
auto regPtr = newTempIntPtr();
switch (type & REGT_TYPE)
@ -465,6 +476,7 @@ void JitCompiler::EmitNativeCall(VMNativeFunction *target)
call->setArg(numparams + i - startret, regPtr);
}
}
cc.setCursor(cursorAfter);
@ -621,14 +633,11 @@ asmjit::FuncSignature JitCompiler::CreateFuncSignature()
rettype = TypeIdOf<double>::kTypeId;
key += "rf";
break;
case REGT_STRING:
rettype = TypeIdOf<void*>::kTypeId;
key += "rs";
break;
case REGT_POINTER:
rettype = TypeIdOf<void*>::kTypeId;
key += "rv";
break;
case REGT_STRING:
default:
startret = 0;
break;

View file

@ -591,7 +591,7 @@ struct AFuncDesc
#define DEFINE_ACTION_FUNCTION_NATIVE(cls, name, native) \
static int AF_##cls##_##name(VM_ARGS); \
VMNativeFunction *cls##_##name##_VMPtr; \
static const AFuncDesc cls##_##name##_Hook = { #cls, #name, AF_##cls##_##name, &cls##_##name##_VMPtr, nullptr/* reinterpret_cast<void*>(native)*/ }; \
static const AFuncDesc cls##_##name##_Hook = { #cls, #name, AF_##cls##_##name, &cls##_##name##_VMPtr, reinterpret_cast<void*>(native) }; \
extern AFuncDesc const *const cls##_##name##_HookPtr; \
MSVC_ASEG AFuncDesc const *const cls##_##name##_HookPtr GCC_ASEG = &cls##_##name##_Hook; \
static int AF_##cls##_##name(VM_ARGS)