New implementation for 'tbclist'

- Fixes a bug, by removing dummy nodes together with the node
itself. (The previous implementation could leave dummy nodes in frames
which otherwise had no tbc variables, and therefore would not close
variables; that could leave 'tbclist' pointing higher than 'top', which
could dangle if the stack shrank.)

- Computes MAXDELTA based on the type of delta, to ease changing its
type if needed.

- Instead of 'isdummy', uses 'delta==0' to signal dummy nodes. (Dummy
nodes always have MAXDELTA for their real delta.)
This commit is contained in:
Roberto Ierusalimschy
2021-03-10 10:27:19 -03:00
parent a7b8b27dd3
commit 81c6021fb4
2 changed files with 32 additions and 13 deletions

View File

@@ -139,13 +139,14 @@ typedef struct TValue {
** Entries in a Lua stack. Field 'tbclist' forms a list of all
** to-be-closed variables active in this stack. Dummy entries are
** used when the distance between two tbc variables does not fit
** in an unsigned short.
** in an unsigned short. They are represented by delta==0, and
** their real delta is always the maximum value that fits in
** that field.
*/
typedef union StackValue {
TValue val;
struct {
TValuefields;
lu_byte isdummy;
unsigned short delta;
} tbclist;
} StackValue;