Changeset 8369
- Timestamp:
- Jan 29, 2008, 5:50:19 PM (17 years ago)
- Location:
- trunk/source/lisp-kernel
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/lisp-kernel/gc-common.c
r8245 r8369 89 89 natural GCndnodes_in_area = 0, GCndynamic_dnodes_in_area = 0; 90 90 LispObj GCweakvll = (LispObj)NULL; 91 LispObj GCdwsweakvll = (LispObj)NULL; 91 92 LispObj GCephemeral_low = 0; 92 93 natural GCn_ephemeral_dnodes = 0; … … 210 211 dnode, 211 212 npairs = (header_element_count(hashp->header) - 212 ( (sizeof(hash_table_vector_header)/sizeof(LispObj))-1)) >> 1;213 (hash_table_vector_header_count -1)) >> 1; 213 214 LispObj *pairp = (LispObj*) (hashp+1), weakelement; 214 215 Boolean … … 235 236 pairp += 2; 236 237 } 237 } 238 238 } 239 240 void 241 traditional_dws_mark_htabv(LispObj htabv) 242 { 243 /* Do nothing, just add htabv to GCweakvll */ 244 LispObj *base = (LispObj *) ptr_from_lispobj(untag(htabv)); 245 246 deref(base,1) = GCweakvll; 247 GCweakvll = htabv; 248 } 249 250 void 251 ncircle_dws_mark_htabv(LispObj htabv) 252 { 253 /* Do nothing, just add htabv to GCdwsweakvll */ 254 LispObj *base = (LispObj *) ptr_from_lispobj(untag(htabv)); 255 256 deref(base,1) = GCdwsweakvll; 257 GCdwsweakvll = htabv; 258 } 259 260 void 261 traditional_mark_weak_htabv(LispObj htabv) 262 { 263 int i, skip = hash_table_vector_header_count;; 264 265 for (i = 2; i <= skip; i++) { 266 rmark(deref(htabv,i)); 267 } 268 269 deref(htabv,1) = GCweakvll; 270 GCweakvll = htabv; 271 } 272 273 void 274 ncircle_mark_weak_htabv(LispObj htabv) 275 { 276 int i, skip = hash_table_vector_header_count;; 277 hash_table_vector_header *hashp = (hash_table_vector_header *)(untag(htabv)); 278 natural 279 dnode, 280 npairs = (header_element_count(hashp->header) - 281 (hash_table_vector_header_count - 1)) >> 1; 282 LispObj *pairp = (LispObj*) (hashp+1), weakelement; 283 Boolean 284 weak_on_value = ((hashp->flags & nhash_weak_value_mask) != 0); 285 bitvector markbits = GCmarkbits; 286 int tag; 287 288 for (i = 2; i <= skip; i++) { 289 rmark(deref(htabv,i)); 290 } 291 292 if (!weak_on_value) { 293 pairp++; 294 } 295 /* unconditionally mark the non-weak element of each pair */ 296 while (npairs--) { 297 rmark(*pairp); 298 pairp += 2; 299 } 300 301 deref(htabv,1) = GCweakvll; 302 GCweakvll = htabv; 303 } 239 304 240 305 … … 249 314 weak_value = ((flags & nhash_weak_value_mask) != 0); 250 315 int 251 skip = (sizeof(hash_table_vector_header)/sizeof(LispObj))-1,316 skip = hash_table_vector_header_count-1, 252 317 key_tag, 253 318 val_tag, … … 351 416 352 417 void 353 markhtabvs()418 traditional_markhtabvs() 354 419 { 355 420 LispObj this, header, pending; … … 389 454 marked_new = true; 390 455 } 391 } else {392 deref(this,1) = (LispObj)NULL;393 for (i = 2; i <= elements; i++) {394 mark_root(deref(this,i));395 }396 456 } 397 457 } else { … … 440 500 441 501 void 502 ncircle_markhtabvs() 503 { 504 LispObj this, header, pending = 0; 505 int subtag; 506 bitvector markbits = GCmarkbits; 507 hash_table_vector_header *hashp; 508 Boolean marked_new; 509 510 /* First, process any weak hash tables that may have 511 been encountered by the link-inverting marker; we 512 should have more stack space now. */ 513 514 while (GCdwsweakvll) { 515 this = GCdwsweakvll; 516 GCdwsweakvll = deref(this,1); 517 ncircle_mark_weak_htabv(this); 518 } 519 520 while (GCweakvll) { 521 this = GCweakvll; 522 GCweakvll = deref(this,1); 523 524 header = header_of(this); 525 subtag = header_subtag(header); 526 527 if (subtag == subtag_weak) { 528 natural weak_type = deref(this,2); 529 deref(this,1) = pending; 530 pending = this; 531 if ((weak_type & population_type_mask) == population_weak_alist) { 532 if (mark_weak_alist(this, weak_type)) { 533 marked_new = true; 534 } 535 } 536 } else if (subtag == subtag_hash_vector) { 537 reaphashv(this); 538 } 539 } 540 541 /* Now, everything's marked that's going to be, and "pending" is a list 542 of populations. CDR down that list and free 543 anything that isn't marked. 544 */ 545 546 while (pending) { 547 this = pending; 548 pending = deref(this,1); 549 deref(this,1) = (LispObj)NULL; 550 551 subtag = header_subtag(header_of(this)); 552 if (subtag == subtag_weak) { 553 reapweakv(this); 554 } else { 555 Bug(NULL, "Bad object on pending list: %s\n", this); 556 } 557 } 558 559 /* Finally, mark the termination lists in all terminatable weak vectors 560 They are now linked together on GCweakvll. 561 This is where to store lisp_global(TERMINATION_LIST) if we decide to do that, 562 but it will force terminatable popualations to hold on to each other 563 (set TERMINATION_LIST before clearing GCweakvll, and don't clear deref(this,1)). 564 */ 565 pending = GCweakvll; 566 GCweakvll = (LispObj)NULL; 567 while (pending) { 568 this = pending; 569 pending = deref(this,1); 570 deref(this,1) = (LispObj)NULL; 571 mark_root(deref(this,1+3)); 572 } 573 } 574 575 void 442 576 mark_tcr_tlb(TCR *tcr) 443 577 { … … 568 702 } 569 703 return c; 704 } 705 706 weak_mark_fun dws_mark_weak_htabv = traditional_dws_mark_htabv; 707 weak_mark_fun mark_weak_htabv = traditional_mark_weak_htabv; 708 weak_process_fun markhtabvs = traditional_markhtabvs; 709 710 void 711 install_weak_mark_functions(int set) { 712 switch(set) { 713 case 0: 714 default: 715 dws_mark_weak_htabv = traditional_dws_mark_htabv; 716 mark_weak_htabv = traditional_mark_weak_htabv; 717 markhtabvs = traditional_markhtabvs; 718 break; 719 case 1: 720 dws_mark_weak_htabv = ncircle_dws_mark_htabv; 721 mark_weak_htabv = ncircle_mark_weak_htabv; 722 markhtabvs = ncircle_markhtabvs; 723 break; 724 } 570 725 } 571 726 … … 834 989 #endif 835 990 991 int weak_hash_toggle = 0; 992 836 993 void 837 994 gc(TCR *tcr, signed_natural param) … … 849 1006 TCR *other_tcr; 850 1007 natural static_dnodes; 1008 1009 install_weak_mark_functions(weak_hash_toggle); 1010 weak_hash_toggle = 1 - weak_hash_toggle; 851 1011 852 1012 #ifndef FORCE_DWS_MARK -
trunk/source/lisp-kernel/gc.h
r8245 r8369 147 147 LispObj GCarealow, GCareadynamiclow; 148 148 natural GCndnodes_in_area, GCndynamic_dnodes_in_area; 149 LispObj GCweakvll ;149 LispObj GCweakvll,GCdwsweakvll; 150 150 LispObj GCephemeral_low; 151 151 natural GCn_ephemeral_dnodes; … … 165 165 Boolean mark_weak_hash_vector(hash_table_vector_header *hashp, natural elements); 166 166 Boolean mark_weak_alist(LispObj weak_alist, int weak_type); 167 void markhtabvs(void);168 167 void mark_tcr_tlb(TCR *); 169 168 void mark_tcr_xframes(TCR *); … … 185 184 /* backend-interface */ 186 185 186 typedef void (*weak_mark_fun) (LispObj); 187 weak_mark_fun mark_weak_htabv, dws_mark_weak_htabv; 188 189 typedef void (*weak_process_fun)(void); 190 191 weak_process_fun markhtabvs; 192 193 194 #define hash_table_vector_header_count (sizeof(hash_table_vector_header)/sizeof(LispObj)) 195 187 196 void mark_root(LispObj); 197 void rmark(LispObj); 188 198 void mark_xp(ExceptionInformation *); 189 199 LispObj dnode_forwarding_address(natural, int); -
trunk/source/lisp-kernel/x86-gc.c
r8248 r8369 325 325 ((hash_table_vector_header *) base)->cache_key = undefined; 326 326 ((hash_table_vector_header *) base)->cache_value = lisp_nil; 327 deref(ptr_to_lispobj(base),1) = GCweakvll; 328 GCweakvll = n; 327 mark_weak_htabv(n); 329 328 return; 330 329 } … … 494 493 ((hash_table_vector_header *) base)->cache_key = undefined; 495 494 ((hash_table_vector_header *) base)->cache_value = lisp_nil; 496 deref(ptr_to_lispobj(base),1) = GCweakvll; 497 GCweakvll = n; 495 mark_weak_htabv(n); 498 496 return; 499 497 } … … 734 732 ((hash_table_vector_header *) base)->cache_key = undefined; 735 733 ((hash_table_vector_header *) base)->cache_value = lisp_nil; 736 deref(ptr_to_lispobj(base),1) = GCweakvll; 737 GCweakvll = this; 738 goto Climb; 734 dws_mark_weak_htabv(this); 735 element_count = hash_table_vector_header_count; 739 736 } 740 737 } … … 998 995 ((hash_table_vector_header *) start)->cache_key = undefined; 999 996 ((hash_table_vector_header *) start)->cache_value = lisp_nil; 1000 start[1] = GCweakvll; 1001 GCweakvll = (LispObj) (((natural) start) + fulltag_misc); 997 mark_weak_htabv((LispObj)start); 1002 998 element_count = 0; 1003 999 } … … 1295 1291 if ((header_subtag(node) == subtag_hash_vector) && 1296 1292 ((((hash_table_vector_header *)p)->flags) & nhash_track_keys_mask)) { 1297 natural skip = (sizeof(hash_table_vector_header)/sizeof(LispObj))-1;1293 natural skip = hash_table_vector_header_count-1; 1298 1294 hashp = (hash_table_vector_header *) p; 1299 1295 p++;
Note:
See TracChangeset
for help on using the changeset viewer.
