aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2013-12-13 13:17:00 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2013-12-13 13:17:00 -0200
commitc8585efc7807b3cfeb1622a73f48a285ea4da5e5 (patch)
tree8d77d69d97c92d8ec3aff7264997a4f9abf13827
parent16493b777f1412beffc5b6640f27ea6c13bcb7d7 (diff)
downloadlua-c8585efc7807b3cfeb1622a73f48a285ea4da5e5.tar.gz
lua-c8585efc7807b3cfeb1622a73f48a285ea4da5e5.tar.bz2
lua-c8585efc7807b3cfeb1622a73f48a285ea4da5e5.zip
use goto to implement a tail call in 'reallymarkobject'
-rw-r--r--lgc.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/lgc.c b/lgc.c
index ee4c90cc..b7371308 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 2.165 2013/09/13 16:21:52 roberto Exp roberto $ 2** $Id: lgc.c,v 2.166 2013/09/17 15:40:06 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*/
@@ -227,6 +227,7 @@ GCObject *luaC_newobj (lua_State *L, int tt, size_t sz) {
227*/ 227*/
228static void reallymarkobject (global_State *g, GCObject *o) { 228static void reallymarkobject (global_State *g, GCObject *o) {
229 lu_mem size; 229 lu_mem size;
230 reentry:
230 white2gray(o); 231 white2gray(o);
231 switch (gch(o)->tt) { 232 switch (gch(o)->tt) {
232 case LUA_TSHRSTR: 233 case LUA_TSHRSTR:
@@ -237,9 +238,13 @@ static void reallymarkobject (global_State *g, GCObject *o) {
237 case LUA_TUSERDATA: { 238 case LUA_TUSERDATA: {
238 Table *mt = gco2u(o)->metatable; 239 Table *mt = gco2u(o)->metatable;
239 markobject(g, mt); 240 markobject(g, mt);
240 markobject(g, gco2u(o)->env); 241 gray2black(o);
241 size = sizeudata(gco2u(o)); 242 g->GCmemtrav += sizeudata(gco2u(o));
242 break; 243 /* markobject(g, gco2u(o)->env); */
244 o = obj2gco(gco2u(o)->env);
245 if (o && iswhite(o))
246 goto reentry;
247 return;
243 } 248 }
244 case LUA_TLCL: { 249 case LUA_TLCL: {
245 gco2lcl(o)->gclist = g->gray; 250 gco2lcl(o)->gclist = g->gray;