Blob Blame Raw
Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 gcl (2.6.12-6) unstable; urgency=medium
 .
   * Version_2_6_13pre5
Author: Camm Maguire <camm@debian.org>

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

--- gcl-2.6.12.orig/o/alloc.c
+++ gcl-2.6.12/o/alloc.c
@@ -254,8 +254,10 @@ empty_relblock(void) {
   object o=sSAleaf_collection_thresholdA->s.s_dbind;
   
   sSAleaf_collection_thresholdA->s.s_dbind=make_fixnum(0);
-  for (;rb_pointer!=rb_start&&rb_pointer!=rb_end;)
+  for (;rb_pointer!=rb_start&&rb_pointer!=rb_end;) {
+    tm_table[t_relocatable].tm_adjgbccnt--;
     GBC(t_relocatable);
+  }
   sSAleaf_collection_thresholdA->s.s_dbind=o;
 
 }
@@ -498,10 +500,10 @@ static int
 rebalance_maxpages(struct typemanager *my_tm,fixnum z) {
 
   fixnum d;
-  ufixnum i,j;
+  ufixnum i,j,r=(my_tm->tm_type==t_relocatable ? 2 : 1);
   
   
-  d=(z-my_tm->tm_maxpage)*(my_tm->tm_type==t_relocatable ? 2 : 1);
+  d=(z-my_tm->tm_maxpage)*r;
   j=sum_maxpages();
 
   if (j+d>phys_pages) {
@@ -517,14 +519,14 @@ rebalance_maxpages(struct typemanager *m
     if (e+phys_pages-j<=0)
       return 0;
 
-    f=1.0-(double)e/k;
+    f=k ? 1.0-(double)e/k : 1.0;
 
     for (i=t_start;i<t_other;i++)
       if (tm_table[i].tm_npage && tm_table+i!=my_tm) {
 	  massert(set_tm_maxpage(tm_table+i,tm_table[i].tm_npage+f*(tm_table[i].tm_maxpage-tm_table[i].tm_npage)));
 	}
     
-    massert(set_tm_maxpage(my_tm,(my_tm->tm_maxpage+(phys_pages-sum_maxpages()))/(my_tm->tm_type==t_relocatable ? 2 : 1)));
+    massert(set_tm_maxpage(my_tm,(my_tm->tm_maxpage*r+(phys_pages-sum_maxpages()))/r));
 
     return 1;
     
@@ -624,7 +626,12 @@ expand_contblock_index_space(void) {
 
   if (cbv->v.v_fillp+1==cbv->v.v_dim) {
 
-    void *v=alloc_relblock(2*cbv->v.v_dim*sizeof(fixnum));
+    void *v;
+    object o=sSAleaf_collection_thresholdA->s.s_dbind;
+
+    sSAleaf_collection_thresholdA->s.s_dbind=make_fixnum(-1);
+    v=alloc_relblock(2*cbv->v.v_dim*sizeof(fixnum));
+    sSAleaf_collection_thresholdA->s.s_dbind=o;
 
     memcpy(v,cbv->v.v_self,cbv->v.v_dim*sizeof(fixnum));
     cbv->v.v_self=v;
@@ -731,13 +738,14 @@ insert_contblock(void *p,ufixnum s) {
 
   cbp->cb_size=s;
   cbp->cb_link=*cbpp;
-  *cbpp=cbp;
   
   if ((!cbp->cb_link || cbp->cb_link->cb_size!=s)) {
     cbppp=expand_contblock_index(cbppp);
     cbppp[1]=&cbp->cb_link;
   }
 
+  *cbpp=cbp;
+
 }
 
 static inline void
@@ -890,6 +898,7 @@ add_pages(struct typemanager *tm,fixnum
     if (rb_pointer>rb_end) {
       fprintf(stderr,"Moving relblock low before expanding relblock pages\n");
       fflush(stderr);
+      tm_table[t_relocatable].tm_adjgbccnt--;
       GBC(t_relocatable);
     }
     nrbpage+=m;
--- gcl-2.6.12.orig/o/gbc.c
+++ gcl-2.6.12/o/gbc.c
@@ -1042,14 +1042,10 @@ contblock_sweep_phase(void) {
 
   struct pageinfo *v;
   STATIC char *s, *e, *p, *q;
-  object o;
   ufixnum i;
     
   reset_contblock_freelist();
 
-  o=sSAleaf_collection_thresholdA->s.s_dbind;
-  sSAleaf_collection_thresholdA->s.s_dbind=make_fixnum(-1);
-
   for (i=0;i<contblock_array->v.v_fillp && (v=(void *)contblock_array->v.v_self[i]);i++) {
 
     bool z;
@@ -1074,8 +1070,6 @@ contblock_sweep_phase(void) {
 
   }
 
-  sSAleaf_collection_thresholdA->s.s_dbind=o;
-
   sweep_link_array();
 
 }
@@ -1646,14 +1640,18 @@ DEFUN_NEW("GBC",object,fSgbc,SI,1,1,NONE
 
    /* 1 args */
   
-  if (x0 == Ct)
+  if (x0 == Ct) {
+    tm_table[t_contiguous].tm_adjgbccnt--;
     GBC(t_other);
-  else if (x0 == Cnil)
+  } else if (x0 == Cnil) {
+    tm_table[t_cons].tm_adjgbccnt--;
     GBC(t_cons);
-  else if (eql(small_fixnum(0),x0))
+  } else if (eql(small_fixnum(0),x0)) {
+    tm_table[t_contiguous].tm_adjgbccnt--;
     GBC(t_contiguous);
-  else {
+  } else {
     x0 = small_fixnum(1);
+    tm_table[t_relocatable].tm_adjgbccnt--;
     GBC(t_relocatable);
   }
   RETURN1(x0);