memory management fixes

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1121 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2004-09-03 03:11:09 +00:00
parent be83a4a309
commit 6711d93b9c
11 changed files with 138 additions and 88 deletions

View File

@ -12,7 +12,7 @@
* Last rev: *
* mods: *
* comments: allocating space *
* version:$Id: alloc.c,v 1.56 2004-08-11 16:14:51 vsc Exp $ *
* version:$Id: alloc.c,v 1.57 2004-09-03 03:11:07 vsc Exp $ *
*************************************************************************/
#ifdef SCCS
static char SccsId[] = "%W% %G%";
@ -398,6 +398,7 @@ AllocHeap(unsigned int size)
{
BlockHeader *b, *n;
YAP_SEG_SIZE *sp;
UInt align, extra;
/* {
static long long int vsc_alloc_ops;
@ -406,26 +407,23 @@ AllocHeap(unsigned int size)
while (q) q = q->b_next_size;
}*/
size += 2*sizeof(YAP_SEG_SIZE);
extra = size/16;
#if SIZEOF_INT_P==4
size = (((size + 7) & 0xfffffff8L) >> 2); /* size in dwords + 2 */
align = 2*sizeof(CELL); /* size in dwords + 2 */
#endif
#if SIZEOF_INT_P==8
size = (((size + 7) & 0xfffffffffffffff8LL) >> 3); /* size in dwords + 2 */
#endif
if (size < (sizeof(YAP_SEG_SIZE)+sizeof(BlockHeader))/sizeof(CELL))
size = (sizeof(YAP_SEG_SIZE)+sizeof(BlockHeader))/sizeof(CELL);
#if SIZEOF_INT_P==4
/*
guarantee that the space seen by the user is always aligned at multiples
of a double word. This improves alignment, and guarantees correctness
for machines which require aligned 64 bits, such as SPARCs.
*/
if ((size & 1) == 0) size++;
align = sizeof(CELL);
#endif
while (align < extra) align *= 2;
size = ALIGN_SIZE(size,align);
if (size < sizeof(BlockHeader))
size = sizeof(BlockHeader);
size += sizeof(YAP_SEG_SIZE);
/* change units to cells */
size = size/sizeof(CELL);
LOCK(FreeBlocksLock);
if ((b = GetBlock(size))) {
if (b->b_size >= size + 6 + 1) {
if (b->b_size >= size+24+1) {
n = (BlockHeader *) (((YAP_SEG_SIZE *) b) + size + 1);
n->b_size = b->b_size - size - 1;
b->b_size = size;

View File

@ -11,8 +11,11 @@
* File: cdmgr.c *
* comments: Code manager *
* *
* Last rev: $Date: 2004-08-16 21:02:04 $,$Author: vsc $ *
* Last rev: $Date: 2004-09-03 03:11:07 $,$Author: vsc $ *
* $Log: not supported by cvs2svn $
* Revision 1.127 2004/08/16 21:02:04 vsc
* more fixes for !
*
* Revision 1.126 2004/07/22 21:32:20 vsc
* debugger fixes
* initial support for JPL
@ -321,6 +324,9 @@ release_wcls(yamop *cop, OPCODE ecs)
if (cop->opc == ecs) {
cop->u.sp.s3--;
if (!cop->u.sp.s3) {
#if DEBUG
Yap_expand_clauses_sz -= (UInt)(NEXTOP((yamop *)NULL,sp)+cop->u.sp.s1*sizeof(yamop *));
#endif
Yap_FreeCodeSpace((char *)cop);
}
}
@ -2663,7 +2669,18 @@ p_toggle_static_predicates_in_use(void)
static void
clause_was_found(PredEntry *pp, Atom *pat, UInt *parity) {
/* we found it */
if (pp->ModuleOfPred == IDB_MODULE) {
if (pp->PredFlags & NumberDBPredFlag) {
*parity = 0;
*pat = Yap_LookupAtom("integer");
} else if (pp->PredFlags & AtomDBPredFlag) {
*parity = 0;
*pat = (Atom)pp->FunctorOfPred;
} else {
*pat = NameOfFunctor(pp->FunctorOfPred);
*parity = ArityOfFunctor(pp->FunctorOfPred);
}
} else {
*parity = pp->ArityOfPE;
if (pp->ArityOfPE) {
*pat = NameOfFunctor(pp->FunctorOfPred);
@ -2671,15 +2688,11 @@ clause_was_found(PredEntry *pp, Atom *pat, UInt *parity) {
*pat = (Atom)(pp->FunctorOfPred);
}
}
}
static void
code_in_pred_info(PredEntry *pp, Atom *pat, UInt *parity) {
*parity = pp->ArityOfPE;
if (pp->ArityOfPE) {
*pat = NameOfFunctor(pp->FunctorOfPred);
} else {
*pat = (Atom)(pp->FunctorOfPred);
}
clause_was_found(pp, pat, parity);
}
static int
@ -2786,11 +2799,19 @@ code_in_pred(PredEntry *pp, Atom *pat, UInt *parity, yamop *codeptr) {
static Int
PredForCode(yamop *codeptr, Atom *pat, UInt *parity, Term *pmodule) {
Int found = 0;
Int i_table;
Int i_table, idb_i = 0;
/* should we allow the user to see hidden predicates? */
for (i_table = NoOfModules-1; i_table >= 0; --i_table) {
PredEntry *pp = ModulePred[i_table];
for (i_table = 0; i_table < NoOfModules; i_table++) {
PredEntry *pp;
if (ModuleName[i_table] == IDB_MODULE) {
idb_i = i_table;
/* do IDB at the very end */
continue;
}
restart:
pp = ModulePred[i_table];
while (pp != NULL) {
if ((found = code_in_pred(pp, pat, parity, codeptr)) != 0) {
if (i_table)
@ -2801,6 +2822,12 @@ PredForCode(yamop *codeptr, Atom *pat, UInt *parity, Term *pmodule) {
}
pp = pp->NextPredOfModule;
}
if (!i_table) {
i_table = idb_i;
goto restart;
} else if (i_table == idb_i) {
return 0;
}
}
return(0);
}

View File

@ -11,8 +11,12 @@
* File: compiler.c *
* comments: Clause compiler *
* *
* Last rev: $Date: 2004-07-15 17:20:23 $,$Author: vsc $ *
* Last rev: $Date: 2004-09-03 03:11:08 $,$Author: vsc $ *
* $Log: not supported by cvs2svn $
* Revision 1.52 2004/07/15 17:20:23 vsc
* fix error message
* change makefile and configure for clpbn
*
* Revision 1.51 2004/06/29 19:04:41 vsc
* fix multithreaded version
* include new version of Ricardo's profiler
@ -864,7 +868,7 @@ c_bifun(Int Op, Term t1, Term t2, Term t3, int mod, compiler_struct *cglobs)
RESET_VARIABLE(H+1);
H += 2;
c_eq(AbsPair(H-2),t3, cglobs);
} else {
} else if (i2 < 16) {
*H++ = (CELL)Yap_MkFunctor(AtomOfTerm(t1),i2);
for (i=0; i < i2; i++) {
if (H >= (CELL *)cglobs->cint.freep0) {

View File

@ -1511,7 +1511,6 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat, UInt extra_size, struc
*/
flag = DBComplex;
#ifdef IDB_LINK_TABLE
CodeAbs++; /* We have one more cell */
CodeAbs += CellPtr(dbg->lr) - CellPtr(dbg->LinkAr);
if ((CELL *)((char *)ntp0+(CELL)CodeAbs) > AuxSp) {
Yap_Error_Size = (UInt)DBLength(CodeAbs);
@ -1612,7 +1611,7 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat, UInt extra_size, struc
nar = (Term *) cpcells(CellPtr(ppt->Contents), ntp0, Unsigned(NOfCells));
} else {
#ifdef IDB_LINK_TABLE
nar = ppt->Contents + Unsigned(NOfCells)+1;
nar = ppt->Contents + Unsigned(NOfCells);
#endif
#ifdef IDB_USE_MBIT
/* we still need to link */
@ -3710,7 +3709,8 @@ p_heap_space_info(void)
{
return
Yap_unify(ARG1,MkIntegerTerm(HeapUsed)) &&
Yap_unify(ARG2,MkIntegerTerm(HeapMax-HeapUsed));
Yap_unify(ARG2,MkIntegerTerm(HeapMax-HeapUsed)) &&
Yap_unify(ARG3,MkIntegerTerm(Yap_expand_clauses_sz));
}
#endif
@ -5079,7 +5079,7 @@ Yap_InitDBPreds(void)
#ifdef DEBUG
Yap_InitCPred("total_erased", 4, p_total_erased, SyncPredFlag);
Yap_InitCPred("key_erased_statistics", 5, p_key_erased_statistics, SyncPredFlag);
Yap_InitCPred("heap_space_info", 2, p_heap_space_info, SyncPredFlag);
Yap_InitCPred("heap_space_info", 3, p_heap_space_info, SyncPredFlag);
#endif
Yap_InitCPred("nth_instance", 3, p_nth_instance, SyncPredFlag);
Yap_InitCPred("$nth_instancep", 3, p_nth_instancep, SyncPredFlag);

View File

@ -297,7 +297,7 @@ dump_stack(void)
fprintf(stderr,"%% YAP ERROR: Code Space Collided against Global\n");
} else {
if (b_ptr != NULL) {
fprintf(stderr," [ Goals with open alternatives:\n");
fprintf(stderr," %% Goals with open alternatives:\n");
while (b_ptr != NULL) {
cl_position(b_ptr->cp_ap);
b_ptr = b_ptr->cp_b;
@ -305,7 +305,7 @@ dump_stack(void)
fprintf(stderr,"\n");
}
if (env_ptr != NULL) {
fprintf(stderr," [ Goals left to continue:\n");
fprintf(stderr," %% Goals left to continue:\n");
while (env_ptr != NULL) {
cl_position((yamop *)(env_ptr[E_CP]));
env_ptr = (CELL *)(env_ptr[E_E]);

View File

@ -944,7 +944,8 @@ execute_growstack(long size0, int from_trail)
if (!Yap_ExtendWorkSpace(size)) {
/* make sure stacks and trail are contiguous */
Int minimal_request = AdjustPageSize(((CELL)Yap_TrailTop-(CELL)Yap_GlobalBase)+4*MinHeapGap+size0);
minimal_request = AdjustPageSize(((CELL)Yap_TrailTop-(CELL)Yap_GlobalBase)+4*MinHeapGap+size0);
size = Yap_ExtendWorkSpaceThroughHole(minimal_request);
if (size < 0) {

View File

@ -674,17 +674,17 @@ inc_vars_of_type(CELL *curr,gc_types val) {
static void
put_type_info(unsigned long total)
{
fprintf(Yap_stderr,"[GC] type info for %lu cells\n", total);
fprintf(Yap_stderr,"[GC] %lu vars\n", vars[gc_var]);
fprintf(Yap_stderr,"[GC] %lu refs\n", vars[gc_ref]);
fprintf(Yap_stderr,"[GC] %lu references from env\n", env_vars);
fprintf(Yap_stderr,"[GC] %lu atoms\n", vars[gc_atom]);
fprintf(Yap_stderr,"[GC] %lu small ints\n", vars[gc_int]);
fprintf(Yap_stderr,"[GC] %lu other numbers\n", vars[gc_num]);
fprintf(Yap_stderr,"[GC] %lu lists\n", vars[gc_list]);
fprintf(Yap_stderr,"[GC] %lu compound terms\n", vars[gc_appl]);
fprintf(Yap_stderr,"[GC] %lu functors\n", vars[gc_func]);
fprintf(Yap_stderr,"[GC] %lu suspensions\n", vars[gc_susp]);
fprintf(Yap_stderr,"%% type info for %lu cells\n", total);
fprintf(Yap_stderr,"%% %lu vars\n", vars[gc_var]);
fprintf(Yap_stderr,"%% %lu refs\n", vars[gc_ref]);
fprintf(Yap_stderr,"%% %lu references from env\n", env_vars);
fprintf(Yap_stderr,"%% %lu atoms\n", vars[gc_atom]);
fprintf(Yap_stderr,"%% %lu small ints\n", vars[gc_int]);
fprintf(Yap_stderr,"%% %lu other numbers\n", vars[gc_num]);
fprintf(Yap_stderr,"%% %lu lists\n", vars[gc_list]);
fprintf(Yap_stderr,"%% %lu compound terms\n", vars[gc_appl]);
fprintf(Yap_stderr,"%% %lu functors\n", vars[gc_func]);
fprintf(Yap_stderr,"%% %lu suspensions\n", vars[gc_susp]);
}
static void
@ -1445,11 +1445,11 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose)
Term mod;
if (Yap_PredForCode(gc_B->cp_ap, &at, &arity, &mod)) {
if (arity)
fprintf(Yap_stderr,"[GC] %s/%ld marked %ld (%s)\n", RepAtom(at)->StrOfAE, (long int)arity, total_marked, op_names[opnum]);
fprintf(Yap_stderr,"%% %s/%ld marked %ld (%s)\n", RepAtom(at)->StrOfAE, (long int)arity, total_marked, op_names[opnum]);
else
fprintf(Yap_stderr,"[GC] %s marked %ld (%s)\n", RepAtom(at)->StrOfAE, total_marked, op_names[opnum]);
fprintf(Yap_stderr,"%% %s marked %ld (%s)\n", RepAtom(at)->StrOfAE, total_marked, op_names[opnum]);
} else
fprintf(Yap_stderr,"[GC] marked %ld (%s)\n", total_marked, op_names[opnum]);
fprintf(Yap_stderr,"%% marked %ld (%s)\n", total_marked, op_names[opnum]);
}
break;
#ifdef TABLING
@ -1460,9 +1460,9 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose)
op_numbers caller_op = Yap_op_from_opcode(ENV_ToOp(gc_B->cp_cp));
/* first condition checks if this was a meta-call */
if ((caller_op != _call && caller_op != _fcall) || pe == NULL) {
fprintf(Yap_stderr,"[GC] marked %ld (%s)\n", total_marked, op_names[opnum]);
fprintf(Yap_stderr,"%% marked %ld (%s)\n", total_marked, op_names[opnum]);
} else
fprintf(Yap_stderr,"[GC] %s/%d marked %ld (%s)\n", RepAtom(NameOfFunctor(pe->FunctorOfPred))->StrOfAE, pe->ArityOfPE, total_marked, op_names[opnum]);
fprintf(Yap_stderr,"%% %s/%d marked %ld (%s)\n", RepAtom(NameOfFunctor(pe->FunctorOfPred))->StrOfAE, pe->ArityOfPE, total_marked, op_names[opnum]);
}
break;
case _trie_retry_var:
@ -1475,19 +1475,19 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose)
case _trie_trust_list:
case _trie_retry_struct:
case _trie_trust_struct:
fprintf(Yap_stderr,"[GC] marked %ld (%s)\n", total_marked, op_names[opnum]);
fprintf(Yap_stderr,"%% marked %ld (%s)\n", total_marked, op_names[opnum]);
break;
#endif
default:
{
PredEntry *pe = (PredEntry *)gc_B->cp_ap->u.ld.p;
if (pe == NULL) {
fprintf(Yap_stderr,"[GC] marked %ld (%s)\n", total_marked, op_names[opnum]);
fprintf(Yap_stderr,"%% marked %ld (%s)\n", total_marked, op_names[opnum]);
} else
if (pe->ArityOfPE)
fprintf(Yap_stderr,"[GC] %s/%d marked %ld (%s)\n", RepAtom(NameOfFunctor(pe->FunctorOfPred))->StrOfAE, pe->ArityOfPE, total_marked, op_names[opnum]);
fprintf(Yap_stderr,"%% %s/%d marked %ld (%s)\n", RepAtom(NameOfFunctor(pe->FunctorOfPred))->StrOfAE, pe->ArityOfPE, total_marked, op_names[opnum]);
else
fprintf(Yap_stderr,"[GC] %s marked %ld (%s)\n", RepAtom((Atom)(pe->FunctorOfPred))->StrOfAE, total_marked, op_names[opnum]);
fprintf(Yap_stderr,"%% %s marked %ld (%s)\n", RepAtom((Atom)(pe->FunctorOfPred))->StrOfAE, total_marked, op_names[opnum]);
}
}
}
@ -2019,26 +2019,26 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR)
if (is_gc_verbose()) {
if (old_TR != (tr_fr_ptr)Yap_TrailBase)
fprintf(Yap_stderr,
"[GC] Trail: discarded %d (%ld%%) cells out of %ld\n",
"%% Trail: discarded %d (%ld%%) cells out of %ld\n",
discard_trail_entries,
(unsigned long int)(discard_trail_entries*100/(old_TR-(tr_fr_ptr)Yap_TrailBase)),
(unsigned long int)(old_TR-(tr_fr_ptr)Yap_TrailBase));
#ifdef DEBUG
if (hp_entrs > 0)
fprintf(Yap_stderr,
"[GC] Trail: unmarked %ld dbentries (%ld%%) out of %ld\n",
"%% Trail: unmarked %ld dbentries (%ld%%) out of %ld\n",
(long int)hp_not_in_use,
(long int)(hp_not_in_use*100/hp_entrs),
(long int)hp_entrs);
if (hp_in_use_erased > 0 && hp_erased > 0)
fprintf(Yap_stderr,
"[GC] Trail: deleted %ld dbentries (%ld%%) out of %ld\n",
"%% Trail: deleted %ld dbentries (%ld%%) out of %ld\n",
(long int)hp_erased,
(long int)(hp_erased*100/(hp_erased+hp_in_use_erased)),
(long int)(hp_erased+hp_in_use_erased));
#endif
fprintf(Yap_stderr,
"[GC] Heap: recovered %ld bytes (%ld%%) out of %ld\n",
"%% Heap: recovered %ld bytes (%ld%%) out of %ld\n",
(unsigned long int)(OldHeapUsed-HeapUsed),
(unsigned long int)((OldHeapUsed-HeapUsed)/(OldHeapUsed/100)),
(unsigned long int)OldHeapUsed);
@ -2609,7 +2609,7 @@ compact_heap(void)
#ifdef DEBUG
if (total_marked != found_marked)
fprintf(Yap_stderr,"[GC] Upward (%d): %ld total against %ld found\n",
fprintf(Yap_stderr,"%% Upward (%d): %ld total against %ld found\n",
gc_calls,
(unsigned long int)total_marked,
(unsigned long int)found_marked);
@ -2667,7 +2667,7 @@ compact_heap(void)
}
#ifdef DEBUG
if (total_marked != found_marked)
fprintf(Yap_stderr,"[GC] Downward (%d): %ld total against %ld found\n",
fprintf(Yap_stderr,"%% Downward (%d): %ld total against %ld found\n",
gc_calls,
(unsigned long int)total_marked,
(unsigned long int)found_marked);
@ -2801,7 +2801,7 @@ icompact_heap(void)
#ifdef DEBUG
if (total_marked != found_marked)
fprintf(Yap_stderr,"[GC] Upward (%d): %ld total against %ld found\n",
fprintf(Yap_stderr,"%% Upward (%d): %ld total against %ld found\n",
gc_calls,
(unsigned long int)total_marked,
(unsigned long int)found_marked);
@ -2856,7 +2856,7 @@ icompact_heap(void)
}
#ifdef DEBUG
if (total_marked != found_marked)
fprintf(Yap_stderr,"[GC] Downward (%d): %ld total against %ld found\n",
fprintf(Yap_stderr,"%% Downward (%d): %ld total against %ld found\n",
gc_calls,
(unsigned long int)total_marked,
(unsigned long int)found_marked);
@ -2961,12 +2961,12 @@ compaction_phase(tr_fr_ptr old_TR, CELL *current_env, yamop *curp, CELL *max)
-total_smarked
#endif
!= iptop-(CELL_PTR *)H && iptop < (CELL_PTR *)ASP -1024)
fprintf(Yap_stderr,"[GC] Oops on iptop-H (%ld) vs %ld\n", (unsigned long int)(iptop-(CELL_PTR *)H), total_marked);
fprintf(Yap_stderr,"%% Oops on iptop-H (%ld) vs %ld\n", (unsigned long int)(iptop-(CELL_PTR *)H), total_marked);
#endif
if (iptop < (CELL_PTR *)ASP && 10*total_marked < H-H0) {
#ifdef INSTRUMENT_GC
int effectiveness = (((H-H0)-total_marked)*100)/(H-H0);
fprintf(Yap_stderr,"[GC] using pointers (%d)\n", effectiveness);
fprintf(Yap_stderr,"%% using pointers (%d)\n", effectiveness);
#endif
quicksort((CELL_PTR *)H, 0, (iptop-(CELL_PTR *)H)-1);
adjust_cp_hbs();
@ -2977,7 +2977,7 @@ compaction_phase(tr_fr_ptr old_TR, CELL *current_env, yamop *curp, CELL *max)
#ifdef DEBUG
#ifdef HYBID_SCHEME
int effectiveness = (((H-H0)-total_marked)*100)/(H-H0);
fprintf(stderr,"[GC] not using pointers (%d) ASP: %p, ip %p (expected %p) \n", effectiveness, ASP, iptop, H+total_marked);
fprintf(stderr,"%% not using pointers (%d) ASP: %p, ip %p (expected %p) \n", effectiveness, ASP, iptop, H+total_marked);
#endif
#endif
compact_heap();
@ -3040,21 +3040,21 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop)
if ((CELL)Yap_TrailTop & (MBIT|RBIT)) {
/* oops, we can't */
if (gc_verbose) {
fprintf(Yap_stderr, "[GC] TrailTop at %p clashes with gc bits: %lx\n", Yap_TrailTop, (unsigned long int)(MBIT|RBIT));
fprintf(Yap_stderr, "[GC] garbage collection disallowed\n");
fprintf(Yap_stderr, "%% TrailTop at %p clashes with gc bits: %lx\n", Yap_TrailTop, (unsigned long int)(MBIT|RBIT));
fprintf(Yap_stderr, "%% garbage collection disallowed\n");
}
return(0);
}
if (gc_trace) {
fprintf(Yap_stderr, "[gc]\n");
} else if (gc_verbose) {
fprintf(Yap_stderr, "[GC] Start of garbage collection %d:\n", gc_calls);
fprintf(Yap_stderr, "%% Start of garbage collection %d:\n", gc_calls);
#ifndef EARLY_RESET
fprintf(Yap_stderr, "[GC] no early reset in trail\n");
fprintf(Yap_stderr, "%% no early reset in trail\n");
#endif
fprintf(Yap_stderr, "[GC] Global: %8ld cells (%p-%p)\n", (long int)heap_cells,H0,H);
fprintf(Yap_stderr, "[GC] Local:%8ld cells (%p-%p)\n", (unsigned long int)(LCL0-ASP),LCL0,ASP);
fprintf(Yap_stderr, "[GC] Trail:%8ld cells (%p-%p)\n",
fprintf(Yap_stderr, "%% Global: %8ld cells (%p-%p)\n", (long int)heap_cells,H0,H);
fprintf(Yap_stderr, "%% Local:%8ld cells (%p-%p)\n", (unsigned long int)(LCL0-ASP),LCL0,ASP);
fprintf(Yap_stderr, "%% Trail:%8ld cells (%p-%p)\n",
(unsigned long int)(TR-(tr_fr_ptr)Yap_TrailBase),Yap_TrailBase,TR);
}
#if !USE_SYSTEM_MALLOC
@ -3089,19 +3089,19 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop)
else
effectiveness = 0;
if (gc_verbose) {
fprintf(Yap_stderr, "[GC] Mark: Recovered %ld cells of %ld (%ld%%) in %g sec\n",
fprintf(Yap_stderr, "%% Mark: Recovered %ld cells of %ld (%ld%%) in %g sec\n",
(long int)(heap_cells-total_marked), (long int)heap_cells, (long int)effectiveness, (double)(m_time-time_start)/1000);
#ifdef INSTRUMENT_GC
{
int i;
for (i=0; i<16; i++) {
if (chain[i]) {
fprintf(Yap_stderr, "[GC] chain[%d]=%lu\n", i, chain[i]);
fprintf(Yap_stderr, "%% chain[%d]=%lu\n", i, chain[i]);
}
}
put_type_info((unsigned long int)total_marked);
fprintf(Yap_stderr,"[GC] %lu/%ld before and %lu/%ld after\n", old_vars, (unsigned long int)(B->cp_h-H0), new_vars, (unsigned long int)(H-B->cp_h));
fprintf(Yap_stderr,"[GC] %ld choicepoints\n", num_bs);
fprintf(Yap_stderr,"%% %lu/%ld before and %lu/%ld after\n", old_vars, (unsigned long int)(B->cp_h-H0), new_vars, (unsigned long int)(H-B->cp_h));
fprintf(Yap_stderr,"%% %ld choicepoints\n", num_bs);
}
#endif
}
@ -3113,14 +3113,14 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop)
YAPLeaveCriticalSection();
c_time = Yap_cputime();
if (gc_verbose) {
fprintf(Yap_stderr, "[GC] Compress: took %g sec\n", (double)(c_time-time_start)/1000);
fprintf(Yap_stderr, "%% Compress: took %g sec\n", (double)(c_time-time_start)/1000);
}
gc_time += (c_time-time_start);
tot_gc_time += gc_time;
tot_gc_recovered += heap_cells-total_marked;
if (gc_verbose) {
fprintf(Yap_stderr, "[GC] GC %d took %g sec, total of %g sec doing GC so far.\n", gc_calls, (double)gc_time/1000, (double)tot_gc_time/1000);
fprintf(Yap_stderr, "[GC] Left %ld cells free in stacks.\n",
fprintf(Yap_stderr, "%% GC %d took %g sec, total of %g sec doing GC so far.\n", gc_calls, (double)gc_time/1000, (double)tot_gc_time/1000);
fprintf(Yap_stderr, "%% Left %ld cells free in stacks.\n",
(unsigned long int)(ASP-H));
}
check_global();

View File

@ -11,8 +11,11 @@
* File: index.c *
* comments: Indexing a Prolog predicate *
* *
* Last rev: $Date: 2004-08-27 20:18:52 $,$Author: vsc $ *
* Last rev: $Date: 2004-09-03 03:11:09 $,$Author: vsc $ *
* $Log: not supported by cvs2svn $
* Revision 1.96 2004/08/27 20:18:52 vsc
* more small fixes
*
* Revision 1.95 2004/08/11 16:14:52 vsc
* whole lot of fixes:
* - memory leak in indexing
@ -137,6 +140,9 @@ cleanup_sw_on_clauses(CELL larg, UInt sz, OPCODE ecls)
if (xp->opc == ecls) {
if (xp->u.sp.s3 == 1) {
UInt nsz = sz + (UInt)(NEXTOP((yamop *)NULL,sp)+xp->u.sp.s1*sizeof(yamop *));
#if DEBUG
Yap_expand_clauses_sz -= (UInt)(NEXTOP((yamop *)NULL,sp)+xp->u.sp.s1*sizeof(yamop *));
#endif
Yap_FreeCodeSpace((char *)xp);
return nsz;
} else {
@ -2917,6 +2923,9 @@ suspend_indexing(ClauseDef *min, ClauseDef *max, PredEntry *ap, struct intermedi
yamop **st;
UInt sz = (UInt)(NEXTOP((yamop *)NULL,sp)+cls*sizeof(yamop *));
#if DEBUG
Yap_expand_clauses_sz += sz;
#endif
if ((ncode = (yamop *)Yap_AllocCodeSpace(sz)) == NULL) {
Yap_Error_Size = recover_from_failed_susp_on_cls(cint, sz);
longjmp(cint->CompilerBotch, 2);
@ -2941,6 +2950,9 @@ recover_ecls_block(yamop *ipc)
{
ipc->u.sp.s3--;
if (!ipc->u.sp.s3) {
#if DEBUG
Yap_expand_clauses_sz -= (UInt)(NEXTOP((yamop *)NULL,sp)+ipc->u.sp.s1*sizeof(yamop *));
#endif
Yap_FreeCodeSpace((char *)ipc);
}
}

View File

@ -1043,6 +1043,9 @@ InitCodes(void)
heap_regs->db_erased_marker->Parent = NULL;
INIT_LOCK(heap_regs->db_erased_marker->lock);
INIT_DBREF_COUNT(heap_regs->db_erased_marker);
#if DEBUG
heap_regs->expand_clauses_sz = 0L;
#endif
}

View File

@ -10,7 +10,7 @@
* File: Heap.h *
* mods: *
* comments: Heap Init Structure *
* version: $Id: Heap.h,v 1.64 2004-07-22 21:32:21 vsc Exp $ *
* version: $Id: Heap.h,v 1.65 2004-09-03 03:11:09 vsc Exp $ *
*************************************************************************/
/* information that can be stored in Code Space */
@ -361,6 +361,7 @@ typedef struct various_codes {
#ifdef DEBUG
struct logic_upd_clause *db_erased_list;
struct logic_upd_index *db_erased_ilist;
UInt expand_clauses_sz;
#endif /* DEBUG */
struct stream_desc *yap_streams;
#ifdef DEBUG
@ -610,6 +611,7 @@ struct various_codes *heap_regs;
#ifdef DEBUG
#define DBErasedList heap_regs->db_erased_list
#define DBErasedIList heap_regs->db_erased_ilist
#define Yap_expand_clauses_sz heap_regs->expand_clauses_sz
#endif /* DEBUG */
#define Stream heap_regs->yap_streams
#define output_msg heap_regs->debugger_output_msg

View File

@ -74,6 +74,9 @@ typedef struct FREEB {
#define ALIGN_YAPTYPE(X,TYPE) (((CELL)(X)+(sizeof(TYPE)-1)) & ~(sizeof(TYPE)-1))
/* SIZE should be a power of 2 */
#define ALIGN_SIZE(X,SIZE) (((CELL)(X)+((SIZE)-1)) & ~((SIZE)-1))
/* I'll assume page size is always a power of two */
#define AdjustPageSize(X) ((X) & (Yap_page_size-1) ? \
((X) + Yap_page_size) & (~(Yap_page_size-1)) : \