aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lgc.c1
-rw-r--r--lobject.h31
-rw-r--r--ltable.c3
-rw-r--r--ltests.c2
4 files changed, 28 insertions, 9 deletions
diff --git a/lgc.c b/lgc.c
index cf62a45c..db519c6d 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1565,6 +1565,7 @@ static void incstep (lua_State *L, global_State *g) {
1565*/ 1565*/
1566void luaC_step (lua_State *L) { 1566void luaC_step (lua_State *L) {
1567 global_State *g = G(L); 1567 global_State *g = G(L);
1568 lua_assert(!g->gcemergency);
1568 if (g->gcrunning) { /* running? */ 1569 if (g->gcrunning) { /* running? */
1569 if(isdecGCmodegen(g)) 1570 if(isdecGCmodegen(g))
1570 genstep(L, g); 1571 genstep(L, g);
diff --git a/lobject.h b/lobject.h
index a22148c0..0c38affe 100644
--- a/lobject.h
+++ b/lobject.h
@@ -17,11 +17,12 @@
17 17
18 18
19/* 19/*
20** Extra tags for non-values 20** Extra tags for collectable non-values
21*/ 21*/
22#define LUA_TUPVAL LUA_NUMTAGS /* upvalues */ 22#define LUA_TUPVAL LUA_NUMTAGS /* upvalues */
23#define LUA_TPROTO (LUA_NUMTAGS+1) /* function prototypes */ 23#define LUA_TPROTO (LUA_NUMTAGS+1) /* function prototypes */
24 24
25
25/* 26/*
26** number of all possible tags (including LUA_TNONE) 27** number of all possible tags (including LUA_TNONE)
27*/ 28*/
@@ -30,7 +31,7 @@
30 31
31/* 32/*
32** tags for Tagged Values have the following use of bits: 33** tags for Tagged Values have the following use of bits:
33** bits 0-3: actual tag (a LUA_T* value) 34** bits 0-3: actual tag (a LUA_T* constant)
34** bits 4-5: variant bits 35** bits 4-5: variant bits
35** bit 6: whether value is collectable 36** bit 6: whether value is collectable
36*/ 37*/
@@ -86,24 +87,35 @@ typedef struct TValue {
86 87
87 88
88/* Macros for internal tests */ 89/* Macros for internal tests */
90
91/* collectable object has the same tag as the original value */
89#define righttt(obj) (ttypetag(obj) == gcvalue(obj)->tt) 92#define righttt(obj) (ttypetag(obj) == gcvalue(obj)->tt)
90 93
94/*
95** Any value being manipulated by the program either is non
96** collectable, or the collectable object has the right tag
97** and it is not dead.
98*/
91#define checkliveness(L,obj) \ 99#define checkliveness(L,obj) \
92 ((void)L, lua_longassert(!iscollectable(obj) || \ 100 ((void)L, lua_longassert(!iscollectable(obj) || \
93 (righttt(obj) && (L == NULL || !isdead(G(L),gcvalue(obj)))))) 101 (righttt(obj) && (L == NULL || !isdead(G(L),gcvalue(obj))))))
94 102
95 103
96/* Macros to set values */ 104/* Macros to set values */
105
106/* set a value's tag */
97#define settt_(o,t) ((o)->tt_=(t)) 107#define settt_(o,t) ((o)->tt_=(t))
98 108
99 109
110/* main macro to copy values (from 'obj1' to 'obj2') */
100#define setobj(L,obj1,obj2) \ 111#define setobj(L,obj1,obj2) \
101 { TValue *io1=(obj1); const TValue *io2=(obj2); \ 112 { TValue *io1=(obj1); const TValue *io2=(obj2); \
102 io1->value_ = io2->value_; io1->tt_ = io2->tt_; \ 113 io1->value_ = io2->value_; settt_(io1, io2->tt_); \
103 checkliveness(L,io1); lua_assert(!isreallyempty(io1)); } 114 checkliveness(L,io1); lua_assert(!isnonstrictnil(io1)); }
104 115
105/* 116/*
106** different types of assignments, according to destination 117** Different types of assignments, according to source and destination.
118** (They are mostly equal now, but may be different in the future.)
107*/ 119*/
108 120
109/* from stack to stack */ 121/* from stack to stack */
@@ -118,13 +130,16 @@ typedef struct TValue {
118#define setobj2t setobj 130#define setobj2t setobj
119 131
120 132
121 133/*
134** Entries in the Lua stack
135*/
122typedef union StackValue { 136typedef union StackValue {
123 TValue val; 137 TValue val;
124} StackValue; 138} StackValue;
125 139
126 140
127typedef StackValue *StkId; /* index to stack elements */ 141/* index to stack elements */
142typedef StackValue *StkId;
128 143
129/* convert a 'StackValue' to a 'TValue' */ 144/* convert a 'StackValue' to a 'TValue' */
130#define s2v(o) (&(o)->val) 145#define s2v(o) (&(o)->val)
@@ -166,7 +181,7 @@ typedef StackValue *StkId; /* index to stack elements */
166/* 181/*
167** macro to detect non-standard nils (used only in assertions) 182** macro to detect non-standard nils (used only in assertions)
168*/ 183*/
169#define isreallyempty(v) (ttisnil(v) && !ttisstrictnil(v)) 184#define isnonstrictnil(v) (ttisnil(v) && !ttisstrictnil(v))
170 185
171 186
172/* 187/*
diff --git a/ltable.c b/ltable.c
index 5561d45e..4c7ae994 100644
--- a/ltable.c
+++ b/ltable.c
@@ -155,6 +155,9 @@ static Node *mainposition (const Table *t, int ktt, const Value *kvl) {
155} 155}
156 156
157 157
158/*
159** Returns the main position of an element given as a 'TValue'
160*/
158static Node *mainpositionTV (const Table *t, const TValue *key) { 161static Node *mainpositionTV (const Table *t, const TValue *key) {
159 return mainposition(t, rawtt(key), valraw(key)); 162 return mainposition(t, rawtt(key), valraw(key));
160} 163}
diff --git a/ltests.c b/ltests.c
index 0d4ec938..bb5dad54 100644
--- a/ltests.c
+++ b/ltests.c
@@ -80,7 +80,7 @@ static int tpanic (lua_State *L) {
80 80
81 81
82/* 82/*
83** Warning function for tests. Fist, it concatenates all parts of 83** Warning function for tests. First, it concatenates all parts of
84** a warning in buffer 'buff'. Then, it has three modes: 84** a warning in buffer 'buff'. Then, it has three modes:
85** - 0.normal: messages starting with '#' are shown on standard output; 85** - 0.normal: messages starting with '#' are shown on standard output;
86** - other messages abort the tests (they represent real warning 86** - other messages abort the tests (they represent real warning