summaryrefslogtreecommitdiff
path: root/src/lj_record.c
diff options
context:
space:
mode:
authorMike Pall <mike>2010-12-31 03:56:30 +0100
committerMike Pall <mike>2010-12-31 03:56:30 +0100
commit1716540c55e8d432f17ea6c0666b1427a485ff4a (patch)
treeee192f7d8e0b4f296504b92226fbf8d9149acdd9 /src/lj_record.c
parent1f269610925829f55ed3e88e4af2b6575598adbc (diff)
downloadluajit-1716540c55e8d432f17ea6c0666b1427a485ff4a.tar.gz
luajit-1716540c55e8d432f17ea6c0666b1427a485ff4a.tar.bz2
luajit-1716540c55e8d432f17ea6c0666b1427a485ff4a.zip
Refactoring of conversion ops, part 4: use CONV instead of TOINT/TONUM.
Also narrow CONV.int.num and CONV.i64.num.
Diffstat (limited to 'src/lj_record.c')
-rw-r--r--src/lj_record.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/lj_record.c b/src/lj_record.c
index ae47f236..ec03afe1 100644
--- a/src/lj_record.c
+++ b/src/lj_record.c
@@ -169,10 +169,10 @@ int lj_record_objcmp(jit_State *J, TRef a, TRef b, cTValue *av, cTValue *bv)
169 if (ta != tb) { 169 if (ta != tb) {
170 /* Widen mixed number/int comparisons to number/number comparison. */ 170 /* Widen mixed number/int comparisons to number/number comparison. */
171 if (ta == IRT_INT && tb == IRT_NUM) { 171 if (ta == IRT_INT && tb == IRT_NUM) {
172 a = emitir(IRTN(IR_TONUM), a, 0); 172 a = emitir(IRTN(IR_CONV), a, IRCONV_NUM_INT);
173 ta = IRT_NUM; 173 ta = IRT_NUM;
174 } else if (ta == IRT_NUM && tb == IRT_INT) { 174 } else if (ta == IRT_NUM && tb == IRT_INT) {
175 b = emitir(IRTN(IR_TONUM), b, 0); 175 b = emitir(IRTN(IR_CONV), b, IRCONV_NUM_INT);
176 } else { 176 } else {
177 return 2; /* Two different types are never equal. */ 177 return 2; /* Two different types are never equal. */
178 } 178 }
@@ -199,7 +199,7 @@ static void canonicalize_slots(jit_State *J)
199 if (tref_isinteger(tr)) { 199 if (tref_isinteger(tr)) {
200 IRIns *ir = IR(tref_ref(tr)); 200 IRIns *ir = IR(tref_ref(tr));
201 if (!(ir->o == IR_SLOAD && (ir->op2 & IRSLOAD_READONLY))) 201 if (!(ir->o == IR_SLOAD && (ir->op2 & IRSLOAD_READONLY)))
202 J->slot[s] = emitir(IRTN(IR_TONUM), tr, 0); 202 J->slot[s] = emitir(IRTN(IR_CONV), tr, IRCONV_NUM_INT);
203 } 203 }
204 } 204 }
205} 205}
@@ -869,7 +869,7 @@ static TRef rec_idx_key(jit_State *J, RecordIndex *ix)
869 if ((MSize)k < LJ_MAX_ASIZE && n == cast_num(k)) { 869 if ((MSize)k < LJ_MAX_ASIZE && n == cast_num(k)) {
870 TRef asizeref, ikey = key; 870 TRef asizeref, ikey = key;
871 if (!tref_isinteger(ikey)) 871 if (!tref_isinteger(ikey))
872 ikey = emitir(IRTGI(IR_TOINT), ikey, IRTOINT_INDEX); 872 ikey = emitir(IRTGI(IR_CONV), ikey, IRCONV_INT_NUM|IRCONV_INDEX);
873 asizeref = emitir(IRTI(IR_FLOAD), ix->tab, IRFL_TAB_ASIZE); 873 asizeref = emitir(IRTI(IR_FLOAD), ix->tab, IRFL_TAB_ASIZE);
874 if ((MSize)k < t->asize) { /* Currently an array key? */ 874 if ((MSize)k < t->asize) { /* Currently an array key? */
875 TRef arrayref; 875 TRef arrayref;
@@ -898,7 +898,7 @@ static TRef rec_idx_key(jit_State *J, RecordIndex *ix)
898 898
899 /* Otherwise the key is located in the hash part. */ 899 /* Otherwise the key is located in the hash part. */
900 if (tref_isinteger(key)) /* Hash keys are based on numbers, not ints. */ 900 if (tref_isinteger(key)) /* Hash keys are based on numbers, not ints. */
901 ix->key = key = emitir(IRTN(IR_TONUM), key, 0); 901 ix->key = key = emitir(IRTN(IR_CONV), key, IRCONV_NUM_INT);
902 if (tref_isk(key)) { 902 if (tref_isk(key)) {
903 /* Optimize lookup of constant hash keys. */ 903 /* Optimize lookup of constant hash keys. */
904 MSize hslot = (MSize)((char *)ix->oldv - (char *)&noderef(t->node)[0].val); 904 MSize hslot = (MSize)((char *)ix->oldv - (char *)&noderef(t->node)[0].val);
@@ -1024,7 +1024,7 @@ TRef lj_record_idx(jit_State *J, RecordIndex *ix)
1024 if (oldv == niltvg(J2G(J))) { /* Need to insert a new key. */ 1024 if (oldv == niltvg(J2G(J))) { /* Need to insert a new key. */
1025 TRef key = ix->key; 1025 TRef key = ix->key;
1026 if (tref_isinteger(key)) /* NEWREF needs a TValue as a key. */ 1026 if (tref_isinteger(key)) /* NEWREF needs a TValue as a key. */
1027 key = emitir(IRTN(IR_TONUM), key, 0); 1027 key = emitir(IRTN(IR_CONV), key, IRCONV_NUM_INT);
1028 xref = emitir(IRT(IR_NEWREF, IRT_P32), ix->tab, key); 1028 xref = emitir(IRT(IR_NEWREF, IRT_P32), ix->tab, key);
1029 keybarrier = 0; /* NEWREF already takes care of the key barrier. */ 1029 keybarrier = 0; /* NEWREF already takes care of the key barrier. */
1030 } 1030 }
@@ -1046,7 +1046,7 @@ TRef lj_record_idx(jit_State *J, RecordIndex *ix)
1046 keybarrier = 0; /* Previous non-nil value kept the key alive. */ 1046 keybarrier = 0; /* Previous non-nil value kept the key alive. */
1047 } 1047 }
1048 if (tref_isinteger(ix->val)) /* Convert int to number before storing. */ 1048 if (tref_isinteger(ix->val)) /* Convert int to number before storing. */
1049 ix->val = emitir(IRTN(IR_TONUM), ix->val, 0); 1049 ix->val = emitir(IRTN(IR_CONV), ix->val, IRCONV_NUM_INT);
1050 emitir(IRT(loadop+IRDELTA_L2S, tref_type(ix->val)), xref, ix->val); 1050 emitir(IRT(loadop+IRDELTA_L2S, tref_type(ix->val)), xref, ix->val);
1051 if (keybarrier || tref_isgcv(ix->val)) 1051 if (keybarrier || tref_isgcv(ix->val))
1052 emitir(IRT(IR_TBAR, IRT_NIL), ix->tab, 0); 1052 emitir(IRT(IR_TBAR, IRT_NIL), ix->tab, 0);
@@ -1100,7 +1100,7 @@ static TRef rec_upvalue(jit_State *J, uint32_t uv, TRef val)
1100 return res; 1100 return res;
1101 } else { /* Upvalue store. */ 1101 } else { /* Upvalue store. */
1102 if (tref_isinteger(val)) /* Convert int to number before storing. */ 1102 if (tref_isinteger(val)) /* Convert int to number before storing. */
1103 val = emitir(IRTN(IR_TONUM), val, 0); 1103 val = emitir(IRTN(IR_CONV), val, IRCONV_NUM_INT);
1104 emitir(IRT(IR_USTORE, tref_type(val)), uref, val); 1104 emitir(IRT(IR_USTORE, tref_type(val)), uref, val);
1105 if (needbarrier && tref_isgcv(val)) 1105 if (needbarrier && tref_isgcv(val))
1106 emitir(IRT(IR_OBAR, IRT_NIL), uref, val); 1106 emitir(IRT(IR_OBAR, IRT_NIL), uref, val);
@@ -1254,7 +1254,7 @@ static void rec_varg(jit_State *J, BCReg dst, ptrdiff_t nresults)
1254 ptrdiff_t idx = lj_ffrecord_select_mode(J, tridx, &J->L->base[dst-1]); 1254 ptrdiff_t idx = lj_ffrecord_select_mode(J, tridx, &J->L->base[dst-1]);
1255 if (idx < 0) goto nyivarg; 1255 if (idx < 0) goto nyivarg;
1256 if (idx != 0 && !tref_isinteger(tridx)) 1256 if (idx != 0 && !tref_isinteger(tridx))
1257 tridx = emitir(IRTGI(IR_TOINT), tridx, IRTOINT_INDEX); 1257 tridx = emitir(IRTGI(IR_CONV), tridx, IRCONV_INT_NUM|IRCONV_INDEX);
1258 if (idx != 0 && tref_isk(tridx)) { 1258 if (idx != 0 && tref_isk(tridx)) {
1259 emitir(IRTGI(idx <= nvararg ? IR_GE : IR_LT), 1259 emitir(IRTGI(idx <= nvararg ? IR_GE : IR_LT),
1260 fr, lj_ir_kint(J, frofs+8*(int32_t)idx)); 1260 fr, lj_ir_kint(J, frofs+8*(int32_t)idx));
@@ -1418,10 +1418,10 @@ void lj_record_ins(jit_State *J)
1418 if (ta != tc) { 1418 if (ta != tc) {
1419 /* Widen mixed number/int comparisons to number/number comparison. */ 1419 /* Widen mixed number/int comparisons to number/number comparison. */
1420 if (ta == IRT_INT && tc == IRT_NUM) { 1420 if (ta == IRT_INT && tc == IRT_NUM) {
1421 ra = emitir(IRTN(IR_TONUM), ra, 0); 1421 ra = emitir(IRTN(IR_CONV), ra, IRCONV_NUM_INT);
1422 ta = IRT_NUM; 1422 ta = IRT_NUM;
1423 } else if (ta == IRT_NUM && tc == IRT_INT) { 1423 } else if (ta == IRT_NUM && tc == IRT_INT) {
1424 rc = emitir(IRTN(IR_TONUM), rc, 0); 1424 rc = emitir(IRTN(IR_CONV), rc, IRCONV_NUM_INT);
1425 } else if (!((ta == IRT_FALSE || ta == IRT_TRUE) && 1425 } else if (!((ta == IRT_FALSE || ta == IRT_TRUE) &&
1426 (tc == IRT_FALSE || tc == IRT_TRUE))) { 1426 (tc == IRT_FALSE || tc == IRT_TRUE))) {
1427 break; /* Interpreter will throw for two different types. */ 1427 break; /* Interpreter will throw for two different types. */