[clean up gc code, rearrange some tests
John Meacham <john@repetae.net>**20100328223243
 Ignore-this: 654cf92de7199b56d1ca6a0eeb5d6e20
] hunk ./src/data/rts/jhc_jgc.h 41
+#define GC_ALIGNMENT (2*sizeof(void *))
hunk ./src/data/rts/jhc_jgc.h 46
-//typedef struct frame *gc_t;
hunk ./src/data/rts/jhc_jgc.h 56
-static void gc_print_stats(gc_t gc);
hunk ./src/data/rts/jhc_jgc.h 102
-                int r;
-                J1S(r,gc_roots,((Word_t)root / GC_BASE) - 1 );
+                int r; J1S(r,gc_roots,(((Word_t)root - sizeof(entry_t)) / GC_ALIGNMENT));
hunk ./src/data/rts/jhc_jgc.h 108
-static bool
-gc_del_root(gc_t gc, void *root)
-{
-        if(SHOULD_FOLLOW(root)) {
-                int r;
-                J1U(r,gc_roots,((Word_t)root / GC_BASE) - 1);
-                return (bool)r;
-        } else
-                return false;
-}
hunk ./src/data/rts/jhc_jgc.h 109
-static void
-gc_print_stats(gc_t gc)
-{
-        Word_t n_allocated,n_roots;
-        J1C(n_allocated,gc_allocated,0,-1);
-        J1C(n_roots,gc_roots,0,-1);
-        fprintf(stderr,"allocated: %5lu roots: %3lu mem_inuse: %5lu heap_threshold: %5lu gcs: %3u\n",n_allocated,n_roots,(long unsigned)mem_inuse,(long unsigned)heap_threshold,number_gcs);
-}
-
hunk ./src/data/rts/jhc_jgc.h 120
-        while(s->size - s->ptr <= n) {
-                s->size += 4096;
+        if(__predict_false(s->size - s->ptr < n)) {
+                s->size += 1024 + n;
hunk ./src/data/rts/jhc_jgc.h 124
-                debugf(stderr, "stack:");
+                debugf("stack:");
hunk ./src/data/rts/jhc_jgc.h 126
-                        debugf(stderr, " %p", (void *)s->stack[i]);
+                        debugf(" %p", (void *)s->stack[i]);
hunk ./src/data/rts/jhc_jgc.h 128
-                debugf(stderr, "\n");
+                debugf("\n");
hunk ./src/data/rts/jhc_jgc.h 150
-                debugf(" %p",(void *)(ix * GC_BASE));
-                stack.stack[stack.ptr++] = ix*GC_BASE;
-                int d; J1S(d,gc_grey,ix);
+                debugf(" %p", (void *)(ix * GC_ALIGNMENT));
+                J1U(r, gc_allocated, ix);
+                if(r) {
+                        J1S(r, gc_grey, ix);
+                        if(r)
+                                stack.stack[stack.ptr++] = (uintptr_t)ix * GC_ALIGNMENT;
+                }
hunk ./src/data/rts/jhc_jgc.h 166
-                        if(__predict_false(!SHOULD_FOLLOW(gc->ptrs[i]))) {
+                        sptr_t ptr = gc->ptrs[i];
+                        if(P_LAZY == GET_PTYPE(ptr)) {
+                                if(!IS_LAZY(GETHEAD(FROM_SPTR(ptr)))) {
+                                        J1U(r,gc_allocated,((uintptr_t)FROM_SPTR(ptr) - sizeof(entry_t))/GC_ALIGNMENT);
+                                        if(r)
+                                                J1S(r,gc_grey,((uintptr_t)FROM_SPTR(ptr) - sizeof(entry_t))/GC_ALIGNMENT);
+                                        number_redirects++;
+                                        debugf(" *");
+                                        ptr = GETHEAD(FROM_SPTR(ptr));
+                                }
+                        }
+                        if(__predict_false(!SHOULD_FOLLOW(ptr))) {
hunk ./src/data/rts/jhc_jgc.h 182
-                        entry_t *e = (entry_t *)FROM_SPTR(gc->ptrs[i]) - 1;
+                        entry_t *e = (entry_t *)FROM_SPTR(ptr) - 1;
hunk ./src/data/rts/jhc_jgc.h 184
-                        int d; J1S(d,gc_grey,(Word_t)e / GC_BASE);
-                        if(d)
-                                stack.stack[stack.ptr++] = (uintptr_t)e;
+                        ix = (Word_t)e / GC_ALIGNMENT;
+                        J1U(r,gc_allocated,ix);
+                        if(r) {
+                                J1S(r,gc_grey,ix);
+                                if(r)
+                                        stack.stack[stack.ptr++] = (uintptr_t)ix * GC_ALIGNMENT;
+                        }
hunk ./src/data/rts/jhc_jgc.h 196
-                uintptr_t ix = stack.stack[--stack.ptr] / GC_BASE;
-                J1T(r,gc_grey,ix);
-                assert(r);
-                debugf("Processing Grey: %p ",(void *)(ix * GC_BASE));
-                J1U(r,gc_allocated,ix);
-                if(__predict_false(r == 0)) {
-                        J1U(r,gc_grey,ix);
-                        debugf("Skipping.\n");
-                        continue;
-                }
-                debugf("Blackening\n");
-                //J1S(r,gc_black,ix);
+                uintptr_t ix = stack.stack[--stack.ptr] / GC_ALIGNMENT;
+                //J1T(r,gc_grey,ix);
+                //assert(r);
+                debugf("Processing Grey: %p\n",(void *)(ix * GC_ALIGNMENT));
hunk ./src/data/rts/jhc_jgc.h 201
-                entry_t *e = (entry_t *)(ix * GC_BASE);
+                entry_t *e = (entry_t *)(ix * GC_ALIGNMENT);
hunk ./src/data/rts/jhc_jgc.h 215
-                                Word_t p = (Word_t)ptr / GC_BASE;
-                                int d;
-                                J1S(d,gc_grey,p);
-                                if(d)
-                                        stack.stack[stack.ptr++] = (uintptr_t)ptr;
+                                Word_t ix = (Word_t)ptr / GC_ALIGNMENT;
+                                J1U(r,gc_allocated,ix);
+                                if(r) {
+                                        J1S(r,gc_grey,ix);
+                                        if(r)
+                                                stack.stack[stack.ptr++] = (uintptr_t)ix * GC_ALIGNMENT;
+                                }
hunk ./src/data/rts/jhc_jgc.h 227
-                entry_t *e = (entry_t *)(ix * GC_BASE);
+                entry_t *e = (entry_t *)(ix * GC_ALIGNMENT);
hunk ./src/data/rts/jhc_jgc.h 234
-#if JGC_STATUS
-        fprintf(stderr, "Ss: %5u Ps: %5u Rs: %5u As: %5u ", number_stack, number_ptr, number_redirects, number_allocs);
-        gc_print_stats(gc);
-#endif
+        if(JGC_STATUS) {
+                fprintf(stderr, "Ss: %5u Ps: %5u Rs: %5u As: %5u ", number_stack, number_ptr, number_redirects, number_allocs);
+                Word_t n_allocated,n_roots;
+                J1C(n_allocated,gc_allocated,0,-1);
+                J1C(n_roots,gc_roots,0,-1);
+                fprintf(stderr,"allocated: %5lu roots: %3lu mem_inuse: %5lu heap_threshold: %5lu gcs: %3u\n",n_allocated,n_roots,(long unsigned)mem_inuse,(long unsigned)heap_threshold,number_gcs);
+        }
hunk ./src/data/rts/jhc_jgc.h 265
-        int r; J1S(r,gc_allocated,(Word_t)e / GC_BASE);
+        int r; J1S(r,gc_allocated,(Word_t)e / GC_ALIGNMENT);