Don't treat all constified cdata content as constant.

This commit is contained in:
Mike Pall 2012-07-24 14:56:29 +02:00
parent 3636a720a5
commit e8af6e9da4
3 changed files with 16 additions and 2 deletions

View File

@ -133,7 +133,8 @@ lj_opt_dce.o: lj_opt_dce.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
lj_ir.h lj_jit.h lj_iropt.h
lj_opt_fold.o: lj_opt_fold.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
lj_str.h lj_tab.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h lj_dispatch.h \
lj_bc.h lj_traceerr.h lj_carith.h lj_vm.h lj_folddef.h
lj_bc.h lj_traceerr.h lj_ctype.h lj_gc.h lj_carith.h lj_vm.h \
lj_folddef.h
lj_opt_loop.o: lj_opt_loop.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
lj_err.h lj_errmsg.h lj_str.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h \
lj_dispatch.h lj_bc.h lj_traceerr.h lj_snap.h lj_vm.h

View File

@ -332,6 +332,7 @@ typedef struct IRType1 { uint8_t irt; } IRType1;
#define irt_islightud(t) (irt_type(t) == IRT_LIGHTUD)
#define irt_isstr(t) (irt_type(t) == IRT_STR)
#define irt_istab(t) (irt_type(t) == IRT_TAB)
#define irt_iscdata(t) (irt_type(t) == IRT_CDATA)
#define irt_isfloat(t) (irt_type(t) == IRT_FLOAT)
#define irt_isnum(t) (irt_type(t) == IRT_NUM)
#define irt_isint(t) (irt_type(t) == IRT_INT)

View File

@ -20,6 +20,9 @@
#include "lj_jit.h"
#include "lj_iropt.h"
#include "lj_trace.h"
#if LJ_HASFFI
#include "lj_ctype.h"
#endif
#include "lj_carith.h"
#include "lj_vm.h"
@ -535,7 +538,16 @@ LJFOLDF(kfold_add_kgc)
#else
ptrdiff_t ofs = fright->i;
#endif
return lj_ir_kkptr(J, (char *)o + ofs);
#if LJ_HASFFI
if (irt_iscdata(fleft->t)) {
CType *ct = ctype_raw(ctype_ctsG(J2G(J)), gco2cd(o)->ctypeid);
if (ctype_isnum(ct->info) || ctype_isenum(ct->info) ||
ctype_isptr(ct->info) || ctype_isfunc(ct->info) ||
ctype_iscomplex(ct->info) || ctype_isvector(ct->info))
return lj_ir_kkptr(J, (char *)o + ofs);
}
#endif
return lj_ir_kptr(J, (char *)o + ofs);
}
LJFOLD(ADD KPTR KINT)