diff options
Diffstat (limited to 'src/lj_gc.c')
-rw-r--r-- | src/lj_gc.c | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/src/lj_gc.c b/src/lj_gc.c index 0d8a03ec..5c9d2bcb 100644 --- a/src/lj_gc.c +++ b/src/lj_gc.c | |||
@@ -73,13 +73,13 @@ static void gc_mark(global_State *g, GCobj *o) | |||
73 | } | 73 | } |
74 | } | 74 | } |
75 | 75 | ||
76 | /* Mark the base metatables. */ | 76 | /* Mark GC roots. */ |
77 | static void gc_mark_basemt(global_State *g) | 77 | static void gc_mark_gcroot(global_State *g) |
78 | { | 78 | { |
79 | int i; | 79 | ptrdiff_t i; |
80 | for (i = 0; i < BASEMT_MAX; i++) | 80 | for (i = 0; i < GCROOT__MAX; i++) |
81 | if (tabref(g->basemt[i]) != NULL) | 81 | if (gcref(g->gcroot[i]) != NULL) |
82 | gc_markobj(g, tabref(g->basemt[i])); | 82 | gc_markobj(g, gcref(g->gcroot[i])); |
83 | } | 83 | } |
84 | 84 | ||
85 | /* Start a GC cycle and mark the root set. */ | 85 | /* Start a GC cycle and mark the root set. */ |
@@ -91,7 +91,7 @@ static void gc_mark_start(global_State *g) | |||
91 | gc_markobj(g, mainthread(g)); | 91 | gc_markobj(g, mainthread(g)); |
92 | gc_markobj(g, tabref(mainthread(g)->env)); | 92 | gc_markobj(g, tabref(mainthread(g)->env)); |
93 | gc_marktv(g, &g->registrytv); | 93 | gc_marktv(g, &g->registrytv); |
94 | gc_mark_basemt(g); | 94 | gc_mark_gcroot(g); |
95 | g->gc.state = GCSpropagate; | 95 | g->gc.state = GCSpropagate; |
96 | } | 96 | } |
97 | 97 | ||
@@ -541,7 +541,7 @@ static void atomic(global_State *g, lua_State *L) | |||
541 | lua_assert(!iswhite(obj2gco(mainthread(g)))); | 541 | lua_assert(!iswhite(obj2gco(mainthread(g)))); |
542 | gc_markobj(g, L); /* Mark running thread. */ | 542 | gc_markobj(g, L); /* Mark running thread. */ |
543 | gc_mark_curtrace(g); /* Mark current trace. */ | 543 | gc_mark_curtrace(g); /* Mark current trace. */ |
544 | gc_mark_basemt(g); /* Mark base metatables (again). */ | 544 | gc_mark_gcroot(g); /* Mark GC roots (again). */ |
545 | gc_propagate_gray(g); /* Propagate all of the above. */ | 545 | gc_propagate_gray(g); /* Propagate all of the above. */ |
546 | 546 | ||
547 | setgcrefr(g->gc.gray, g->gc.grayagain); /* Empty the 2nd chance list. */ | 547 | setgcrefr(g->gc.gray, g->gc.grayagain); /* Empty the 2nd chance list. */ |
@@ -643,16 +643,15 @@ int lj_gc_step(lua_State *L) | |||
643 | } | 643 | } |
644 | 644 | ||
645 | /* Ditto, but fix the stack top first. */ | 645 | /* Ditto, but fix the stack top first. */ |
646 | void lj_gc_step_fixtop(lua_State *L) | 646 | void LJ_FASTCALL lj_gc_step_fixtop(lua_State *L) |
647 | { | 647 | { |
648 | if (curr_funcisL(L)) L->top = curr_topL(L); | 648 | if (curr_funcisL(L)) L->top = curr_topL(L); |
649 | lj_gc_step(L); | 649 | lj_gc_step(L); |
650 | } | 650 | } |
651 | 651 | ||
652 | /* Perform multiple GC steps. Called from JIT-compiled code. */ | 652 | /* Perform multiple GC steps. Called from JIT-compiled code. */ |
653 | void lj_gc_step_jit(lua_State *L, const BCIns *pc, MSize steps) | 653 | void LJ_FASTCALL lj_gc_step_jit(lua_State *L, MSize steps) |
654 | { | 654 | { |
655 | cframe_pc(cframe_raw(L->cframe)) = pc; | ||
656 | L->top = curr_topL(L); | 655 | L->top = curr_topL(L); |
657 | while (steps-- > 0 && lj_gc_step(L) == 0) | 656 | while (steps-- > 0 && lj_gc_step(L) == 0) |
658 | ; | 657 | ; |
@@ -711,17 +710,16 @@ void lj_gc_barrierf(global_State *g, GCobj *o, GCobj *v) | |||
711 | makewhite(g, o); /* Make it white to avoid the following barrier. */ | 710 | makewhite(g, o); /* Make it white to avoid the following barrier. */ |
712 | } | 711 | } |
713 | 712 | ||
714 | /* The reason for duplicating this is that it needs to be visible from ASM. */ | 713 | /* Specialized barrier for closed upvalue. Pass &uv->tv. */ |
715 | void lj_gc_barrieruv(global_State *g, GCobj *o, GCobj *v) | 714 | void LJ_FASTCALL lj_gc_barrieruv(global_State *g, TValue *tv) |
716 | { | 715 | { |
717 | lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o)); | 716 | #define TV2MARKED(x) \ |
718 | lua_assert(g->gc.state != GCSfinalize && g->gc.state != GCSpause); | 717 | (*((uint8_t *)(x) - offsetof(GCupval, tv) + offsetof(GCupval, marked))) |
719 | lua_assert(o->gch.gct == ~LJ_TUPVAL); | ||
720 | /* Preserve invariant during propagation. Otherwise it doesn't matter. */ | ||
721 | if (g->gc.state == GCSpropagate) | 718 | if (g->gc.state == GCSpropagate) |
722 | gc_mark(g, v); /* Move frontier forward. */ | 719 | gc_mark(g, gcV(tv)); |
723 | else | 720 | else |
724 | makewhite(g, o); /* Make it white to avoid the following barrier. */ | 721 | TV2MARKED(tv) = (TV2MARKED(tv) & cast_byte(~LJ_GC_COLORS)) | curwhite(g); |
722 | #undef TV2MARKED | ||
725 | } | 723 | } |
726 | 724 | ||
727 | /* Close upvalue. Also needs a write barrier. */ | 725 | /* Close upvalue. Also needs a write barrier. */ |