diff options
author | Mike Pall <mike> | 2013-03-23 14:55:35 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2013-03-23 14:55:35 +0100 |
commit | 3b0b3afbb1357cbf206b56a46cd03955b201fa4b (patch) | |
tree | 11ff958a69f6a2d0f958b0055c27a054bb2e8bfd | |
parent | f1dbd65c0ec8024105ef5b059886ba0ff2783080 (diff) | |
parent | 172bd953657904e1b133b99ec328271c4e69c52c (diff) | |
download | luajit-3b0b3afbb1357cbf206b56a46cd03955b201fa4b.tar.gz luajit-3b0b3afbb1357cbf206b56a46cd03955b201fa4b.tar.bz2 luajit-3b0b3afbb1357cbf206b56a46cd03955b201fa4b.zip |
Merge branch 'master' into v2.1
-rw-r--r-- | src/lj_opt_split.c | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/src/lj_opt_split.c b/src/lj_opt_split.c index a0526c9d..6ab509eb 100644 --- a/src/lj_opt_split.c +++ b/src/lj_opt_split.c | |||
@@ -308,6 +308,19 @@ static IRRef split_bitop(jit_State *J, IRRef1 *hisubst, | |||
308 | } | 308 | } |
309 | #endif | 309 | #endif |
310 | 310 | ||
311 | /* Substitute references of a snapshot. */ | ||
312 | static void split_subst_snap(jit_State *J, SnapShot *snap, IRIns *oir) | ||
313 | { | ||
314 | SnapEntry *map = &J->cur.snapmap[snap->mapofs]; | ||
315 | MSize n, nent = snap->nent; | ||
316 | for (n = 0; n < nent; n++) { | ||
317 | SnapEntry sn = map[n]; | ||
318 | IRIns *ir = &oir[snap_ref(sn)]; | ||
319 | if (!(LJ_SOFTFP && (sn & SNAP_SOFTFPNUM) && irref_isk(snap_ref(sn)))) | ||
320 | map[n] = ((sn & 0xffff0000) | ir->prev); | ||
321 | } | ||
322 | } | ||
323 | |||
311 | /* Transform the old IR to the new IR. */ | 324 | /* Transform the old IR to the new IR. */ |
312 | static void split_ir(jit_State *J) | 325 | static void split_ir(jit_State *J) |
313 | { | 326 | { |
@@ -316,7 +329,8 @@ static void split_ir(jit_State *J) | |||
316 | MSize need = (irlen+1)*(sizeof(IRIns) + sizeof(IRRef1)); | 329 | MSize need = (irlen+1)*(sizeof(IRIns) + sizeof(IRRef1)); |
317 | IRIns *oir = (IRIns *)lj_buf_tmp(J->L, need); | 330 | IRIns *oir = (IRIns *)lj_buf_tmp(J->L, need); |
318 | IRRef1 *hisubst; | 331 | IRRef1 *hisubst; |
319 | IRRef ref; | 332 | IRRef ref, snref; |
333 | SnapShot *snap; | ||
320 | 334 | ||
321 | /* Copy old IR to buffer. */ | 335 | /* Copy old IR to buffer. */ |
322 | memcpy(oir, IR(nk), irlen*sizeof(IRIns)); | 336 | memcpy(oir, IR(nk), irlen*sizeof(IRIns)); |
@@ -343,12 +357,20 @@ static void split_ir(jit_State *J) | |||
343 | } | 357 | } |
344 | 358 | ||
345 | /* Process old IR instructions. */ | 359 | /* Process old IR instructions. */ |
360 | snap = J->cur.snap; | ||
361 | snref = snap->ref; | ||
346 | for (ref = REF_FIRST; ref < nins; ref++) { | 362 | for (ref = REF_FIRST; ref < nins; ref++) { |
347 | IRIns *ir = &oir[ref]; | 363 | IRIns *ir = &oir[ref]; |
348 | IRRef nref = lj_ir_nextins(J); | 364 | IRRef nref = lj_ir_nextins(J); |
349 | IRIns *nir = IR(nref); | 365 | IRIns *nir = IR(nref); |
350 | IRRef hi = 0; | 366 | IRRef hi = 0; |
351 | 367 | ||
368 | if (ref >= snref) { | ||
369 | snap->ref = nref; | ||
370 | split_subst_snap(J, snap++, oir); | ||
371 | snref = snap < &J->cur.snap[J->cur.nsnap] ? snap->ref : ~(IRRef)0; | ||
372 | } | ||
373 | |||
352 | /* Copy-substitute old instruction to new instruction. */ | 374 | /* Copy-substitute old instruction to new instruction. */ |
353 | nir->op1 = ir->op1 < nk ? ir->op1 : oir[ir->op1].prev; | 375 | nir->op1 = ir->op1 < nk ? ir->op1 : oir[ir->op1].prev; |
354 | nir->op2 = ir->op2 < nk ? ir->op2 : oir[ir->op2].prev; | 376 | nir->op2 = ir->op2 < nk ? ir->op2 : oir[ir->op2].prev; |
@@ -761,6 +783,10 @@ static void split_ir(jit_State *J) | |||
761 | } | 783 | } |
762 | hisubst[ref] = hi; /* Store hiword substitution. */ | 784 | hisubst[ref] = hi; /* Store hiword substitution. */ |
763 | } | 785 | } |
786 | if (snref == nins) { /* Substitution for last snapshot. */ | ||
787 | snap->ref = J->cur.nins; | ||
788 | split_subst_snap(J, snap, oir); | ||
789 | } | ||
764 | 790 | ||
765 | /* Add PHI marks. */ | 791 | /* Add PHI marks. */ |
766 | for (ref = J->cur.nins-1; ref >= REF_FIRST; ref--) { | 792 | for (ref = J->cur.nins-1; ref >= REF_FIRST; ref--) { |
@@ -769,24 +795,6 @@ static void split_ir(jit_State *J) | |||
769 | if (!irref_isk(ir->op1)) irt_setphi(IR(ir->op1)->t); | 795 | if (!irref_isk(ir->op1)) irt_setphi(IR(ir->op1)->t); |
770 | if (ir->op2 > J->loopref) irt_setphi(IR(ir->op2)->t); | 796 | if (ir->op2 > J->loopref) irt_setphi(IR(ir->op2)->t); |
771 | } | 797 | } |
772 | |||
773 | /* Substitute snapshot maps. */ | ||
774 | oir[nins].prev = J->cur.nins; /* Substitution for last snapshot. */ | ||
775 | { | ||
776 | SnapNo i, nsnap = J->cur.nsnap; | ||
777 | for (i = 0; i < nsnap; i++) { | ||
778 | SnapShot *snap = &J->cur.snap[i]; | ||
779 | SnapEntry *map = &J->cur.snapmap[snap->mapofs]; | ||
780 | MSize n, nent = snap->nent; | ||
781 | snap->ref = snap->ref == REF_FIRST ? REF_FIRST : oir[snap->ref].prev; | ||
782 | for (n = 0; n < nent; n++) { | ||
783 | SnapEntry sn = map[n]; | ||
784 | IRIns *ir = &oir[snap_ref(sn)]; | ||
785 | if (!(LJ_SOFTFP && (sn & SNAP_SOFTFPNUM) && irref_isk(snap_ref(sn)))) | ||
786 | map[n] = ((sn & 0xffff0000) | ir->prev); | ||
787 | } | ||
788 | } | ||
789 | } | ||
790 | } | 798 | } |
791 | 799 | ||
792 | /* Protected callback for split pass. */ | 800 | /* Protected callback for split pass. */ |