diff options
| author | Mike Pall <mike> | 2020-08-27 18:05:32 +0200 |
|---|---|---|
| committer | Mike Pall <mike> | 2020-08-27 18:05:32 +0200 |
| commit | ff1e72acead01df7d8ed0fbb31efd32f57953618 (patch) | |
| tree | e542edcd180a9684140013698f456a0c5d7da44f /src | |
| parent | 94d4abcca966df2cc423e821bcacd04898f73117 (diff) | |
| download | luajit-ff1e72acead01df7d8ed0fbb31efd32f57953618.tar.gz luajit-ff1e72acead01df7d8ed0fbb31efd32f57953618.tar.bz2 luajit-ff1e72acead01df7d8ed0fbb31efd32f57953618.zip | |
LJ_GC64: Always snapshot functions for non-base frames.
Reported by Arseny Vakhrushev.
Analysis and fix contributed by Peter Cawley.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lj_record.c | 1 | ||||
| -rw-r--r-- | src/lj_snap.c | 9 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/lj_record.c b/src/lj_record.c index df428818..9e41ce05 100644 --- a/src/lj_record.c +++ b/src/lj_record.c | |||
| @@ -211,6 +211,7 @@ static TRef getcurrf(jit_State *J) | |||
| 211 | { | 211 | { |
| 212 | if (J->base[-1-LJ_FR2]) | 212 | if (J->base[-1-LJ_FR2]) |
| 213 | return J->base[-1-LJ_FR2]; | 213 | return J->base[-1-LJ_FR2]; |
| 214 | /* Non-base frame functions ought to be loaded already. */ | ||
| 214 | lj_assertJ(J->baseslot == 1+LJ_FR2, "bad baseslot"); | 215 | lj_assertJ(J->baseslot == 1+LJ_FR2, "bad baseslot"); |
| 215 | return sloadt(J, -1-LJ_FR2, IRT_FUNC, IRSLOAD_READONLY); | 216 | return sloadt(J, -1-LJ_FR2, IRT_FUNC, IRSLOAD_READONLY); |
| 216 | } | 217 | } |
diff --git a/src/lj_snap.c b/src/lj_snap.c index a21894f6..36f81528 100644 --- a/src/lj_snap.c +++ b/src/lj_snap.c | |||
| @@ -85,8 +85,13 @@ static MSize snapshot_slots(jit_State *J, SnapEntry *map, BCReg nslots) | |||
| 85 | IRIns *ir = &J->cur.ir[ref]; | 85 | IRIns *ir = &J->cur.ir[ref]; |
| 86 | if ((LJ_FR2 || !(sn & (SNAP_CONT|SNAP_FRAME))) && | 86 | if ((LJ_FR2 || !(sn & (SNAP_CONT|SNAP_FRAME))) && |
| 87 | ir->o == IR_SLOAD && ir->op1 == s && ref > retf) { | 87 | ir->o == IR_SLOAD && ir->op1 == s && ref > retf) { |
| 88 | /* No need to snapshot unmodified non-inherited slots. */ | 88 | /* |
| 89 | if (!(ir->op2 & IRSLOAD_INHERIT)) | 89 | ** No need to snapshot unmodified non-inherited slots. |
| 90 | ** But always snapshot the function below a frame in LJ_FR2 mode. | ||
| 91 | */ | ||
| 92 | if (!(ir->op2 & IRSLOAD_INHERIT) && | ||
| 93 | (!LJ_FR2 || s == 0 || s+1 == nslots || | ||
| 94 | !(J->slot[s+1] & (TREF_CONT|TREF_FRAME)))) | ||
| 90 | continue; | 95 | continue; |
| 91 | /* No need to restore readonly slots and unmodified non-parent slots. */ | 96 | /* No need to restore readonly slots and unmodified non-parent slots. */ |
| 92 | if (!(LJ_DUALNUM && (ir->op2 & IRSLOAD_CONVERT)) && | 97 | if (!(LJ_DUALNUM && (ir->op2 & IRSLOAD_CONVERT)) && |
