diff options
author | Mike Pall <mike> | 2011-02-03 04:13:51 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2011-02-03 04:22:27 +0100 |
commit | df65b8b419c12327254dec0df116c62525aaabad (patch) | |
tree | b4ba6ea2841692123b49b3033420dbb7282cbcd6 /src/lj_opt_fold.c | |
parent | 1027018b2135caf45057c3d3b3da03ffb0c6add3 (diff) | |
download | luajit-df65b8b419c12327254dec0df116c62525aaabad.tar.gz luajit-df65b8b419c12327254dec0df116c62525aaabad.tar.bz2 luajit-df65b8b419c12327254dec0df116c62525aaabad.zip |
FFI: Rename IR_CNEWP to IR_CNEWI and use it to box 64 bit integers.
Generates smaller IR and DCE eliminates many intermediate boxes.
Needs allocation sinking to eliminate the boxes kept alive by PHIs.
Diffstat (limited to 'src/lj_opt_fold.c')
-rw-r--r-- | src/lj_opt_fold.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/lj_opt_fold.c b/src/lj_opt_fold.c index c3b0a082..28758013 100644 --- a/src/lj_opt_fold.c +++ b/src/lj_opt_fold.c | |||
@@ -154,7 +154,7 @@ typedef IRRef (LJ_FASTCALL *FoldFunc)(jit_State *J); | |||
154 | #define gcstep_barrier(J, ref) \ | 154 | #define gcstep_barrier(J, ref) \ |
155 | ((ref) < J->chain[IR_LOOP] && \ | 155 | ((ref) < J->chain[IR_LOOP] && \ |
156 | (J->chain[IR_SNEW] || J->chain[IR_TNEW] || J->chain[IR_TDUP] || \ | 156 | (J->chain[IR_SNEW] || J->chain[IR_TNEW] || J->chain[IR_TDUP] || \ |
157 | J->chain[IR_CNEW] || J->chain[IR_CNEWP] || J->chain[IR_TOSTR])) | 157 | J->chain[IR_CNEW] || J->chain[IR_CNEWI] || J->chain[IR_TOSTR])) |
158 | 158 | ||
159 | /* -- Constant folding for FP numbers ------------------------------------- */ | 159 | /* -- Constant folding for FP numbers ------------------------------------- */ |
160 | 160 | ||
@@ -307,7 +307,7 @@ static uint64_t kfold_int64arith(uint64_t k1, uint64_t k2, IROp op) | |||
307 | case IR_BOR: k1 |= k2; break; | 307 | case IR_BOR: k1 |= k2; break; |
308 | case IR_BXOR: k1 ^= k2; break; | 308 | case IR_BXOR: k1 ^= k2; break; |
309 | #endif | 309 | #endif |
310 | default: lua_assert(0); break; | 310 | default: UNUSED(k2); lua_assert(0); break; |
311 | } | 311 | } |
312 | return k1; | 312 | return k1; |
313 | } | 313 | } |
@@ -1765,18 +1765,28 @@ LJFOLDF(fload_cdata_typeid_kgc) | |||
1765 | return NEXTFOLD; | 1765 | return NEXTFOLD; |
1766 | } | 1766 | } |
1767 | 1767 | ||
1768 | /* The content of int64 cdata objects is immutable. */ | ||
1769 | LJFOLD(FLOAD KGC IRFL_CDATA_INT64) | ||
1770 | LJFOLDF(fload_cdata_int64_kgc) | ||
1771 | { | ||
1772 | if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD)) | ||
1773 | return INT64FOLD(*(uint64_t *)cdataptr(ir_kcdata(fleft))); | ||
1774 | return NEXTFOLD; | ||
1775 | } | ||
1776 | |||
1768 | LJFOLD(FLOAD CNEW IRFL_CDATA_TYPEID) | 1777 | LJFOLD(FLOAD CNEW IRFL_CDATA_TYPEID) |
1769 | LJFOLD(FLOAD CNEWP IRFL_CDATA_TYPEID) | 1778 | LJFOLD(FLOAD CNEWI IRFL_CDATA_TYPEID) |
1770 | LJFOLDF(fload_cdata_typeid_cnew) | 1779 | LJFOLDF(fload_cdata_typeid_cnew) |
1771 | { | 1780 | { |
1772 | if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD)) | 1781 | if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD)) |
1773 | return fleft->op1; /* No PHI barrier needed. CNEW/CNEWP op1 is const. */ | 1782 | return fleft->op1; /* No PHI barrier needed. CNEW/CNEWI op1 is const. */ |
1774 | return NEXTFOLD; | 1783 | return NEXTFOLD; |
1775 | } | 1784 | } |
1776 | 1785 | ||
1777 | /* Pointer cdata objects are immutable. */ | 1786 | /* Pointer and int64 cdata objects are immutable. */ |
1778 | LJFOLD(FLOAD CNEWP IRFL_CDATA_PTR) | 1787 | LJFOLD(FLOAD CNEWI IRFL_CDATA_PTR) |
1779 | LJFOLDF(fload_cdata_ptr_cnew) | 1788 | LJFOLD(FLOAD CNEWI IRFL_CDATA_INT64) |
1789 | LJFOLDF(fload_cdata_ptr_int64_cnew) | ||
1780 | { | 1790 | { |
1781 | if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD)) | 1791 | if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD)) |
1782 | return fleft->op2; /* Fold even across PHI to avoid allocations. */ | 1792 | return fleft->op2; /* Fold even across PHI to avoid allocations. */ |
@@ -1786,6 +1796,7 @@ LJFOLDF(fload_cdata_ptr_cnew) | |||
1786 | LJFOLD(FLOAD any IRFL_STR_LEN) | 1796 | LJFOLD(FLOAD any IRFL_STR_LEN) |
1787 | LJFOLD(FLOAD any IRFL_CDATA_TYPEID) | 1797 | LJFOLD(FLOAD any IRFL_CDATA_TYPEID) |
1788 | LJFOLD(FLOAD any IRFL_CDATA_PTR) | 1798 | LJFOLD(FLOAD any IRFL_CDATA_PTR) |
1799 | LJFOLD(FLOAD any IRFL_CDATA_INT64) | ||
1789 | LJFOLD(VLOAD any any) /* Vararg loads have no corresponding stores. */ | 1800 | LJFOLD(VLOAD any any) /* Vararg loads have no corresponding stores. */ |
1790 | LJFOLDX(lj_opt_cse) | 1801 | LJFOLDX(lj_opt_cse) |
1791 | 1802 | ||