예제 #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
/*
** 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);
}