aboutsummaryrefslogtreecommitdiff
path: root/ldo.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-01-31 13:51:38 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-01-31 13:51:38 -0300
commitfa1382b5cd504bdfc5fc3f5c447ed09a4c9804fd (patch)
tree5c5f4f75e46a0ce1e82eca4395457627895c665c /ldo.c
parentd1e677c52be3b107a7a29fdc482158f6d9251e79 (diff)
downloadlua-fa1382b5cd504bdfc5fc3f5c447ed09a4c9804fd.tar.gz
lua-fa1382b5cd504bdfc5fc3f5c447ed09a4c9804fd.tar.bz2
lua-fa1382b5cd504bdfc5fc3f5c447ed09a4c9804fd.zip
Main thread is a regular field of global_State
They were already allocated as a single block, so there is no need for the global_State to point to its main thread.
Diffstat (limited to 'ldo.c')
-rw-r--r--ldo.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/ldo.c b/ldo.c
index 3f9c8b7d..65252e07 100644
--- a/ldo.c
+++ b/ldo.c
@@ -132,11 +132,12 @@ l_noret luaD_throw (lua_State *L, TStatus errcode) {
132 } 132 }
133 else { /* thread has no error handler */ 133 else { /* thread has no error handler */
134 global_State *g = G(L); 134 global_State *g = G(L);
135 lua_State *mainth = mainthread(g);
135 errcode = luaE_resetthread(L, errcode); /* close all upvalues */ 136 errcode = luaE_resetthread(L, errcode); /* close all upvalues */
136 L->status = errcode; 137 L->status = errcode;
137 if (g->mainthread->errorJmp) { /* main thread has a handler? */ 138 if (mainth->errorJmp) { /* main thread has a handler? */
138 setobjs2s(L, g->mainthread->top.p++, L->top.p - 1); /* copy error obj. */ 139 setobjs2s(L, mainth->top.p++, L->top.p - 1); /* copy error obj. */
139 luaD_throw(g->mainthread, errcode); /* re-throw in main thread */ 140 luaD_throw(mainth, errcode); /* re-throw in main thread */
140 } 141 }
141 else { /* no handler at all; abort */ 142 else { /* no handler at all; abort */
142 if (g->panic) { /* panic function? */ 143 if (g->panic) { /* panic function? */
@@ -961,7 +962,7 @@ LUA_API int lua_yieldk (lua_State *L, int nresults, lua_KContext ctx,
961 ci = L->ci; 962 ci = L->ci;
962 api_checkpop(L, nresults); 963 api_checkpop(L, nresults);
963 if (l_unlikely(!yieldable(L))) { 964 if (l_unlikely(!yieldable(L))) {
964 if (L != G(L)->mainthread) 965 if (L != mainthread(G(L)))
965 luaG_runerror(L, "attempt to yield across a C-call boundary"); 966 luaG_runerror(L, "attempt to yield across a C-call boundary");
966 else 967 else
967 luaG_runerror(L, "attempt to yield from outside a coroutine"); 968 luaG_runerror(L, "attempt to yield from outside a coroutine");