/* Sweep a list of objects to enter generational mode. Deletes dead objects and turns the non dead to old. All non-dead threads */
static void sweep2old(lua_State *L, GCObject **p)
/* Sweep a list of objects to enter generational mode. Deletes dead objects and turns the non dead to old. All non-dead threads */
static void sweep2old(lua_State *L, GCObject **p)
{
    if (iswhite(curr)) {
      lua_assert(isdead(g, curr));
      *p = curr->next;
      freeobj(L, curr);
    }
    else {
      setage(curr, G_OLD);
      if (curr->tt == LUA_VTHREAD) {
        lua_State *th = gco2th(curr);
        linkgclist(th, g->grayagain);
      }
      else if (curr->tt == LUA_VUPVAL && upisopen(gco2upv(curr)))
        set2gray(curr);
      else
        nw2black(curr);
      p = &curr->next;
    }
  }
}