summaryrefslogtreecommitdiff
path: root/src/lj_emit_arm64.h
diff options
context:
space:
mode:
authorMike Pall <mike>2020-06-13 00:52:54 +0200
committerMike Pall <mike>2020-06-15 02:52:00 +0200
commit8ae5170cdc9c307bd81019b3e014391c9fd00581 (patch)
treeccf9f17035d0754c1758faee209e9a26b4e03418 /src/lj_emit_arm64.h
parent8b55054473452963f24b01efb7c4cc72497c74ec (diff)
downloadluajit-8ae5170cdc9c307bd81019b3e014391c9fd00581.tar.gz
luajit-8ae5170cdc9c307bd81019b3e014391c9fd00581.tar.bz2
luajit-8ae5170cdc9c307bd81019b3e014391c9fd00581.zip
Improve assertions.
Diffstat (limited to 'src/lj_emit_arm64.h')
-rw-r--r--src/lj_emit_arm64.h21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/lj_emit_arm64.h b/src/lj_emit_arm64.h
index f09c0f3a..61a2df82 100644
--- a/src/lj_emit_arm64.h
+++ b/src/lj_emit_arm64.h
@@ -8,8 +8,9 @@
8 8
9/* -- Constant encoding --------------------------------------------------- */ 9/* -- Constant encoding --------------------------------------------------- */
10 10
11static uint64_t get_k64val(IRIns *ir) 11static uint64_t get_k64val(ASMState *as, IRRef ref)
12{ 12{
13 IRIns *ir = IR(ref);
13 if (ir->o == IR_KINT64) { 14 if (ir->o == IR_KINT64) {
14 return ir_kint64(ir)->u64; 15 return ir_kint64(ir)->u64;
15 } else if (ir->o == IR_KGC) { 16 } else if (ir->o == IR_KGC) {
@@ -17,7 +18,8 @@ static uint64_t get_k64val(IRIns *ir)
17 } else if (ir->o == IR_KPTR || ir->o == IR_KKPTR) { 18 } else if (ir->o == IR_KPTR || ir->o == IR_KKPTR) {
18 return (uint64_t)ir_kptr(ir); 19 return (uint64_t)ir_kptr(ir);
19 } else { 20 } else {
20 lua_assert(ir->o == IR_KINT || ir->o == IR_KNULL); 21 lj_assertA(ir->o == IR_KINT || ir->o == IR_KNULL,
22 "bad 64 bit const IR op %d", ir->o);
21 return ir->i; /* Sign-extended. */ 23 return ir->i; /* Sign-extended. */
22 } 24 }
23} 25}
@@ -122,7 +124,7 @@ static int emit_checkofs(A64Ins ai, int64_t ofs)
122static void emit_lso(ASMState *as, A64Ins ai, Reg rd, Reg rn, int64_t ofs) 124static void emit_lso(ASMState *as, A64Ins ai, Reg rd, Reg rn, int64_t ofs)
123{ 125{
124 int ot = emit_checkofs(ai, ofs), sc = (ai >> 30) & 3; 126 int ot = emit_checkofs(ai, ofs), sc = (ai >> 30) & 3;
125 lua_assert(ot); 127 lj_assertA(ot, "load/store offset %d out of range", ofs);
126 /* Combine LDR/STR pairs to LDP/STP. */ 128 /* Combine LDR/STR pairs to LDP/STP. */
127 if ((sc == 2 || sc == 3) && 129 if ((sc == 2 || sc == 3) &&
128 (!(ai & 0x400000) || rd != rn) && 130 (!(ai & 0x400000) || rd != rn) &&
@@ -166,10 +168,10 @@ static int emit_kdelta(ASMState *as, Reg rd, uint64_t k, int lim)
166 while (work) { 168 while (work) {
167 Reg r = rset_picktop(work); 169 Reg r = rset_picktop(work);
168 IRRef ref = regcost_ref(as->cost[r]); 170 IRRef ref = regcost_ref(as->cost[r]);
169 lua_assert(r != rd); 171 lj_assertA(r != rd, "dest reg %d not free", rd);
170 if (ref < REF_TRUE) { 172 if (ref < REF_TRUE) {
171 uint64_t kx = ra_iskref(ref) ? (uint64_t)ra_krefk(as, ref) : 173 uint64_t kx = ra_iskref(ref) ? (uint64_t)ra_krefk(as, ref) :
172 get_k64val(IR(ref)); 174 get_k64val(as, ref);
173 int64_t delta = (int64_t)(k - kx); 175 int64_t delta = (int64_t)(k - kx);
174 if (delta == 0) { 176 if (delta == 0) {
175 emit_dm(as, A64I_MOVx, rd, r); 177 emit_dm(as, A64I_MOVx, rd, r);
@@ -312,7 +314,7 @@ static void emit_cond_branch(ASMState *as, A64CC cond, MCode *target)
312{ 314{
313 MCode *p = --as->mcp; 315 MCode *p = --as->mcp;
314 ptrdiff_t delta = target - p; 316 ptrdiff_t delta = target - p;
315 lua_assert(A64F_S_OK(delta, 19)); 317 lj_assertA(A64F_S_OK(delta, 19), "branch target out of range");
316 *p = A64I_BCC | A64F_S19(delta) | cond; 318 *p = A64I_BCC | A64F_S19(delta) | cond;
317} 319}
318 320
@@ -320,7 +322,7 @@ static void emit_branch(ASMState *as, A64Ins ai, MCode *target)
320{ 322{
321 MCode *p = --as->mcp; 323 MCode *p = --as->mcp;
322 ptrdiff_t delta = target - p; 324 ptrdiff_t delta = target - p;
323 lua_assert(A64F_S_OK(delta, 26)); 325 lj_assertA(A64F_S_OK(delta, 26), "branch target out of range");
324 *p = ai | A64F_S26(delta); 326 *p = ai | A64F_S26(delta);
325} 327}
326 328
@@ -328,7 +330,8 @@ static void emit_tnb(ASMState *as, A64Ins ai, Reg r, uint32_t bit, MCode *target
328{ 330{
329 MCode *p = --as->mcp; 331 MCode *p = --as->mcp;
330 ptrdiff_t delta = target - p; 332 ptrdiff_t delta = target - p;
331 lua_assert(bit < 63 && A64F_S_OK(delta, 14)); 333 lj_assertA(bit < 63, "bit number out of range");
334 lj_assertA(A64F_S_OK(delta, 14), "branch target out of range");
332 if (bit > 31) ai |= A64I_X; 335 if (bit > 31) ai |= A64I_X;
333 *p = ai | A64F_BIT(bit & 31) | A64F_S14(delta) | r; 336 *p = ai | A64F_BIT(bit & 31) | A64F_S14(delta) | r;
334} 337}
@@ -337,7 +340,7 @@ static void emit_cnb(ASMState *as, A64Ins ai, Reg r, MCode *target)
337{ 340{
338 MCode *p = --as->mcp; 341 MCode *p = --as->mcp;
339 ptrdiff_t delta = target - p; 342 ptrdiff_t delta = target - p;
340 lua_assert(A64F_S_OK(delta, 19)); 343 lj_assertA(A64F_S_OK(delta, 19), "branch target out of range");
341 *p = ai | A64F_S19(delta) | r; 344 *p = ai | A64F_S19(delta) | r;
342} 345}
343 346