summaryrefslogtreecommitdiff
path: root/src/lj_asm.c
diff options
context:
space:
mode:
authorMike Pall <mike>2011-10-27 01:52:37 +0200
committerMike Pall <mike>2011-10-27 01:57:30 +0200
commit2dc574d06bc6e828109a3bffa975592f9417434c (patch)
tree1239baece908e2390eb378e6d7d8063825926f9b /src/lj_asm.c
parent1d190c99a2547b44deb8f5e483452d9f51925fb2 (diff)
downloadluajit2-2dc574d06bc6e828109a3bffa975592f9417434c.tar.gz
FFI: Compile calls to stdcall, fastcall and vararg functions.
Diffstat (limited to 'src/lj_asm.c')
-rw-r--r--src/lj_asm.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/lj_asm.c b/src/lj_asm.c
index 2e204239..9fe53416 100644
--- a/src/lj_asm.c
+++ b/src/lj_asm.c
@@ -888,7 +888,16 @@ static uint32_t asm_callx_flags(ASMState *as, IRIns *ir)
nargs++;
while (ira->o == IR_CARG) { nargs++; ira = IR(ira->op1); }
}
- /* NYI: fastcall etc. */
+#if LJ_HASFFI
+ if (IR(ir->op2)->o == IR_CARG) { /* Copy calling convention info. */
+ CTypeID id = (CTypeID)IR(IR(ir->op2)->op2)->i;
+ CType *ct = ctype_get(ctype_ctsG(J2G(as->J)), id);
+ nargs |= ((ct->info & CTF_VARARG) ? CCI_VARARG : 0);
+#if LJ_TARGET_X86
+ nargs |= (ctype_cconv(ct->info) << CCI_CC_SHIFT);
+#endif
+ }
+#endif
return (nargs | (ir->t.irt << CCI_OTSHIFT));
}