Back to index

plt-scheme  4.2.1
var_stack.c
Go to the documentation of this file.
00001 
00002 void GC_X_variable_stack(void **var_stack, long delta, void *limit, void *stack_mem)
00003 {
00004   long size, count;
00005   void ***p, **a;
00006 
00007 #if TIME
00008   stack_depth = 0;
00009 #endif
00010 
00011   while (var_stack) {
00012     var_stack = (void **)((char *)var_stack + delta);
00013 
00014     size = *(long *)(var_stack + 1);
00015     p = (void ***)(var_stack + 2);
00016 
00017 #if CHECKS
00018     oo_var_stack = o_var_stack;
00019     o_var_stack = var_stack;
00020 #endif
00021 
00022     if ((var_stack == limit)
00023        || (var_stack + size + 2 == limit)) {
00024       /* Last frame: need to X things that are shallower than the
00025         limit: */
00026      
00027       while (size--) {
00028        a = *p;
00029        if (!a) {
00030          /* Array */
00031          count = ((long *)p)[2];
00032          a = ((void ***)p)[1];
00033          p += 2;
00034          size -= 2;
00035          a = (void **)((char *)a + delta);
00036          if (SHALLOWER_STACK_ADDRESS(a, limit)) {
00037            while (count--) {
00038              X_source(stack_mem, a);
00039              gcX(a);
00040              a++;
00041            }
00042          }
00043        } else {
00044          a = (void **)((char *)a + delta);
00045          if (SHALLOWER_STACK_ADDRESS(a, limit)) {
00046            X_source(stack_mem, a);
00047            gcX(a);
00048          }
00049        }
00050        p++;
00051       }
00052 
00053       return;
00054     }
00055 
00056     while (size--) {
00057       a = *p;
00058       if (!a) {
00059        /* Array */
00060        count = ((long *)p)[2];
00061        a = ((void ***)p)[1];
00062        p += 2;
00063        size -= 2;
00064        a = (void **)((char *)a + delta);
00065        while (count--) {
00066          X_source(stack_mem, a);
00067          gcX(a);
00068          a++;
00069        }
00070       } else {
00071        a = (void **)((char *)a + delta);
00072        X_source(stack_mem, a);
00073        gcX(a);
00074       }
00075       p++;
00076     }
00077 
00078     var_stack = *var_stack;
00079 
00080 #if TIME
00081     stack_depth++;
00082 #endif
00083   }
00084 }