Index: /branches/ia32/lisp-kernel/x86-gc.c
===================================================================
--- /branches/ia32/lisp-kernel/x86-gc.c	(revision 9458)
+++ /branches/ia32/lisp-kernel/x86-gc.c	(revision 9459)
@@ -50,14 +50,4 @@
 #endif
 
-int
-function_code_words(LispObj *f)
-{
-#ifdef X8664
-  return (int)f[1];
-#else
-  return (unsigned short)f[1];
-#endif
-}
-
 void
 comma_output_decimal(char *buf, int len, natural n) 
@@ -155,7 +145,6 @@
       LispObj fun;
 
-      if (*((unsigned char *)n) == RECOVER_FN_OPCODE) {
-	fun = (LispObj)(*((natural *)(n + 1)));
-      }
+      if (*(unsigned char *)n == RECOVER_FN_OPCODE)
+	fun = *(LispObj *)(n + 1);
       if (fun == 0 ||
 	 (header_subtag(header_of(fun)) != subtag_function) ||
@@ -368,8 +357,6 @@
 #ifdef X8632
   if (tag_n == fulltag_tra) {
-    unsigned char *p = (unsigned char *)n;
-
-    if (*p == RECOVER_FN_OPCODE) {
-      n = *(LispObj *)(p + 1);
+    if (*(unsigned char *)n == RECOVER_FN_OPCODE) {
+      n = *(LispObj *)(n + 1);
       tag_n = fulltag_misc;
     } else
@@ -495,5 +482,4 @@
 	prefix_nodes = (natural) ((int) deref(base,1));
 #endif
-	prefix_nodes = (natural)function_code_words(base);
         if (prefix_nodes > element_count) {
           Bug(NULL, "Function 0x%lx trashed",n);
@@ -575,11 +561,10 @@
 #ifdef X8632
   if (tag_n == fulltag_tra) {
-    unsigned char *p = (unsigned char *)n;
-
-    if (*p == RECOVER_FN_OPCODE) {
-      n = *(LispObj *)(p + 1);
+    if (*(unsigned char *)n == RECOVER_FN_OPCODE) {
+      n = *(LispObj *)(n + 1);
       tag_n = fulltag_misc;
-    } else
+    } else {
       return;
+    }
   }
 #endif
@@ -720,4 +705,7 @@
     }
   } else {
+#ifdef X8632
+    fprintf(stderr, "probably in trouble here\n");
+#endif
     /* This is all a bit more complicated than the PPC version:
 
@@ -910,6 +898,5 @@
 #else
     if (tag_n == fulltag_tra) {
-      unsigned char *p = (unsigned char *)n;
-      LispObj fn = *(LispObj *)(p + 1);
+      LispObj fn = *(LispObj *)(n + 1);
 
       base = (LispObj *)untag(fn);
@@ -1739,9 +1726,8 @@
   int i;
 
-  for (i = 0; i < 8; i ++) {
-    if (node_regs_mask & (1<<i)) {
+  for (i = 0; i < 8; i++)
+    if (node_regs_mask & (1<<i))
       mark_root(regs[i]);
-    }
-  }
+
   /* If the EIP isn't pointing into a marked function, we're probably
      in trouble.  We can -maybe- recover from that if it's tagged as a
@@ -1755,9 +1741,9 @@
     } else if ((fulltag_of(eip) == fulltag_misc) &&
                (header_subtag(header_of(eip)) == subtag_function) &&
-               (*((unsigned char *)(eip)) == RECOVER_FN_OPCODE) &&
-	       ((LispObj)(*((natural *)(eip + 1))) == eip)) {
+               (*(unsigned char *)eip == RECOVER_FN_OPCODE) &&
+	       (*(LispObj *)(eip + 1)) == eip) {
       mark_root(eip);
     } else {
-      Bug(NULL, "Can't find function for eip 0x%8x", eip);
+      Bug(NULL, "Can't find function for eip 0x%4x", eip);
     }
   }
@@ -1803,4 +1789,11 @@
 #endif
   }
+#ifdef X8632
+  mark_root(tcr->save0);
+  mark_root(tcr->save1);
+  mark_root(tcr->save2);
+  mark_root(tcr->save3);
+  mark_root(tcr->next_method_context);
+#endif
   
   for (xframes = (xframe_list *) tcr->xframe; 
@@ -1810,15 +1803,7 @@
       mark_xp(xframes->curr);
 #else
-      mark_xp(xframes->curr, tcr->node_regs_mask);
-#endif
-  }
-
-#ifdef X8632
-  mark_root(tcr->save0);
-  mark_root(tcr->save1);
-  mark_root(tcr->save2);
-  mark_root(tcr->save3);
-  mark_root(tcr->next_method_context);
-#endif
+      mark_xp(xframes->curr, xframes->node_regs_mask);
+#endif
+  }
 }
       
@@ -2050,5 +2035,5 @@
 }
 #else
-
+#ifdef X8664
 /* Quicker, dirtier */
 LispObj
@@ -2076,4 +2061,51 @@
   return new;
 }
+#endif
+#ifdef X8632
+LispObj
+dnode_forwarding_address(natural dnode, int tag_n)
+{
+  natural pagelet, nbits;
+  unsigned short near_bits;
+  LispObj new;
+
+  if (GCDebug) {
+    if (! ref_bit(GCdynamic_markbits, dnode)) {
+      Bug(NULL, "unmarked object being forwarded!\n");
+    }
+  }
+
+  pagelet = dnode >> 5;
+  nbits = dnode & 0x1f;
+  near_bits = ((unsigned short *)GCdynamic_markbits)[dnode>>4];
+
+  if (nbits < 16) {
+    new = GCrelocptr[pagelet] + tag_n;;
+    /* Increment "new" by the count of 1 bits which precede the dnode */
+    if (near_bits == 0xffff) {
+      return (new + (nbits << 3));
+    } else {
+      near_bits &= (0xffff0000 >> nbits);
+      if (nbits > 7) {
+        new += one_bits(near_bits & 0xff);
+      }
+      return (new + (one_bits(near_bits >> 8))); 
+    }
+  } else {
+    new = GCrelocptr[pagelet+1] + tag_n;
+    nbits = 32-nbits;
+
+    if (near_bits == 0xffff) {
+      return (new - (nbits << 3));
+    } else {
+      near_bits &= (1<<nbits)-1;
+      if (nbits > 7) {
+        new -= one_bits(near_bits >> 8);
+      }
+      return (new - one_bits(near_bits & 0xff));
+    }
+  }
+}
+#endif
 #endif
 
@@ -2338,5 +2370,4 @@
 }
 
-
 void
 forward_xp(ExceptionInformation *xp)
@@ -2357,6 +2388,14 @@
   update_noderef(&(regs[Itemp2]));
   update_locref(&(regs[Iip]));
-#endif
-}
+#else
+  update_noderef(&(regs[Iarg_z]));
+  update_noderef(&(regs[Iarg_y]));
+  update_noderef(&(regs[Ifn]));
+  update_noderef(&(regs[Itemp0]));
+  update_noderef(&(regs[Itemp1]));
+  update_locref(&(regs[Iip]));
+#endif
+}
+
 
 void
@@ -2620,7 +2659,5 @@
         }
       }
-  
-    }
-
+    }
   }
   return ptr_to_lispobj(dest);
@@ -3339,5 +3376,5 @@
           if (header_subtag(header) == subtag_function) {
 #ifdef X8632
-            int skip = (int)((unsigned short*)start[2]);
+            int skip = (unsigned short)(start[1]);
 #else
             int skip = (int)(start[1]);
