aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2012-08-28 15:24:53 +0200
committerMike Pall <mike>2012-08-28 15:24:53 +0200
commit751cd9d82180f1bd99a738acc29bc114995a42e4 (patch)
treef472c16ba66eabf209d938c29a19047780dcce61 /src
parentc7826af5a0403b48eeeb6c18532dc076146b1966 (diff)
downloadluajit-751cd9d82180f1bd99a738acc29bc114995a42e4.tar.gz
luajit-751cd9d82180f1bd99a738acc29bc114995a42e4.tar.bz2
luajit-751cd9d82180f1bd99a738acc29bc114995a42e4.zip
Don't constify upvalues that may retain large amounts of memory.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.dep5
-rw-r--r--src/lj_record.c28
2 files changed, 30 insertions, 3 deletions
diff --git a/src/Makefile.dep b/src/Makefile.dep
index 9b130deb..94a963ba 100644
--- a/src/Makefile.dep
+++ b/src/Makefile.dep
@@ -155,8 +155,9 @@ lj_parse.o: lj_parse.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
155 lj_state.h lj_bc.h lj_ctype.h lj_lex.h lj_parse.h lj_vm.h lj_vmevent.h 155 lj_state.h lj_bc.h lj_ctype.h lj_lex.h lj_parse.h lj_vm.h lj_vmevent.h
156lj_record.o: lj_record.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ 156lj_record.o: lj_record.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
157 lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_meta.h lj_frame.h lj_bc.h \ 157 lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_meta.h lj_frame.h lj_bc.h \
158 lj_ff.h lj_ffdef.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_trace.h \ 158 lj_ctype.h lj_gc.h lj_ff.h lj_ffdef.h lj_ir.h lj_jit.h lj_ircall.h \
159 lj_dispatch.h lj_traceerr.h lj_record.h lj_ffrecord.h lj_snap.h lj_vm.h 159 lj_iropt.h lj_trace.h lj_dispatch.h lj_traceerr.h lj_record.h \
160 lj_ffrecord.h lj_snap.h lj_vm.h
160lj_snap.o: lj_snap.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ 161lj_snap.o: lj_snap.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \
161 lj_tab.h lj_state.h lj_frame.h lj_bc.h lj_ir.h lj_jit.h lj_iropt.h \ 162 lj_tab.h lj_state.h lj_frame.h lj_bc.h lj_ir.h lj_jit.h lj_iropt.h \
162 lj_trace.h lj_dispatch.h lj_traceerr.h lj_snap.h lj_target.h \ 163 lj_trace.h lj_dispatch.h lj_traceerr.h lj_snap.h lj_target.h \
diff --git a/src/lj_record.c b/src/lj_record.c
index a593af99..ce25f29e 100644
--- a/src/lj_record.c
+++ b/src/lj_record.c
@@ -15,6 +15,9 @@
15#include "lj_tab.h" 15#include "lj_tab.h"
16#include "lj_meta.h" 16#include "lj_meta.h"
17#include "lj_frame.h" 17#include "lj_frame.h"
18#if LJ_HASFFI
19#include "lj_ctype.h"
20#endif
18#include "lj_bc.h" 21#include "lj_bc.h"
19#include "lj_ff.h" 22#include "lj_ff.h"
20#include "lj_ir.h" 23#include "lj_ir.h"
@@ -1275,6 +1278,29 @@ TRef lj_record_idx(jit_State *J, RecordIndex *ix)
1275 1278
1276/* -- Upvalue access ------------------------------------------------------ */ 1279/* -- Upvalue access ------------------------------------------------------ */
1277 1280
1281/* Check whether upvalue is immutable and ok to constify. */
1282static int rec_upvalue_constify(jit_State *J, GCupval *uvp)
1283{
1284 if (uvp->immutable) {
1285 cTValue *o = uvval(uvp);
1286 /* Don't constify objects that may retain large amounts of memory. */
1287#if LJ_HASFFI
1288 if (tviscdata(o)) {
1289 GCcdata *cd = cdataV(o);
1290 if (!cdataisv(cd) && !(cd->marked & LJ_GC_CDATA_FIN)) {
1291 CType *ct = ctype_raw(ctype_ctsG(J2G(J)), cd->ctypeid);
1292 if (!ctype_hassize(ct->info) || ct->size <= 16)
1293 return 1;
1294 }
1295 return 0;
1296 }
1297#endif
1298 if (!(tvistab(o) || tvisudata(o) || tvisthread(o)))
1299 return 1;
1300 }
1301 return 0;
1302}
1303
1278/* Record upvalue load/store. */ 1304/* Record upvalue load/store. */
1279static TRef rec_upvalue(jit_State *J, uint32_t uv, TRef val) 1305static TRef rec_upvalue(jit_State *J, uint32_t uv, TRef val)
1280{ 1306{
@@ -1282,7 +1308,7 @@ static TRef rec_upvalue(jit_State *J, uint32_t uv, TRef val)
1282 TRef fn = getcurrf(J); 1308 TRef fn = getcurrf(J);
1283 IRRef uref; 1309 IRRef uref;
1284 int needbarrier = 0; 1310 int needbarrier = 0;
1285 if (uvp->immutable) { /* Try to constify immutable upvalue. */ 1311 if (rec_upvalue_constify(J, uvp)) { /* Try to constify immutable upvalue. */
1286 TRef tr, kfunc; 1312 TRef tr, kfunc;
1287 lua_assert(val == 0); 1313 lua_assert(val == 0);
1288 if (!tref_isk(fn)) { /* Late specialization of current function. */ 1314 if (!tref_isk(fn)) { /* Late specialization of current function. */