diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-11-06 19:41:53 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-11-06 19:41:53 -0200 |
commit | 26bf2adaceb18877d836174226d2bfdc3f1fc512 (patch) | |
tree | b23ccd2e297e7c5e732ce65e88f35145271f7faa /lfunc.c | |
parent | fd48dcc7c8734091181d8d0e54b0ba3d1770f4c3 (diff) | |
download | lua-26bf2adaceb18877d836174226d2bfdc3f1fc512.tar.gz lua-26bf2adaceb18877d836174226d2bfdc3f1fc512.tar.bz2 lua-26bf2adaceb18877d836174226d2bfdc3f1fc512.zip |
optimizations for space in LClosures and time cleanning weak tables
Diffstat (limited to 'lfunc.c')
-rw-r--r-- | lfunc.c | 22 |
1 files changed, 10 insertions, 12 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lfunc.c,v 1.47 2001/09/07 17:39:10 roberto Exp $ | 2 | ** $Id: lfunc.c,v 1.48 2001/10/02 16:45:03 roberto Exp $ |
3 | ** Auxiliary functions to manipulate prototypes and closures | 3 | ** Auxiliary functions to manipulate prototypes and closures |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -20,7 +20,7 @@ | |||
20 | cast(int, sizeof(TObject)*((n)-1))) | 20 | cast(int, sizeof(TObject)*((n)-1))) |
21 | 21 | ||
22 | #define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ | 22 | #define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ |
23 | cast(int, sizeof(LClosureEntry)*((n)-1))) | 23 | cast(int, sizeof(TObject *)*((n)-1))) |
24 | 24 | ||
25 | 25 | ||
26 | Closure *luaF_newCclosure (lua_State *L, int nelems) { | 26 | Closure *luaF_newCclosure (lua_State *L, int nelems) { |
@@ -50,8 +50,8 @@ static StkId uppoint (LClosure *cl) { | |||
50 | StkId lp = NULL; | 50 | StkId lp = NULL; |
51 | int i; | 51 | int i; |
52 | for (i=0; i<cl->nupvalues; i++) { | 52 | for (i=0; i<cl->nupvalues; i++) { |
53 | if (cl->upvals[i].heap == NULL && (lp == NULL || cl->upvals[i].val > lp)) | 53 | if (!isclosed(cl->upvals[i]) && (lp == NULL || cl->upvals[i] > lp)) |
54 | lp = cl->upvals[i].val; | 54 | lp = cl->upvals[i]; |
55 | } | 55 | } |
56 | return lp; | 56 | return lp; |
57 | } | 57 | } |
@@ -77,17 +77,15 @@ static int closeCl (lua_State *L, LClosure *cl, StkId level) { | |||
77 | int i; | 77 | int i; |
78 | for (i=0; i<cl->nupvalues; i++) { | 78 | for (i=0; i<cl->nupvalues; i++) { |
79 | StkId var; | 79 | StkId var; |
80 | if (cl->upvals[i].heap == NULL && (var=cl->upvals[i].val) >= level) { | 80 | if (!isclosed(cl->upvals[i]) && (var=cl->upvals[i]) >= level) { |
81 | if (ttype(var) != LUA_TUPVAL) { | 81 | if (ttype(var) != LUA_TUPVAL) { |
82 | UpVal *v = luaM_new(L, UpVal); | 82 | TObject *v = luaM_newvector(L, 2, TObject); |
83 | v->val = *var; | 83 | v[1] = *var; |
84 | v->marked = 0; | 84 | setupvalue(v, G(L)->rootupval, LUA_HEAPUPVAL); |
85 | v->next = G(L)->rootupval; | ||
86 | G(L)->rootupval = v; | 85 | G(L)->rootupval = v; |
87 | setupvalue(var, v); | 86 | setupvalue(var, &v[1], LUA_TUPVAL); |
88 | } | 87 | } |
89 | cl->upvals[i].heap = vvalue(var); | 88 | cl->upvals[i] = vvalue(var); |
90 | cl->upvals[i].val = &vvalue(var)->val; | ||
91 | got = 1; | 89 | got = 1; |
92 | } | 90 | } |
93 | } | 91 | } |