From dc01fbd6e8d19035753dd70a8e30d94ed7bc959e Mon Sep 17 00:00:00 2001 From: Camm Maguire Date: Sun, 13 Nov 2022 12:55:14 +0000 Subject: [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-4) unstable; urgency=medium * Version_2_6_13pre3a Gbp-Pq: Name Version_2_6_13pre4 --- h/elf64_ppcle_reloc_special.h | 2 - h/page.h | 5 +- h/protoize.h | 9 +++ o/alloc.c | 132 ++++++++++++++++++++++++++-------- o/array.c | 5 ++ o/gbc.c | 87 ++++++---------------- o/sfaslelf.c | 28 +------- o/sgbc.c | 56 ++++----------- 8 files changed, 154 insertions(+), 170 deletions(-) diff --git a/h/elf64_ppcle_reloc_special.h b/h/elf64_ppcle_reloc_special.h index e60fcdd..f2c6c16 100644 --- a/h/elf64_ppcle_reloc_special.h +++ b/h/elf64_ppcle_reloc_special.h @@ -15,8 +15,6 @@ find_special_params(void *v,Shdr *sec1,Shdr *sece,const char *sn, Shdr *sec; Rela *r; void *ve; - ul j,*u; - massert((sec=get_section(".rela.plt",sec1,sece,sn))); diff --git a/h/page.h b/h/page.h index ae7990c..c384077 100755 --- a/h/page.h +++ b/h/page.h @@ -88,7 +88,8 @@ extern int reserve_pages_for_signal_handler; /* #define CONT_MARK_PAGE (((page(heap_end)-first_data_page)*(PAGESIZE/(CPTR_SIZE*CHAR_SIZE))+PAGESIZE-1)/PAGESIZE) */ /* #define available_pages ((fixnum)(real_maxpage-page(heap_end)-2*nrbpage-CONT_MARK_PAGE-resv_pages)) */ -extern struct pageinfo *cell_list_head,*cell_list_tail,*contblock_list_head,*contblock_list_tail; +extern struct pageinfo *cell_list_head,*cell_list_tail/* ,*contblock_list_head,*contblock_list_tail */; +extern object contblock_array; #define PAGE_MAGIC 0x2e @@ -114,7 +115,7 @@ EXTER void *data_start,*initial_sbrk; #define CB_BITS CPTR_SIZE*CHAR_SIZE #define ceil(a_,b_) (((a_)+(b_)-1)/(b_)) #define npage(m_) ceil(m_,PAGESIZE) -#define cpage(m_) ({ufixnum _m=(m_);ceil(sizeof(struct pageinfo)+_m+2*ceil(_m,(CB_BITS-2)),PAGESIZE);}) +#define cpage(m_) CEI(({ufixnum _m=(m_);ceil(sizeof(struct pageinfo)+_m+2*ceil(_m,(CB_BITS-2)),PAGESIZE);}),256) #define mbytes(p_) ceil((p_)*PAGESIZE-sizeof(struct pageinfo),CB_BITS) #define tpage(tm_,m_) (tm_->tm_type==t_relocatable ? npage(m_-(rb_limit-rb_pointer)+1) : (tm_->tm_type==t_contiguous ? cpage(m_) : npage(m_))) diff --git a/h/protoize.h b/h/protoize.h index 98517d3..9e5ef79 100644 --- a/h/protoize.h +++ b/h/protoize.h @@ -1941,3 +1941,12 @@ mbrk(void *); void maybe_set_hole_from_maxpages(void); + +void * +alloc_code_space(size_t); + +object +fSmake_vector1_2(fixnum,fixnum,object,object); + +inline struct pageinfo * +get_pageinfo(void *); diff --git a/o/alloc.c b/o/alloc.c index 963bff4..4534719 100644 --- a/o/alloc.c +++ b/o/alloc.c @@ -78,6 +78,72 @@ struct rlimit data_rlimit; #endif #endif +static inline void * +bsearchleq(void *i,void *v1,size_t n,size_t s,int (*c)(const void *,const void *)) { + + ufixnum nn=n>>1; + void *v=v1+nn*s; + int j=c(i,v); + + if (nn) + return !j ? v : (j>0 ? bsearchleq(i,v,n-nn,s,c) : bsearchleq(i,v1,nn,s,c)); + else + return j<=0 ? v : v+s; + +} + + +object contblock_array=Cnil; + +static inline void +expand_contblock_array(void) { + + if (contblock_array==Cnil) { + contblock_array=fSmake_vector1_2(16,aet_fix,Cnil,make_fixnum(0)); + contblock_array->v.v_self[0]=(object)&cb_pointer; + enter_mark_origin(&contblock_array); + } + + if (contblock_array->v.v_fillp==contblock_array->v.v_dim) { + + void *v=alloc_relblock(2*contblock_array->v.v_dim*sizeof(fixnum)); + + memcpy(v,contblock_array->v.v_self,contblock_array->v.v_dim*sizeof(fixnum)); + contblock_array->v.v_self=v; + contblock_array->v.v_dim*=2; + + } + +} + +static void +contblock_array_push(void *p) { + + expand_contblock_array(); + contblock_array->v.v_self[contblock_array->v.v_fillp]=p; + contblock_array->v.v_fillp++; + +} + +static inline int +acomp(const void *v1,const void *v2) { + + void *p1=*(void * const *)v1,*p2=*(void * const *)v2; + + return p1v.v_self,contblock_array->v.v_fillp,sizeof(*contblock_array->v.v_self),acomp); + struct pageinfo *p=(void *)pp>(void *)contblock_array->v.v_self ? pp[-1] : NULL; + + return p && (void *)p+p->in_use*PAGESIZE>x ? p : NULL; + +} + inline void add_page_to_contblock_list(void *p,fixnum m) { @@ -89,13 +155,8 @@ add_page_to_contblock_list(void *p,fixnum m) { massert(pp->in_use==m); pp->magic=PAGE_MAGIC; - if (contblock_list_head==NULL) - contblock_list_tail=contblock_list_head=p; - else if (pp > contblock_list_tail) { - contblock_list_tail->next=p; - contblock_list_tail=p; - } - + contblock_array_push(p); + bzero(pagetochar(page(pp)),CB_DATA_START(pp)-(void *)pagetochar(page(pp))); #ifdef SGC if (sgc_enabled && tm_table[t_contiguous].tm_sgc) { @@ -458,7 +519,7 @@ rebalance_maxpages(struct typemanager *my_tm,fixnum z) { for (i=t_start;iv.v_self[0]=(object)&cb_pointer; enter_mark_origin(&cbv); } @@ -612,21 +673,6 @@ cbcomp(const void *v1,const void *v2) { } -static inline void * -bsearchleq(void *i,void *v1,size_t n,size_t s,int (*c)(const void *,const void *)) { - - ufixnum nn=n>>1; - void *v=v1+nn*s; - int j=c(i,v); - - if (nn) - return !j ? v : (j>0 ? bsearchleq(i,v,n-nn,s,c) : bsearchleq(i,v1,nn,s,c)); - else - return j<=0 ? v : v+s; - -} - - static inline struct contblock *** find_cbppp(struct contblock *cbp) { @@ -777,7 +823,7 @@ grow_linear1(struct typemanager *tm) { static inline int too_full_p(struct typemanager *tm) { - fixnum j,k,pf=tm->tm_percent_free ? tm->tm_percent_free : 30; + fixnum i,j,k,pf=tm->tm_percent_free ? tm->tm_percent_free : 30; struct contblock *cbp; struct pageinfo *pi; @@ -787,11 +833,13 @@ too_full_p(struct typemanager *tm) { break; case t_contiguous: for (cbp=cb_pointer,k=0;cbp;cbp=cbp->cb_link) k+=cbp->cb_size; - for (pi=contblock_list_head,j=0;pi;pi=pi->next) + for (i=j=0;iv.v_fillp;i++) { + pi=(void *)contblock_array->v.v_self[i]; #ifdef SGC if (!sgc_enabled || pi->sgc_flags&SGC_PAGE_FLAG) #endif j+=pi->in_use; + } return 100*ktm_maxpage-tm->tm_npage; */ add_pages(tm,m); return alloc_from_freelist(tm,n); @@ -997,6 +1042,34 @@ alloc_contblock_no_gc(size_t n) { } +#ifndef MAX_CODE_ADDRESS +#define MAX_CODE_ADDRESS -1UL +#endif + +void * +alloc_code_space(size_t sz) { + + void *v; + + sz=CEI(sz,CPTR_SIZE); + + if (sSAcode_block_reserveA && + sSAcode_block_reserveA->s.s_dbind!=Cnil && sSAcode_block_reserveA->s.s_dbind->st.st_dim>=sz) { + + v=sSAcode_block_reserveA->s.s_dbind->st.st_self; + sSAcode_block_reserveA->s.s_dbind->st.st_self+=sz; + sSAcode_block_reserveA->s.s_dbind->st.st_dim-=sz; + sSAcode_block_reserveA->s.s_dbind->st.st_fillp=sSAcode_block_reserveA->s.s_dbind->st.st_dim; + + } else + v=alloc_contblock(sz); + + massert(v && (unsigned long)(v+sz)type==t_contiguous && p+v->in_use*PAGESIZE>x); - - return p; - -} - -/* inline struct pageinfo * */ -/* get_pageinfo(void *x) { */ -/* struct pageinfo *v=contblock_list_head;void *vv; */ -/* for (;(vv=v) && (vv>=x || vv+v->in_use*PAGESIZE<=x);v=v->next); */ -/* return v; */ -/* } */ - inline char get_bit(char *v,struct pageinfo *pi,void *x) { void *ve=CB_DATA_START(pi); @@ -811,7 +784,7 @@ mark_stack_carefully(void *topv, void *bottomv, int offset) { for (j=top ; j >= bottom ; j--) { - void *v=(void *)(*j),**a; + void *v=(void *)(*j); struct pageinfo *pi; if (!VALID_DATA_ADDRESS_P(v)) continue; @@ -822,7 +795,7 @@ mark_stack_carefully(void *topv, void *bottomv, int offset) { pi=pagetoinfo(p); if (!pageinfo_p(pi)) continue; - if ((a=contblock_stack_list) && in_contblock_stack_list(pi,&a)) continue; + if (get_pageinfo(pi)) continue; tm=tm_of(pi->type); if (tm->tm_type>=t_end) continue; @@ -1067,14 +1040,24 @@ sweep_phase(void) { static void contblock_sweep_phase(void) { + struct pageinfo *v; STATIC char *s, *e, *p, *q; - STATIC struct pageinfo *v; + object o; + ufixnum i; reset_contblock_freelist(); - - for (v=contblock_list_head;v;v=v->next) { + + o=sSAleaf_collection_thresholdA->s.s_dbind; + sSAleaf_collection_thresholdA->s.s_dbind=make_fixnum(-1); + + for (i=0;iv.v_fillp && (v=(void *)contblock_array->v.v_self[i]);i++) { + bool z; +#ifdef SGC + if (sgc_enabled && !(v->sgc_flags&SGC_PAGE_FLAG)) continue; +#endif + s=CB_DATA_START(v); e=(void *)v+v->in_use*PAGESIZE; @@ -1090,14 +1073,9 @@ contblock_sweep_phase(void) { bzero(CB_MARK_START(v),CB_SGCF_START(v)-CB_MARK_START(v)); } -#ifdef DEBUG - if (debug) { - for (cbp = cb_pointer; cbp != NULL; cbp = cbp->cb_link) - printf("%lud-byte contblock\n", cbp->cb_size); - fflush(stdout); - } -#endif - + + sSAleaf_collection_thresholdA->s.s_dbind=o; + sweep_link_array(); } @@ -1143,24 +1121,6 @@ GBC(enum type t) { ngc_thresh=fix(sSAleaf_collection_thresholdA->s.s_dbind); - { /*FIXME try to get this below the setjmp in mark_c_stack*/ - struct pageinfo *v,*tv; - ufixnum i; - void *a; - - for (v=contblock_list_head,contblock_stack_list=NULL;v;v=v->next) - for (i=1;iin_use;i++) { - tv=pagetoinfo(page(v)+i); - if (pageinfo_p(tv)) { - a=contblock_stack_list; - /* fprintf(stderr,"pushing %p\n",tv); */ - contblock_stack_list=alloca(2*sizeof(a)); - contblock_stack_list[0]=tv; - contblock_stack_list[1]=a; - } - } - } - if (in_signal_handler && t == t_relocatable) error("cant gc relocatable in signal handler"); @@ -1312,12 +1272,7 @@ GBC(enum type t) { } #endif -#ifdef SGC - if (sgc_enabled) - sgc_contblock_sweep_phase(); - else -#endif - contblock_sweep_phase(); + contblock_sweep_phase(); #ifdef DEBUG if (debug) printf("contblock sweep ended (%d)\n", @@ -1574,7 +1529,7 @@ mark_contblock(void *p, int s) { sizeof(struct contblock). CM 20030827 */ x = (char *)PFLR(p,CPTR_SIZE); y = (char *)PCEI(q,CPTR_SIZE); - v=get_pageinfo(x); + massert(v=get_pageinfo(x)); #ifdef SGC if (!sgc_enabled || (v->sgc_flags&SGC_PAGE_FLAG)) #endif @@ -1595,7 +1550,7 @@ DEFUN_NEW("CONTIGUOUS-REPORT",object,fScontiguous_report,SI,1,1,NONE,OO,OO,OO,OO } fprintf(stderr,"\nTotal free %lu in %lu pieces\n\n",i,j); - for (i=j=0,v=contblock_list_head;v;i+=v->in_use,j++,v=v->next) + for (i=j=k=0;kv.v_fillp && (v=(void *)contblock_array->v.v_self[k]);k++,i+=v->in_use,j++) fprintf(stderr,"%lu pages at %p\n",(unsigned long)v->in_use,v); fprintf(stderr,"\nTotal pages %lu in %lu pieces\n\n",i,j); diff --git a/o/sfaslelf.c b/o/sfaslelf.c index 54b5b27..8234671 100755 --- a/o/sfaslelf.c +++ b/o/sfaslelf.c @@ -242,32 +242,6 @@ relocate_symbols(Sym *sym,Sym *syme,Shdr *sec1,Shdr *sece,const char *st1) { } -#ifndef MAX_CODE_ADDRESS -#define MAX_CODE_ADDRESS -1UL -#endif - -static void * -alloc_memory(ul sz) { - - void *v; - - if (sSAcode_block_reserveA && - sSAcode_block_reserveA->s.s_dbind!=Cnil && sSAcode_block_reserveA->s.s_dbind->st.st_dim>=sz) { - - v=sSAcode_block_reserveA->s.s_dbind->st.st_self; - sSAcode_block_reserveA->s.s_dbind->st.st_self+=sz; - sSAcode_block_reserveA->s.s_dbind->st.st_dim-=sz; - sSAcode_block_reserveA->s.s_dbind->st.st_fillp=sSAcode_block_reserveA->s.s_dbind->st.st_dim; - - } else - v=alloc_contblock(sz); - - massert(v && (ul)(v+sz)cfd.cfd_size=sz; memory->cfd.cfd_self=0; memory->cfd.cfd_start=0; - memory->cfd.cfd_start=alloc_memory(sz); + memory->cfd.cfd_start=alloc_code_space(sz); a=(ul)memory->cfd.cfd_start; a=(a+ma)&~ma; diff --git a/o/sgbc.c b/o/sgbc.c index d76626d..759863e 100755 --- a/o/sgbc.c +++ b/o/sgbc.c @@ -99,7 +99,7 @@ sgc_mark_phase(void) { /* mark all non recent data on writable contiguous pages */ if (what_to_collect == t_contiguous) - for (v=contblock_list_head;v;v=v->next) + for (i=0;iv.v_fillp && (v=(void *)contblock_array->v.v_self[i]);i++) if (v->sgc_flags&SGC_PAGE_FLAG) { void *s=CB_DATA_START(v),*e=CB_DATA_END(v),*p,*q; bool z=get_sgc_bit(v,s); @@ -213,40 +213,6 @@ sgc_sweep_phase(void) { } } - -static void -sgc_contblock_sweep_phase(void) { - - STATIC char *s, *e, *p, *q; - STATIC struct pageinfo *v; - - reset_contblock_freelist(); - - for (v=contblock_list_head;v;v=v->next) { - bool z; - - if (!(v->sgc_flags&SGC_PAGE_FLAG)) continue; - - s=CB_DATA_START(v); - e=CB_DATA_END(v); - - z=get_mark_bit(v,s); - for (p=s;pnext) { + for (i=0;iv.v_fillp && (pi=(void *)contblock_array->v.v_self[i]) && countv.v_fillp; if (maxcbpagev.v_fillp); - contblock_list_tail->sgc_flags=SGC_PAGE_FLAG; + ((struct pageinfo *)contblock_array->v.v_self[fp])->sgc_flags=SGC_PAGE_FLAG; } @@ -743,17 +709,19 @@ sgc_start(void) { { struct pageinfo *pi; - + ufixnum j; + { struct contblock **cbpp; void *p=NULL,*pe; struct pageinfo *pi; + ufixnum i; old_cb_pointer=cb_pointer; reset_contblock_freelist(); - for (pi=contblock_list_head;pi;pi=pi->next) { + for (i=0;iv.v_fillp && (pi=(void *)contblock_array->v.v_self[i]);i++) { if (pi->sgc_flags!=SGC_PAGE_FLAG) continue; @@ -786,7 +754,7 @@ sgc_start(void) { else tm_of(pi->type)->tm_alt_npage++; } - for (pi=contblock_list_head;pi;pi=pi->next)/*FIXME*/ + for (j=0;jv.v_fillp && (pi=(void *)contblock_array->v.v_self[j]);j++) if (pi->sgc_flags&SGC_WRITABLE) for (i=0;iin_use;i++) SET_WRITABLE(page(pi)+i); @@ -932,7 +900,7 @@ sgc_quit(void) { ((object) p)->d.s=SGC_NORMAL; #endif - for (v=contblock_list_head;v;v=v->next) + for (i=0;iv.v_fillp &&(v=(void *)contblock_array->v.v_self[i]);i++) if (v->sgc_flags&SGC_PAGE_FLAG) bzero(CB_SGCF_START(v),CB_DATA_START(v)-CB_SGCF_START(v)); @@ -940,7 +908,7 @@ sgc_quit(void) { struct pageinfo *pi; for (pi=cell_list_head;pi;pi=pi->next) pi->sgc_flags&=SGC_PERM_WRITABLE; - for (pi=contblock_list_head;pi;pi=pi->next) + for (i=0;iv.v_fillp &&(pi=(void *)contblock_array->v.v_self[i]);i++) pi->sgc_flags&=SGC_PERM_WRITABLE; } -- 2.30.2