debug API to skip JITed Lua functions - issue 16

pull/81/head
Dibyendu Majumdar 9 years ago
parent 99ff0e37ca
commit 614ecf0101

@ -59,13 +59,13 @@ LUAI_FUNC void luaV_objlen (lua_State *L, StkId ra, const TValue *rb);
LUAI_FUNC int luaV_forlimit(const TValue *obj, lua_Integer *p, lua_Integer step,
int *stopnow);
LUAI_FUNC void luaV_op_loadnil(CallInfo *ci, int a, int b);
LUAI_FUNC void luaV_newarrayint(lua_State *L, CallInfo *ci, TValue *ra);
LUAI_FUNC void luaV_newarrayfloat(lua_State *L, CallInfo *ci, TValue *ra);
LUAI_FUNC void luaV_newtable(lua_State *L, CallInfo *ci, TValue *ra, int b, int c);
LUAI_FUNC void luaV_setlist(lua_State *L, CallInfo *ci, TValue *ra, int b, int c);
LUAI_FUNC void luaV_opconcat(lua_State *L, CallInfo *ci, int a, int b, int c);
LUAI_FUNC void luaV_opclosure(lua_State *L, CallInfo *ci, LClosure *cl, int a, int Bx);
LUAI_FUNC void luaV_opvararg(lua_State *L, CallInfo *ci, LClosure *cl, int a, int b);
LUAI_FUNC void raviV_op_loadnil(CallInfo *ci, int a, int b);
LUAI_FUNC void raviV_op_newarrayint(lua_State *L, CallInfo *ci, TValue *ra);
LUAI_FUNC void raviV_op_newarrayfloat(lua_State *L, CallInfo *ci, TValue *ra);
LUAI_FUNC void raviV_op_newtable(lua_State *L, CallInfo *ci, TValue *ra, int b, int c);
LUAI_FUNC void raviV_op_setlist(lua_State *L, CallInfo *ci, TValue *ra, int b, int c);
LUAI_FUNC void raviV_op_concat(lua_State *L, CallInfo *ci, int a, int b, int c);
LUAI_FUNC void raviV_op_closure(lua_State *L, CallInfo *ci, LClosure *cl, int a, int Bx);
LUAI_FUNC void raviV_op_vararg(lua_State *L, CallInfo *ci, LClosure *cl, int a, int b);
#endif

@ -213,14 +213,18 @@ struct LuaLLVMTypes {
llvm::FunctionType *luaV_executeT;
llvm::FunctionType *luaV_gettableT;
llvm::FunctionType *luaV_settableT;
llvm::FunctionType *luaV_newarrayintT;
llvm::FunctionType *luaV_newarrayfloatT;
llvm::FunctionType *luaV_setlistT;
llvm::FunctionType *luaV_newtableT;
llvm::FunctionType *luaV_op_loadnilT;
llvm::FunctionType *luaV_opconcatT;
llvm::FunctionType *luaV_opclosureT;
llvm::FunctionType *luaV_opvarargT;
// Following are functions that handle specific bytecodes
// We cheat for these bytecodes by calling the function that
// implements it
llvm::FunctionType *raviV_op_newarrayintT;
llvm::FunctionType *raviV_op_newarrayfloatT;
llvm::FunctionType *raviV_op_setlistT;
llvm::FunctionType *raviV_op_newtableT;
llvm::FunctionType *raviV_op_loadnilT;
llvm::FunctionType *raviV_op_concatT;
llvm::FunctionType *raviV_op_closureT;
llvm::FunctionType *raviV_op_varargT;
llvm::FunctionType *raviH_set_intT;
llvm::FunctionType *raviH_set_floatT;
@ -433,14 +437,14 @@ struct RaviFunctionDef {
// Some cheats - these correspond to OPCODEs that
// are not inlined as of now
llvm::Constant *luaV_newarrayintF;
llvm::Constant *luaV_newarrayfloatF;
llvm::Constant *luaV_setlistF;
llvm::Constant *luaV_newtableF;
llvm::Constant *luaV_op_loadnilF;
llvm::Constant *luaV_opconcatF;
llvm::Constant *luaV_opclosureF;
llvm::Constant *luaV_opvarargF;
llvm::Constant *raviV_op_newarrayintF;
llvm::Constant *raviV_op_newarrayfloatF;
llvm::Constant *raviV_op_setlistF;
llvm::Constant *raviV_op_newtableF;
llvm::Constant *raviV_op_loadnilF;
llvm::Constant *raviV_op_concatF;
llvm::Constant *raviV_op_closureF;
llvm::Constant *raviV_op_varargF;
llvm::Constant *raviH_set_intF;
llvm::Constant *raviH_set_floatF;

@ -43,16 +43,6 @@
/* limit for table tag-method chains (to avoid loops) */
#define MAXTAGLOOP 2000
// This is a cheat for a boring opcode
void luaV_op_loadnil(CallInfo *ci, int a, int b) {
StkId base;
base = ci->u.l.base;
TValue *ra = base + a;
do {
setnilvalue(ra++);
} while (b--);
}
/*
** Similar to 'tonumber', but does not attempt to convert strings and
** ensure correct precision (no extra bits). Used in comparisons.
@ -719,213 +709,6 @@ void luaV_finishOp (lua_State *L) {
#define vmcase(l,b) case l: {b} break;
#define vmcasenb(l,b) case l: {b} /* nb = no break */
void ravi_dump_ci(lua_State *L, CallInfo *ci) {
StkId func = ci->func;
int func_type = ttype(func);
StkId base = NULL;
const char *func_typename;
Proto *p = NULL;
int funcpos = ci->func - L->stack;
StkId stack_ptr = ci->top - 1;
int i;
switch (func_type) {
case LUA_TLCF:
printf("stack[%d] = Light C function\n", funcpos);
printf("---> called from \n");
return;
case LUA_TCCL:
printf("stack[%d] = C closure\n", funcpos);
printf("---> called from \n");
return;
case LUA_TFUNCTION:
p = clLvalue(func)->p;
base = ci->u.l.base;
i = ci->top - L->stack - 1;
break;
default:
return;
}
for (; stack_ptr >= base; stack_ptr--, i--) {
printf("stack[%d] = %s", i, (stack_ptr == base ? "(base) " : ""));
if (ttisCclosure(stack_ptr))
printf("C closure\n");
else if (ttislcf(stack_ptr))
printf("light C function\n");
else if (ttisLclosure(stack_ptr))
printf("Lua closure\n");
else if (ttisfunction(stack_ptr))
printf("function\n");
else if (ttislngstring(stack_ptr) || ttisshrstring(stack_ptr) || ttisstring(stack_ptr))
printf("'%s'\n", svalue(stack_ptr));
else if (ttistable(stack_ptr))
printf("table\n");
else if (ttisnil(stack_ptr))
printf("nil\n");
else if (ttisfloat(stack_ptr))
printf("%.6f\n", fltvalue(stack_ptr));
else if (ttisinteger(stack_ptr))
printf("%lld\n", ivalue(stack_ptr));
else if (ttislightuserdata(stack_ptr))
printf("light user data\n");
else if (ttisfulluserdata(stack_ptr))
printf("full user data\n");
else if (ttisboolean(stack_ptr))
printf("boolean\n");
else if (ttisthread(stack_ptr))
printf("thread\n");
else
printf("other\n");
}
printf("stack[%d] = Lua function (registers = %d, params = %d, locals = %d)\n", funcpos, (int)(p->maxstacksize), (int)(p->numparams), p->sizelocvars);
printf("---> called from \n");
}
void ravi_dump_stack(lua_State *L, const char *s) {
if (!s)
return;
CallInfo *ci = L->ci;
printf("=======================\n");
printf("Stack dump %s\n", s);
printf("=======================\n");
while (ci) {
ravi_dump_ci(L, ci);
ci = ci->previous;
}
printf("\n");
}
void luaV_newarrayint(lua_State *L, CallInfo *ci, TValue *ra) {
Table *t = raviH_new(L, RAVI_TARRAYINT);
sethvalue(L, ra, t);
luaC_condGC(
L, {
L->top = ra + 1; /* limit of live values */
luaC_step(L);
L->top = ci->top;
}) /* restore top */
luai_threadyield(L);
}
void luaV_newarrayfloat(lua_State *L, CallInfo *ci, TValue *ra) {
Table *t = raviH_new(L, RAVI_TARRAYFLT);
sethvalue(L, ra, t);
luaC_condGC(
L, {
L->top = ra + 1; /* limit of live values */
luaC_step(L);
L->top = ci->top;
}) /* restore top */
luai_threadyield(L);
}
void luaV_newtable(lua_State *L, CallInfo *ci, TValue *ra, int b, int c) {
Table *t = luaH_new(L);
sethvalue(L, ra, t);
if (b != 0 || c != 0)
luaH_resize(L, t, luaO_fb2int(b), luaO_fb2int(c));
luaC_condGC(
L, {
L->top = ra + 1; /* limit of live values */
luaC_step(L);
L->top = ci->top;
}) /* restore top */
luai_threadyield(L);
}
void luaV_setlist(lua_State *L, CallInfo *ci, TValue *ra, int b, int c) {
int n = b;
unsigned int last;
Table *h;
if (n == 0) n = cast_int(L->top - ra) - 1;
luai_runtimecheck(L, ttistable(ra));
h = hvalue(ra);
last = ((c - 1)*LFIELDS_PER_FLUSH) + n;
if (h->ravi_array.type == RAVI_TTABLE) {
if (last > h->sizearray) /* needs more space? */
luaH_resizearray(L, h, last); /* pre-allocate it at once */
for (; n > 0; n--) {
TValue *val = ra + n;
luaH_setint(L, h, last--, val);
luaC_barrierback(L, h, val);
}
}
else {
int i = last - n + 1;
for (; i <= (int)last; i++) {
TValue *val = ra + i;
lua_Unsigned u = (lua_Unsigned)(i - 1);
switch (h->ravi_array.type) {
case RAVI_TARRAYINT: {
if (ttisinteger(val))
raviH_set_int(L, h, u, ivalue(val));
else
raviH_set_int(L, h, u, (lua_Integer)(fltvalue(val)));
} break;
case RAVI_TARRAYFLT: {
if (ttisinteger(val))
raviH_set_float(L, h, u, (lua_Number)(ivalue(val)));
else
raviH_set_float(L, h, u, fltvalue(val));
} break;
default:
lua_assert(0);
}
}
}
L->top = ci->top; /* correct top (in case of previous open call) */
}
void luaV_opconcat(lua_State *L, CallInfo *ci, int a, int b, int c) {
StkId rb, ra;
StkId base = ci->u.l.base;
L->top = base + c + 1; /* mark the end of concat operands */
Protect(luaV_concat(L, c - b + 1));
ra = base + a; /* 'luav_concat' may invoke TMs and move the stack */
rb = base + b;
setobjs2s(L, ra, rb);
checkGC(L, (ra >= rb ? ra + 1 : rb));
L->top = ci->top; /* restore top */
}
void luaV_opclosure(lua_State *L, CallInfo *ci, LClosure *cl, int a, int Bx) {
StkId base = ci->u.l.base;
Proto *p = cl->p->p[Bx];
LClosure *ncl = getcached(p, cl->upvals, base); /* cached closure */
StkId ra = base + a;
if (ncl == NULL) /* no match? */ {
pushclosure(L, p, cl->upvals, base, ra); /* create a new one */
}
else {
setclLvalue(L, ra, ncl); /* push cashed closure */
}
checkGC(L, ra + 1);
}
void luaV_opvararg(lua_State *L, CallInfo *ci, LClosure *cl, int a, int b) {
StkId base = ci->u.l.base;
int j;
int n = cast_int(base - ci->func) - cl->p->numparams - 1;
StkId ra;
b = b - 1;
if (b < 0) { /* B == 0? */
b = n; /* get all var. arguments */
Protect(luaD_checkstack(L, n));
ra = base + a; /* previous call may change the stack */
L->top = ra + n;
}
else {
ra = base + a;
}
for (j = 0; j < b; j++) {
if (j < n) {
setobjs2s(L, ra + j, base - n + j);
}
else {
setnilvalue(ra + j);
}
}
}
void luaV_execute (lua_State *L) {
CallInfo *ci = L->ci;
@ -1680,5 +1463,223 @@ newframe: /* reentry point when frame changes (call/return) */
}
}
void ravi_dump_ci(lua_State *L, CallInfo *ci) {
StkId func = ci->func;
int func_type = ttype(func);
StkId base = NULL;
const char *func_typename;
Proto *p = NULL;
int funcpos = ci->func - L->stack;
StkId stack_ptr = ci->top - 1;
int i;
switch (func_type) {
case LUA_TLCF:
printf("stack[%d] = Light C function\n", funcpos);
printf("---> called from \n");
return;
case LUA_TCCL:
printf("stack[%d] = C closure\n", funcpos);
printf("---> called from \n");
return;
case LUA_TFUNCTION:
p = clLvalue(func)->p;
base = ci->u.l.base;
i = ci->top - L->stack - 1;
break;
default:
return;
}
for (; stack_ptr >= base; stack_ptr--, i--) {
printf("stack[%d] = %s", i, (stack_ptr == base ? "(base) " : ""));
if (ttisCclosure(stack_ptr))
printf("C closure\n");
else if (ttislcf(stack_ptr))
printf("light C function\n");
else if (ttisLclosure(stack_ptr))
printf("Lua closure\n");
else if (ttisfunction(stack_ptr))
printf("function\n");
else if (ttislngstring(stack_ptr) || ttisshrstring(stack_ptr) ||
ttisstring(stack_ptr))
printf("'%s'\n", svalue(stack_ptr));
else if (ttistable(stack_ptr))
printf("table\n");
else if (ttisnil(stack_ptr))
printf("nil\n");
else if (ttisfloat(stack_ptr))
printf("%.6f\n", fltvalue(stack_ptr));
else if (ttisinteger(stack_ptr))
printf("%lld\n", ivalue(stack_ptr));
else if (ttislightuserdata(stack_ptr))
printf("light user data\n");
else if (ttisfulluserdata(stack_ptr))
printf("full user data\n");
else if (ttisboolean(stack_ptr))
printf("boolean\n");
else if (ttisthread(stack_ptr))
printf("thread\n");
else
printf("other\n");
}
printf(
"stack[%d] = Lua function (registers = %d, params = %d, locals = %d)\n",
funcpos, (int)(p->maxstacksize), (int)(p->numparams), p->sizelocvars);
printf("---> called from \n");
}
void ravi_dump_stack(lua_State *L, const char *s) {
if (!s)
return;
CallInfo *ci = L->ci;
printf("=======================\n");
printf("Stack dump %s\n", s);
printf("=======================\n");
while (ci) {
ravi_dump_ci(L, ci);
ci = ci->previous;
}
printf("\n");
}
void raviV_op_newarrayint(lua_State *L, CallInfo *ci, TValue *ra) {
Table *t = raviH_new(L, RAVI_TARRAYINT);
sethvalue(L, ra, t);
luaC_condGC(
L, {
L->top = ra + 1; /* limit of live values */
luaC_step(L);
L->top = ci->top;
}) /* restore top */
luai_threadyield(L);
}
void raviV_op_newarrayfloat(lua_State *L, CallInfo *ci, TValue *ra) {
Table *t = raviH_new(L, RAVI_TARRAYFLT);
sethvalue(L, ra, t);
luaC_condGC(
L, {
L->top = ra + 1; /* limit of live values */
luaC_step(L);
L->top = ci->top;
}) /* restore top */
luai_threadyield(L);
}
void raviV_op_newtable(lua_State *L, CallInfo *ci, TValue *ra, int b, int c) {
Table *t = luaH_new(L);
sethvalue(L, ra, t);
if (b != 0 || c != 0)
luaH_resize(L, t, luaO_fb2int(b), luaO_fb2int(c));
luaC_condGC(
L, {
L->top = ra + 1; /* limit of live values */
luaC_step(L);
L->top = ci->top;
}) /* restore top */
luai_threadyield(L);
}
void raviV_op_setlist(lua_State *L, CallInfo *ci, TValue *ra, int b, int c) {
int n = b;
unsigned int last;
Table *h;
if (n == 0)
n = cast_int(L->top - ra) - 1;
luai_runtimecheck(L, ttistable(ra));
h = hvalue(ra);
last = ((c - 1) * LFIELDS_PER_FLUSH) + n;
if (h->ravi_array.type == RAVI_TTABLE) {
if (last > h->sizearray) /* needs more space? */
luaH_resizearray(L, h, last); /* pre-allocate it at once */
for (; n > 0; n--) {
TValue *val = ra + n;
luaH_setint(L, h, last--, val);
luaC_barrierback(L, h, val);
}
} else {
int i = last - n + 1;
for (; i <= (int)last; i++) {
TValue *val = ra + i;
lua_Unsigned u = (lua_Unsigned)(i - 1);
switch (h->ravi_array.type) {
case RAVI_TARRAYINT: {
if (ttisinteger(val))
raviH_set_int(L, h, u, ivalue(val));
else
raviH_set_int(L, h, u, (lua_Integer)(fltvalue(val)));
} break;
case RAVI_TARRAYFLT: {
if (ttisinteger(val))
raviH_set_float(L, h, u, (lua_Number)(ivalue(val)));
else
raviH_set_float(L, h, u, fltvalue(val));
} break;
default:
lua_assert(0);
}
}
}
L->top = ci->top; /* correct top (in case of previous open call) */
}
void raviV_op_concat(lua_State *L, CallInfo *ci, int a, int b, int c) {
StkId rb, ra;
StkId base = ci->u.l.base;
L->top = base + c + 1; /* mark the end of concat operands */
Protect(luaV_concat(L, c - b + 1));
ra = base + a; /* 'luav_concat' may invoke TMs and move the stack */
rb = base + b;
setobjs2s(L, ra, rb);
checkGC(L, (ra >= rb ? ra + 1 : rb));
L->top = ci->top; /* restore top */
}
void raviV_op_closure(lua_State *L, CallInfo *ci, LClosure *cl, int a, int Bx) {
StkId base = ci->u.l.base;
Proto *p = cl->p->p[Bx];
LClosure *ncl = getcached(p, cl->upvals, base); /* cached closure */
StkId ra = base + a;
if (ncl == NULL) /* no match? */ {
pushclosure(L, p, cl->upvals, base, ra); /* create a new one */
} else {
setclLvalue(L, ra, ncl); /* push cashed closure */
}
checkGC(L, ra + 1);
}
void raviV_op_vararg(lua_State *L, CallInfo *ci, LClosure *cl, int a, int b) {
StkId base = ci->u.l.base;
int j;
int n = cast_int(base - ci->func) - cl->p->numparams - 1;
StkId ra;
b = b - 1;
if (b < 0) { /* B == 0? */
b = n; /* get all var. arguments */
Protect(luaD_checkstack(L, n));
ra = base + a; /* previous call may change the stack */
L->top = ra + n;
} else {
ra = base + a;
}
for (j = 0; j < b; j++) {
if (j < n) {
setobjs2s(L, ra + j, base - n + j);
} else {
setnilvalue(ra + j);
}
}
}
// This is a cheat for a boring opcode
void raviV_op_loadnil(CallInfo *ci, int a, int b) {
StkId base;
base = ci->u.l.base;
TValue *ra = base + a;
do {
setnilvalue(ra++);
} while (b--);
}
/* }================================================================== */

@ -449,21 +449,21 @@ void RaviCodeGenerator::emit_extern_declarations(RaviFunctionDef *def) {
def->luaV_gettableF = def->raviF->addExternFunction(
def->types->luaV_gettableT, reinterpret_cast<void *>(&luaV_gettable),
"luaV_gettable");
def->luaV_op_loadnilF = def->raviF->addExternFunction(
def->types->luaV_op_loadnilT, reinterpret_cast<void *>(&luaV_op_loadnil),
"luaV_op_loadnil");
def->luaV_newarrayintF = def->raviF->addExternFunction(
def->types->luaV_newarrayintT,
reinterpret_cast<void *>(&luaV_newarrayint), "luaV_newarrayint");
def->luaV_newarrayfloatF = def->raviF->addExternFunction(
def->types->luaV_newarrayfloatT,
reinterpret_cast<void *>(&luaV_newarrayfloat), "luaV_newarrayfloat");
def->luaV_newtableF = def->raviF->addExternFunction(
def->types->luaV_newtableT, reinterpret_cast<void *>(&luaV_newtable),
"luaV_newtable");
def->luaV_setlistF = def->raviF->addExternFunction(
def->types->luaV_setlistT, reinterpret_cast<void *>(&luaV_setlist),
"luaV_setlist");
def->raviV_op_loadnilF = def->raviF->addExternFunction(
def->types->raviV_op_loadnilT, reinterpret_cast<void *>(&raviV_op_loadnil),
"raviV_op_loadnil");
def->raviV_op_newarrayintF = def->raviF->addExternFunction(
def->types->raviV_op_newarrayintT,
reinterpret_cast<void *>(&raviV_op_newarrayint), "raviV_op_newarrayint");
def->raviV_op_newarrayfloatF = def->raviF->addExternFunction(
def->types->raviV_op_newarrayfloatT,
reinterpret_cast<void *>(&raviV_op_newarrayfloat), "raviV_op_newarrayfloat");
def->raviV_op_newtableF = def->raviF->addExternFunction(
def->types->raviV_op_newtableT, reinterpret_cast<void *>(&raviV_op_newtable),
"raviV_op_newtable");
def->raviV_op_setlistF = def->raviF->addExternFunction(
def->types->raviV_op_setlistT, reinterpret_cast<void *>(&raviV_op_setlist),
"raviV_op_setlist");
def->luaV_modF = def->raviF->addExternFunction(
def->types->luaV_modT, reinterpret_cast<void *>(&luaV_mod), "luaV_mod");
def->luaV_divF = def->raviF->addExternFunction(
@ -474,15 +474,15 @@ void RaviCodeGenerator::emit_extern_declarations(RaviFunctionDef *def) {
def->luaC_upvalbarrierF = def->raviF->addExternFunction(
def->types->luaC_upvalbarrierT,
reinterpret_cast<void *>(&luaC_upvalbarrier_), "luaC_upvalbarrier_");
def->luaV_opconcatF = def->raviF->addExternFunction(
def->types->luaV_opconcatT, reinterpret_cast<void *>(&luaV_opconcat),
"luaV_opconcat");
def->luaV_opclosureF = def->raviF->addExternFunction(
def->types->luaV_opclosureT, reinterpret_cast<void *>(&luaV_opclosure),
"luaV_opclosure");
def->luaV_opvarargF = def->raviF->addExternFunction(
def->types->luaV_opvarargT, reinterpret_cast<void *>(&luaV_opvararg),
"luaV_opvararg");
def->raviV_op_concatF = def->raviF->addExternFunction(
def->types->raviV_op_concatT, reinterpret_cast<void *>(&raviV_op_concat),
"raviV_op_concat");
def->raviV_op_closureF = def->raviF->addExternFunction(
def->types->raviV_op_closureT, reinterpret_cast<void *>(&raviV_op_closure),
"raviV_op_closure");
def->raviV_op_varargF = def->raviF->addExternFunction(
def->types->raviV_op_varargT, reinterpret_cast<void *>(&raviV_op_vararg),
"raviV_op_vararg");
def->raviH_set_intF = def->raviF->addExternFunction(
def->types->raviH_set_intT, reinterpret_cast<void *>(&raviH_set_int),
"raviH_set_int");

@ -26,7 +26,7 @@ namespace ravi {
void RaviCodeGenerator::emit_LOADNIL(RaviFunctionDef *def, llvm::Value *L_ci,
llvm::Value *proto, int A, int B) {
def->builder->CreateCall3(def->luaV_op_loadnilF, def->ci_val,
def->builder->CreateCall3(def->raviV_op_loadnilF, def->ci_val,
llvm::ConstantInt::get(def->types->C_intT, A),
llvm::ConstantInt::get(def->types->C_intT, B));
}

@ -26,7 +26,7 @@ namespace ravi {
void RaviCodeGenerator::emit_CONCAT(RaviFunctionDef *def, llvm::Value *L_ci,
llvm::Value *proto, int A, int B, int C) {
def->builder->CreateCall5(def->luaV_opconcatF, def->L, def->ci_val,
def->builder->CreateCall5(def->raviV_op_concatF, def->L, def->ci_val,
llvm::ConstantInt::get(def->types->C_intT, A),
llvm::ConstantInt::get(def->types->C_intT, B),
llvm::ConstantInt::get(def->types->C_intT, C));
@ -34,7 +34,7 @@ void RaviCodeGenerator::emit_CONCAT(RaviFunctionDef *def, llvm::Value *L_ci,
void RaviCodeGenerator::emit_CLOSURE(RaviFunctionDef *def, llvm::Value *L_ci,
llvm::Value *proto, int A, int Bx) {
def->builder->CreateCall5(def->luaV_opclosureF, def->L, def->ci_val,
def->builder->CreateCall5(def->raviV_op_closureF, def->L, def->ci_val,
def->p_LClosure,
llvm::ConstantInt::get(def->types->C_intT, A),
llvm::ConstantInt::get(def->types->C_intT, Bx));
@ -42,7 +42,7 @@ void RaviCodeGenerator::emit_CLOSURE(RaviFunctionDef *def, llvm::Value *L_ci,
void RaviCodeGenerator::emit_VARARG(RaviFunctionDef *def, llvm::Value *L_ci,
llvm::Value *proto, int A, int B) {
def->builder->CreateCall5(def->luaV_opvarargF, def->L, def->ci_val,
def->builder->CreateCall5(def->raviV_op_varargF, def->L, def->ci_val,
def->p_LClosure,
llvm::ConstantInt::get(def->types->C_intT, A),
llvm::ConstantInt::get(def->types->C_intT, B));

@ -24,6 +24,7 @@
namespace ravi {
// R(A+1) := R(B); R(A) := R(B)[RK(C)]
void RaviCodeGenerator::emit_SELF(RaviFunctionDef *def, llvm::Value *L_ci,
llvm::Value *proto, int A, int B, int C) {
// StkId rb = RB(i);
@ -38,6 +39,7 @@ void RaviCodeGenerator::emit_SELF(RaviFunctionDef *def, llvm::Value *L_ci,
def->builder->CreateCall4(def->luaV_gettableF, def->L, rb, rc, ra);
}
// R(A) := length of R(B)
void RaviCodeGenerator::emit_LEN(RaviFunctionDef *def, llvm::Value *L_ci,
llvm::Value *proto, int A, int B) {
// Protect(luaV_objlen(L, ra, RB(i)));
@ -346,7 +348,7 @@ void RaviCodeGenerator::emit_NEWARRAYINT(RaviFunctionDef *def,
int A) {
llvm::Instruction *base_ptr = emit_load_base(def);
llvm::Value *ra = emit_gep_ra(def, base_ptr, A);
def->builder->CreateCall3(def->luaV_newarrayintF, def->L, def->ci_val, ra);
def->builder->CreateCall3(def->raviV_op_newarrayintF, def->L, def->ci_val, ra);
}
void RaviCodeGenerator::emit_NEWARRAYFLOAT(RaviFunctionDef *def,
@ -354,7 +356,7 @@ void RaviCodeGenerator::emit_NEWARRAYFLOAT(RaviFunctionDef *def,
llvm::Value *proto, int A) {
llvm::Instruction *base_ptr = emit_load_base(def);
llvm::Value *ra = emit_gep_ra(def, base_ptr, A);
def->builder->CreateCall3(def->luaV_newarrayfloatF, def->L, def->ci_val, ra);
def->builder->CreateCall3(def->raviV_op_newarrayfloatF, def->L, def->ci_val, ra);
}
void RaviCodeGenerator::emit_NEWTABLE(RaviFunctionDef *def, llvm::Value *L_ci,
@ -371,7 +373,7 @@ void RaviCodeGenerator::emit_NEWTABLE(RaviFunctionDef *def, llvm::Value *L_ci,
llvm::Instruction *base_ptr = emit_load_base(def);
llvm::Value *ra = emit_gep_ra(def, base_ptr, A);
def->builder->CreateCall5(def->luaV_newtableF, def->L, def->ci_val, ra,
def->builder->CreateCall5(def->raviV_op_newtableF, def->L, def->ci_val, ra,
def->types->kInt[B], def->types->kInt[C]);
}
@ -379,7 +381,7 @@ void RaviCodeGenerator::emit_SETLIST(RaviFunctionDef *def, llvm::Value *L_ci,
llvm::Value *proto, int A, int B, int C) {
llvm::Instruction *base_ptr = emit_load_base(def);
llvm::Value *ra = emit_gep_ra(def, base_ptr, A);
def->builder->CreateCall5(def->luaV_setlistF, def->L, def->ci_val, ra,
def->builder->CreateCall5(def->raviV_op_setlistF, def->L, def->ci_val, ra,
def->types->kInt[B], def->types->kInt[C]);
}
}

@ -762,23 +762,23 @@ LuaLLVMTypes::LuaLLVMTypes(llvm::LLVMContext &context) : mdbuilder(context) {
elements.push_back(pCallInfoT);
elements.push_back(C_intT);
elements.push_back(C_intT);
luaV_op_loadnilT =
raviV_op_loadnilT =
llvm::FunctionType::get(llvm::Type::getVoidTy(context), elements, false);
elements.clear();
elements.push_back(plua_StateT);
elements.push_back(pCallInfoT);
elements.push_back(pTValueT);
luaV_newarrayintT =
raviV_op_newarrayintT =
llvm::FunctionType::get(llvm::Type::getVoidTy(context), elements, false);
luaV_newarrayfloatT =
raviV_op_newarrayfloatT =
llvm::FunctionType::get(llvm::Type::getVoidTy(context), elements, false);
elements.push_back(C_intT);
elements.push_back(C_intT);
luaV_newtableT =
raviV_op_newtableT =
llvm::FunctionType::get(llvm::Type::getVoidTy(context), elements, false);
luaV_setlistT =
raviV_op_setlistT =
llvm::FunctionType::get(llvm::Type::getVoidTy(context), elements, false);
elements.clear();
@ -795,7 +795,7 @@ LuaLLVMTypes::LuaLLVMTypes(llvm::LLVMContext &context) : mdbuilder(context) {
elements.push_back(C_intT);
elements.push_back(C_intT);
elements.push_back(C_intT);
luaV_opconcatT =
raviV_op_concatT =
llvm::FunctionType::get(llvm::Type::getVoidTy(context), elements, false);
// void luaV_opclosure(lua_State *L, CallInfo *ci, LClosure *cl, int a, int
@ -807,9 +807,9 @@ LuaLLVMTypes::LuaLLVMTypes(llvm::LLVMContext &context) : mdbuilder(context) {
elements.push_back(pLClosureT);
elements.push_back(C_intT);
elements.push_back(C_intT);
luaV_opclosureT =
raviV_op_closureT =
llvm::FunctionType::get(llvm::Type::getVoidTy(context), elements, false);
luaV_opvarargT =
raviV_op_varargT =
llvm::FunctionType::get(llvm::Type::getVoidTy(context), elements, false);
// void raviH_set_int(lua_State *L, Table *t, lua_Unsigned key, lua_Integer

Loading…
Cancel
Save