From fabe4ec487cb034ef983a29c52df2927be463d3c Mon Sep 17 00:00:00 2001
From: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Mon, 7 Jun 2010 13:55:34 -0300
Subject: better barrier for prototypes

---
 lvm.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

(limited to 'lvm.c')

diff --git a/lvm.c b/lvm.c
index 3a66e0aa..8361d3dd 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
 /*
-** $Id: lvm.c,v 2.120 2010/05/13 19:53:05 roberto Exp roberto $
+** $Id: lvm.c,v 2.121 2010/06/04 13:25:10 roberto Exp roberto $
 ** Lua virtual machine
 ** See Copyright Notice in lua.h
 */
@@ -368,7 +368,9 @@ static Closure *getcached (Proto *p, UpVal **encup, StkId base) {
 
 /*
 ** create a new Lua closure, push it in the stack, and initialize
-** its upvalues
+** its upvalues. Note that the call to 'luaC_barrierproto' must come
+** before the assignment to 'p->cache', as the function needs the
+** orginal value of that field.
 */
 static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base,
                          StkId ra) {
@@ -383,8 +385,8 @@ static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base,
     else  /* get upvalue from enclosing function */
       ncl->l.upvals[i] = encup[uv[i].idx];
   }
-  p->cache = ncl;  /* save it on cache, so it can be reused */
-  luaC_barrierproto(L, obj2gco(p));
+  luaC_barrierproto(L, p, ncl);
+  p->cache = ncl;  /* save it on cache for reuse */
 }
 
 
-- 
cgit v1.2.3-55-g6feb