diff options
| author | Mike Pall <mike> | 2025-05-28 21:06:44 +0200 |
|---|---|---|
| committer | Mike Pall <mike> | 2025-05-28 21:06:44 +0200 |
| commit | 0a8cd58ea19850a08d7765f82b79f75553a3d71c (patch) | |
| tree | e770812afc8f673663c5e627c54f4d4070a13830 /src | |
| parent | 852c3a08aef8e3709e37622a23e74c655dc2926a (diff) | |
| parent | cd4af8ad80bb6430ad2e547f7af236268c9be7d9 (diff) | |
| download | luajit-0a8cd58ea19850a08d7765f82b79f75553a3d71c.tar.gz luajit-0a8cd58ea19850a08d7765f82b79f75553a3d71c.tar.bz2 luajit-0a8cd58ea19850a08d7765f82b79f75553a3d71c.zip | |
Merge branch 'master' into v2.1
Diffstat (limited to 'src')
| -rw-r--r-- | src/lj_bc.h | 5 | ||||
| -rw-r--r-- | src/lj_parse.c | 14 | ||||
| -rw-r--r-- | src/lj_snap.c | 6 |
3 files changed, 10 insertions, 15 deletions
diff --git a/src/lj_bc.h b/src/lj_bc.h index a94ea4e4..53b3e501 100644 --- a/src/lj_bc.h +++ b/src/lj_bc.h | |||
| @@ -259,6 +259,11 @@ static LJ_AINLINE int bc_isret(BCOp op) | |||
| 259 | return (op == BC_RETM || op == BC_RET || op == BC_RET0 || op == BC_RET1); | 259 | return (op == BC_RETM || op == BC_RET || op == BC_RET0 || op == BC_RET1); |
| 260 | } | 260 | } |
| 261 | 261 | ||
| 262 | static LJ_AINLINE int bc_isret_or_tail(BCOp op) | ||
| 263 | { | ||
| 264 | return (op == BC_CALLMT || op == BC_CALLT || bc_isret(op)); | ||
| 265 | } | ||
| 266 | |||
| 262 | LJ_DATA const uint16_t lj_bc_mode[]; | 267 | LJ_DATA const uint16_t lj_bc_mode[]; |
| 263 | LJ_DATA const uint16_t lj_bc_ofs[]; | 268 | LJ_DATA const uint16_t lj_bc_ofs[]; |
| 264 | 269 | ||
diff --git a/src/lj_parse.c b/src/lj_parse.c index f4116380..e326432a 100644 --- a/src/lj_parse.c +++ b/src/lj_parse.c | |||
| @@ -1517,23 +1517,11 @@ static void fs_fixup_var(LexState *ls, GCproto *pt, uint8_t *p, size_t ofsvar) | |||
| 1517 | 1517 | ||
| 1518 | #endif | 1518 | #endif |
| 1519 | 1519 | ||
| 1520 | /* Check if bytecode op returns. */ | ||
| 1521 | static int bcopisret(BCOp op) | ||
| 1522 | { | ||
| 1523 | switch (op) { | ||
| 1524 | case BC_CALLMT: case BC_CALLT: | ||
| 1525 | case BC_RETM: case BC_RET: case BC_RET0: case BC_RET1: | ||
| 1526 | return 1; | ||
| 1527 | default: | ||
| 1528 | return 0; | ||
| 1529 | } | ||
| 1530 | } | ||
| 1531 | |||
| 1532 | /* Fixup return instruction for prototype. */ | 1520 | /* Fixup return instruction for prototype. */ |
| 1533 | static void fs_fixup_ret(FuncState *fs) | 1521 | static void fs_fixup_ret(FuncState *fs) |
| 1534 | { | 1522 | { |
| 1535 | BCPos lastpc = fs->pc; | 1523 | BCPos lastpc = fs->pc; |
| 1536 | if (lastpc <= fs->lasttarget || !bcopisret(bc_op(fs->bcbase[lastpc-1].ins))) { | 1524 | if (lastpc <= fs->lasttarget || !bc_isret_or_tail(bc_op(fs->bcbase[lastpc-1].ins))) { |
| 1537 | if ((fs->bl->flags & FSCOPE_UPVAL)) | 1525 | if ((fs->bl->flags & FSCOPE_UPVAL)) |
| 1538 | bcemit_AJ(fs, BC_UCLO, 0, 0); | 1526 | bcemit_AJ(fs, BC_UCLO, 0, 0); |
| 1539 | bcemit_AD(fs, BC_RET0, 0, 1); /* Need final return. */ | 1527 | bcemit_AD(fs, BC_RET0, 0, 1); /* Need final return. */ |
diff --git a/src/lj_snap.c b/src/lj_snap.c index cb104439..d0d28c81 100644 --- a/src/lj_snap.c +++ b/src/lj_snap.c | |||
| @@ -956,8 +956,10 @@ const BCIns *lj_snap_restore(jit_State *J, void *exptr) | |||
| 956 | const BCIns *pc = snap_pc(&map[nent]); | 956 | const BCIns *pc = snap_pc(&map[nent]); |
| 957 | lua_State *L = J->L; | 957 | lua_State *L = J->L; |
| 958 | 958 | ||
| 959 | /* Set interpreter PC to the next PC to get correct error messages. */ | 959 | /* Set interpreter PC to the next PC to get correct error messages. |
| 960 | setcframe_pc(L->cframe, pc+1); | 960 | ** But not for returns or tail calls, since pc+1 may be out-of-range. |
| 961 | */ | ||
| 962 | setcframe_pc(L->cframe, bc_isret_or_tail(bc_op(*pc)) ? pc : pc+1); | ||
| 961 | setcframe_pc(cframe_raw(cframe_prev(L->cframe)), pc); | 963 | setcframe_pc(cframe_raw(cframe_prev(L->cframe)), pc); |
| 962 | 964 | ||
| 963 | /* Make sure the stack is big enough for the slots from the snapshot. */ | 965 | /* Make sure the stack is big enough for the slots from the snapshot. */ |
