diff options
| author | Mike Pall <mike> | 2012-07-24 14:56:29 +0200 |
|---|---|---|
| committer | Mike Pall <mike> | 2012-07-24 14:56:29 +0200 |
| commit | e8af6e9da4465ffb02f89bee8dfc372b48741bf7 (patch) | |
| tree | 2021e6d195b26deaab04e11b81447b4f676284dd | |
| parent | 3636a720a57adefb84c7ac70b68f640caf47f27f (diff) | |
| download | luajit-e8af6e9da4465ffb02f89bee8dfc372b48741bf7.tar.gz luajit-e8af6e9da4465ffb02f89bee8dfc372b48741bf7.tar.bz2 luajit-e8af6e9da4465ffb02f89bee8dfc372b48741bf7.zip | |
Don't treat all constified cdata content as constant.
| -rw-r--r-- | src/Makefile.dep | 3 | ||||
| -rw-r--r-- | src/lj_ir.h | 1 | ||||
| -rw-r--r-- | src/lj_opt_fold.c | 14 |
3 files changed, 16 insertions, 2 deletions
diff --git a/src/Makefile.dep b/src/Makefile.dep index 1c7e5dc0..f9e658e1 100644 --- a/src/Makefile.dep +++ b/src/Makefile.dep | |||
| @@ -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 \ | |||
| 133 | lj_ir.h lj_jit.h lj_iropt.h | 133 | lj_ir.h lj_jit.h lj_iropt.h |
| 134 | lj_opt_fold.o: lj_opt_fold.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ | 134 | lj_opt_fold.o: lj_opt_fold.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ |
| 135 | lj_str.h lj_tab.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h lj_dispatch.h \ | 135 | lj_str.h lj_tab.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h lj_dispatch.h \ |
| 136 | lj_bc.h lj_traceerr.h lj_carith.h lj_vm.h lj_folddef.h | 136 | lj_bc.h lj_traceerr.h lj_ctype.h lj_gc.h lj_carith.h lj_vm.h \ |
| 137 | lj_folddef.h | ||
| 137 | lj_opt_loop.o: lj_opt_loop.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ | 138 | lj_opt_loop.o: lj_opt_loop.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ |
| 138 | lj_err.h lj_errmsg.h lj_str.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h \ | 139 | lj_err.h lj_errmsg.h lj_str.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h \ |
| 139 | lj_dispatch.h lj_bc.h lj_traceerr.h lj_snap.h lj_vm.h | 140 | lj_dispatch.h lj_bc.h lj_traceerr.h lj_snap.h lj_vm.h |
diff --git a/src/lj_ir.h b/src/lj_ir.h index 0bdc19df..6d016b93 100644 --- a/src/lj_ir.h +++ b/src/lj_ir.h | |||
| @@ -332,6 +332,7 @@ typedef struct IRType1 { uint8_t irt; } IRType1; | |||
| 332 | #define irt_islightud(t) (irt_type(t) == IRT_LIGHTUD) | 332 | #define irt_islightud(t) (irt_type(t) == IRT_LIGHTUD) |
| 333 | #define irt_isstr(t) (irt_type(t) == IRT_STR) | 333 | #define irt_isstr(t) (irt_type(t) == IRT_STR) |
| 334 | #define irt_istab(t) (irt_type(t) == IRT_TAB) | 334 | #define irt_istab(t) (irt_type(t) == IRT_TAB) |
| 335 | #define irt_iscdata(t) (irt_type(t) == IRT_CDATA) | ||
| 335 | #define irt_isfloat(t) (irt_type(t) == IRT_FLOAT) | 336 | #define irt_isfloat(t) (irt_type(t) == IRT_FLOAT) |
| 336 | #define irt_isnum(t) (irt_type(t) == IRT_NUM) | 337 | #define irt_isnum(t) (irt_type(t) == IRT_NUM) |
| 337 | #define irt_isint(t) (irt_type(t) == IRT_INT) | 338 | #define irt_isint(t) (irt_type(t) == IRT_INT) |
diff --git a/src/lj_opt_fold.c b/src/lj_opt_fold.c index f4aadb8d..74cea785 100644 --- a/src/lj_opt_fold.c +++ b/src/lj_opt_fold.c | |||
| @@ -20,6 +20,9 @@ | |||
| 20 | #include "lj_jit.h" | 20 | #include "lj_jit.h" |
| 21 | #include "lj_iropt.h" | 21 | #include "lj_iropt.h" |
| 22 | #include "lj_trace.h" | 22 | #include "lj_trace.h" |
| 23 | #if LJ_HASFFI | ||
| 24 | #include "lj_ctype.h" | ||
| 25 | #endif | ||
| 23 | #include "lj_carith.h" | 26 | #include "lj_carith.h" |
| 24 | #include "lj_vm.h" | 27 | #include "lj_vm.h" |
| 25 | 28 | ||
| @@ -535,7 +538,16 @@ LJFOLDF(kfold_add_kgc) | |||
| 535 | #else | 538 | #else |
| 536 | ptrdiff_t ofs = fright->i; | 539 | ptrdiff_t ofs = fright->i; |
| 537 | #endif | 540 | #endif |
| 538 | return lj_ir_kkptr(J, (char *)o + ofs); | 541 | #if LJ_HASFFI |
| 542 | if (irt_iscdata(fleft->t)) { | ||
| 543 | CType *ct = ctype_raw(ctype_ctsG(J2G(J)), gco2cd(o)->ctypeid); | ||
| 544 | if (ctype_isnum(ct->info) || ctype_isenum(ct->info) || | ||
| 545 | ctype_isptr(ct->info) || ctype_isfunc(ct->info) || | ||
| 546 | ctype_iscomplex(ct->info) || ctype_isvector(ct->info)) | ||
| 547 | return lj_ir_kkptr(J, (char *)o + ofs); | ||
| 548 | } | ||
| 549 | #endif | ||
| 550 | return lj_ir_kptr(J, (char *)o + ofs); | ||
| 539 | } | 551 | } |
| 540 | 552 | ||
| 541 | LJFOLD(ADD KPTR KINT) | 553 | LJFOLD(ADD KPTR KINT) |
