Changeset 15823


Ignore:
Timestamp:
May 26, 2013, 7:37:18 PM (6 years ago)
Author:
gb
Message:

Still not working; may not be for another few days.
Will create a branch for this and revert trunk.

Location:
trunk/source/lisp-kernel
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/gc-common.c

    r15821 r15823  
    10901090}
    10911091
    1092 void
    1093 forward_memoized_area(area *a, natural num_memo_dnodes, bitvector refbits)
    1094 {
    1095   LispObj *p = (LispObj *) a->low, x1, x2, new;
     1092typedef struct {
     1093  bitvector refidx;
     1094  bitvector refbits;
     1095  bitvector idxp;
     1096  bitvector idxlimit;
     1097  bitvector rangelimit;
     1098  bitvector reflimit;
     1099  bitvector refp;
     1100  natural idx;
     1101  bitvector idxbase;
     1102} bitidx_state;
     1103
     1104natural *
     1105next_refbits(bitidx_state *s)
     1106{
     1107  bitvector p, limit;
     1108  natural idxbit, idx;
     1109
     1110  while (1) {
     1111    p = s->refp;
     1112    limit = s->rangelimit;
     1113    while (p < limit) {
     1114      if (*p) {
     1115        s->refp = p+1;
     1116        return p;
     1117      }
     1118      p++;
     1119    }
     1120    idx = s->idx;
     1121    while (idx == 0) {
     1122      if (s->idxp == s->idxlimit) {
     1123        return NULL;
     1124      }
     1125      idx = *(s->idxp);
     1126      if (idx) {
     1127        s->idx = idx;
     1128        s->idxbase = s->refbits + ((s->idxp - s->refidx) * (WORD_SIZE * (256 / WORD_SIZE)));
     1129      }
     1130      s->idxp++;
     1131    }
     1132    idxbit = count_leading_zeros(idx);
     1133    s->idx &= ~(BIT0_MASK>>idxbit);
     1134    p = s->idxbase + (idxbit * (256/WORD_SIZE));
     1135    s->refp = p;
     1136    s->rangelimit = p + (256/WORD_SIZE);
     1137    if (s->reflimit < s->rangelimit) {
     1138      s->rangelimit = s->reflimit;
     1139    }
     1140  }
     1141}
     1142
     1143void
     1144init_bitidx_state(bitidx_state *s, bitvector refidx, bitvector refbits, natural ndnodes)
     1145{
     1146  s->refidx = refidx;
     1147  s->refbits = refbits;
     1148  s->idxp = refidx;
     1149  s->idxlimit = refidx + ((((ndnodes + 255) >> 8) + (WORD_SIZE-1)) >> bitmap_shift);
     1150  s->idx = 0;
     1151  s->reflimit = refbits + ((ndnodes + (WORD_SIZE-1)) >> bitmap_shift);
     1152  s->refp = s->rangelimit = s->idxbase = NULL;
     1153}
     1154
     1155
     1156void
     1157forward_memoized_area(area *a, natural num_memo_dnodes, bitvector refbits, bitvector refidx)
     1158{
     1159  LispObj *p = (LispObj *) a->low, *pbase = p, x1, x2, new;
    10961160#ifdef ARM
    10971161  LispObj *p0 = p;
    10981162#endif
    1099   natural bits, bitidx, *bitsp, nextbit, diff, memo_dnode = 0, hash_dnode_limit = 0;
     1163  natural bits, *bitsp, nextbit,  memo_dnode = 0, ref_dnode, hash_dnode_limit = 0;
    11001164  int tag_x1;
    11011165  hash_table_vector_header *hashp = NULL;
    11021166  Boolean header_p;
    1103   bitvector refidx = NULL;
    1104  
    1105   if (refbits == a->refbits) {
    1106     refidx = a->refidx;
    1107   }
     1167  bitidx_state state;
     1168
    11081169
    11091170
    11101171
    11111172  if (num_memo_dnodes) {
     1173    init_bitidx_state(&state, refidx, refbits, num_memo_dnodes);
    11121174    if (GCDebug) {
    11131175      check_refmap_consistency(p, p+(num_memo_dnodes << 1), refbits, refidx);
     
    11171179       when we move a key in a hash table vector that wants
    11181180       us to tell it about that. */
    1119 
    1120     set_bitidx_vars(refbits, 0, bitsp, bits, bitidx);
    1121     while (memo_dnode < num_memo_dnodes) {
     1181   
     1182    bits = 0;
     1183    while (1) {
    11221184      if (bits == 0) {
    1123         int remain = nbits_in_word - bitidx;
    1124         memo_dnode += remain;
    1125         p += (remain+remain);
    1126         if (memo_dnode < num_memo_dnodes) {
    1127           bits = *++bitsp;
    1128         }
    1129         bitidx = 0;
    1130       } else {
    1131         nextbit = count_leading_zeros(bits);
    1132         if ((diff = (nextbit - bitidx)) != 0) {
    1133           memo_dnode += diff;
    1134           bitidx = nextbit;
    1135           p += (diff+diff);
    1136         }
    1137         x1 = p[0];
    1138         x2 = p[1];
    1139         tag_x1 = fulltag_of(x1);
    1140         bits &= ~(BIT0_MASK >> bitidx);
    1141         header_p = (nodeheader_tag_p(tag_x1));
    1142 
    1143         if (header_p &&
    1144             (header_subtag(x1) == subtag_hash_vector)) {
    1145           hashp = (hash_table_vector_header *) p;
    1146           if (hashp->flags & nhash_track_keys_mask) {
    1147             hash_dnode_limit = memo_dnode + ((header_element_count(x1)+2)>>1);
    1148           } else {
    1149             hashp = NULL;
    1150           }
    1151         }
    1152 
    1153 
    1154         if (! header_p) {
    1155           new = node_forwarding_address(x1);
    1156           if (new != x1) {
    1157             *p = new;
     1185        bitsp = next_refbits(&state);
     1186        if (bitsp == NULL) {
     1187          return;
     1188        }
     1189        bits = *bitsp;
     1190        ref_dnode = (bitsp-refbits)<<bitmap_shift;
     1191      }
     1192      nextbit = count_leading_zeros(bits);
     1193      bits &= ~(BIT0_MASK>>nextbit);
     1194      memo_dnode = ref_dnode + nextbit;
     1195      p = pbase+(memo_dnode*2);
     1196      x1 = p[0];
     1197      x2 = p[1];
     1198      tag_x1 = fulltag_of(x1);
     1199      header_p = (nodeheader_tag_p(tag_x1));
     1200
     1201      if (header_p &&
     1202          (header_subtag(x1) == subtag_hash_vector)) {
     1203        hashp = (hash_table_vector_header *) p;
     1204        if (hashp->flags & nhash_track_keys_mask) {
     1205          hash_dnode_limit = memo_dnode + ((header_element_count(x1)+2)>>1);
     1206        } else {
     1207          hashp = NULL;
     1208        }
     1209      }
     1210      if (! header_p) {
     1211        new = node_forwarding_address(x1);
     1212        if (new != x1) {
     1213          *p = new;
    11581214#ifdef ARM
    1159             if (p != p0) {
    1160               if(header_subtag(p[-2]) == subtag_function) {
    1161                 /* Just updated the code vector; fix the entrypoint */
    1162                 if (p[-1] == (untag(x1)+fulltag_odd_fixnum)) {
    1163                   p[-1] = (untag(new)+fulltag_odd_fixnum);
    1164                 }
     1215          /* This is heuristic: the two words before P might be immediate
     1216             data that just happens to look like a function header and
     1217             an unboxed reference to p[0].  That's extremely unlikely,
     1218             but close doesn't count ... Fix this. */
     1219          if (p != p0) {
     1220            if(header_subtag(p[-2]) == subtag_function) {
     1221              /* Just updated the code vector; fix the entrypoint */
     1222              if (p[-1] == (untag(x1)+fulltag_odd_fixnum)) {
     1223                p[-1] = (untag(new)+fulltag_odd_fixnum);
    11651224              }
    11661225            }
     1226          }
    11671227#endif
    1168           }
    1169         }
    1170         p++;
    1171 
    1172         new = node_forwarding_address(x2);
    1173         if (new != x2) {
    1174           *p = new;
    1175           if (memo_dnode < hash_dnode_limit) {
    1176             /* If this code is reached, 'hashp' is non-NULL and pointing
    1177                at the header of a hash_table_vector, and 'memo_dnode' identifies
    1178                a pair of words inside the hash_table_vector.  It may be
    1179                hard for program analysis tools to recognize that, but I
    1180                believe that warnings about 'hashp' being NULL here can
    1181                be safely ignored. */
    1182             hashp->flags |= nhash_key_moved_mask;
    1183             hash_dnode_limit = 0;
    1184             hashp = NULL;
    1185           }
    1186         }
    1187         p++;
    1188         memo_dnode++;
    1189         bitidx++;
    1190 
     1228        }
     1229      }
     1230      p++;
     1231     
     1232      new = node_forwarding_address(x2);
     1233      if (new != x2) {
     1234        *p = new;
     1235        if (memo_dnode < hash_dnode_limit) {
     1236          /* If this code is reached, 'hashp' is non-NULL and pointing
     1237             at the header of a hash_table_vector, and 'memo_dnode' identifies
     1238             a pair of words inside the hash_table_vector.  It may be
     1239             hard for program analysis tools to recognize that, but I
     1240             believe that warnings about 'hashp' being NULL here can
     1241             be safely ignored. */
     1242          hashp->flags |= nhash_key_moved_mask;
     1243          hash_dnode_limit = 0;
     1244          hashp = NULL;
     1245        }
    11911246      }
    11921247    }
     
    13011356}
    13021357
    1303 void
    1304 mark_managed_static_refs(area *a, BytePtr low_dynamic_address, natural ndynamic_dnodes)
     1358
     1359void
     1360mark_managed_static_refs(area *a, BytePtr low_dynamic_address, natural ndynamic_dnodes, bitvector refidx)
    13051361{
    13061362  bitvector refbits = managed_static_refbits;
     1363  dnode *dnodes = (dnode *)a->low, *d;
    13071364  LispObj *p = (LispObj *) a->low, x1, x2;
    1308   natural inbits, outbits, bits, bitidx, *bitsp, nextbit, diff, memo_dnode = 0,
    1309     num_memo_dnodes = a->ndnodes;
     1365  natural inbits, outbits, bits, *bitsp, nextbit, memo_dnode = 0,
     1366    num_memo_dnodes = a->ndnodes, ref_dnode;
    13101367  Boolean keep_x1, keep_x2;
     1368  bitidx_state state;
    13111369
    13121370  if (num_memo_dnodes) {
     1371    init_bitidx_state(&state, refidx, refbits, num_memo_dnodes);
     1372
    13131373    if (GCDebug) {
    1314       check_refmap_consistency(p, p+(num_memo_dnodes << 1), refbits, NULL);
     1374      check_refmap_consistency(p, p+(num_memo_dnodes << 1), refbits, refidx);
    13151375    }
    13161376
    13171377 
    1318     set_bitidx_vars(refbits, 0, bitsp, bits, bitidx);
    1319     inbits = outbits = bits;
    1320     while (memo_dnode < num_memo_dnodes) {
     1378
     1379
     1380    inbits = outbits = bits = 0;
     1381    while (1) {
    13211382      if (bits == 0) {
    1322         int remain = nbits_in_word - bitidx;
    1323         memo_dnode += remain;
    1324         p += (remain+remain);
    13251383        if (outbits != inbits) {
    13261384          *bitsp = outbits;
    13271385        }
    1328         if (memo_dnode < num_memo_dnodes) {
    1329           bits = *++bitsp;
    1330         }
    1331         inbits = outbits = bits;
    1332         bitidx = 0;
    1333       } else {
    1334         nextbit = count_leading_zeros(bits);
    1335         if ((diff = (nextbit - bitidx)) != 0) {
    1336           memo_dnode += diff;
    1337           bitidx = nextbit;
    1338           p += (diff+diff);
    1339         }
    1340         x1 = *p++;
    1341         x2 = *p++;
    1342         bits &= ~(BIT0_MASK >> bitidx);
    1343         keep_x1 = mark_static_ref(x1, low_dynamic_address, ndynamic_dnodes);
    1344         keep_x2 = mark_static_ref(x2, low_dynamic_address, ndynamic_dnodes);
    1345         if ((keep_x1 == false) &&
    1346             (keep_x2 == false)) {
    1347           outbits &= ~(BIT0_MASK >> bitidx);
    1348         }
    1349         memo_dnode++;
    1350         bitidx++;
     1386        bitsp = next_refbits(&state);
     1387        if (bitsp == NULL) {
     1388          break;
     1389        }
     1390        inbits = outbits = bits = *bitsp;
     1391        ref_dnode = (bitsp-refbits)<<bitmap_shift;
     1392      }
     1393      nextbit = count_leading_zeros(bits);
     1394      bits &= ~(BIT0_MASK>>nextbit);
     1395      memo_dnode = ref_dnode + nextbit;
     1396      d = dnodes+memo_dnode;
     1397      x1 = d->w0;
     1398      x2 = d->w1;
     1399      keep_x1 = mark_static_ref(x1, low_dynamic_address, ndynamic_dnodes);
     1400      keep_x2 = mark_static_ref(x2, low_dynamic_address, ndynamic_dnodes);
     1401      if ((keep_x1 == false) &&
     1402          (keep_x2 == false)) {
     1403        outbits &= ~(BIT0_MASK >> nextbit);
    13511404      }
    13521405    }
     
    13581411}
    13591412
    1360 void
    1361 mark_memoized_area(area *a, natural num_memo_dnodes)
     1413
     1414void
     1415mark_memoized_area(area *a, natural num_memo_dnodes, bitvector refidx)
    13621416{
    13631417  bitvector refbits = a->refbits;
    1364   LispObj *p = (LispObj *) a->low, x1, x2;
    1365   natural inbits, outbits, bits, bitidx, *bitsp, nextbit, diff, memo_dnode = 0;
     1418  dnode *dnodes = (dnode *)a->low, *d;
     1419  LispObj *p = (LispObj *) a->low,x1, x2;
     1420  natural inbits, outbits, bits, bitidx, *bitsp, nextbit, diff, memo_dnode = 0, ref_dnode = 0;
    13661421  Boolean keep_x1, keep_x2;
    13671422  natural hash_dnode_limit = 0;
    13681423  hash_table_vector_header *hashp = NULL;
    13691424  int mark_method = 3;
     1425  bitidx_state state;
     1426
     1427
    13701428
    13711429  if (num_memo_dnodes) {
     1430    init_bitidx_state(&state, refidx, refbits, num_memo_dnodes);   
     1431   
    13721432    if (GCDebug) {
    1373       check_refmap_consistency(p, p+(num_memo_dnodes << 1), refbits, a->refidx);
     1433      check_refmap_consistency(p, p+(num_memo_dnodes << 1), refbits, refidx);
    13741434    }
    13751435
     
    13791439       or readonly areas is definitely uninteresting, but other cases are
    13801440       more complicated (and some of these cases are hard to detect.)
    1381 
    13821441       Some headers are "interesting", to the forwarder if not to us.
    13831442
     
    14021461      }
    14031462    }
    1404        
    1405     set_bitidx_vars(refbits, 0, bitsp, bits, bitidx);
    1406     inbits = outbits = bits;
    1407     while (memo_dnode < num_memo_dnodes) {
     1463     
     1464     
     1465
     1466    inbits = outbits = bits = 0;
     1467    while (1) {
    14081468      if (bits == 0) {
    1409         int remain = nbits_in_word - bitidx;
    1410         memo_dnode += remain;
    1411         p += (remain+remain);
    14121469        if (outbits != inbits) {
    14131470          *bitsp = outbits;
    14141471        }
    1415         if (memo_dnode < num_memo_dnodes) {
    1416           bits = *++bitsp;
    1417         }
    1418         inbits = outbits = bits;
    1419         bitidx = 0;
    1420       } else {
    1421         nextbit = count_leading_zeros(bits);
    1422         if ((diff = (nextbit - bitidx)) != 0) {
    1423           memo_dnode += diff;
    1424           bitidx = nextbit;
    1425           p += (diff+diff);
    1426         }
    1427         x1 = *p++;
    1428         x2 = *p++;
    1429         bits &= ~(BIT0_MASK >> bitidx);
    1430 
    1431 
    1432         if (hashp) {
    1433           Boolean force_x1 = false;
    1434           if ((memo_dnode >= hash_dnode_limit) && (mark_method == 3)) {
    1435             /* if vector_header_count is odd, x1 might be the last word of the header */
    1436             force_x1 = (hash_table_vector_header_count & 1) && (memo_dnode == hash_dnode_limit);
    1437             /* was marking header, switch to data */
    1438             hash_dnode_limit = area_dnode(((LispObj *)hashp)
    1439                                           + 1
    1440                                           + header_element_count(hashp->header),
    1441                                           a->low);
    1442             /* In traditional weak method, don't mark vector entries at all. */
    1443             /* Otherwise mark the non-weak elements only */
    1444             mark_method = ((lisp_global(WEAK_GC_METHOD) == 0) ? 0 :
    1445                            ((hashp->flags & nhash_weak_value_mask)
    1446                             ? (1 + (hash_table_vector_header_count & 1))
    1447                             : (2 - (hash_table_vector_header_count & 1))));
     1472        bitsp = next_refbits(&state);
     1473        if (bitsp == NULL) {
     1474          break;
     1475        }
     1476        inbits = outbits = bits = *bitsp;
     1477        ref_dnode = (bitsp-refbits)<<bitmap_shift;
     1478      }
     1479      nextbit = count_leading_zeros(bits);
     1480      bits &= ~(BIT0_MASK >> nextbit);
     1481      memo_dnode = ref_dnode + nextbit;
     1482      d = dnodes+memo_dnode;
     1483      x1 = d->w0;
     1484      x2 = d->w1;
     1485
     1486
     1487      if (hashp) {
     1488        Boolean force_x1 = false;
     1489        if ((memo_dnode >= hash_dnode_limit) && (mark_method == 3)) {
     1490          /* if vector_header_count is odd, x1 might be the last word of the header */
     1491          force_x1 = (hash_table_vector_header_count & 1) && (memo_dnode == hash_dnode_limit);
     1492          /* was marking header, switch to data */
     1493          hash_dnode_limit = area_dnode(((LispObj *)hashp)
     1494                                        + 1
     1495                                        + header_element_count(hashp->header),
     1496                                        a->low);
     1497          /* In traditional weak method, don't mark vector entries at all. */
     1498          /* Otherwise mark the non-weak elements only */
     1499          mark_method = ((lisp_global(WEAK_GC_METHOD) == 0) ? 0 :
     1500                         ((hashp->flags & nhash_weak_value_mask)
     1501                          ? (1 + (hash_table_vector_header_count & 1))
     1502                          : (2 - (hash_table_vector_header_count & 1))));
     1503        }
     1504       
     1505        if (memo_dnode < hash_dnode_limit) {
     1506          /* perhaps ignore one or both of the elements */
     1507          if (!force_x1 && !(mark_method & 1)) x1 = 0;
     1508          if (!(mark_method & 2)) x2 = 0;
     1509        } else {
     1510          hashp = NULL;
     1511        }
     1512      }
     1513
     1514      if (header_subtag(x1) == subtag_hash_vector) {
     1515        if (hashp) Bug(NULL, "header inside hash vector?");
     1516        hash_table_vector_header *hp = (hash_table_vector_header *)d;
     1517        if (hp->flags & nhash_weak_mask) {
     1518          /* Work around the issue that seems to cause ticket:817,
     1519             which is that tenured hash vectors that are weak on value
     1520             aren't always maintained on GCweakvll.  If they aren't and
     1521             we process them weakly here, nothing will delete the unreferenced
     1522             elements. */
     1523          if (!(hp->flags & nhash_weak_value_mask)) {
     1524            /* If header_count is odd, this cuts off the last header field */
     1525            /* That case is handled specially above */
     1526            hash_dnode_limit = memo_dnode + ((hash_table_vector_header_count) >>1);
     1527            hashp = hp;
     1528            mark_method = 3;
    14481529          }
    1449 
    1450           if (memo_dnode < hash_dnode_limit) {
    1451             /* perhaps ignore one or both of the elements */
    1452             if (!force_x1 && !(mark_method & 1)) x1 = 0;
    1453             if (!(mark_method & 2)) x2 = 0;
    1454           } else {
    1455             hashp = NULL;
    1456           }
    1457         }
    1458 
    1459         if (header_subtag(x1) == subtag_hash_vector) {
    1460           if (hashp) Bug(NULL, "header inside hash vector?");
    1461           hash_table_vector_header *hp = (hash_table_vector_header *)(p - 2);
    1462           if (hp->flags & nhash_weak_mask) {
    1463             /* Work around the issue that seems to cause ticket:817,
    1464                which is that tenured hash vectors that are weak on value
    1465                aren't always maintained on GCweakvll.  If they aren't and
    1466                we process them weakly here, nothing will delete the unreferenced
    1467                elements. */
    1468             if (!(hp->flags & nhash_weak_value_mask)) {
    1469               /* If header_count is odd, this cuts off the last header field */
    1470               /* That case is handled specially above */
    1471               hash_dnode_limit = memo_dnode + ((hash_table_vector_header_count) >>1);
    1472               hashp = hp;
    1473               mark_method = 3;
    1474             }
    1475           }
    1476         }
    1477 
    1478         keep_x1 = mark_ephemeral_root(x1);
    1479         keep_x2 = mark_ephemeral_root(x2);
    1480         if ((keep_x1 == false) &&
    1481             (keep_x2 == false) &&
    1482             (hashp == NULL)) {
    1483           outbits &= ~(BIT0_MASK >> bitidx);
    1484         }
    1485         memo_dnode++;
    1486         bitidx++;
     1530        }
     1531      }
     1532
     1533      keep_x1 = mark_ephemeral_root(x1);
     1534      keep_x2 = mark_ephemeral_root(x2);
     1535      if ((keep_x1 == false) &&
     1536          (keep_x2 == false) &&
     1537          (hashp == NULL)) {
     1538        outbits &= ~(BIT0_MASK >> bitidx);
    14871539      }
    14881540    }
     
    16911743
    16921744    if (GCephemeral_low) {
    1693       mark_memoized_area(tenured_area, area_dnode(a->low,tenured_area->low));
    1694       mark_memoized_area(managed_static_area,managed_static_area->ndnodes);
     1745      mark_memoized_area(tenured_area, area_dnode(a->low,tenured_area->low), tenured_area->refidx);
     1746      mark_memoized_area(managed_static_area,managed_static_area->ndnodes, managed_static_area->refidx);
    16951747    } else {
    1696       mark_managed_static_refs(managed_static_area,low_markable_address,area_dnode(a->active,low_markable_address));
     1748      mark_managed_static_refs(managed_static_area,low_markable_address,area_dnode(a->active,low_markable_address), managed_static_refidx);
    16971749    }
    16981750    other_tcr = tcr;
     
    18271879
    18281880    if (GCephemeral_low) {
    1829       forward_memoized_area(tenured_area, area_dnode(a->low, tenured_area->low), tenured_area->refbits);
    1830       forward_memoized_area(managed_static_area,managed_static_area->ndnodes, managed_static_area->refbits);
     1881      forward_memoized_area(tenured_area, area_dnode(a->low, tenured_area->low), tenured_area->refbits, tenured_area->refidx);
     1882      forward_memoized_area(managed_static_area,managed_static_area->ndnodes, managed_static_area->refbits, managed_static_area->refidx);
    18311883    } else {
    1832       forward_memoized_area(managed_static_area,area_dnode(managed_static_area->active,managed_static_area->low),managed_static_refbits);
     1884      forward_memoized_area(managed_static_area,area_dnode(managed_static_area->active,managed_static_area->low),managed_static_refbits, managed_static_refidx);
    18331885    }
    18341886    a->active = (BytePtr) ptr_from_lispobj(compact_dynamic_heap());
  • trunk/source/lisp-kernel/gc.h

    r15821 r15823  
    6464extern LispObj GCarealow, GCareadynamiclow;
    6565extern natural GCndnodes_in_area, GCndynamic_dnodes_in_area;
    66 extern bitvector GCmarkbits, GCdynamic_markbits,managed_static_refbits,global_refidx,dynamic_refidx;
     66extern bitvector GCmarkbits, GCdynamic_markbits,managed_static_refbits,global_refidx,dynamic_refidx,managed_static_refidx;
    6767LispObj *global_reloctab, *GCrelocptr;
    6868LispObj GCfirstunmarked;
     
    187187void update_locref(LispObj *);
    188188void forward_gcable_ptrs(void);
    189 void forward_memoized_area(area *, natural, bitvector);
     189void forward_memoized_area(area *, natural, bitvector, bitvector);
     190
    190191void forward_tcr_tlb(TCR *);
    191192void reclaim_static_dnodes(void);
     
    220221void mark_cstack_area(area *);
    221222void mark_simple_area_range(LispObj *, LispObj *);
    222 void mark_memoized_area(area *, natural);
     223void mark_memoized_area(area *, natural, bitvector);
    223224LispObj calculate_relocation(void);
    224225void forward_range(LispObj *, LispObj *);
     
    253254did_gc_notification_since_last_full_gc;
    254255
     256
     257
    255258#endif                          /* __GC_H__ */
  • trunk/source/lisp-kernel/image.c

    r15429 r15823  
    282282                   fd)) {
    283283        return;
     284      }
     285      /* Should change image format and store this in the image */
     286      {
     287        natural ndnodes = area_dnode(a->active, a->low), i;
     288        if (!CommitMemory(managed_static_refidx,(((ndnodes +255)>>8)+7)>>3)) {
     289          return;
     290        }
     291        for (i=0; i < ndnodes; i++) {
     292          if (ref_bit(managed_static_refbits,i)) {
     293            set_bit(managed_static_refidx,i>>8);
     294          }
     295        }
    284296      }
    285297      advance += refbits_size;
  • trunk/source/lisp-kernel/lisp_globals.h

    r15815 r15823  
    7979#define MANAGED_STATIC_DNODES (-51) /* ndnodes in managed_static_area */
    8080#define EPHEMERAL_REFIDX      (-52) /* compressed refmap to ephmeral space */
     81#define MANAGED_STATIC_REFIDX (-53) /* compressed refmap from managed static to dynamic */
    8182
    82 
    83 #define MIN_KERNEL_GLOBAL EPHEMERAL_REFIDX
     83#define MIN_KERNEL_GLOBAL MANAGED_STATIC_REFIDX
    8484
    8585/* These are only non-zero when an image is being saved or loaded */
  • trunk/source/lisp-kernel/lisp_globals.s

    r15815 r15823  
    213213         _rnode(managed_static_dnodes) /* ndnodes in managed_static_area */
    214214         _rnode(ephemeral_refidx) /* index of refbits */
     215         _rnode(managed_static_refidx) /* index of managed_static_refbits */
    215216        _ends
    216217
  • trunk/source/lisp-kernel/mach-o-image.c

    r15470 r15823  
    712712  void *lib;
    713713  LispObj image_nil = 0;
     714  natural i;
    714715
    715716  /* Because of the way that we've reserved memory, we can only
     
    843844    CommitMemory(global_mark_ref_bits,align_to_power_of_2(nrefbytes, 12));
    844845    CommitMemory(managed_static_refbits,align_to_power_of_2(nrefbytes, 12));
     846    CommitMemory(managed_static_refidx,(managed_static_area->ndnodes+255)>>3);
    845847    memcpy(managed_static_refbits,ms_end,nrefbytes);
    846848    memset(ms_end,0,nrefbytes);
    847    
     849    for (i = 0; i < managed_static_area->ndnodes; i++) {
     850      if (ref_bit(managed_static_refbits,i)) {
     851        set_bit(managed_static_refidx,i>>8);
     852      }
     853    }
    848854    return image_nil;
    849855  }
  • trunk/source/lisp-kernel/memory.c

    r15821 r15823  
    406406}
    407407
     408void
     409zero_refbits(bitvector refidx, bitvector refbits, natural ndnodes)
     410{
     411  bitvector refbase = refbits, refword, limit = refbase + ((ndnodes + (WORD_SIZE-1)) >> node_shift), reflimit;
     412  natural i, n = (((ndnodes + 255) >> 8) + (WORD_SIZE-1)) >> bitmap_shift, bit, idx;
     413
     414  for (i = 0; i < n; i++, refbase += WORD_SIZE * (256 / WORD_SIZE)) {
     415    idx = *refidx;
     416   
     417    if (idx != 0) {
     418      *refidx = 0;
     419      while (idx) {
     420        bit = count_leading_zeros(idx);
     421        idx &= ~(BIT0_MASK>>bit);
     422        refword = refbase + bit * (256/WORD_SIZE);
     423        reflimit = refword + (256/WORD_SIZE);
     424        if (limit < reflimit) {
     425          reflimit = limit;
     426        }
     427        while (refword < reflimit) {
     428          *refword++ = 0;
     429        }
     430      }
     431    }
     432    refidx++;
     433  }
     434#if 0
     435  /* Check,slowly */
     436  for (i=0;i<ndnodes;i++) {
     437    if (ref_bit(refbits,i)) {
     438      Bug(NULL, "Bit 0x" LISP " set unexpectedly\n", i);
     439    }
     440  }
     441#endif
     442}
     443
    408444
    409445 
     
    654690 
    655691  if (target == tenured_area) {
     692    zero_refbits(global_refidx,managed_static_area->refbits, managed_static_area->ndnodes);
    656693    zero_bits(refbits, new_tenured_dnodes);
    657     zero_bits(managed_static_area->refbits, managed_static_area->ndnodes);
    658     zero_bits(global_refidx, (managed_static_area->ndnodes+255)>>8);
    659694    zero_bits(dynamic_refidx,(new_tenured_dnodes+255)>>8);
    660695    lisp_global(OLDEST_EPHEMERAL) = ptr_to_lispobj(curfree);
     
    890925}
    891926
     927
     928   
     929
     930 
    892931#ifdef DARWIN
    893932/*
  • trunk/source/lisp-kernel/memprotect.h

    r15366 r15823  
    129129
    130130
     131void
     132initialize_refidx_from_refbits(bitvector, bitvector, natural);
    131133 
    132134#endif /* __memprotect_h__ */
  • trunk/source/lisp-kernel/pmcl-kernel.c

    r15820 r15823  
    136136
    137137LispObj lisp_nil = (LispObj) 0;
    138 bitvector global_mark_ref_bits = NULL, dynamic_mark_ref_bits = NULL, relocatable_mark_ref_bits = NULL, global_refidx = NULL, dynamic_refidx = NULL;
     138bitvector global_mark_ref_bits = NULL, dynamic_mark_ref_bits = NULL, relocatable_mark_ref_bits = NULL, global_refidx = NULL, dynamic_refidx = NULL,managed_static_refidx = NULL;
    139139
    140140
     
    597597      exit(1);
    598598    }
     599    managed_static_refidx = ReserveMemory(((((MANAGED_STATIC_SIZE>>dnode_shift)+255)>>8)+7)>>3);
     600    if (managed_static_refidx == NULL) {
     601#ifdef WINDOWS
     602      wperror("allocate refidx for managed static area");
     603#else
     604      perror("allocate refidx for managed static area");
     605#endif
     606      exit(1);
     607    }     
    599608  }
    600609#endif
     
    20792088  }
    20802089  lisp_global(MANAGED_STATIC_REFBITS) = (LispObj)managed_static_refbits;
     2090  lisp_global(MANAGED_STATIC_REFIDX) = (LispObj)managed_static_refidx;
    20812091  lisp_global(MANAGED_STATIC_DNODES) = (LispObj)managed_static_area->ndnodes;
    20822092  atexit(lazarus);
  • trunk/source/lisp-kernel/x86-exceptions.c

    r15816 r15823  
    27682768        if (bitnumber < lisp_global(MANAGED_STATIC_DNODES)) {
    27692769          atomic_set_bit(managed_static_refbits,bitnumber);
     2770          atomic_set_bit(managed_static_refidx,bitnumber>>8);
    27702771          if (need_memoize_root) {
    27712772            atomic_set_bit(managed_static_refbits, rootbitnumber);
     2773            atomic_set_bit(managed_static_refidx,rootbitnumber>>8);
    27722774          }
    27732775        }
  • trunk/source/lisp-kernel/x86-gc.c

    r15821 r15823  
    26882688    *base = start, *prev = start;
    26892689  int tag;
    2690   bitvector refbits = managed_static_refbits;
     2690  bitvector refbits = managed_static_refbits, refidx = managed_static_refidx;
    26912691  natural ref_dnode, node_dnode;
    26922692  Boolean intergen_ref;
     
    27322732        ref_dnode = area_dnode(start, base);
    27332733        set_bit(refbits, ref_dnode);
     2734        set_bit(refidx, ref_dnode>>8);
    27342735      }
    27352736      start += 2;
     
    28382839        CommitMemory(managed_static_area->refbits, refbytes); /* zeros them */
    28392840        CommitMemory(managed_static_refbits,refbytes); /* zeroes them, too */
     2841        CommitMemory(managed_static_refidx,((managed_dnodes+255)>>8)>>3);
    28402842        update_managed_refs(managed_static_area, low_markable_address, area_dnode(a->active,low_markable_address));
    28412843      }
  • trunk/source/lisp-kernel/x86-spentry32.s

    r15816 r15823  
    17481748        __(xorb $31,%imm0_b)
    17491749        __(lock)
     1750        __(btsl %imm0,(%temp0))
     1751        __(ref_global(managed_static_refidx,%temp0))
     1752        __(shrl $8,%imm0)
     1753        __(xorb $31,%imm0_b)
     1754        __(lock)
    17501755        __(btsl %imm0,(%temp0))       
    17511756        __(ret)
     
    17821787        __(lock)
    17831788        __(btsl %imm0,(%temp0))       
     1789        __(ref_global(managed_static_refidx,%temp0))
     1790        __(shrl $8,%imm0)
     1791        __(xorb $31,%imm0_b)
     1792        __(lock)
     1793        __(btsl %imm0,(%temp0))       
    17841794        __(ret)
    17851795_endsubp(rplacd)
     
    18171827        __(lock)
    18181828        __(btsl %imm0,(%temp1))
     1829        __(ref_global(managed_static_refidx,%temp1))
     1830        __(shrl $8,%imm0)
     1831        __(xorb $31,%imm0_b)
     1832        __(lock)
     1833        __(btsl %imm0,(%temp1))       
    18191834        __(ret)
    18201835_endsubp(gvset)
     
    18681883        __(lock)
    18691884        __(btsl %imm0,(%temp1))
     1885        __(ref_global(managed_static_refidx,%temp1))
     1886        __(shrl $8,%imm0)
     1887        __(xorb $31,%imm0_b)
     1888        __(lock)
     1889        __(btsl %imm0,(%temp1))
    18701890        /* Now memoize the address of the hash vector */
     1891        __(ref_global(managed_static_refbits,%temp1))
    18711892        __(movl %temp0,%imm0)
    18721893        __(subl lisp_global(ref_base),%imm0)
     
    18751896        __(lock)
    18761897        __(btsl %imm0,(%temp1))               
     1898        __(ref_global(managed_static_refidx,%temp1))
     1899        __(shrl $8,%imm0)
     1900        __(xorb $31,%imm0_b)
     1901        __(lock)
     1902        __(btsl %imm0,(%temp1))
    18771903        __(ret)
    18781904_endsubp(set_hash_key)
     
    19181944        __(jae 8f)
    19191945        __(ref_global(managed_static_refbits,%arg_y))
     1946        __(xorb $31,%imm0_b)
     1947        __(lock)
     1948        __(btsl %imm0,(%arg_y))
     1949        __(ref_global(managed_static_refidx,%arg_y))
     1950        __(shrl $8,%imm0)
    19201951        __(xorb $31,%imm0_b)
    19211952        __(lock)
     
    19792010        __(lock)
    19802011        __(btsl %imm0,(%arg_y))
     2012        __(ref_global(managed_static_refidx,%arg_y))
     2013        __(shrl $8,%imm0)
     2014        __(xorb $31,%imm0_b)
     2015        __(lock)
     2016        __(btsl %imm0,(%arg_y))
     2017        __(ref_global(managed_static_refbits,%arg_y))
    19812018        /* Now memoize the address of the hash vector */
    19822019        __(movl %temp1,%imm0)
     
    19862023        __(lock)
    19872024        __(btsl %imm0,(%arg_y))
     2025        __(ref_global(managed_static_refidx,%arg_y))
     2026        __(shrl $8,%imm0)
     2027        __(xorb $31,%imm0_b)
     2028        __(lock)
     2029        __(btsl %imm0,(%arg_y))
    19882030        .globl C(egc_write_barrier_end)
    19892031C(egc_write_barrier_end):
  • trunk/source/lisp-kernel/x86-spentry64.s

    r15816 r15823  
    17751775        __(jae 2f)
    17761776        __(ref_global(refbits,%temp0))
    1777         __(xorb $63,%imm0_b)
     1777        __(xorq $63,%imm0)
    17781778        __(lock)
    17791779        __(btsq %imm0,(%temp0))
    17801780        __(ref_global(ephemeral_refidx,%temp0))
    17811781        __(shrq $8,%imm0)
    1782         __(xorb $63,%imm0_b)
     1782        __(xorq $63,%imm0)
    17831783        __(lock)
    17841784        __(btsq %imm0,(%temp0))
     
    17861786        __(jae 0b)
    17871787        __(ref_global(managed_static_refbits,%temp0))
    1788         __(xorb $63,%imm1_b)
     1788        __(xor $63,%imm1)
    17891789        __(lock)
     1790        __(btsq %imm1,(%temp0))
     1791        __(shrq $8,%imm1)
     1792        __(ref_global(managed_static_refidx,%temp0))
     1793        __(xorb $63,(%temp0))
    17901794        __(btsq %imm1,(%temp0))
    17911795        __(ret)
     
    18071811        __(jae 2f)
    18081812        __(ref_global(refbits,%temp0))
    1809         __(xorb $63,%imm0_b)
     1813        __(xorq $63,%imm0)
    18101814        __(lock)
    18111815        __(btsq %imm0,(%temp0))
    18121816        __(ref_global(ephemeral_refidx,%temp0))
    18131817        __(shrq $8,%imm0)
    1814         __(xorb $63,%imm0_b)
     1818        __(xorq $63,%imm0)
    18151819        __(lock)
    18161820        __(btsq %imm0,(%temp0))
     
    18181822        __(jae 0b)
    18191823        __(ref_global(managed_static_refbits,%temp0))
    1820         __(xorb $63,%imm1_b)
     1824        __(xor $63,%imm1)
     1825        __(lock)
     1826        __(btsq %imm1,(%temp0))
     1827        __(shrq $8,%imm1)
     1828        __(ref_global(managed_static_refidx,%temp0))
     1829        __(xorb $63,(%temp0))
    18211830        __(lock)
    18221831        __(btsq %imm1,(%temp0))
     
    18421851        __(jae 2f)
    18431852        __(ref_global(refbits,%temp0))
    1844         __(xorb $63,%imm0_b)
     1853        __(xorq $63,%imm0)
    18451854        __(lock)
    18461855        __(btsq %imm0,(%temp0))
    18471856        __(ref_global(ephemeral_refidx,%temp0))
    18481857        __(shrq $8,%imm0)
    1849         __(xorb $63,%imm0_b)
     1858        __(xorq $63,%imm0)
    18501859        __(lock)
    18511860        __(btsq %imm0,(%temp0))
     
    18531862        __(jae 0b)
    18541863        __(ref_global(managed_static_refbits,%temp0))
    1855         __(xorb $63,%imm1_b)
     1864        __(xor $63,%imm1)
    18561865        __(lock)
    18571866        __(btsq %imm1,(%temp0))       
     1867        __(shrq $8,%imm1)
     1868        __(ref_global(managed_static_refidx,%temp0))
     1869        __(xor $63,%imm1)
     1870        __(lock)
     1871        __(btsq %imm1,(%temp0))
    18581872        __(ret)               
    18591873_endsubp(gvset)
     
    18791893        __(jae 2f)
    18801894        __(ref_global(refbits,%temp0))
    1881         __(xorb $63,%imm0_b)
     1895        __(xorq $63,%imm0)
    18821896        __(lock)
    18831897        __(btsq %imm0,(%temp0))
    18841898        __(ref_global(ephemeral_refidx,%temp0))
    18851899        __(shrq $8,%imm0)
    1886         __(xorb $63,%imm0_b)
     1900        __(xorq $63,%imm0)
    18871901        __(lock)
    18881902        __(btsq %imm0,(%temp0))
     
    18921906        __(subq lisp_global(ref_base),%imm0)
    18931907        __(shrq $dnode_shift,%imm0)
    1894         __(xorb $63,%imm0_b)
     1908        __(xorq $63,%imm0)
    18951909        __(lock)
    18961910        __(btsq %imm0,(%temp0))
    18971911        __(ref_global(ephemeral_refidx,%temp0))
    18981912        __(shrq $8,%imm0)
    1899         __(xorb $63,%imm0_b)
     1913        __(xorq $63,%imm0)
    19001914        __(lock)
    19011915        __(btsq %imm0,(%temp0))
     
    19031917        __(jae 0b)
    19041918        __(ref_global(managed_static_refbits,%temp0))
    1905         __(xorb $63,%imm1_b)
     1919        __(xor $63,%imm1)
    19061920        __(lock)
    19071921        __(btsq %imm1,(%temp0))
     
    19101924        __(subq lisp_global(ref_base),%imm0)
    19111925        __(shrq $dnode_shift,%imm0)
    1912         __(xorb $63,%imm0_b)
     1926        __(xorq $63,%imm0)
    19131927        __(lock)
    19141928        __(btsq %imm0,(%temp0))
     1929        __(ref_global(managed_static_refidx,%temp0))
     1930        __(shrq $8,%imm0)
     1931        __(xorq $63,%imm0)
     1932        __(lock)
     1933        __(btsq %imm0,(%temp0))
     1934        __(shrq $8,%imm1)
     1935        __(xor $63,%imm1)
     1936        __(lock)
     1937        __(btsq %imm1,(%temp0))
    19151938        __(ret)
    19161939_endsubp(set_hash_key)
     
    19411964        __(ref_global(refbits,%temp1))
    19421965        __(jae 2f)
    1943         __(xorb $63,%imm0_b)
     1966        __(xorq $63,%imm0)
    19441967        __(lock)
    19451968        __(btsq %imm0,(%temp1))
    19461969        __(shrq $8,%imm0)
    19471970        __(ref_global(ephemeral_refidx,%temp1))
    1948         __(xorb $63,%imm0_b)
     1971        __(xorq $63,%imm0)
    19491972        __(lock)
    19501973        __(btsq %imm0,(%temp1))
     
    19521975        __(jae 8f)
    19531976        __(ref_global(managed_static_refbits,%temp1))
    1954         __(xorb $63,%imm1_b)
     1977        __(xor $63,%imm1)
    19551978        __(lock)
    1956         __(btsq %imm1,(%temp1))       
     1979        __(btsq %imm1,(%temp1))   
     1980        __(ref_global(managed_static_refidx,%temp1))
     1981        __(shrq $8,%imm1)
     1982        __(xor $63,%imm1)
     1983        __(lock)
     1984        __(btsq %imm1,(%temp1))   
    19571985        .globl C(egc_store_node_conditional_success_end)
    19581986C(egc_store_node_conditional_success_end):
     
    19822010        __(ref_global(refbits,%temp1))
    19832011        __(jae 2f)
    1984         __(xorb $63,%imm0_b)
     2012        __(xorq $63,%imm0)
    19852013        __(lock)
    19862014        __(btsq %imm0,(%temp1))
    19872015        __(shrq $8,%imm0)
    1988         __(xorb $63,%imm0_b)
     2016        __(xorq $63,%imm0)
    19892017        __(ref_global(ephemeral_refidx,%temp1))
    19902018        __(lock)
     
    19952023        __(ref_global(refbits,%temp1))
    19962024        __(shrq $dnode_shift,%imm0)
    1997         __(xorb $63,%imm0_b)
     2025        __(xorq $63,%imm0)
    19982026        __(lock)
    19992027        __(btsq %imm0,(%temp1))
    20002028        __(shrq $8,%imm0)
    2001         __(xorb $63,%imm0_b)
     2029        __(xorq $63,%imm0)
    20022030        __(ref_global(ephemeral_refidx,%temp1))
    20032031        __(lock)
     
    20062034        __(jae 8f)
    20072035        __(ref_global(managed_static_refbits,%temp1))
    2008         __(xorb $63,%imm1_b)
     2036        __(xor $63,%imm1)
    20092037        __(lock)
    20102038        __(btsq %imm1,(%temp1))
     
    20132041        __(subq lisp_global(ref_base),%imm0)
    20142042        __(shrq $dnode_shift,%imm0)
    2015         __(xorb $63,%imm0_b)
     2043        __(xorq $63,%imm0)
     2044        __(lock)
     2045        __(btsq %imm0,(%temp1))
     2046        __(ref_global(managed_static_refidx,%temp1))
     2047        __(shrq $8,%imm1)
     2048        __(xor $63,%imm1)
     2049        __(lock)
     2050        __(btsq %imm1,(%temp1))
     2051        __(shrq $8,%imm0)
     2052        __(xorq $63,%imm0)
    20162053        __(lock)
    20172054        __(btsq %imm0,(%temp1))
Note: See TracChangeset for help on using the changeset viewer.