aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-09-03 11:14:01 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-09-03 11:14:01 -0300
commit6828f6d42786de735d6696da8cccbb47c8bad347 (patch)
tree4645194f43ebcfbd7a00af35278b1e688148760c
parentdaa5fe3e31d8ca28a8770df135cbad7fa6fdfa4b (diff)
downloadlua-6828f6d42786de735d6696da8cccbb47c8bad347.tar.gz
lua-6828f6d42786de735d6696da8cccbb47c8bad347.tar.bz2
lua-6828f6d42786de735d6696da8cccbb47c8bad347.zip
new parameter 'majorinc' to control frequency of major collections
in generational mode
-rw-r--r--lapi.c7
-rw-r--r--lbaselib.c8
-rw-r--r--lgc.c4
-rw-r--r--lstate.c7
-rw-r--r--lstate.h3
-rw-r--r--lua.h9
6 files changed, 25 insertions, 13 deletions
diff --git a/lapi.c b/lapi.c
index f4a53621..b19ac922 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 2.133 2010/07/25 15:18:19 roberto Exp roberto $ 2** $Id: lapi.c,v 2.134 2010/08/04 18:40:28 roberto Exp roberto $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -976,6 +976,11 @@ LUA_API int lua_gc (lua_State *L, int what, int data) {
976 g->gcpause = data; 976 g->gcpause = data;
977 break; 977 break;
978 } 978 }
979 case LUA_GCSETMAJORINC: {
980 res = g->gcmajorinc;
981 g->gcmajorinc = data;
982 break;
983 }
979 case LUA_GCSETSTEPMUL: { 984 case LUA_GCSETSTEPMUL: {
980 res = g->gcstepmul; 985 res = g->gcstepmul;
981 g->gcstepmul = data; 986 g->gcstepmul = data;
diff --git a/lbaselib.c b/lbaselib.c
index b834d54f..b8dc6b50 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbaselib.c,v 1.246 2010/07/02 11:38:13 roberto Exp roberto $ 2** $Id: lbaselib.c,v 1.247 2010/08/23 18:03:11 roberto Exp roberto $
3** Basic library 3** Basic library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -142,11 +142,11 @@ static int luaB_rawset (lua_State *L) {
142 142
143static int luaB_collectgarbage (lua_State *L) { 143static int luaB_collectgarbage (lua_State *L) {
144 static const char *const opts[] = {"stop", "restart", "collect", 144 static const char *const opts[] = {"stop", "restart", "collect",
145 "count", "step", "setpause", "setstepmul", "isrunning", 145 "count", "step", "setpause", "setstepmul",
146 "gen", "inc", NULL}; 146 "setmajorinc", "isrunning", "gen", "inc", NULL};
147 static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT, 147 static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT,
148 LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL, 148 LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL,
149 LUA_GCISRUNNING, LUA_GCGEN, LUA_GCINC}; 149 LUA_GCSETMAJORINC, LUA_GCISRUNNING, LUA_GCGEN, LUA_GCINC};
150 int o = optsnum[luaL_checkoption(L, 1, "collect", opts)]; 150 int o = optsnum[luaL_checkoption(L, 1, "collect", opts)];
151 int ex = luaL_optint(L, 2, 0); 151 int ex = luaL_optint(L, 2, 0);
152 int res = lua_gc(L, o, ex); 152 int res = lua_gc(L, o, ex);
diff --git a/lgc.c b/lgc.c
index 930542e1..beccc1a6 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 2.100 2010/06/25 12:18:10 roberto Exp roberto $ 2** $Id: lgc.c,v 2.101 2010/06/30 14:11:17 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*/
@@ -960,7 +960,7 @@ static void generationalcollection (lua_State *L) {
960 else { 960 else {
961 luaC_runtilstate(L, ~bitmask(GCSpause)); /* run complete cycle */ 961 luaC_runtilstate(L, ~bitmask(GCSpause)); /* run complete cycle */
962 luaC_runtilstate(L, bitmask(GCSpause)); 962 luaC_runtilstate(L, bitmask(GCSpause));
963 if (g->totalbytes > g->lastmajormem/100 * g->gcpause) 963 if (g->totalbytes > g->lastmajormem/100 * g->gcmajorinc)
964 g->lastmajormem = 0; /* signal for a major collection */ 964 g->lastmajormem = 0; /* signal for a major collection */
965 } 965 }
966 g->GCdebt = stddebt(g); 966 g->GCdebt = stddebt(g);
diff --git a/lstate.c b/lstate.c
index e48e9999..ef4f89cd 100644
--- a/lstate.c
+++ b/lstate.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstate.c,v 2.84 2010/04/30 14:22:23 roberto Exp roberto $ 2** $Id: lstate.c,v 2.85 2010/04/30 18:36:22 roberto Exp roberto $
3** Global State 3** Global State
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -29,6 +29,10 @@
29#define LUAI_GCPAUSE 200 /* 200% */ 29#define LUAI_GCPAUSE 200 /* 200% */
30#endif 30#endif
31 31
32#if !defined(LUAI_GCMAJOR)
33#define LUAI_GCMAJOR 200 /* 200% */
34#endif
35
32#if !defined(LUAI_GCMUL) 36#if !defined(LUAI_GCMUL)
33#define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */ 37#define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */
34#endif 38#endif
@@ -254,6 +258,7 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
254 g->weak = g->ephemeron = g->allweak = NULL; 258 g->weak = g->ephemeron = g->allweak = NULL;
255 g->totalbytes = sizeof(LG); 259 g->totalbytes = sizeof(LG);
256 g->gcpause = LUAI_GCPAUSE; 260 g->gcpause = LUAI_GCPAUSE;
261 g->gcmajorinc = LUAI_GCMAJOR;
257 g->gcstepmul = LUAI_GCMUL; 262 g->gcstepmul = LUAI_GCMUL;
258 for (i=0; i < LUA_NUMTAGS; i++) g->mt[i] = NULL; 263 for (i=0; i < LUA_NUMTAGS; i++) g->mt[i] = NULL;
259 if (luaD_rawrunprotected(L, f_luaopen, NULL) != LUA_OK) { 264 if (luaD_rawrunprotected(L, f_luaopen, NULL) != LUA_OK) {
diff --git a/lstate.h b/lstate.h
index 452046fb..0d834801 100644
--- a/lstate.h
+++ b/lstate.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstate.h,v 2.64 2010/04/29 17:31:31 roberto Exp roberto $ 2** $Id: lstate.h,v 2.65 2010/05/03 17:39:48 roberto Exp roberto $
3** Global State 3** Global State
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -136,6 +136,7 @@ typedef struct global_State {
136 UpVal uvhead; /* head of double-linked list of all open upvalues */ 136 UpVal uvhead; /* head of double-linked list of all open upvalues */
137 Mbuffer buff; /* temporary buffer for string concatenation */ 137 Mbuffer buff; /* temporary buffer for string concatenation */
138 int gcpause; /* size of pause between successive GCs */ 138 int gcpause; /* size of pause between successive GCs */
139 int gcmajorinc; /* how much to wait for a major GC (only in gen. mode) */
139 int gcstepmul; /* GC `granularity' */ 140 int gcstepmul; /* GC `granularity' */
140 lua_CFunction panic; /* to be called in unprotected errors */ 141 lua_CFunction panic; /* to be called in unprotected errors */
141 struct lua_State *mainthread; 142 struct lua_State *mainthread;
diff --git a/lua.h b/lua.h
index d17d8dc3..42c34ea5 100644
--- a/lua.h
+++ b/lua.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lua.h,v 1.272 2010/07/25 15:02:41 roberto Exp roberto $ 2** $Id: lua.h,v 1.273 2010/07/25 15:18:19 roberto Exp roberto $
3** Lua - A Scripting Language 3** Lua - A Scripting Language
4** Lua.org, PUC-Rio, Brazil (http://www.lua.org) 4** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
5** See Copyright Notice at the end of this file 5** See Copyright Notice at the end of this file
@@ -271,9 +271,10 @@ LUA_API int (lua_status) (lua_State *L);
271#define LUA_GCSTEP 5 271#define LUA_GCSTEP 5
272#define LUA_GCSETPAUSE 6 272#define LUA_GCSETPAUSE 6
273#define LUA_GCSETSTEPMUL 7 273#define LUA_GCSETSTEPMUL 7
274#define LUA_GCISRUNNING 8 274#define LUA_GCSETMAJORINC 8
275#define LUA_GCGEN 9 275#define LUA_GCISRUNNING 9
276#define LUA_GCINC 10 276#define LUA_GCGEN 10
277#define LUA_GCINC 11
277 278
278LUA_API int (lua_gc) (lua_State *L, int what, int data); 279LUA_API int (lua_gc) (lua_State *L, int what, int data);
279 280