diff options
Diffstat (limited to 'src/lj_gc.c')
-rw-r--r-- | src/lj_gc.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/lj_gc.c b/src/lj_gc.c index aba19d3f..7999e31f 100644 --- a/src/lj_gc.c +++ b/src/lj_gc.c | |||
@@ -494,12 +494,13 @@ static void gc_finalize(lua_State *L) | |||
494 | setgcrefnull(g->gc.mmudata); | 494 | setgcrefnull(g->gc.mmudata); |
495 | else | 495 | else |
496 | setgcrefr(gcref(g->gc.mmudata)->gch.nextgc, o->gch.nextgc); | 496 | setgcrefr(gcref(g->gc.mmudata)->gch.nextgc, o->gch.nextgc); |
497 | makewhite(g, o); | ||
498 | #if LJ_HASFFI | 497 | #if LJ_HASFFI |
499 | if (o->gch.gct == ~LJ_TCDATA) { | 498 | if (o->gch.gct == ~LJ_TCDATA) { |
500 | TValue tmp, *tv; | 499 | TValue tmp, *tv; |
501 | setgcrefr(o->gch.nextgc, g->gc.root); /* Add cdata back to the gc list. */ | 500 | /* Add cdata back to the GC list and make it white. */ |
501 | setgcrefr(o->gch.nextgc, g->gc.root); | ||
502 | setgcref(g->gc.root, o); | 502 | setgcref(g->gc.root, o); |
503 | o->gch.marked = curwhite(g); | ||
503 | /* Resolve finalizer. */ | 504 | /* Resolve finalizer. */ |
504 | setcdataV(L, &tmp, gco2cd(o)); | 505 | setcdataV(L, &tmp, gco2cd(o)); |
505 | tv = lj_tab_set(L, ctype_ctsG(g)->finalizer, &tmp); | 506 | tv = lj_tab_set(L, ctype_ctsG(g)->finalizer, &tmp); |
@@ -511,9 +512,10 @@ static void gc_finalize(lua_State *L) | |||
511 | return; | 512 | return; |
512 | } | 513 | } |
513 | #endif | 514 | #endif |
514 | /* Add userdata back to the main userdata list. */ | 515 | /* Add userdata back to the main userdata list and make it white. */ |
515 | setgcrefr(o->gch.nextgc, mainthread(g)->nextgc); | 516 | setgcrefr(o->gch.nextgc, mainthread(g)->nextgc); |
516 | setgcref(mainthread(g)->nextgc, o); | 517 | setgcref(mainthread(g)->nextgc, o); |
518 | makewhite(g, o); | ||
517 | /* Resolve the __gc metamethod. */ | 519 | /* Resolve the __gc metamethod. */ |
518 | mo = lj_meta_fastg(g, tabref(gco2ud(o)->metatable), MM_gc); | 520 | mo = lj_meta_fastg(g, tabref(gco2ud(o)->metatable), MM_gc); |
519 | if (mo) | 521 | if (mo) |
@@ -542,7 +544,7 @@ void lj_gc_finalize_cdata(lua_State *L) | |||
542 | if (!tvisnil(&node[i].val) && tviscdata(&node[i].key)) { | 544 | if (!tvisnil(&node[i].val) && tviscdata(&node[i].key)) { |
543 | GCobj *o = gcV(&node[i].key); | 545 | GCobj *o = gcV(&node[i].key); |
544 | TValue tmp; | 546 | TValue tmp; |
545 | o->gch.marked &= ~LJ_GC_CDATA_FIN; | 547 | o->gch.marked = curwhite(g); |
546 | copyTV(L, &tmp, &node[i].val); | 548 | copyTV(L, &tmp, &node[i].val); |
547 | setnilV(&node[i].val); | 549 | setnilV(&node[i].val); |
548 | gc_call_finalizer(g, L, &tmp, o); | 550 | gc_call_finalizer(g, L, &tmp, o); |