aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pall <mike>2020-03-20 13:35:49 +0100
committerMike Pall <mike>2020-03-20 13:35:49 +0100
commite613105ca92fe25e7bd63031b409faa8c908ac35 (patch)
tree98ba088a848a608d02aea34f5359d708bf2160e5
parent522d2073da4be2af79db4728cbb375db0fbdfc48 (diff)
downloadluajit-e613105ca92fe25e7bd63031b409faa8c908ac35.tar.gz
luajit-e613105ca92fe25e7bd63031b409faa8c908ac35.tar.bz2
luajit-e613105ca92fe25e7bd63031b409faa8c908ac35.zip
Fix write barrier for lua_setupvalue() and debug.setupvalue().
-rw-r--r--src/lj_api.c8
-rw-r--r--src/lj_debug.c7
-rw-r--r--src/lj_debug.h3
3 files changed, 12 insertions, 6 deletions
diff --git a/src/lj_api.c b/src/lj_api.c
index e2d7e533..1a34a774 100644
--- a/src/lj_api.c
+++ b/src/lj_api.c
@@ -841,7 +841,8 @@ LUA_API int lua_next(lua_State *L, int idx)
841LUA_API const char *lua_getupvalue(lua_State *L, int idx, int n) 841LUA_API const char *lua_getupvalue(lua_State *L, int idx, int n)
842{ 842{
843 TValue *val; 843 TValue *val;
844 const char *name = lj_debug_uvnamev(index2adr(L, idx), (uint32_t)(n-1), &val); 844 GCobj *o;
845 const char *name = lj_debug_uvnamev(index2adr(L, idx), (uint32_t)(n-1), &val, &o);
845 if (name) { 846 if (name) {
846 copyTV(L, L->top, val); 847 copyTV(L, L->top, val);
847 incr_top(L); 848 incr_top(L);
@@ -1014,13 +1015,14 @@ LUA_API const char *lua_setupvalue(lua_State *L, int idx, int n)
1014{ 1015{
1015 cTValue *f = index2adr(L, idx); 1016 cTValue *f = index2adr(L, idx);
1016 TValue *val; 1017 TValue *val;
1018 GCobj *o;
1017 const char *name; 1019 const char *name;
1018 api_checknelems(L, 1); 1020 api_checknelems(L, 1);
1019 name = lj_debug_uvnamev(f, (uint32_t)(n-1), &val); 1021 name = lj_debug_uvnamev(f, (uint32_t)(n-1), &val, &o);
1020 if (name) { 1022 if (name) {
1021 L->top--; 1023 L->top--;
1022 copyTV(L, val, L->top); 1024 copyTV(L, val, L->top);
1023 lj_gc_barrier(L, funcV(f), L->top); 1025 lj_gc_barrier(L, o, L->top);
1024 } 1026 }
1025 return name; 1027 return name;
1026} 1028}
diff --git a/src/lj_debug.c b/src/lj_debug.c
index 04fecfaf..1d73da7e 100644
--- a/src/lj_debug.c
+++ b/src/lj_debug.c
@@ -235,19 +235,22 @@ const char *lj_debug_uvname(GCproto *pt, uint32_t idx)
235} 235}
236 236
237/* Get name and value of upvalue. */ 237/* Get name and value of upvalue. */
238const char *lj_debug_uvnamev(cTValue *o, uint32_t idx, TValue **tvp) 238const char *lj_debug_uvnamev(cTValue *o, uint32_t idx, TValue **tvp, GCobj **op)
239{ 239{
240 if (tvisfunc(o)) { 240 if (tvisfunc(o)) {
241 GCfunc *fn = funcV(o); 241 GCfunc *fn = funcV(o);
242 if (isluafunc(fn)) { 242 if (isluafunc(fn)) {
243 GCproto *pt = funcproto(fn); 243 GCproto *pt = funcproto(fn);
244 if (idx < pt->sizeuv) { 244 if (idx < pt->sizeuv) {
245 *tvp = uvval(&gcref(fn->l.uvptr[idx])->uv); 245 GCobj *uvo = gcref(fn->l.uvptr[idx]);
246 *tvp = uvval(&uvo->uv);
247 *op = uvo;
246 return lj_debug_uvname(pt, idx); 248 return lj_debug_uvname(pt, idx);
247 } 249 }
248 } else { 250 } else {
249 if (idx < fn->c.nupvalues) { 251 if (idx < fn->c.nupvalues) {
250 *tvp = &fn->c.upvalue[idx]; 252 *tvp = &fn->c.upvalue[idx];
253 *op = obj2gco(fn);
251 return ""; 254 return "";
252 } 255 }
253 } 256 }
diff --git a/src/lj_debug.h b/src/lj_debug.h
index 75ea927c..43fb9c19 100644
--- a/src/lj_debug.h
+++ b/src/lj_debug.h
@@ -29,7 +29,8 @@ typedef struct lj_Debug {
29LJ_FUNC cTValue *lj_debug_frame(lua_State *L, int level, int *size); 29LJ_FUNC cTValue *lj_debug_frame(lua_State *L, int level, int *size);
30LJ_FUNC BCLine LJ_FASTCALL lj_debug_line(GCproto *pt, BCPos pc); 30LJ_FUNC BCLine LJ_FASTCALL lj_debug_line(GCproto *pt, BCPos pc);
31LJ_FUNC const char *lj_debug_uvname(GCproto *pt, uint32_t idx); 31LJ_FUNC const char *lj_debug_uvname(GCproto *pt, uint32_t idx);
32LJ_FUNC const char *lj_debug_uvnamev(cTValue *o, uint32_t idx, TValue **tvp); 32LJ_FUNC const char *lj_debug_uvnamev(cTValue *o, uint32_t idx, TValue **tvp,
33 GCobj **op);
33LJ_FUNC const char *lj_debug_slotname(GCproto *pt, const BCIns *pc, 34LJ_FUNC const char *lj_debug_slotname(GCproto *pt, const BCIns *pc,
34 BCReg slot, const char **name); 35 BCReg slot, const char **name);
35LJ_FUNC const char *lj_debug_funcname(lua_State *L, TValue *frame, 36LJ_FUNC const char *lj_debug_funcname(lua_State *L, TValue *frame,