From f69ba78f02384388a9f5070ff3ebd9baa143b04e Mon Sep 17 00:00:00 2001 From: vsc Date: Sat, 5 Aug 2006 03:06:31 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1683 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/dbase.c | 3 +++ C/heapgc.c | 47 ++++++++++++++++++++++++++++++----------------- C/readutil.c | 2 -- C/tracer.c | 11 +++++++++++ H/heapgc.h | 17 ++++++++++++++++- changes-5.1.html | 6 ++++-- 6 files changed, 64 insertions(+), 22 deletions(-) diff --git a/C/dbase.c b/C/dbase.c index 45dedcc62..de09e676d 100644 --- a/C/dbase.c +++ b/C/dbase.c @@ -2379,6 +2379,9 @@ p_still_variant(void) link_entry *lp = (link_entry *)(dbt->Contents+dbt->NOfCells); link_entry link; + if (!dbt->NOfCells) { + return IsVarTerm(t2); + } while ((link = *lp++)) { Term t2 = Deref(old_h[link-1]); if (IsUnboundVar(dbt->Contents+(link-1))) { diff --git a/C/heapgc.c b/C/heapgc.c index a1b8538c5..92770e953 100644 --- a/C/heapgc.c +++ b/C/heapgc.c @@ -1098,12 +1098,12 @@ mark_variable(CELL_PTR current) CELL_PTR next; register CELL ccur; unsigned int arity; + char *local_bp = Yap_bp; begin: - if (MARKED_PTR(current)) { + if (UNMARKED_MARK(current,local_bp)) { POP_CONTINUATION(); } - MARK(current); if (current >= H0 && current < H) { total_marked++; if (current < HGEN) { @@ -1203,14 +1203,35 @@ mark_variable(CELL_PTR current) #endif } POP_CONTINUATION(); + } else if (IsAtomOrIntTerm(ccur)) { +#ifdef INSTRUMENT_GC + if (IsAtomTerm(ccur)) + inc_vars_of_type(current,gc_atom); + else + inc_vars_of_type(current, gc_int); +#endif + POP_CONTINUATION(); } else if (IsPairTerm(ccur)) { #ifdef INSTRUMENT_GC inc_vars_of_type(current,gc_list); #endif if (ONHEAP(next)) { - PUSH_CONTINUATION(next+1,1); - current = next; - goto begin; + /* speedup for strings */ + if (IsAtomOrIntTerm(*next)) { + if (!UNMARKED_MARK(next,local_bp)) { + total_marked++; + if (next < HGEN) { + total_oldies++; + } + PUSH_POINTER(next); + } + current = next+1; + goto begin; + } else { + PUSH_CONTINUATION(next+1,1); + current = next; + goto begin; + } } else if (ONCODE(next)) { mark_db_fixed(RepPair(ccur)); } @@ -1323,13 +1344,6 @@ mark_variable(CELL_PTR current) PUSH_CONTINUATION(current+1,arity-1); goto begin; } -#ifdef INSTRUMENT_GC - else if (IsAtomTerm(ccur)) - inc_vars_of_type(current,gc_atom); - else - inc_vars_of_type(current, gc_int); -#endif - POP_CONTINUATION(); } void @@ -3451,18 +3465,17 @@ static void sweep_oldgen(CELL *max, CELL *base) { CELL *ptr = base; - long int nof = 0; + char *bpb = Yap_bp+(base-(CELL*)Yap_GlobalBase); + while (ptr < max) { - if (MARKED_PTR(ptr)) { - nof++; - UNMARK(ptr); + if (*bpb & MARK_BIT) { if (HEAP_PTR(*ptr)) { into_relocation_chain(ptr, GET_NEXT(*ptr)); } } ptr++; + bpb++; } - /* fprintf(stderr,"found %d, %p-%p\n", nof, base, max); */ } #ifdef COROUTINING diff --git a/C/readutil.c b/C/readutil.c index 665f9ad3d..ab1bc4cd3 100644 --- a/C/readutil.c +++ b/C/readutil.c @@ -120,7 +120,6 @@ p_stream_to_codes(void) RESET_VARIABLE(h0); ARG4 = AbsPair(HBASE); ARG5 = (CELL)h0; - fprintf(stderr,"+ %p-%p=%p\n",HBASE,H,H-HBASE); if (!Yap_gc(5, ENV, P)) { Yap_Error(OUT_OF_STACK_ERROR, ARG1, "read_stream_to_codes/3"); return FALSE; @@ -128,7 +127,6 @@ p_stream_to_codes(void) /* build a legal term again */ h0 = (CELL *)ARG5; HBASE = RepPair(ARG4); - fprintf(stderr,"- %p-%p=%d\n",HBASE,h0,h0-HBASE); } } if (H == HBASE) diff --git a/C/tracer.c b/C/tracer.c index acd131f7d..3ba554c43 100644 --- a/C/tracer.c +++ b/C/tracer.c @@ -355,6 +355,16 @@ static Int p_stop_low_level_trace(void) return(TRUE); } +volatile int vsc_wait; + +static Int p_vsc_wait(void) +{ + fprintf(stderr,"attach %d\n",getpid()); + while (!vsc_wait); + vsc_wait=1; + return(TRUE); +} + void Yap_InitLowLevelTrace(void) { @@ -363,6 +373,7 @@ Yap_InitLowLevelTrace(void) Yap_InitCPred("start_low_level_trace", 1, p_start_low_level_trace2, SafePredFlag); #endif Yap_InitCPred("stop_low_level_trace", 0, p_stop_low_level_trace, SafePredFlag); + Yap_InitCPred("vsc_wait", 0, p_vsc_wait, SafePredFlag); } #endif diff --git a/H/heapgc.h b/H/heapgc.h index cfbe87c49..dbf867989 100644 --- a/H/heapgc.h +++ b/H/heapgc.h @@ -96,7 +96,7 @@ extern char *Yap_bp; #define MARK_BIT 1 #define RMARK_BIT 2 -#define mcell(X) Yap_bp[X-(CELL *)Yap_GlobalBase] +#define mcell(X) Yap_bp[(X)-(CELL *)Yap_GlobalBase] static inline Int MARKED_PTR(CELL* ptr) @@ -104,6 +104,18 @@ MARKED_PTR(CELL* ptr) return mcell(ptr) & MARK_BIT; } +static inline Int +UNMARKED_MARK(CELL* ptr, char *bp) +{ + Int pos = ptr - (CELL *)Yap_GlobalBase; + char t = bp[pos]; + if (t & MARK_BIT) { + return TRUE; + } + bp[pos] = t | MARK_BIT; + return FALSE; +} + static inline void MARK(CELL* ptr) { @@ -116,6 +128,9 @@ UNMARK(CELL* ptr) mcell(ptr) = mcell(ptr) & ~MARK_BIT; } +/* not really that useful */ +#define MAY_UNMARK(X) + #define UNMARK_CELL(X) (X) static inline void diff --git a/changes-5.1.html b/changes-5.1.html index edfe5f07f..8703d446c 100644 --- a/changes-5.1.html +++ b/changes-5.1.html @@ -16,8 +16,10 @@

Yap-5.1.2: