aboutsummaryrefslogtreecommitdiff
path: root/lfunc.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-10-23 14:26:37 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-10-23 14:26:37 -0200
commit907368ead5978b689a97118b75e89a2095122530 (patch)
treeed428793e87ab4a3c8de49be5586878af54c8d34 /lfunc.c
parent81489beea1a201b58dba964b6bbfd263f3683f25 (diff)
downloadlua-907368ead5978b689a97118b75e89a2095122530.tar.gz
lua-907368ead5978b689a97118b75e89a2095122530.tar.bz2
lua-907368ead5978b689a97118b75e89a2095122530.zip
GC now considers an "estimate" of object size, instead of just the number
of objects.
Diffstat (limited to 'lfunc.c')
-rw-r--r--lfunc.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/lfunc.c b/lfunc.c
index 4e802cee..a29894e2 100644
--- a/lfunc.c
+++ b/lfunc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lfunc.c,v 1.2 1997/09/26 16:46:20 roberto Exp roberto $ 2** $Id: lfunc.c,v 1.3 1997/10/16 10:59:34 roberto Exp roberto $
3** Lua Funcion auxiliar 3** Lua Funcion auxiliar
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -10,6 +10,8 @@
10#include "lfunc.h" 10#include "lfunc.h"
11#include "lmem.h" 11#include "lmem.h"
12 12
13#define gcsizeproto(p) 5
14#define gcsizeclosure(c) 1
13 15
14GCnode luaF_root = {NULL, 0}; 16GCnode luaF_root = {NULL, 0};
15GCnode luaF_rootcl = {NULL, 0}; 17GCnode luaF_rootcl = {NULL, 0};
@@ -20,6 +22,7 @@ Closure *luaF_newclosure (int nelems)
20{ 22{
21 Closure *c = (Closure *)luaM_malloc(sizeof(Closure)+nelems*sizeof(TObject)); 23 Closure *c = (Closure *)luaM_malloc(sizeof(Closure)+nelems*sizeof(TObject));
22 luaO_insertlist(&luaF_rootcl, (GCnode *)c); 24 luaO_insertlist(&luaF_rootcl, (GCnode *)c);
25 luaO_nblocks += gcsizeclosure(c);
23 return c; 26 return c;
24} 27}
25 28
@@ -34,6 +37,7 @@ TProtoFunc *luaF_newproto (void)
34 f->nconsts = 0; 37 f->nconsts = 0;
35 f->locvars = NULL; 38 f->locvars = NULL;
36 luaO_insertlist(&luaF_root, (GCnode *)f); 39 luaO_insertlist(&luaF_root, (GCnode *)f);
40 luaO_nblocks += gcsizeproto(f);
37 return f; 41 return f;
38} 42}
39 43
@@ -52,6 +56,7 @@ void luaF_freeproto (TProtoFunc *l)
52{ 56{
53 while (l) { 57 while (l) {
54 TProtoFunc *next = (TProtoFunc *)l->head.next; 58 TProtoFunc *next = (TProtoFunc *)l->head.next;
59 luaO_nblocks -= gcsizeproto(l);
55 freefunc(l); 60 freefunc(l);
56 l = next; 61 l = next;
57 } 62 }
@@ -62,6 +67,7 @@ void luaF_freeclosure (Closure *l)
62{ 67{
63 while (l) { 68 while (l) {
64 Closure *next = (Closure *)l->head.next; 69 Closure *next = (Closure *)l->head.next;
70 luaO_nblocks -= gcsizeclosure(l);
65 luaM_free(l); 71 luaM_free(l);
66 l = next; 72 l = next;
67 } 73 }