diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-06-19 15:27:20 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-06-19 15:27:20 -0300 |
| commit | 89b56e7d84d84de58fcc9d540c2003c6c2f8c134 (patch) | |
| tree | 85ba9c3aa3cdb5ff57fd4f82bf322fb2e75e7292 /lvm.c | |
| parent | 14929f5764a7990dfb62c8792cfdfe03c061da21 (diff) | |
| download | lua-89b56e7d84d84de58fcc9d540c2003c6c2f8c134.tar.gz lua-89b56e7d84d84de58fcc9d540c2003c6c2f8c134.tar.bz2 lua-89b56e7d84d84de58fcc9d540c2003c6c2f8c134.zip | |
more precision between closure types ('LClosure' x 'CClosure')
Diffstat (limited to 'lvm.c')
| -rw-r--r-- | lvm.c | 20 |
1 files changed, 10 insertions, 10 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lvm.c,v 2.214 2014/05/26 17:10:22 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.215 2014/06/10 18:53:18 roberto Exp roberto $ |
| 3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -503,15 +503,15 @@ lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y) { | |||
| 503 | ** whether there is a cached closure with the same upvalues needed by | 503 | ** whether there is a cached closure with the same upvalues needed by |
| 504 | ** new closure to be created. | 504 | ** new closure to be created. |
| 505 | */ | 505 | */ |
| 506 | static Closure *getcached (Proto *p, UpVal **encup, StkId base) { | 506 | static LClosure *getcached (Proto *p, UpVal **encup, StkId base) { |
| 507 | Closure *c = p->cache; | 507 | LClosure *c = p->cache; |
| 508 | if (c != NULL) { /* is there a cached closure? */ | 508 | if (c != NULL) { /* is there a cached closure? */ |
| 509 | int nup = p->sizeupvalues; | 509 | int nup = p->sizeupvalues; |
| 510 | Upvaldesc *uv = p->upvalues; | 510 | Upvaldesc *uv = p->upvalues; |
| 511 | int i; | 511 | int i; |
| 512 | for (i = 0; i < nup; i++) { /* check whether it has right upvalues */ | 512 | for (i = 0; i < nup; i++) { /* check whether it has right upvalues */ |
| 513 | TValue *v = uv[i].instack ? base + uv[i].idx : encup[uv[i].idx]->v; | 513 | TValue *v = uv[i].instack ? base + uv[i].idx : encup[uv[i].idx]->v; |
| 514 | if (c->l.upvals[i]->v != v) | 514 | if (c->upvals[i]->v != v) |
| 515 | return NULL; /* wrong upvalue; cannot reuse closure */ | 515 | return NULL; /* wrong upvalue; cannot reuse closure */ |
| 516 | } | 516 | } |
| 517 | } | 517 | } |
| @@ -530,15 +530,15 @@ static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base, | |||
| 530 | int nup = p->sizeupvalues; | 530 | int nup = p->sizeupvalues; |
| 531 | Upvaldesc *uv = p->upvalues; | 531 | Upvaldesc *uv = p->upvalues; |
| 532 | int i; | 532 | int i; |
| 533 | Closure *ncl = luaF_newLclosure(L, nup); | 533 | LClosure *ncl = luaF_newLclosure(L, nup); |
| 534 | ncl->l.p = p; | 534 | ncl->p = p; |
| 535 | setclLvalue(L, ra, ncl); /* anchor new closure in stack */ | 535 | setclLvalue(L, ra, ncl); /* anchor new closure in stack */ |
| 536 | for (i = 0; i < nup; i++) { /* fill in its upvalues */ | 536 | for (i = 0; i < nup; i++) { /* fill in its upvalues */ |
| 537 | if (uv[i].instack) /* upvalue refers to local variable? */ | 537 | if (uv[i].instack) /* upvalue refers to local variable? */ |
| 538 | ncl->l.upvals[i] = luaF_findupval(L, base + uv[i].idx); | 538 | ncl->upvals[i] = luaF_findupval(L, base + uv[i].idx); |
| 539 | else /* get upvalue from enclosing function */ | 539 | else /* get upvalue from enclosing function */ |
| 540 | ncl->l.upvals[i] = encup[uv[i].idx]; | 540 | ncl->upvals[i] = encup[uv[i].idx]; |
| 541 | ncl->l.upvals[i]->refcount++; | 541 | ncl->upvals[i]->refcount++; |
| 542 | /* new closure is white, so we do not need a barrier here */ | 542 | /* new closure is white, so we do not need a barrier here */ |
| 543 | } | 543 | } |
| 544 | if (!isblack(obj2gco(p))) /* cache will not break GC invariant? */ | 544 | if (!isblack(obj2gco(p))) /* cache will not break GC invariant? */ |
| @@ -1109,7 +1109,7 @@ void luaV_execute (lua_State *L) { | |||
| 1109 | ) | 1109 | ) |
| 1110 | vmcase(OP_CLOSURE, | 1110 | vmcase(OP_CLOSURE, |
| 1111 | Proto *p = cl->p->p[GETARG_Bx(i)]; | 1111 | Proto *p = cl->p->p[GETARG_Bx(i)]; |
| 1112 | Closure *ncl = getcached(p, cl->upvals, base); /* cached closure */ | 1112 | LClosure *ncl = getcached(p, cl->upvals, base); /* cached closure */ |
| 1113 | if (ncl == NULL) /* no match? */ | 1113 | if (ncl == NULL) /* no match? */ |
| 1114 | pushclosure(L, p, cl->upvals, base, ra); /* create a new one */ | 1114 | pushclosure(L, p, cl->upvals, base, ra); /* create a new one */ |
| 1115 | else | 1115 | else |
