Skip to content

Commit c96cc68

Browse files
committed
simx86: remove alive checks for node validation
We don't have dead nodes any more, except in TraverseAndClean() where they are immediately removed now. Relatedly G->addr must always be set, so assert on that.
1 parent e896fda commit c96cc68

File tree

1 file changed

+15
-31
lines changed

1 file changed

+15
-31
lines changed

src/base/emu-i386/simx86/trees.c

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ void NodeLinker(TNode *LG, TNode *G)
800800
#endif
801801
if (debug_level('e')>8 && LG) e_printf("NodeLinker: %08x->%08x\n",LG->key,G->key);
802802

803-
if (LG && LG->alive>0) {
803+
if (LG) {
804804
linknode(LG, G, &LG->clink_t, 'T');
805805
linknode(LG, G, &LG->clink_nt, 'N');
806806
}
@@ -953,10 +953,6 @@ static void CheckLinks(void)
953953
return;
954954
}
955955
G = p->data;
956-
if (G->alive <= 0) {
957-
e_printf("Node %p invalidated\n",G);
958-
continue;
959-
}
960956
if (debug_level('e')>5) e_printf("Node %p at %08x\n",G,G->key);
961957
checklink(G, &G->clink_t, 'T');
962958
checklink(G, &G->clink_nt, 'N');
@@ -990,11 +986,6 @@ static void DumpTree (FILE *fd)
990986
}
991987
fprintf(fd,"\n-----------------------------------------------------------\n");
992988
G = p->data;
993-
if (G->alive <= 0) {
994-
fprintf(fd,"%04d Node %p invalidated\n",nn,G);
995-
nn++;
996-
continue;
997-
}
998989
fprintf(fd,"%04d Node %p at %08x..%08x addr=%p flags=%#x\n",
999990
nn,G,G->key,(G->key+G->seqlen-1),G->addr,G->flags);
1000991
fprintf(fd," AVL (%p:%p),%d,%d,%d,%d\n",p->link[0],p->link[1],
@@ -1019,7 +1010,8 @@ static void DumpTree (FILE *fd)
10191010
B = B->next;
10201011
}
10211012
}
1022-
if (G->addr) {
1013+
assert(G->addr);
1014+
{
10231015
int i, j, k;
10241016
unsigned char *p = G->addr;
10251017
Addr2Pc *AP = G->meta;
@@ -1079,15 +1071,11 @@ static int TraverseAndClean(void)
10791071
}
10801072

10811073
G = p->data;
1082-
if ((G->addr != NULL) && (G->alive>0)) {
1083-
G->alive -= AGENODE;
1084-
if (G->alive <= 0) {
1085-
if (debug_level('e')>2) e_printf("TraverseAndClean: node at %08x decayed\n",G->key);
1086-
e_unmarkpage(G->key, G->seqlen);
1087-
NodeUnlinker(G);
1088-
}
1089-
}
1090-
if ((G->addr == NULL) || (G->alive<=0)) {
1074+
G->alive -= AGENODE;
1075+
if (G->alive <= 0) {
1076+
if (debug_level('e')>2) e_printf("TraverseAndClean: node at %08x decayed\n",G->key);
1077+
e_unmarkpage(G->key, G->seqlen);
1078+
NodeUnlinker(G);
10911079
if (debug_level('e')>2) e_printf("Delete node %08x\n",G->key);
10921080
avltr_delete(G->key);
10931081
cnt++;
@@ -1275,10 +1263,9 @@ static TNode *FindTree_tail(int key)
12751263
#endif
12761264

12771265
I = avltr_find(key);
1278-
if (!I) goto endsrch;
1279-
G = *I;
1280-
assert(G);
1281-
if (G->addr && (G->alive>0)) {
1266+
if (I) {
1267+
G = *I;
1268+
assert(G && G->addr);
12821269
if (debug_level('e')>3) e_printf("Found key %08x\n",key);
12831270
G->alive = NODELIFE(G);
12841271
#if PROFILE
@@ -1292,7 +1279,6 @@ static TNode *FindTree_tail(int key)
12921279
return G;
12931280
}
12941281

1295-
endsrch:
12961282
#if PROFILE >= 2
12971283
if (debug_level('e')) SearchTime += (GETTSC() - t0);
12981284
#endif
@@ -1319,7 +1305,7 @@ TNode *FindTree(int key)
13191305
~99.99% success rate */
13201306
I = __atomic_load_n(&findtree_cache[key&FINDTREE_CACHE_HASH_MASK],
13211307
__ATOMIC_RELAXED);
1322-
if (I && (I->alive>0) && (I->key==key)) {
1308+
if (I && (I->key==key)) {
13231309
if (debug_level('e')) {
13241310
if (debug_level('e')>4)
13251311
e_printf("Found key %08x via cache\n", key);
@@ -1350,7 +1336,7 @@ TNode *FindTree_unlocked(int key)
13501336
/* fast path: using cache indexed by low 12 bits of PC:
13511337
~99.99% success rate */
13521338
I = findtree_cache[key&FINDTREE_CACHE_HASH_MASK];
1353-
if (I && (I->alive>0) && (I->key==key)) {
1339+
if (I && (I->key==key)) {
13541340
if (debug_level('e')) {
13551341
if (debug_level('e')>4)
13561342
e_printf("Found key %08x via cache\n", key);
@@ -1437,12 +1423,11 @@ int InvalidateNodeRange(int al, int len, unsigned char *eip)
14371423
if (!G || G->key >= ah)
14381424
break;
14391425
ahG = G->key + G->seqlen;
1440-
if (G->addr && (G->alive>0)) {
1441-
if (RANGE_INTERSECT(G->key,ahG,al,ah)) {
1426+
assert (G->addr);
1427+
if (RANGE_INTERSECT(G->key,ahG,al,ah)) {
14421428
unsigned char *ahE;
14431429
if (debug_level('e')>1)
14441430
dbug_printf("Invalidated node %p at %08x\n",G,G->key);
1445-
G->alive = 0;
14461431
e_unmarkpage(G->key, G->seqlen);
14471432
NodeUnlinker(G);
14481433
cleaned++;
@@ -1468,7 +1453,6 @@ int InvalidateNodeRange(int al, int len, unsigned char *eip)
14681453
if (debug_level('e')>2) e_printf("Delete node %08x\n",G->key);
14691454
avltr_delete(G->key);
14701455
}
1471-
}
14721456
}
14731457
if (ahG >= ah)
14741458
break;

0 commit comments

Comments
 (0)