aboutsummaryrefslogtreecommitdiff
path: root/src/lj_cconv.c
diff options
context:
space:
mode:
authorMike Pall <mike>2010-12-30 12:16:25 +0100
committerMike Pall <mike>2010-12-30 12:16:25 +0100
commit4668b229de64a839857391808c90f92290125ad8 (patch)
treec5ed7341b02e478c636c4422d3968a00c0e44a39 /src/lj_cconv.c
parent158de60b8c5a46b3f00c00ae54ed026ef46487b3 (diff)
downloadluajit-4668b229de64a839857391808c90f92290125ad8.tar.gz
luajit-4668b229de64a839857391808c90f92290125ad8.tar.bz2
luajit-4668b229de64a839857391808c90f92290125ad8.zip
FFI: Add missing GC steps for implicit allocations.
Diffstat (limited to 'src/lj_cconv.c')
-rw-r--r--src/lj_cconv.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/lj_cconv.c b/src/lj_cconv.c
index 642a4852..5df33d04 100644
--- a/src/lj_cconv.c
+++ b/src/lj_cconv.c
@@ -375,8 +375,8 @@ copyval: /* Copy value. */
375/* -- C type to TValue conversion ----------------------------------------- */ 375/* -- C type to TValue conversion ----------------------------------------- */
376 376
377/* Convert C type to TValue. Caveat: expects to get the raw CType! */ 377/* Convert C type to TValue. Caveat: expects to get the raw CType! */
378void lj_cconv_tv_ct(CTState *cts, CType *s, CTypeID sid, 378int lj_cconv_tv_ct(CTState *cts, CType *s, CTypeID sid,
379 TValue *o, uint8_t *sp) 379 TValue *o, uint8_t *sp)
380{ 380{
381 CTInfo sinfo = s->info; 381 CTInfo sinfo = s->info;
382 lua_assert(!ctype_isenum(sinfo)); 382 lua_assert(!ctype_isenum(sinfo));
@@ -398,9 +398,11 @@ void lj_cconv_tv_ct(CTState *cts, CType *s, CTypeID sid,
398 setboolV(o, tmpbool); 398 setboolV(o, tmpbool);
399 else 399 else
400 lua_assert(tvisnum(o)); 400 lua_assert(tvisnum(o));
401 return 0;
401 } else if (ctype_isrefarray(sinfo) || ctype_isstruct(sinfo)) { 402 } else if (ctype_isrefarray(sinfo) || ctype_isstruct(sinfo)) {
402 /* Create reference. */ 403 /* Create reference. */
403 setcdataV(cts->L, o, lj_cdata_newref(cts, sp, sid)); 404 setcdataV(cts->L, o, lj_cdata_newref(cts, sp, sid));
405 return 1; /* Need GC step. */
404 } else { 406 } else {
405 GCcdata *cd; 407 GCcdata *cd;
406 CTSize sz; 408 CTSize sz;
@@ -411,11 +413,12 @@ void lj_cconv_tv_ct(CTState *cts, CType *s, CTypeID sid,
411 cd = lj_cdata_new(cts, ctype_typeid(cts, s), sz); 413 cd = lj_cdata_new(cts, ctype_typeid(cts, s), sz);
412 setcdataV(cts->L, o, cd); 414 setcdataV(cts->L, o, cd);
413 memcpy(cdataptr(cd), sp, sz); 415 memcpy(cdataptr(cd), sp, sz);
416 return 1; /* Need GC step. */
414 } 417 }
415} 418}
416 419
417/* Convert bitfield to TValue. */ 420/* Convert bitfield to TValue. */
418void lj_cconv_tv_bf(CTState *cts, CType *s, TValue *o, uint8_t *sp) 421int lj_cconv_tv_bf(CTState *cts, CType *s, TValue *o, uint8_t *sp)
419{ 422{
420 CTInfo info = s->info; 423 CTInfo info = s->info;
421 CTSize pos, bsz; 424 CTSize pos, bsz;
@@ -445,6 +448,7 @@ void lj_cconv_tv_bf(CTState *cts, CType *s, TValue *o, uint8_t *sp)
445 lua_assert(bsz == 1); 448 lua_assert(bsz == 1);
446 setboolV(o, (val >> pos) & 1); 449 setboolV(o, (val >> pos) & 1);
447 } 450 }
451 return 0; /* No GC step needed. */
448} 452}
449 453
450/* -- TValue to C type conversion ----------------------------------------- */ 454/* -- TValue to C type conversion ----------------------------------------- */