aboutsummaryrefslogtreecommitdiff
path: root/lgc.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-02-14 14:43:14 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-02-14 14:43:14 -0200
commit1cce3e6842fd76099b1973dabd8504566610f068 (patch)
tree1f28b6c3952db089a664877a8cb693e66ec9c243 /lgc.c
parent0b04c561f5c08600831f3bb6126b062658d434b1 (diff)
downloadlua-1cce3e6842fd76099b1973dabd8504566610f068.tar.gz
lua-1cce3e6842fd76099b1973dabd8504566610f068.tar.bz2
lua-1cce3e6842fd76099b1973dabd8504566610f068.zip
change in the way 'collectgarbage("step", size)' interprets 'size'
(mimicking the way the GC itself behaves when Lua allocates 'size' Kbytes)
Diffstat (limited to 'lgc.c')
-rw-r--r--lgc.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/lgc.c b/lgc.c
index ea0537df..5c365e32 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 2.172 2014/02/13 14:46:38 roberto Exp roberto $ 2** $Id: lgc.c,v 2.173 2014/02/13 17:25:20 roberto Exp roberto $
3** Garbage Collector 3** Garbage Collector
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -1087,11 +1087,15 @@ static l_mem getdebt (global_State *g) {
1087} 1087}
1088 1088
1089/* 1089/*
1090** performs a basic GC step 1090** performs a basic GC step when collector is running
1091*/ 1091*/
1092void luaC_forcestep (lua_State *L) { 1092void luaC_step (lua_State *L) {
1093 global_State *g = G(L); 1093 global_State *g = G(L);
1094 l_mem debt = getdebt(g); 1094 l_mem debt = getdebt(g);
1095 if (!g->gcrunning) { /* not running? */
1096 luaE_setdebt(g, -GCSTEPSIZE * 10); /* avoid being called too often */
1097 return;
1098 }
1095 do { 1099 do {
1096 if (g->gcstate == GCScallfin && g->tobefnz) { 1100 if (g->gcstate == GCScallfin && g->tobefnz) {
1097 unsigned int n = runafewfinalizers(L); 1101 unsigned int n = runafewfinalizers(L);
@@ -1113,18 +1117,6 @@ void luaC_forcestep (lua_State *L) {
1113 1117
1114 1118
1115/* 1119/*
1116** performs a basic GC step when collector is running
1117*/
1118void luaC_step (lua_State *L) {
1119 if (!G(L)->gcrunning)
1120 luaE_setdebt(G(L), -GCSTEPSIZE); /* avoid being called too often */
1121 else
1122 luaC_forcestep(L);
1123}
1124
1125
1126
1127/*
1128** performs a full GC cycle; if "isemergency", does not call 1120** performs a full GC cycle; if "isemergency", does not call
1129** finalizers (which could change stack positions) 1121** finalizers (which could change stack positions)
1130*/ 1122*/