MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / luaC_checkfinalizer

Function luaC_checkfinalizer

third-party/lua-5.2.4/src/lgc.c:873–897  ·  view source on GitHub ↗

** if object 'o' has a finalizer, remove it from 'allgc' list (must ** search the list to find it) and link it in 'finobj' list. */

Source from the content-addressed store, hash-verified

871** search the list to find it) and link it in 'finobj' list.
872*/
873void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt) {
874 global_State *g = G(L);
875 if (testbit(gch(o)->marked, SEPARATED) || /* obj. is already separated... */
876 isfinalized(o) || /* ... or is finalized... */
877 gfasttm(g, mt, TM_GC) == NULL) /* or has no finalizer? */
878 return; /* nothing to be done */
879 else { /* move 'o' to 'finobj' list */
880 GCObject **p;
881 GCheader *ho = gch(o);
882 if (g->sweepgc == &ho->next) { /* avoid removing current sweep object */
883 lua_assert(issweepphase(g));
884 g->sweepgc = sweeptolive(L, g->sweepgc, NULL);
885 }
886 /* search for pointer pointing to 'o' */
887 for (p = &g->allgc; *p != o; p = &gch(*p)->next) { /* empty */ }
888 *p = ho->next; /* remove 'o' from root list */
889 ho->next = g->finobj; /* link it in list 'finobj' */
890 g->finobj = o;
891 l_setbit(ho->marked, SEPARATED); /* mark it as such */
892 if (!keepinvariantout(g)) /* not keeping invariant? */
893 makewhite(g, o); /* "sweep" object */
894 else
895 resetoldbit(o); /* see MOVE OLD rule */
896 }
897}
898
899/* }====================================================== */
900

Callers 1

lua_setmetatableFunction · 0.70

Calls 1

sweeptoliveFunction · 0.70

Tested by

no test coverage detected