diff options
author | Mike Pall <mike> | 2020-10-12 15:45:05 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2020-10-12 15:45:05 +0200 |
commit | 5c46f47736f7609be407c88d531ecd1689d40a79 (patch) | |
tree | 7358e4fedb6fdfd9080d96631c76e17a95906411 /src | |
parent | de6b1a11dd1a3349179084578c5d533be1c30234 (diff) | |
download | luajit-5c46f47736f7609be407c88d531ecd1689d40a79.tar.gz luajit-5c46f47736f7609be407c88d531ecd1689d40a79.tar.bz2 luajit-5c46f47736f7609be407c88d531ecd1689d40a79.zip |
Fix snapshot PC when linking to BC_JLOOP that was a BC_RET*.
Reported by Arseny Vakhrushev.
Fix contributed by Peter Cawley.
Diffstat (limited to 'src')
-rw-r--r-- | src/lj_record.c | 9 | ||||
-rw-r--r-- | src/lj_snap.c | 3 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/lj_record.c b/src/lj_record.c index 69822f54..f5632f6c 100644 --- a/src/lj_record.c +++ b/src/lj_record.c | |||
@@ -513,10 +513,10 @@ static LoopEvent rec_iterl(jit_State *J, const BCIns iterins) | |||
513 | } | 513 | } |
514 | 514 | ||
515 | /* Record LOOP/JLOOP. Now, that was easy. */ | 515 | /* Record LOOP/JLOOP. Now, that was easy. */ |
516 | static LoopEvent rec_loop(jit_State *J, BCReg ra) | 516 | static LoopEvent rec_loop(jit_State *J, BCReg ra, int skip) |
517 | { | 517 | { |
518 | if (ra < J->maxslot) J->maxslot = ra; | 518 | if (ra < J->maxslot) J->maxslot = ra; |
519 | J->pc++; | 519 | J->pc += skip; |
520 | return LOOPEV_ENTER; | 520 | return LOOPEV_ENTER; |
521 | } | 521 | } |
522 | 522 | ||
@@ -2027,7 +2027,7 @@ void lj_record_ins(jit_State *J) | |||
2027 | rec_loop_interp(J, pc, rec_iterl(J, *pc)); | 2027 | rec_loop_interp(J, pc, rec_iterl(J, *pc)); |
2028 | break; | 2028 | break; |
2029 | case BC_LOOP: | 2029 | case BC_LOOP: |
2030 | rec_loop_interp(J, pc, rec_loop(J, ra)); | 2030 | rec_loop_interp(J, pc, rec_loop(J, ra, 1)); |
2031 | break; | 2031 | break; |
2032 | 2032 | ||
2033 | case BC_JFORL: | 2033 | case BC_JFORL: |
@@ -2037,7 +2037,8 @@ void lj_record_ins(jit_State *J) | |||
2037 | rec_loop_jit(J, rc, rec_iterl(J, traceref(J, rc)->startins)); | 2037 | rec_loop_jit(J, rc, rec_iterl(J, traceref(J, rc)->startins)); |
2038 | break; | 2038 | break; |
2039 | case BC_JLOOP: | 2039 | case BC_JLOOP: |
2040 | rec_loop_jit(J, rc, rec_loop(J, ra)); | 2040 | rec_loop_jit(J, rc, rec_loop(J, ra, |
2041 | !bc_isret(bc_op(traceref(J, rc)->startins)))); | ||
2041 | break; | 2042 | break; |
2042 | 2043 | ||
2043 | case BC_IFORL: | 2044 | case BC_IFORL: |
diff --git a/src/lj_snap.c b/src/lj_snap.c index de8068ac..bcd03038 100644 --- a/src/lj_snap.c +++ b/src/lj_snap.c | |||
@@ -97,6 +97,9 @@ static BCReg snapshot_framelinks(jit_State *J, SnapEntry *map) | |||
97 | cTValue *ftop = frame + funcproto(frame_func(frame))->framesize; | 97 | cTValue *ftop = frame + funcproto(frame_func(frame))->framesize; |
98 | MSize f = 0; | 98 | MSize f = 0; |
99 | map[f++] = SNAP_MKPC(J->pc); /* The current PC is always the first entry. */ | 99 | map[f++] = SNAP_MKPC(J->pc); /* The current PC is always the first entry. */ |
100 | lua_assert(!J->pt || | ||
101 | (J->pc >= proto_bc(J->pt) && | ||
102 | J->pc < proto_bc(J->pt) + J->pt->sizebc)); | ||
100 | while (frame > lim) { /* Backwards traversal of all frames above base. */ | 103 | while (frame > lim) { /* Backwards traversal of all frames above base. */ |
101 | if (frame_islua(frame)) { | 104 | if (frame_islua(frame)) { |
102 | map[f++] = SNAP_MKPC(frame_pc(frame)); | 105 | map[f++] = SNAP_MKPC(frame_pc(frame)); |