diff options
author | Mike Pall <mike> | 2010-04-21 01:45:58 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2010-04-21 01:45:58 +0200 |
commit | ab45481199e9c9dd3efec922647bcec122504bcb (patch) | |
tree | 0484341edff50a0afe98133ad66fb6a59915996a /src/lj_tab.c | |
parent | d8cb69ed076c3444258f63314662451c9d117cae (diff) | |
download | luajit-ab45481199e9c9dd3efec922647bcec122504bcb.tar.gz luajit-ab45481199e9c9dd3efec922647bcec122504bcb.tar.bz2 luajit-ab45481199e9c9dd3efec922647bcec122504bcb.zip |
No longer let the GC replace dead keys with the LJ_TDEADKEY tag.
Important: this changes the semantics of the write barrier!
Carefully read the big comment block in lj_obj.h
This helps HREFK key slot specialization and allows safely hoisting
HREF/HREFK across GC steps, too (fix for a barely reproducible bug).
Dead keys are only removed during a table resize (as before).
Diffstat (limited to 'src/lj_tab.c')
-rw-r--r-- | src/lj_tab.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/lj_tab.c b/src/lj_tab.c index d77aa05a..5d68cc54 100644 --- a/src/lj_tab.c +++ b/src/lj_tab.c | |||
@@ -192,7 +192,7 @@ GCtab * LJ_FASTCALL lj_tab_dup(lua_State *L, const GCtab *kt) | |||
192 | Node *kn = &knode[i]; | 192 | Node *kn = &knode[i]; |
193 | Node *n = &node[i]; | 193 | Node *n = &node[i]; |
194 | Node *next = nextnode(kn); | 194 | Node *next = nextnode(kn); |
195 | /* Don't use copyTV here, since it asserts on a copy of a DEADKEY. */ | 195 | /* Don't use copyTV here, since it asserts on a copy of a dead key. */ |
196 | n->val = kn->val; n->key = kn->key; | 196 | n->val = kn->val; n->key = kn->key; |
197 | setmref(n->next, next == NULL? next : (Node *)((char *)next + d)); | 197 | setmref(n->next, next == NULL? next : (Node *)((char *)next + d)); |
198 | } | 198 | } |
@@ -448,7 +448,7 @@ TValue *lj_tab_newkey(lua_State *L, GCtab *t, cTValue *key) | |||
448 | n->key.u64 = key->u64; | 448 | n->key.u64 = key->u64; |
449 | if (LJ_UNLIKELY(tvismzero(&n->key))) | 449 | if (LJ_UNLIKELY(tvismzero(&n->key))) |
450 | n->key.u64 = 0; | 450 | n->key.u64 = 0; |
451 | lj_gc_barriert(L, t, key); | 451 | lj_gc_anybarriert(L, t); |
452 | lua_assert(tvisnil(&n->val)); | 452 | lua_assert(tvisnil(&n->val)); |
453 | return &n->val; | 453 | return &n->val; |
454 | } | 454 | } |
@@ -517,9 +517,7 @@ static uint32_t keyindex(lua_State *L, GCtab *t, cTValue *key) | |||
517 | if (!tvisnil(key)) { | 517 | if (!tvisnil(key)) { |
518 | Node *n = hashkey(t, key); | 518 | Node *n = hashkey(t, key); |
519 | do { | 519 | do { |
520 | if (lj_obj_equal(&n->key, key) || | 520 | if (lj_obj_equal(&n->key, key)) |
521 | (itype(&n->key) == LJ_TDEADKEY && tvisgcv(key) && | ||
522 | gcV(&n->key) == gcV(key))) | ||
523 | return t->asize + (uint32_t)(n - noderef(t->node)); | 521 | return t->asize + (uint32_t)(n - noderef(t->node)); |
524 | /* Hash key indexes: [t->asize..t->asize+t->nmask] */ | 522 | /* Hash key indexes: [t->asize..t->asize+t->nmask] */ |
525 | } while ((n = nextnode(n))); | 523 | } while ((n = nextnode(n))); |