aboutsummaryrefslogtreecommitdiff
path: root/lobject.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2022-10-31 15:06:20 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2022-10-31 15:06:20 -0300
commitee645472ebe153e2c6669c84a632297a8110bdb6 (patch)
tree13444ccb5fd4bfb04bc62e2c6b035d97eb979e8f /lobject.h
parent413a393e6222482f46599e138bebac162610a572 (diff)
downloadlua-ee645472ebe153e2c6669c84a632297a8110bdb6.tar.gz
lua-ee645472ebe153e2c6669c84a632297a8110bdb6.tar.bz2
lua-ee645472ebe153e2c6669c84a632297a8110bdb6.zip
Stack reallocation done with a single realloc
To avoid the need of both the old and the new stack addresses valid at the same time, to correct the pointers to the stack, these pointers are changed to offsets before the reallocation and then changed back to pointers after the reallocation.
Diffstat (limited to 'lobject.h')
-rw-r--r--lobject.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/lobject.h b/lobject.h
index 7af7bd89..e7f58cbd 100644
--- a/lobject.h
+++ b/lobject.h
@@ -158,8 +158,13 @@ typedef union StackValue {
158typedef StackValue *StkId; 158typedef StackValue *StkId;
159 159
160 160
161/*
162** When reallocating the stack, change all pointers to the stack into
163** proper offsets.
164*/
161typedef union { 165typedef union {
162 StkId p; /* actual pointer */ 166 StkId p; /* actual pointer */
167 ptrdiff_t offset; /* used while the stack is being reallocated */
163} StkIdRel; 168} StkIdRel;
164 169
165 170
@@ -626,6 +631,7 @@ typedef struct UpVal {
626 lu_byte tbc; /* true if it represents a to-be-closed variable */ 631 lu_byte tbc; /* true if it represents a to-be-closed variable */
627 union { 632 union {
628 TValue *p; /* points to stack or to its own value */ 633 TValue *p; /* points to stack or to its own value */
634 ptrdiff_t offset; /* used while the stack is being reallocated */
629 } v; 635 } v;
630 union { 636 union {
631 struct { /* (when open) */ 637 struct { /* (when open) */