diff options
author | Li Jin <dragon-fly@qq.com> | 2022-12-02 10:40:09 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2022-12-02 10:40:09 +0800 |
commit | 298b18dbe852300199cc529c942a181bead5f135 (patch) | |
tree | f4b5ae89b6920fa0a12c693118f85334f19754f8 /src/3rdParty/lua/lgc.c | |
parent | a6a65ba26a9d320611abcbfba49fa724edfb4dad (diff) | |
download | yuescript-298b18dbe852300199cc529c942a181bead5f135.tar.gz yuescript-298b18dbe852300199cc529c942a181bead5f135.tar.bz2 yuescript-298b18dbe852300199cc529c942a181bead5f135.zip |
update Lua.
Diffstat (limited to 'src/3rdParty/lua/lgc.c')
-rw-r--r-- | src/3rdParty/lua/lgc.c | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/src/3rdParty/lua/lgc.c b/src/3rdParty/lua/lgc.c index 317ea45..2e74990 100644 --- a/src/3rdParty/lua/lgc.c +++ b/src/3rdParty/lua/lgc.c | |||
@@ -252,12 +252,13 @@ void luaC_fix (lua_State *L, GCObject *o) { | |||
252 | 252 | ||
253 | 253 | ||
254 | /* | 254 | /* |
255 | ** create a new collectable object (with given type and size) and link | 255 | ** create a new collectable object (with given type, size, and offset) |
256 | ** it to 'allgc' list. | 256 | ** and link it to 'allgc' list. |
257 | */ | 257 | */ |
258 | GCObject *luaC_newobj (lua_State *L, int tt, size_t sz) { | 258 | GCObject *luaC_newobjdt (lua_State *L, int tt, size_t sz, size_t offset) { |
259 | global_State *g = G(L); | 259 | global_State *g = G(L); |
260 | GCObject *o = cast(GCObject *, luaM_newobject(L, novariant(tt), sz)); | 260 | char *p = cast_charp(luaM_newobject(L, novariant(tt), sz)); |
261 | GCObject *o = cast(GCObject *, p + offset); | ||
261 | o->marked = luaC_white(g); | 262 | o->marked = luaC_white(g); |
262 | o->tt = tt; | 263 | o->tt = tt; |
263 | o->next = g->allgc; | 264 | o->next = g->allgc; |
@@ -265,6 +266,11 @@ GCObject *luaC_newobj (lua_State *L, int tt, size_t sz) { | |||
265 | return o; | 266 | return o; |
266 | } | 267 | } |
267 | 268 | ||
269 | |||
270 | GCObject *luaC_newobj (lua_State *L, int tt, size_t sz) { | ||
271 | return luaC_newobjdt(L, tt, sz, 0); | ||
272 | } | ||
273 | |||
268 | /* }====================================================== */ | 274 | /* }====================================================== */ |
269 | 275 | ||
270 | 276 | ||
@@ -301,7 +307,7 @@ static void reallymarkobject (global_State *g, GCObject *o) { | |||
301 | set2gray(uv); /* open upvalues are kept gray */ | 307 | set2gray(uv); /* open upvalues are kept gray */ |
302 | else | 308 | else |
303 | set2black(uv); /* closed upvalues are visited here */ | 309 | set2black(uv); /* closed upvalues are visited here */ |
304 | markvalue(g, uv->v); /* mark its content */ | 310 | markvalue(g, uv->v.p); /* mark its content */ |
305 | break; | 311 | break; |
306 | } | 312 | } |
307 | case LUA_VUSERDATA: { | 313 | case LUA_VUSERDATA: { |
@@ -376,7 +382,7 @@ static int remarkupvals (global_State *g) { | |||
376 | work++; | 382 | work++; |
377 | if (!iswhite(uv)) { /* upvalue already visited? */ | 383 | if (!iswhite(uv)) { /* upvalue already visited? */ |
378 | lua_assert(upisopen(uv) && isgray(uv)); | 384 | lua_assert(upisopen(uv) && isgray(uv)); |
379 | markvalue(g, uv->v); /* mark its value */ | 385 | markvalue(g, uv->v.p); /* mark its value */ |
380 | } | 386 | } |
381 | } | 387 | } |
382 | } | 388 | } |
@@ -620,19 +626,19 @@ static int traverseLclosure (global_State *g, LClosure *cl) { | |||
620 | */ | 626 | */ |
621 | static int traversethread (global_State *g, lua_State *th) { | 627 | static int traversethread (global_State *g, lua_State *th) { |
622 | UpVal *uv; | 628 | UpVal *uv; |
623 | StkId o = th->stack; | 629 | StkId o = th->stack.p; |
624 | if (isold(th) || g->gcstate == GCSpropagate) | 630 | if (isold(th) || g->gcstate == GCSpropagate) |
625 | linkgclist(th, g->grayagain); /* insert into 'grayagain' list */ | 631 | linkgclist(th, g->grayagain); /* insert into 'grayagain' list */ |
626 | if (o == NULL) | 632 | if (o == NULL) |
627 | return 1; /* stack not completely built yet */ | 633 | return 1; /* stack not completely built yet */ |
628 | lua_assert(g->gcstate == GCSatomic || | 634 | lua_assert(g->gcstate == GCSatomic || |
629 | th->openupval == NULL || isintwups(th)); | 635 | th->openupval == NULL || isintwups(th)); |
630 | for (; o < th->top; o++) /* mark live elements in the stack */ | 636 | for (; o < th->top.p; o++) /* mark live elements in the stack */ |
631 | markvalue(g, s2v(o)); | 637 | markvalue(g, s2v(o)); |
632 | for (uv = th->openupval; uv != NULL; uv = uv->u.open.next) | 638 | for (uv = th->openupval; uv != NULL; uv = uv->u.open.next) |
633 | markobject(g, uv); /* open upvalues cannot be collected */ | 639 | markobject(g, uv); /* open upvalues cannot be collected */ |
634 | if (g->gcstate == GCSatomic) { /* final traversal? */ | 640 | if (g->gcstate == GCSatomic) { /* final traversal? */ |
635 | for (; o < th->stack_last + EXTRA_STACK; o++) | 641 | for (; o < th->stack_last.p + EXTRA_STACK; o++) |
636 | setnilvalue(s2v(o)); /* clear dead stack slice */ | 642 | setnilvalue(s2v(o)); /* clear dead stack slice */ |
637 | /* 'remarkupvals' may have removed thread from 'twups' list */ | 643 | /* 'remarkupvals' may have removed thread from 'twups' list */ |
638 | if (!isintwups(th) && th->openupval != NULL) { | 644 | if (!isintwups(th) && th->openupval != NULL) { |
@@ -892,7 +898,7 @@ static GCObject *udata2finalize (global_State *g) { | |||
892 | 898 | ||
893 | static void dothecall (lua_State *L, void *ud) { | 899 | static void dothecall (lua_State *L, void *ud) { |
894 | UNUSED(ud); | 900 | UNUSED(ud); |
895 | luaD_callnoyield(L, L->top - 2, 0); | 901 | luaD_callnoyield(L, L->top.p - 2, 0); |
896 | } | 902 | } |
897 | 903 | ||
898 | 904 | ||
@@ -909,16 +915,16 @@ static void GCTM (lua_State *L) { | |||
909 | int oldgcstp = g->gcstp; | 915 | int oldgcstp = g->gcstp; |
910 | g->gcstp |= GCSTPGC; /* avoid GC steps */ | 916 | g->gcstp |= GCSTPGC; /* avoid GC steps */ |
911 | L->allowhook = 0; /* stop debug hooks during GC metamethod */ | 917 | L->allowhook = 0; /* stop debug hooks during GC metamethod */ |
912 | setobj2s(L, L->top++, tm); /* push finalizer... */ | 918 | setobj2s(L, L->top.p++, tm); /* push finalizer... */ |
913 | setobj2s(L, L->top++, &v); /* ... and its argument */ | 919 | setobj2s(L, L->top.p++, &v); /* ... and its argument */ |
914 | L->ci->callstatus |= CIST_FIN; /* will run a finalizer */ | 920 | L->ci->callstatus |= CIST_FIN; /* will run a finalizer */ |
915 | status = luaD_pcall(L, dothecall, NULL, savestack(L, L->top - 2), 0); | 921 | status = luaD_pcall(L, dothecall, NULL, savestack(L, L->top.p - 2), 0); |
916 | L->ci->callstatus &= ~CIST_FIN; /* not running a finalizer anymore */ | 922 | L->ci->callstatus &= ~CIST_FIN; /* not running a finalizer anymore */ |
917 | L->allowhook = oldah; /* restore hooks */ | 923 | L->allowhook = oldah; /* restore hooks */ |
918 | g->gcstp = oldgcstp; /* restore state */ | 924 | g->gcstp = oldgcstp; /* restore state */ |
919 | if (l_unlikely(status != LUA_OK)) { /* error while running __gc? */ | 925 | if (l_unlikely(status != LUA_OK)) { /* error while running __gc? */ |
920 | luaE_warnerror(L, "__gc"); | 926 | luaE_warnerror(L, "__gc"); |
921 | L->top--; /* pops error object */ | 927 | L->top.p--; /* pops error object */ |
922 | } | 928 | } |
923 | } | 929 | } |
924 | } | 930 | } |