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

@@ -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);
}
}
@@ -2662,24 +2668,31 @@ p_toggle_static_predicates_in_use(void)
}
static void
clause_was_found(PredEntry *pp, Atom *pat, UInt *parity) {
/* we found it */
*parity = pp->ArityOfPE;
if (pp->ArityOfPE) {
*pat = NameOfFunctor(pp->FunctorOfPred);
clause_was_found(PredEntry *pp, Atom *pat, UInt *parity) {
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 {
*pat = (Atom)(pp->FunctorOfPred);
*parity = pp->ArityOfPE;
if (pp->ArityOfPE) {
*pat = NameOfFunctor(pp->FunctorOfPred);
} else {
*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);
}