diff options
Diffstat (limited to 'src/lj_snap.c')
-rw-r--r-- | src/lj_snap.c | 96 |
1 files changed, 58 insertions, 38 deletions
diff --git a/src/lj_snap.c b/src/lj_snap.c index a47c0e3e..a21894f6 100644 --- a/src/lj_snap.c +++ b/src/lj_snap.c | |||
@@ -110,7 +110,7 @@ static MSize snapshot_framelinks(jit_State *J, SnapEntry *map, uint8_t *topslot) | |||
110 | cTValue *ftop = isluafunc(fn) ? (frame+funcproto(fn)->framesize) : J->L->top; | 110 | cTValue *ftop = isluafunc(fn) ? (frame+funcproto(fn)->framesize) : J->L->top; |
111 | #if LJ_FR2 | 111 | #if LJ_FR2 |
112 | uint64_t pcbase = (u64ptr(J->pc) << 8) | (J->baseslot - 2); | 112 | uint64_t pcbase = (u64ptr(J->pc) << 8) | (J->baseslot - 2); |
113 | lua_assert(2 <= J->baseslot && J->baseslot <= 257); | 113 | lj_assertJ(2 <= J->baseslot && J->baseslot <= 257, "bad baseslot"); |
114 | memcpy(map, &pcbase, sizeof(uint64_t)); | 114 | memcpy(map, &pcbase, sizeof(uint64_t)); |
115 | #else | 115 | #else |
116 | MSize f = 0; | 116 | MSize f = 0; |
@@ -129,7 +129,7 @@ static MSize snapshot_framelinks(jit_State *J, SnapEntry *map, uint8_t *topslot) | |||
129 | #endif | 129 | #endif |
130 | frame = frame_prevd(frame); | 130 | frame = frame_prevd(frame); |
131 | } else { | 131 | } else { |
132 | lua_assert(!frame_isc(frame)); | 132 | lj_assertJ(!frame_isc(frame), "broken frame chain"); |
133 | #if !LJ_FR2 | 133 | #if !LJ_FR2 |
134 | map[f++] = SNAP_MKFTSZ(frame_ftsz(frame)); | 134 | map[f++] = SNAP_MKFTSZ(frame_ftsz(frame)); |
135 | #endif | 135 | #endif |
@@ -141,10 +141,10 @@ static MSize snapshot_framelinks(jit_State *J, SnapEntry *map, uint8_t *topslot) | |||
141 | } | 141 | } |
142 | *topslot = (uint8_t)(ftop - lim); | 142 | *topslot = (uint8_t)(ftop - lim); |
143 | #if LJ_FR2 | 143 | #if LJ_FR2 |
144 | lua_assert(sizeof(SnapEntry) * 2 == sizeof(uint64_t)); | 144 | lj_assertJ(sizeof(SnapEntry) * 2 == sizeof(uint64_t), "bad SnapEntry def"); |
145 | return 2; | 145 | return 2; |
146 | #else | 146 | #else |
147 | lua_assert(f == (MSize)(1 + J->framedepth)); | 147 | lj_assertJ(f == (MSize)(1 + J->framedepth), "miscalculated snapshot size"); |
148 | return f; | 148 | return f; |
149 | #endif | 149 | #endif |
150 | } | 150 | } |
@@ -222,7 +222,8 @@ static BCReg snap_usedef(jit_State *J, uint8_t *udf, | |||
222 | #define DEF_SLOT(s) udf[(s)] *= 3 | 222 | #define DEF_SLOT(s) udf[(s)] *= 3 |
223 | 223 | ||
224 | /* Scan through following bytecode and check for uses/defs. */ | 224 | /* Scan through following bytecode and check for uses/defs. */ |
225 | lua_assert(pc >= proto_bc(J->pt) && pc < proto_bc(J->pt) + J->pt->sizebc); | 225 | lj_assertJ(pc >= proto_bc(J->pt) && pc < proto_bc(J->pt) + J->pt->sizebc, |
226 | "snapshot PC out of range"); | ||
226 | for (;;) { | 227 | for (;;) { |
227 | BCIns ins = *pc++; | 228 | BCIns ins = *pc++; |
228 | BCOp op = bc_op(ins); | 229 | BCOp op = bc_op(ins); |
@@ -233,7 +234,7 @@ static BCReg snap_usedef(jit_State *J, uint8_t *udf, | |||
233 | switch (bcmode_c(op)) { | 234 | switch (bcmode_c(op)) { |
234 | case BCMvar: USE_SLOT(bc_c(ins)); break; | 235 | case BCMvar: USE_SLOT(bc_c(ins)); break; |
235 | case BCMrbase: | 236 | case BCMrbase: |
236 | lua_assert(op == BC_CAT); | 237 | lj_assertJ(op == BC_CAT, "unhandled op %d with RC rbase", op); |
237 | for (s = bc_b(ins); s <= bc_c(ins); s++) USE_SLOT(s); | 238 | for (s = bc_b(ins); s <= bc_c(ins); s++) USE_SLOT(s); |
238 | for (; s < maxslot; s++) DEF_SLOT(s); | 239 | for (; s < maxslot; s++) DEF_SLOT(s); |
239 | break; | 240 | break; |
@@ -285,7 +286,8 @@ static BCReg snap_usedef(jit_State *J, uint8_t *udf, | |||
285 | break; | 286 | break; |
286 | default: break; | 287 | default: break; |
287 | } | 288 | } |
288 | lua_assert(pc >= proto_bc(J->pt) && pc < proto_bc(J->pt) + J->pt->sizebc); | 289 | lj_assertJ(pc >= proto_bc(J->pt) && pc < proto_bc(J->pt) + J->pt->sizebc, |
290 | "use/def analysis PC out of range"); | ||
289 | } | 291 | } |
290 | 292 | ||
291 | #undef USE_SLOT | 293 | #undef USE_SLOT |
@@ -356,19 +358,20 @@ static RegSP snap_renameref(GCtrace *T, SnapNo lim, IRRef ref, RegSP rs) | |||
356 | } | 358 | } |
357 | 359 | ||
358 | /* Copy RegSP from parent snapshot to the parent links of the IR. */ | 360 | /* Copy RegSP from parent snapshot to the parent links of the IR. */ |
359 | IRIns *lj_snap_regspmap(GCtrace *T, SnapNo snapno, IRIns *ir) | 361 | IRIns *lj_snap_regspmap(jit_State *J, GCtrace *T, SnapNo snapno, IRIns *ir) |
360 | { | 362 | { |
361 | SnapShot *snap = &T->snap[snapno]; | 363 | SnapShot *snap = &T->snap[snapno]; |
362 | SnapEntry *map = &T->snapmap[snap->mapofs]; | 364 | SnapEntry *map = &T->snapmap[snap->mapofs]; |
363 | BloomFilter rfilt = snap_renamefilter(T, snapno); | 365 | BloomFilter rfilt = snap_renamefilter(T, snapno); |
364 | MSize n = 0; | 366 | MSize n = 0; |
365 | IRRef ref = 0; | 367 | IRRef ref = 0; |
368 | UNUSED(J); | ||
366 | for ( ; ; ir++) { | 369 | for ( ; ; ir++) { |
367 | uint32_t rs; | 370 | uint32_t rs; |
368 | if (ir->o == IR_SLOAD) { | 371 | if (ir->o == IR_SLOAD) { |
369 | if (!(ir->op2 & IRSLOAD_PARENT)) break; | 372 | if (!(ir->op2 & IRSLOAD_PARENT)) break; |
370 | for ( ; ; n++) { | 373 | for ( ; ; n++) { |
371 | lua_assert(n < snap->nent); | 374 | lj_assertJ(n < snap->nent, "slot %d not found in snapshot", ir->op1); |
372 | if (snap_slot(map[n]) == ir->op1) { | 375 | if (snap_slot(map[n]) == ir->op1) { |
373 | ref = snap_ref(map[n++]); | 376 | ref = snap_ref(map[n++]); |
374 | break; | 377 | break; |
@@ -385,7 +388,7 @@ IRIns *lj_snap_regspmap(GCtrace *T, SnapNo snapno, IRIns *ir) | |||
385 | if (bloomtest(rfilt, ref)) | 388 | if (bloomtest(rfilt, ref)) |
386 | rs = snap_renameref(T, snapno, ref, rs); | 389 | rs = snap_renameref(T, snapno, ref, rs); |
387 | ir->prev = (uint16_t)rs; | 390 | ir->prev = (uint16_t)rs; |
388 | lua_assert(regsp_used(rs)); | 391 | lj_assertJ(regsp_used(rs), "unused IR %04d in snapshot", ref - REF_BIAS); |
389 | } | 392 | } |
390 | return ir; | 393 | return ir; |
391 | } | 394 | } |
@@ -403,7 +406,7 @@ static TRef snap_replay_const(jit_State *J, IRIns *ir) | |||
403 | case IR_KNUM: case IR_KINT64: | 406 | case IR_KNUM: case IR_KINT64: |
404 | return lj_ir_k64(J, (IROp)ir->o, ir_k64(ir)->u64); | 407 | return lj_ir_k64(J, (IROp)ir->o, ir_k64(ir)->u64); |
405 | case IR_KPTR: return lj_ir_kptr(J, ir_kptr(ir)); /* Continuation. */ | 408 | case IR_KPTR: return lj_ir_kptr(J, ir_kptr(ir)); /* Continuation. */ |
406 | default: lua_assert(0); return TREF_NIL; break; | 409 | default: lj_assertJ(0, "bad IR constant op %d", ir->o); return TREF_NIL; |
407 | } | 410 | } |
408 | } | 411 | } |
409 | 412 | ||
@@ -481,7 +484,7 @@ void lj_snap_replay(jit_State *J, GCtrace *T) | |||
481 | tr = snap_replay_const(J, ir); | 484 | tr = snap_replay_const(J, ir); |
482 | } else if (!regsp_used(ir->prev)) { | 485 | } else if (!regsp_used(ir->prev)) { |
483 | pass23 = 1; | 486 | pass23 = 1; |
484 | lua_assert(s != 0); | 487 | lj_assertJ(s != 0, "unused slot 0 in snapshot"); |
485 | tr = s; | 488 | tr = s; |
486 | } else { | 489 | } else { |
487 | IRType t = irt_type(ir->t); | 490 | IRType t = irt_type(ir->t); |
@@ -507,8 +510,9 @@ void lj_snap_replay(jit_State *J, GCtrace *T) | |||
507 | if (regsp_reg(ir->r) == RID_SUNK) { | 510 | if (regsp_reg(ir->r) == RID_SUNK) { |
508 | if (J->slot[snap_slot(sn)] != snap_slot(sn)) continue; | 511 | if (J->slot[snap_slot(sn)] != snap_slot(sn)) continue; |
509 | pass23 = 1; | 512 | pass23 = 1; |
510 | lua_assert(ir->o == IR_TNEW || ir->o == IR_TDUP || | 513 | lj_assertJ(ir->o == IR_TNEW || ir->o == IR_TDUP || |
511 | ir->o == IR_CNEW || ir->o == IR_CNEWI); | 514 | ir->o == IR_CNEW || ir->o == IR_CNEWI, |
515 | "sunk parent IR %04d has bad op %d", refp - REF_BIAS, ir->o); | ||
512 | if (ir->op1 >= T->nk) snap_pref(J, T, map, nent, seen, ir->op1); | 516 | if (ir->op1 >= T->nk) snap_pref(J, T, map, nent, seen, ir->op1); |
513 | if (ir->op2 >= T->nk) snap_pref(J, T, map, nent, seen, ir->op2); | 517 | if (ir->op2 >= T->nk) snap_pref(J, T, map, nent, seen, ir->op2); |
514 | if (LJ_HASFFI && ir->o == IR_CNEWI) { | 518 | if (LJ_HASFFI && ir->o == IR_CNEWI) { |
@@ -526,7 +530,8 @@ void lj_snap_replay(jit_State *J, GCtrace *T) | |||
526 | } | 530 | } |
527 | } | 531 | } |
528 | } else if (!irref_isk(refp) && !regsp_used(ir->prev)) { | 532 | } else if (!irref_isk(refp) && !regsp_used(ir->prev)) { |
529 | lua_assert(ir->o == IR_CONV && ir->op2 == IRCONV_NUM_INT); | 533 | lj_assertJ(ir->o == IR_CONV && ir->op2 == IRCONV_NUM_INT, |
534 | "sunk parent IR %04d has bad op %d", refp - REF_BIAS, ir->o); | ||
530 | J->slot[snap_slot(sn)] = snap_pref(J, T, map, nent, seen, ir->op1); | 535 | J->slot[snap_slot(sn)] = snap_pref(J, T, map, nent, seen, ir->op1); |
531 | } | 536 | } |
532 | } | 537 | } |
@@ -576,7 +581,9 @@ void lj_snap_replay(jit_State *J, GCtrace *T) | |||
576 | val = snap_pref(J, T, map, nent, seen, irs->op2); | 581 | val = snap_pref(J, T, map, nent, seen, irs->op2); |
577 | if (val == 0) { | 582 | if (val == 0) { |
578 | IRIns *irc = &T->ir[irs->op2]; | 583 | IRIns *irc = &T->ir[irs->op2]; |
579 | lua_assert(irc->o == IR_CONV && irc->op2 == IRCONV_NUM_INT); | 584 | lj_assertJ(irc->o == IR_CONV && irc->op2 == IRCONV_NUM_INT, |
585 | "sunk store for parent IR %04d with bad op %d", | ||
586 | refp - REF_BIAS, irc->o); | ||
580 | val = snap_pref(J, T, map, nent, seen, irc->op1); | 587 | val = snap_pref(J, T, map, nent, seen, irc->op1); |
581 | val = emitir(IRTN(IR_CONV), val, IRCONV_NUM_INT); | 588 | val = emitir(IRTN(IR_CONV), val, IRCONV_NUM_INT); |
582 | } else if ((LJ_SOFTFP32 || (LJ_32 && LJ_HASFFI)) && | 589 | } else if ((LJ_SOFTFP32 || (LJ_32 && LJ_HASFFI)) && |
@@ -645,13 +652,14 @@ static void snap_restoreval(jit_State *J, GCtrace *T, ExitState *ex, | |||
645 | o->u64 = *(uint64_t *)sps; | 652 | o->u64 = *(uint64_t *)sps; |
646 | #endif | 653 | #endif |
647 | } else { | 654 | } else { |
648 | lua_assert(!irt_ispri(t)); /* PRI refs never have a spill slot. */ | 655 | lj_assertJ(!irt_ispri(t), "PRI ref with spill slot"); |
649 | setgcV(J->L, o, (GCobj *)(uintptr_t)*(GCSize *)sps, irt_toitype(t)); | 656 | setgcV(J->L, o, (GCobj *)(uintptr_t)*(GCSize *)sps, irt_toitype(t)); |
650 | } | 657 | } |
651 | } else { /* Restore from register. */ | 658 | } else { /* Restore from register. */ |
652 | Reg r = regsp_reg(rs); | 659 | Reg r = regsp_reg(rs); |
653 | if (ra_noreg(r)) { | 660 | if (ra_noreg(r)) { |
654 | lua_assert(ir->o == IR_CONV && ir->op2 == IRCONV_NUM_INT); | 661 | lj_assertJ(ir->o == IR_CONV && ir->op2 == IRCONV_NUM_INT, |
662 | "restore from IR %04d has no reg", ref - REF_BIAS); | ||
655 | snap_restoreval(J, T, ex, snapno, rfilt, ir->op1, o); | 663 | snap_restoreval(J, T, ex, snapno, rfilt, ir->op1, o); |
656 | if (LJ_DUALNUM) setnumV(o, (lua_Number)intV(o)); | 664 | if (LJ_DUALNUM) setnumV(o, (lua_Number)intV(o)); |
657 | return; | 665 | return; |
@@ -679,7 +687,7 @@ static void snap_restoreval(jit_State *J, GCtrace *T, ExitState *ex, | |||
679 | 687 | ||
680 | #if LJ_HASFFI | 688 | #if LJ_HASFFI |
681 | /* Restore raw data from the trace exit state. */ | 689 | /* Restore raw data from the trace exit state. */ |
682 | static void snap_restoredata(GCtrace *T, ExitState *ex, | 690 | static void snap_restoredata(jit_State *J, GCtrace *T, ExitState *ex, |
683 | SnapNo snapno, BloomFilter rfilt, | 691 | SnapNo snapno, BloomFilter rfilt, |
684 | IRRef ref, void *dst, CTSize sz) | 692 | IRRef ref, void *dst, CTSize sz) |
685 | { | 693 | { |
@@ -687,6 +695,7 @@ static void snap_restoredata(GCtrace *T, ExitState *ex, | |||
687 | RegSP rs = ir->prev; | 695 | RegSP rs = ir->prev; |
688 | int32_t *src; | 696 | int32_t *src; |
689 | uint64_t tmp; | 697 | uint64_t tmp; |
698 | UNUSED(J); | ||
690 | if (irref_isk(ref)) { | 699 | if (irref_isk(ref)) { |
691 | if (ir_isk64(ir)) { | 700 | if (ir_isk64(ir)) { |
692 | src = (int32_t *)&ir[1]; | 701 | src = (int32_t *)&ir[1]; |
@@ -709,8 +718,9 @@ static void snap_restoredata(GCtrace *T, ExitState *ex, | |||
709 | Reg r = regsp_reg(rs); | 718 | Reg r = regsp_reg(rs); |
710 | if (ra_noreg(r)) { | 719 | if (ra_noreg(r)) { |
711 | /* Note: this assumes CNEWI is never used for SOFTFP split numbers. */ | 720 | /* Note: this assumes CNEWI is never used for SOFTFP split numbers. */ |
712 | lua_assert(sz == 8 && ir->o == IR_CONV && ir->op2 == IRCONV_NUM_INT); | 721 | lj_assertJ(sz == 8 && ir->o == IR_CONV && ir->op2 == IRCONV_NUM_INT, |
713 | snap_restoredata(T, ex, snapno, rfilt, ir->op1, dst, 4); | 722 | "restore from IR %04d has no reg", ref - REF_BIAS); |
723 | snap_restoredata(J, T, ex, snapno, rfilt, ir->op1, dst, 4); | ||
714 | *(lua_Number *)dst = (lua_Number)*(int32_t *)dst; | 724 | *(lua_Number *)dst = (lua_Number)*(int32_t *)dst; |
715 | return; | 725 | return; |
716 | } | 726 | } |
@@ -731,7 +741,8 @@ static void snap_restoredata(GCtrace *T, ExitState *ex, | |||
731 | if (LJ_64 && LJ_BE && sz == 4) src++; | 741 | if (LJ_64 && LJ_BE && sz == 4) src++; |
732 | } | 742 | } |
733 | } | 743 | } |
734 | lua_assert(sz == 1 || sz == 2 || sz == 4 || sz == 8); | 744 | lj_assertJ(sz == 1 || sz == 2 || sz == 4 || sz == 8, |
745 | "restore from IR %04d with bad size %d", ref - REF_BIAS, sz); | ||
735 | if (sz == 4) *(int32_t *)dst = *src; | 746 | if (sz == 4) *(int32_t *)dst = *src; |
736 | else if (sz == 8) *(int64_t *)dst = *(int64_t *)src; | 747 | else if (sz == 8) *(int64_t *)dst = *(int64_t *)src; |
737 | else if (sz == 1) *(int8_t *)dst = (int8_t)*src; | 748 | else if (sz == 1) *(int8_t *)dst = (int8_t)*src; |
@@ -744,8 +755,9 @@ static void snap_unsink(jit_State *J, GCtrace *T, ExitState *ex, | |||
744 | SnapNo snapno, BloomFilter rfilt, | 755 | SnapNo snapno, BloomFilter rfilt, |
745 | IRIns *ir, TValue *o) | 756 | IRIns *ir, TValue *o) |
746 | { | 757 | { |
747 | lua_assert(ir->o == IR_TNEW || ir->o == IR_TDUP || | 758 | lj_assertJ(ir->o == IR_TNEW || ir->o == IR_TDUP || |
748 | ir->o == IR_CNEW || ir->o == IR_CNEWI); | 759 | ir->o == IR_CNEW || ir->o == IR_CNEWI, |
760 | "sunk allocation with bad op %d", ir->o); | ||
749 | #if LJ_HASFFI | 761 | #if LJ_HASFFI |
750 | if (ir->o == IR_CNEW || ir->o == IR_CNEWI) { | 762 | if (ir->o == IR_CNEW || ir->o == IR_CNEWI) { |
751 | CTState *cts = ctype_cts(J->L); | 763 | CTState *cts = ctype_cts(J->L); |
@@ -756,13 +768,14 @@ static void snap_unsink(jit_State *J, GCtrace *T, ExitState *ex, | |||
756 | setcdataV(J->L, o, cd); | 768 | setcdataV(J->L, o, cd); |
757 | if (ir->o == IR_CNEWI) { | 769 | if (ir->o == IR_CNEWI) { |
758 | uint8_t *p = (uint8_t *)cdataptr(cd); | 770 | uint8_t *p = (uint8_t *)cdataptr(cd); |
759 | lua_assert(sz == 4 || sz == 8); | 771 | lj_assertJ(sz == 4 || sz == 8, "sunk cdata with bad size %d", sz); |
760 | if (LJ_32 && sz == 8 && ir+1 < T->ir + T->nins && (ir+1)->o == IR_HIOP) { | 772 | if (LJ_32 && sz == 8 && ir+1 < T->ir + T->nins && (ir+1)->o == IR_HIOP) { |
761 | snap_restoredata(T, ex, snapno, rfilt, (ir+1)->op2, LJ_LE?p+4:p, 4); | 773 | snap_restoredata(J, T, ex, snapno, rfilt, (ir+1)->op2, |
774 | LJ_LE ? p+4 : p, 4); | ||
762 | if (LJ_BE) p += 4; | 775 | if (LJ_BE) p += 4; |
763 | sz = 4; | 776 | sz = 4; |
764 | } | 777 | } |
765 | snap_restoredata(T, ex, snapno, rfilt, ir->op2, p, sz); | 778 | snap_restoredata(J, T, ex, snapno, rfilt, ir->op2, p, sz); |
766 | } else { | 779 | } else { |
767 | IRIns *irs, *irlast = &T->ir[T->snap[snapno].ref]; | 780 | IRIns *irs, *irlast = &T->ir[T->snap[snapno].ref]; |
768 | for (irs = ir+1; irs < irlast; irs++) | 781 | for (irs = ir+1; irs < irlast; irs++) |
@@ -770,8 +783,11 @@ static void snap_unsink(jit_State *J, GCtrace *T, ExitState *ex, | |||
770 | IRIns *iro = &T->ir[T->ir[irs->op1].op2]; | 783 | IRIns *iro = &T->ir[T->ir[irs->op1].op2]; |
771 | uint8_t *p = (uint8_t *)cd; | 784 | uint8_t *p = (uint8_t *)cd; |
772 | CTSize szs; | 785 | CTSize szs; |
773 | lua_assert(irs->o == IR_XSTORE && T->ir[irs->op1].o == IR_ADD); | 786 | lj_assertJ(irs->o == IR_XSTORE, "sunk store with bad op %d", irs->o); |
774 | lua_assert(iro->o == IR_KINT || iro->o == IR_KINT64); | 787 | lj_assertJ(T->ir[irs->op1].o == IR_ADD, |
788 | "sunk store with bad add op %d", T->ir[irs->op1].o); | ||
789 | lj_assertJ(iro->o == IR_KINT || iro->o == IR_KINT64, | ||
790 | "sunk store with bad const offset op %d", iro->o); | ||
775 | if (irt_is64(irs->t)) szs = 8; | 791 | if (irt_is64(irs->t)) szs = 8; |
776 | else if (irt_isi8(irs->t) || irt_isu8(irs->t)) szs = 1; | 792 | else if (irt_isi8(irs->t) || irt_isu8(irs->t)) szs = 1; |
777 | else if (irt_isi16(irs->t) || irt_isu16(irs->t)) szs = 2; | 793 | else if (irt_isi16(irs->t) || irt_isu16(irs->t)) szs = 2; |
@@ -780,14 +796,16 @@ static void snap_unsink(jit_State *J, GCtrace *T, ExitState *ex, | |||
780 | p += (int64_t)ir_k64(iro)->u64; | 796 | p += (int64_t)ir_k64(iro)->u64; |
781 | else | 797 | else |
782 | p += iro->i; | 798 | p += iro->i; |
783 | lua_assert(p >= (uint8_t *)cdataptr(cd) && | 799 | lj_assertJ(p >= (uint8_t *)cdataptr(cd) && |
784 | p + szs <= (uint8_t *)cdataptr(cd) + sz); | 800 | p + szs <= (uint8_t *)cdataptr(cd) + sz, |
801 | "sunk store with offset out of range"); | ||
785 | if (LJ_32 && irs+1 < T->ir + T->nins && (irs+1)->o == IR_HIOP) { | 802 | if (LJ_32 && irs+1 < T->ir + T->nins && (irs+1)->o == IR_HIOP) { |
786 | lua_assert(szs == 4); | 803 | lj_assertJ(szs == 4, "sunk store with bad size %d", szs); |
787 | snap_restoredata(T, ex, snapno, rfilt, (irs+1)->op2, LJ_LE?p+4:p,4); | 804 | snap_restoredata(J, T, ex, snapno, rfilt, (irs+1)->op2, |
805 | LJ_LE ? p+4 : p, 4); | ||
788 | if (LJ_BE) p += 4; | 806 | if (LJ_BE) p += 4; |
789 | } | 807 | } |
790 | snap_restoredata(T, ex, snapno, rfilt, irs->op2, p, szs); | 808 | snap_restoredata(J, T, ex, snapno, rfilt, irs->op2, p, szs); |
791 | } | 809 | } |
792 | } | 810 | } |
793 | } else | 811 | } else |
@@ -802,10 +820,12 @@ static void snap_unsink(jit_State *J, GCtrace *T, ExitState *ex, | |||
802 | if (irs->r == RID_SINK && snap_sunk_store(T, ir, irs)) { | 820 | if (irs->r == RID_SINK && snap_sunk_store(T, ir, irs)) { |
803 | IRIns *irk = &T->ir[irs->op1]; | 821 | IRIns *irk = &T->ir[irs->op1]; |
804 | TValue tmp, *val; | 822 | TValue tmp, *val; |
805 | lua_assert(irs->o == IR_ASTORE || irs->o == IR_HSTORE || | 823 | lj_assertJ(irs->o == IR_ASTORE || irs->o == IR_HSTORE || |
806 | irs->o == IR_FSTORE); | 824 | irs->o == IR_FSTORE, |
825 | "sunk store with bad op %d", irs->o); | ||
807 | if (irk->o == IR_FREF) { | 826 | if (irk->o == IR_FREF) { |
808 | lua_assert(irk->op2 == IRFL_TAB_META); | 827 | lj_assertJ(irk->op2 == IRFL_TAB_META, |
828 | "sunk store with bad field %d", irk->op2); | ||
809 | snap_restoreval(J, T, ex, snapno, rfilt, irs->op2, &tmp); | 829 | snap_restoreval(J, T, ex, snapno, rfilt, irs->op2, &tmp); |
810 | /* NOBARRIER: The table is new (marked white). */ | 830 | /* NOBARRIER: The table is new (marked white). */ |
811 | setgcref(t->metatable, obj2gco(tabV(&tmp))); | 831 | setgcref(t->metatable, obj2gco(tabV(&tmp))); |
@@ -893,7 +913,7 @@ const BCIns *lj_snap_restore(jit_State *J, void *exptr) | |||
893 | #if LJ_FR2 | 913 | #if LJ_FR2 |
894 | L->base += (map[nent+LJ_BE] & 0xff); | 914 | L->base += (map[nent+LJ_BE] & 0xff); |
895 | #endif | 915 | #endif |
896 | lua_assert(map + nent == flinks); | 916 | lj_assertJ(map + nent == flinks, "inconsistent frames in snapshot"); |
897 | 917 | ||
898 | /* Compute current stack top. */ | 918 | /* Compute current stack top. */ |
899 | switch (bc_op(*pc)) { | 919 | switch (bc_op(*pc)) { |