コード例 #1
0
ファイル: lgc.c プロジェクト: crazii/mameplus
/*
** performs a full GC cycle; if "isemergency", does not call
** finalizers (which could change stack positions)
*/
void luaC_fullgc (lua_State *L, int isemergency) {
	global_State *g = G(L);
	int origkind = g->gckind;
	lua_assert(origkind != KGC_EMERGENCY);
	if (isemergency)  /* do not run finalizers during emergency GC */
	g->gckind = KGC_EMERGENCY;
	else {
	g->gckind = KGC_NORMAL;
	callallpendingfinalizers(L, 1);
	}
	if (keepinvariant(g)) {  /* may there be some black objects? */
	/* must sweep all objects to turn them back to white
	   (as white has not changed, nothing will be collected) */
	entersweep(L);
	}
	/* finish any pending sweep phase to start a new cycle */
	luaC_runtilstate(L, bitmask(GCSpause));
	luaC_runtilstate(L, ~bitmask(GCSpause));  /* start new collection */
	luaC_runtilstate(L, bitmask(GCSpause));  /* run entire collection */
	if (origkind == KGC_GEN) {  /* generational mode? */
	/* generational mode must be kept in propagate phase */
	luaC_runtilstate(L, bitmask(GCSpropagate));
	}
	g->gckind = origkind;
	setpause(g, gettotalbytes(g));
	if (!isemergency)   /* do not run finalizers during emergency GC */
	callallpendingfinalizers(L, 1);
}
コード例 #2
0
ファイル: lgc.c プロジェクト: alucard-dracula/yggdrasil
/*
** performs a full GC cycle; if "isemergency", does not call
** finalizers (which could change stack positions)
*/
void luaC_fullgc (lua_State *L, int isemergency) {
  global_State *g = G(L);
  int origkind = g->gckind;
  lua_assert(origkind != KGC_EMERGENCY);
  if (!isemergency)   /* do not run finalizers during emergency GC */
    callallpendingfinalizers(L, 1);
  if (keepinvariant(g)) {  /* marking phase? */
    /* must sweep all objects to turn them back to white
       (as white has not changed, nothing will be collected) */
    g->sweepstrgc = 0;
    g->gcstate = GCSsweepstring;
  }
  g->gckind = isemergency ? KGC_EMERGENCY : KGC_NORMAL;
  /* finish any pending sweep phase to start a new cycle */
  luaC_runtilstate(L, bitmask(GCSpause));
  /* run entire collector */
  luaC_runtilstate(L, ~bitmask(GCSpause));
  luaC_runtilstate(L, bitmask(GCSpause));
  if (origkind == KGC_GEN) {  /* generational mode? */
    /* generational mode must always start in propagate phase */
    luaC_runtilstate(L, bitmask(GCSpropagate));
  }
  g->gckind = origkind;
  luaE_setdebt(g, stddebt(g));
  if (!isemergency)   /* do not run finalizers during emergency GC */
    callallpendingfinalizers(L, 1);
}
コード例 #3
0
ファイル: lgc.c プロジェクト: charleeli/srpc
void luaC_freeallobjects (lua_State *L) {
  global_State *g = G(L);
  separatetobefnz(g, 1);  /* separate all objects with finalizers */
  lua_assert(g->finobj == NULL);
  callallpendingfinalizers(L, 0);
  lua_assert(g->tobefnz == NULL);
  g->currentwhite = WHITEBITS; /* this "white" makes all objects look dead */
  g->gckind = KGC_NORMAL;
  sweepwholelist(L, &g->finobj);
  sweepwholelist(L, &g->allgc);
  sweepwholelist(L, &g->fixedgc);  /* collect fixed objects */
  lua_assert(g->strt.nuse == 0);
}
コード例 #4
0
ファイル: lgc.c プロジェクト: crazii/mameplus
void luaC_freeallobjects (lua_State *L) {
	global_State *g = G(L);
	int i;
	separatetobefnz(L, 1);  /* separate all objects with finalizers */
	lua_assert(g->finobj == NULL);
	callallpendingfinalizers(L, 0);
	g->currentwhite = WHITEBITS; /* this "white" makes all objects look dead */
	g->gckind = KGC_NORMAL;
	sweepwholelist(L, &g->finobj);  /* finalizers can create objs. in 'finobj' */
	sweepwholelist(L, &g->allgc);
	for (i = 0; i < g->strt.size; i++)  /* free all string lists */
	sweepwholelist(L, &g->strt.hash[i]);
	lua_assert(g->strt.nuse == 0);
}