summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lgc.c4
-rw-r--r--lobject.h12
-rw-r--r--ltable.c9
-rw-r--r--ltable.h9
4 files changed, 23 insertions, 11 deletions
diff --git a/lgc.c b/lgc.c
index 0fe426e8..a4059d34 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 2.190 2014/07/19 15:09:37 roberto Exp roberto $ 2** $Id: lgc.c,v 2.191 2014/07/19 15:14:46 roberto Exp roberto $
3** Garbage Collector 3** Garbage Collector
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -112,7 +112,7 @@ static void reallymarkobject (global_State *g, GCObject *o);
112static void removeentry (Node *n) { 112static void removeentry (Node *n) {
113 lua_assert(ttisnil(gval(n))); 113 lua_assert(ttisnil(gval(n)));
114 if (valiswhite(gkey(n))) 114 if (valiswhite(gkey(n)))
115 setdeadvalue(gkey(n)); /* unused and unmarked key; remove it */ 115 setdeadvalue(wgkey(n)); /* unused and unmarked key; remove it */
116} 116}
117 117
118 118
diff --git a/lobject.h b/lobject.h
index a5827f84..93356dd2 100644
--- a/lobject.h
+++ b/lobject.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.h,v 2.98 2014/07/18 13:36:14 roberto Exp roberto $ 2** $Id: lobject.h,v 2.99 2014/07/18 14:46:47 roberto Exp roberto $
3** Type definitions for Lua objects 3** Type definitions for Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -241,8 +241,7 @@ typedef struct lua_TValue TValue;
241 241
242 242
243#define setobj(L,obj1,obj2) \ 243#define setobj(L,obj1,obj2) \
244 { const TValue *io2=(obj2); TValue *io1=(obj1); \ 244 { TValue *io1=(obj1); *io1 = *(obj2); \
245 io1->value_ = io2->value_; io1->tt_ = io2->tt_; \
246 (void)L; checkliveness(G(L),io1); } 245 (void)L; checkliveness(G(L),io1); }
247 246
248 247
@@ -471,6 +470,13 @@ typedef union TKey {
471} TKey; 470} TKey;
472 471
473 472
473/* copy a value into a key without messing up field 'next' */
474#define setkey(L,key,obj) \
475 { TKey *k_=(key); const TValue *io_=(obj); \
476 k_->nk.value_ = io_->value_; k_->nk.tt_ = io_->tt_; \
477 (void)L; checkliveness(G(L),io_); }
478
479
474typedef struct Node { 480typedef struct Node {
475 TValue i_val; 481 TValue i_val;
476 TKey i_key; 482 TKey i_key;
diff --git a/ltable.c b/ltable.c
index a234bebb..543c34df 100644
--- a/ltable.c
+++ b/ltable.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltable.c,v 2.91 2014/06/26 16:17:35 roberto Exp roberto $ 2** $Id: ltable.c,v 2.92 2014/07/18 13:36:14 roberto Exp roberto $
3** Lua tables (hash) 3** Lua tables (hash)
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -309,7 +309,7 @@ static void setnodevector (lua_State *L, Table *t, int size) {
309 for (i=0; i<size; i++) { 309 for (i=0; i<size; i++) {
310 Node *n = gnode(t, i); 310 Node *n = gnode(t, i);
311 gnext(n) = 0; 311 gnext(n) = 0;
312 setnilvalue(gkey(n)); 312 setnilvalue(wgkey(n));
313 setnilvalue(gval(n)); 313 setnilvalue(gval(n));
314 } 314 }
315 } 315 }
@@ -466,7 +466,7 @@ TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) {
466 mp = f; 466 mp = f;
467 } 467 }
468 } 468 }
469 setobj2t(L, gkey(mp), key); 469 setkey(L, &mp->i_key, key);
470 luaC_barrierback(L, t, key); 470 luaC_barrierback(L, t, key);
471 lua_assert(ttisnil(gval(mp))); 471 lua_assert(ttisnil(gval(mp)));
472 return gval(mp); 472 return gval(mp);
@@ -503,7 +503,8 @@ const TValue *luaH_getstr (Table *t, TString *key) {
503 Node *n = hashstr(t, key); 503 Node *n = hashstr(t, key);
504 lua_assert(key->tt == LUA_TSHRSTR); 504 lua_assert(key->tt == LUA_TSHRSTR);
505 for (;;) { /* check whether `key' is somewhere in the chain */ 505 for (;;) { /* check whether `key' is somewhere in the chain */
506 if (ttisshrstring(gkey(n)) && eqshrstr(tsvalue(gkey(n)), key)) 506 const TValue *k = gkey(n);
507 if (ttisshrstring(k) && eqshrstr(tsvalue(k), key))
507 return gval(n); /* that's it */ 508 return gval(n); /* that's it */
508 else { 509 else {
509 int nx = gnext(n); 510 int nx = gnext(n);
diff --git a/ltable.h b/ltable.h
index f377c009..a4570d9d 100644
--- a/ltable.h
+++ b/ltable.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltable.h,v 2.17 2013/04/26 15:39:25 roberto Exp roberto $ 2** $Id: ltable.h,v 2.18 2013/08/30 16:01:37 roberto Exp roberto $
3** Lua tables (hash) 3** Lua tables (hash)
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -11,10 +11,15 @@
11 11
12 12
13#define gnode(t,i) (&(t)->node[i]) 13#define gnode(t,i) (&(t)->node[i])
14#define gkey(n) (&(n)->i_key.tvk)
15#define gval(n) (&(n)->i_val) 14#define gval(n) (&(n)->i_val)
16#define gnext(n) ((n)->i_key.nk.next) 15#define gnext(n) ((n)->i_key.nk.next)
17 16
17
18/* 'const' to avoid wrong writings that can mess up field 'next' */
19#define gkey(n) cast(const TValue*, (&(n)->i_key.tvk))
20
21#define wgkey(n) (&(n)->i_key.nk)
22
18#define invalidateTMcache(t) ((t)->flags = 0) 23#define invalidateTMcache(t) ((t)->flags = 0)
19 24
20 25