1estranha
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1709 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
776262bc9b
commit
9c506b2a2c
46
C/amasm.c
46
C/amasm.c
|
@ -11,8 +11,13 @@
|
|||
* File: amasm.c *
|
||||
* comments: abstract machine assembler *
|
||||
* *
|
||||
* Last rev: $Date: 2006-10-11 14:53:57 $ *
|
||||
* Last rev: $Date: 2006-11-06 18:35:03 $ *
|
||||
* $Log: not supported by cvs2svn $
|
||||
* Revision 1.90 2006/10/11 14:53:57 vsc
|
||||
* fix memory leak
|
||||
* fix overflow handling
|
||||
* VS: ----------------------------------------------------------------------
|
||||
*
|
||||
* Revision 1.89 2006/10/10 14:08:16 vsc
|
||||
* small fixes on threaded implementation.
|
||||
*
|
||||
|
@ -1483,9 +1488,15 @@ a_4sw(op_numbers opcode, yamop *code_p, int pass_no, struct intermediates *cip)
|
|||
code_p->u.ollll.l3 = emit_ilabel(seq_ptr[2], cip);
|
||||
code_p->u.ollll.l4 = emit_ilabel(seq_ptr[3], cip);
|
||||
if (cip->CurrentPred->PredFlags & LogUpdatePredFlag) {
|
||||
Yap_FreeCodeSpace((char *)ClauseCodeToLogUpdIndex(ars));
|
||||
LogUpdIndex *icl = ClauseCodeToLogUpdIndex(ars);
|
||||
|
||||
Yap_LUIndexSpace_Tree -= icl->ClSize;
|
||||
Yap_FreeCodeSpace((char *)icl);
|
||||
} else {
|
||||
Yap_FreeCodeSpace((char *)ClauseCodeToStaticIndex(ars));
|
||||
StaticIndex *icl = ClauseCodeToStaticIndex(ars);
|
||||
|
||||
Yap_IndexSpace_Tree -= icl->ClSize;
|
||||
Yap_FreeCodeSpace((char *)icl);
|
||||
}
|
||||
}
|
||||
GONEXT(ollll);
|
||||
|
@ -1690,6 +1701,7 @@ a_try(op_numbers opcode, CELL lab, CELL opr, int nofalts, int hascut, yamop *cod
|
|||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch,2);
|
||||
}
|
||||
Yap_LUIndexSpace_CP += size;
|
||||
#ifdef DEBUG
|
||||
Yap_NewCps++;
|
||||
Yap_LiveCps++;
|
||||
|
@ -3254,9 +3266,11 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
|
|||
a_fetch_vv(&cmp_info, pass_no, cip);
|
||||
break;
|
||||
case fetch_args_vc_op:
|
||||
case fetch_args_vi_op:
|
||||
a_fetch_vc(&cmp_info, pass_no, cip);
|
||||
break;
|
||||
case fetch_args_cv_op:
|
||||
case fetch_args_iv_op:
|
||||
a_fetch_cv(&cmp_info, pass_no, cip);
|
||||
break;
|
||||
case f_val_op:
|
||||
|
@ -3332,7 +3346,7 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
|
|||
|
||||
|
||||
static DBTerm *
|
||||
fetch_clause_space(Term* tp, UInt size, struct intermediates *cip)
|
||||
fetch_clause_space(Term* tp, UInt size, struct intermediates *cip, UInt *osizep)
|
||||
{
|
||||
CELL *h0 = H;
|
||||
DBTerm *x;
|
||||
|
@ -3340,7 +3354,7 @@ fetch_clause_space(Term* tp, UInt size, struct intermediates *cip)
|
|||
/* This stuff should be just about fetching the space from the data-base,
|
||||
unfortunately we have to do all sorts of error handling :-( */
|
||||
H = (CELL *)cip->freep;
|
||||
while ((x = Yap_StoreTermInDBPlusExtraSpace(*tp, size)) == NULL) {
|
||||
while ((x = Yap_StoreTermInDBPlusExtraSpace(*tp, size, osizep)) == NULL) {
|
||||
|
||||
H = h0;
|
||||
switch (Yap_Error_TYPE) {
|
||||
|
@ -3412,13 +3426,14 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates
|
|||
!is_fact) {
|
||||
DBTerm *x;
|
||||
LogUpdClause *cl;
|
||||
UInt osize;
|
||||
|
||||
if(!(x = fetch_clause_space(&t,size,cip))){
|
||||
if(!(x = fetch_clause_space(&t,size,cip,&osize))){
|
||||
return NULL;
|
||||
}
|
||||
cl = (LogUpdClause *)((CODEADDR)x-(UInt)size);
|
||||
cl->ClSize += sizeof(DBTerm) + sizeof(CELL)*x->NOfCells;
|
||||
cl->ClSource = x;
|
||||
cl->ClSize = osize;
|
||||
cip->code_addr = (yamop *)cl;
|
||||
} else if (mode == ASSEMBLING_CLAUSE &&
|
||||
(ap->PredFlags & SourcePredFlag ||
|
||||
|
@ -3426,15 +3441,17 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates
|
|||
!is_fact) {
|
||||
DBTerm *x;
|
||||
StaticClause *cl;
|
||||
if(!(x = fetch_clause_space(&t,size,cip))) {
|
||||
UInt osize;
|
||||
|
||||
if(!(x = fetch_clause_space(&t,size,cip,&osize))) {
|
||||
return NULL;
|
||||
}
|
||||
cl = (StaticClause *)((CODEADDR)x-(UInt)size);
|
||||
cip->code_addr = (yamop *)cl;
|
||||
code_p = do_pass(1, &entry_code, mode, &clause_has_blobs, cip, size);
|
||||
/* make sure we copy after second pass */
|
||||
cl->ClSize += sizeof(DBTerm) + sizeof(CELL)*x->NOfCells;
|
||||
cl->usc.ClSource = x;
|
||||
cl->ClSize = osize;
|
||||
ProfEnd=code_p;
|
||||
return entry_code;
|
||||
} else {
|
||||
|
@ -3446,6 +3463,17 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates
|
|||
return NULL;
|
||||
}
|
||||
}
|
||||
if (mode == ASSEMBLING_CLAUSE) {
|
||||
if (ap->PredFlags & LogUpdatePredFlag) {
|
||||
Yap_LUClauseSpace += size;
|
||||
} else
|
||||
Yap_ClauseSpace += size;
|
||||
} else {
|
||||
if (ap->PredFlags & LogUpdatePredFlag) {
|
||||
Yap_LUIndexSpace_Tree += size;
|
||||
} else
|
||||
Yap_IndexSpace_Tree += size;
|
||||
}
|
||||
}
|
||||
code_p = do_pass(1, &entry_code, mode, &clause_has_blobs, cip, size);
|
||||
ProfEnd=code_p;
|
||||
|
|
35
C/cdmgr.c
35
C/cdmgr.c
|
@ -11,8 +11,11 @@
|
|||
* File: cdmgr.c *
|
||||
* comments: Code manager *
|
||||
* *
|
||||
* Last rev: $Date: 2006-10-16 17:12:48 $,$Author: vsc $ *
|
||||
* Last rev: $Date: 2006-11-06 18:35:03 $,$Author: vsc $ *
|
||||
* $Log: not supported by cvs2svn $
|
||||
* Revision 1.196 2006/10/16 17:12:48 vsc
|
||||
* fixes for threaded version.
|
||||
*
|
||||
* Revision 1.195 2006/10/11 17:24:36 vsc
|
||||
* make sure we only follow pointers *before* we removed the respective code block,
|
||||
* ie don't kill the child before checking pointers from parent!
|
||||
|
@ -635,6 +638,7 @@ Yap_BuildMegaClause(PredEntry *ap)
|
|||
return;
|
||||
}
|
||||
}
|
||||
Yap_ClauseSpace += required;
|
||||
/* cool, it's our turn to do the conversion */
|
||||
mcl->ClFlags = MegaMask | has_blobs;
|
||||
mcl->ClSize = sz*ap->cs.p_code.NOfClauses;
|
||||
|
@ -664,6 +668,7 @@ Yap_BuildMegaClause(PredEntry *ap)
|
|||
|
||||
ncl = cl->ClNext;
|
||||
Yap_InformOfRemoval((CODEADDR)cl);
|
||||
Yap_ClauseSpace -= cl->ClSize;
|
||||
Yap_FreeCodeSpace((ADDR)cl);
|
||||
if (curcl->ClCode == ap->cs.p_code.LastClause)
|
||||
break;
|
||||
|
@ -696,6 +701,7 @@ split_megaclause(PredEntry *ap)
|
|||
StaticClause *cl = start;
|
||||
start = cl->ClNext;
|
||||
Yap_InformOfRemoval((CODEADDR)cl);
|
||||
Yap_ClauseSpace -= cl->ClSize;
|
||||
Yap_FreeCodeSpace((char *)cl);
|
||||
}
|
||||
if (ap->ArityOfPE) {
|
||||
|
@ -707,6 +713,7 @@ split_megaclause(PredEntry *ap)
|
|||
return;
|
||||
}
|
||||
}
|
||||
Yap_ClauseSpace += sizeof(StaticClause)+mcl->ClItemSize;
|
||||
new->ClFlags = FactMask;
|
||||
new->ClSize = mcl->ClItemSize;
|
||||
new->usc.ClPred = ap;
|
||||
|
@ -878,6 +885,11 @@ release_wcls(yamop *cop, OPCODE ecs)
|
|||
Yap_expand_clauses_sz -= (UInt)(NEXTOP((yamop *)NULL,sp)+cop->u.sp.s1*sizeof(yamop *));
|
||||
#endif
|
||||
Yap_InformOfRemoval((CODEADDR)cop);
|
||||
if (cop->u.sp.p->PredFlags & LogUpdatePredFlag) {
|
||||
Yap_LUIndexSpace_EXT -= (UInt)NEXTOP((yamop *)NULL,sp)+cop->u.sp.s1*sizeof(yamop *);
|
||||
} else {
|
||||
Yap_IndexSpace_EXT -= (UInt)NEXTOP((yamop *)NULL,sp)+cop->u.sp.s1*sizeof(yamop *);
|
||||
}
|
||||
Yap_FreeCodeSpace((char *)cop);
|
||||
}
|
||||
}
|
||||
|
@ -944,6 +956,7 @@ cleanup_dangling_indices(yamop *ipc, yamop *beg, yamop *end, yamop *suspend_code
|
|||
yamop *oipc = ipc;
|
||||
decrease_ref_counter(ipc->u.lld.d->ClCode, beg, end, suspend_code);
|
||||
ipc = ipc->u.lld.n;
|
||||
Yap_LUIndexSpace_CP -= (UInt)NEXTOP((yamop *)NULL,lld);
|
||||
Yap_FreeCodeSpace((ADDR)oipc);
|
||||
#ifdef DEBUG
|
||||
Yap_DirtyCps--;
|
||||
|
@ -960,6 +973,7 @@ cleanup_dangling_indices(yamop *ipc, yamop *beg, yamop *end, yamop *suspend_code
|
|||
Yap_FreedCps++;
|
||||
#endif
|
||||
decrease_ref_counter(ipc->u.lld.d->ClCode, beg, end, suspend_code);
|
||||
Yap_LUIndexSpace_CP -= (UInt)NEXTOP((yamop *)NULL,lld);
|
||||
Yap_FreeCodeSpace((ADDR)ipc);
|
||||
end = ipc;
|
||||
return;
|
||||
|
@ -1082,6 +1096,10 @@ kill_static_child_indxs(StaticIndex *indx, int in_use)
|
|||
UNLOCK(DeadStaticIndicesLock);
|
||||
} else {
|
||||
Yap_InformOfRemoval((CODEADDR)indx);
|
||||
if (indx->ClFlags & SwitchTableMask)
|
||||
Yap_IndexSpace_SW -= indx->ClSize;
|
||||
else
|
||||
Yap_IndexSpace_Tree -= indx->ClSize;
|
||||
Yap_FreeCodeSpace((char *)indx);
|
||||
}
|
||||
}
|
||||
|
@ -1143,6 +1161,11 @@ kill_off_lu_block(LogUpdIndex *c, LogUpdIndex *parent, PredEntry *ap)
|
|||
}
|
||||
}
|
||||
Yap_InformOfRemoval((CODEADDR)c);
|
||||
if (c->ClFlags & SwitchTableMask)
|
||||
Yap_LUIndexSpace_SW -= c->ClSize;
|
||||
else {
|
||||
Yap_LUIndexSpace_Tree -= c->ClSize;
|
||||
}
|
||||
Yap_FreeCodeSpace((char *)c);
|
||||
}
|
||||
|
||||
|
@ -1348,6 +1371,7 @@ retract_all(PredEntry *p, int in_use)
|
|||
UNLOCK(DeadMegaClausesLock);
|
||||
} else {
|
||||
Yap_InformOfRemoval((CODEADDR)cl);
|
||||
Yap_ClauseSpace -= cl->ClSize;
|
||||
Yap_FreeCodeSpace((char *)cl);
|
||||
}
|
||||
/* make sure this is not a MegaClause */
|
||||
|
@ -1366,6 +1390,7 @@ retract_all(PredEntry *p, int in_use)
|
|||
UNLOCK(DeadStaticClausesLock);
|
||||
} else {
|
||||
Yap_InformOfRemoval((CODEADDR)cl);
|
||||
Yap_ClauseSpace -= cl->ClSize;
|
||||
Yap_FreeCodeSpace((char *)cl);
|
||||
}
|
||||
p->cs.p_code.NOfClauses--;
|
||||
|
@ -1479,6 +1504,7 @@ add_first_dynamic(PredEntry *p, yamop *cp, int spy_flag)
|
|||
Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"Heap crashed against Stacks");
|
||||
return;
|
||||
}
|
||||
Yap_ClauseSpace += (Int)NEXTOP(NEXTOP(NEXTOP(ncp,ld),e),l);
|
||||
/* skip the first entry, this contains the back link and will always be
|
||||
empty for this entry */
|
||||
ncp = (yamop *)(((CELL *)ncp)+1);
|
||||
|
@ -2070,6 +2096,7 @@ Yap_EraseStaticClause(StaticClause *cl, Term mod) {
|
|||
UNLOCK(DeadStaticClausesLock);
|
||||
} else {
|
||||
Yap_InformOfRemoval((CODEADDR)cl);
|
||||
Yap_ClauseSpace -= cl->ClSize;
|
||||
Yap_FreeCodeSpace((char *)cl);
|
||||
}
|
||||
if (ap->cs.p_code.NOfClauses == 0) {
|
||||
|
@ -4575,18 +4602,24 @@ p_clean_up_dead_clauses(void)
|
|||
{
|
||||
while (DeadStaticClauses != NULL) {
|
||||
char *pt = (char *)DeadStaticClauses;
|
||||
Yap_ClauseSpace -= DeadStaticClauses->ClSize;
|
||||
DeadStaticClauses = DeadStaticClauses->ClNext;
|
||||
Yap_InformOfRemoval((CODEADDR)pt);
|
||||
Yap_FreeCodeSpace(pt);
|
||||
}
|
||||
while (DeadStaticIndices != NULL) {
|
||||
char *pt = (char *)DeadStaticIndices;
|
||||
if (DeadStaticIndices->ClFlags & SwitchTableMask)
|
||||
Yap_IndexSpace_SW -= DeadStaticIndices->ClSize;
|
||||
else
|
||||
Yap_IndexSpace_Tree -= DeadStaticIndices->ClSize;
|
||||
DeadStaticIndices = DeadStaticIndices->SiblingIndex;
|
||||
Yap_InformOfRemoval((CODEADDR)pt);
|
||||
Yap_FreeCodeSpace(pt);
|
||||
}
|
||||
while (DeadMegaClauses != NULL) {
|
||||
char *pt = (char *)DeadMegaClauses;
|
||||
Yap_ClauseSpace -= DeadMegaClauses->ClSize;
|
||||
DeadMegaClauses = DeadMegaClauses->ClNext;
|
||||
Yap_InformOfRemoval((CODEADDR)pt);
|
||||
Yap_FreeCodeSpace(pt);
|
||||
|
|
14
C/compiler.c
14
C/compiler.c
|
@ -11,8 +11,12 @@
|
|||
* File: compiler.c *
|
||||
* comments: Clause compiler *
|
||||
* *
|
||||
* Last rev: $Date: 2006-10-11 15:08:03 $,$Author: vsc $ *
|
||||
* Last rev: $Date: 2006-11-06 18:35:03 $,$Author: vsc $ *
|
||||
* $Log: not supported by cvs2svn $
|
||||
* Revision 1.81 2006/10/11 15:08:03 vsc
|
||||
* fix bb entries
|
||||
* comment development code for timestamp overflow.
|
||||
*
|
||||
* Revision 1.80 2006/09/20 20:03:51 vsc
|
||||
* improve indexing on floats
|
||||
* fix sending large lists to DB
|
||||
|
@ -894,7 +898,7 @@ c_bifun(Int Op, Term t1, Term t2, Term t3, int mod, compiler_struct *cglobs)
|
|||
/* first temp */
|
||||
Int v1 = --cglobs->tmpreg;
|
||||
|
||||
Yap_emit(fetch_args_vc_op, IntegerOfTerm(t2), Zero, &cglobs->cint);
|
||||
Yap_emit(fetch_args_vi_op, IntegerOfTerm(t2), 0L, &cglobs->cint);
|
||||
/* these should be the arguments */
|
||||
c_var(t1, v1, 0, 0, cglobs);
|
||||
/* now we know where the arguments are */
|
||||
|
@ -1130,7 +1134,7 @@ c_bifun(Int Op, Term t1, Term t2, Term t3, int mod, compiler_struct *cglobs)
|
|||
} else if (IsIntegerTerm(t1)) {
|
||||
/* first temp */
|
||||
Int v1 = --cglobs->tmpreg;
|
||||
Yap_emit(fetch_args_cv_op, IntegerOfTerm(t1), Zero, &cglobs->cint);
|
||||
Yap_emit(fetch_args_iv_op, IntegerOfTerm(t1), 0L, &cglobs->cint);
|
||||
/* these should be the arguments */
|
||||
c_var(t2, v1, 0, 0, cglobs);
|
||||
/* now we know where the arguments are */
|
||||
|
@ -1217,7 +1221,7 @@ c_functor(Term Goal, int mod, compiler_struct *cglobs)
|
|||
} else if (IsVarTerm(t2) && IsNewVar(t2) &&
|
||||
IsVarTerm(t3) && IsNewVar(t3)) {
|
||||
Int v1 = --cglobs->tmpreg;
|
||||
Yap_emit(fetch_args_vc_op, Zero, Zero, &cglobs->cint);
|
||||
Yap_emit(fetch_args_vi_op, Zero, Zero, &cglobs->cint);
|
||||
c_var(t1, v1, 0, 0, cglobs);
|
||||
c_var(t2,f_flag,(unsigned int)_functor, 0, cglobs);
|
||||
c_var(t3,f_flag,(unsigned int)_functor, 0, cglobs);
|
||||
|
@ -2698,6 +2702,8 @@ c_layout(compiler_struct *cglobs)
|
|||
break;
|
||||
case fetch_args_cv_op:
|
||||
case fetch_args_vc_op:
|
||||
case fetch_args_iv_op:
|
||||
case fetch_args_vi_op:
|
||||
rn_to_kill[1]=rn_to_kill[0]=0;
|
||||
if (cglobs->cint.cpc->nextInst &&
|
||||
cglobs->cint.cpc->nextInst->op == put_val_op &&
|
||||
|
|
50
C/dbase.c
50
C/dbase.c
|
@ -157,6 +157,7 @@ typedef struct db_globs {
|
|||
SFKeep *SFAr, *TopSF; /* Where are we putting our SFunctors */
|
||||
#endif
|
||||
DBRef found_one; /* Place where we started recording */
|
||||
UInt sz; /* total size */
|
||||
} dbglobs;
|
||||
|
||||
static dbglobs *s_dbg;
|
||||
|
@ -322,6 +323,7 @@ static void create_hash_table(DBProp p, Int hint) {
|
|||
hint <<= 1;
|
||||
/* clean up the table */
|
||||
pt = tbl = (hash_db_entry *)AllocDBSpace(hint*sizeof(hash_db_entry));
|
||||
Yap_LUClauseSpace += hint*sizeof(hash_db_entry);
|
||||
for (i=0; i< hint; i++) {
|
||||
pt->key = NULL;
|
||||
pt++;
|
||||
|
@ -1219,7 +1221,7 @@ generate_dberror_msg(int errnumb, UInt sz, char *msg)
|
|||
}
|
||||
|
||||
static DBRef
|
||||
CreateDBWithDBRef(Term Tm, DBProp p)
|
||||
CreateDBWithDBRef(Term Tm, DBProp p, struct db_globs *dbg)
|
||||
{
|
||||
DBRef pp, dbr = DBRefOfTerm(Tm);
|
||||
DBTerm *ppt;
|
||||
|
@ -1229,12 +1231,15 @@ CreateDBWithDBRef(Term Tm, DBProp p)
|
|||
if (ppt == NULL) {
|
||||
return generate_dberror_msg(OUT_OF_HEAP_ERROR, TermNil, "could not allocate space");
|
||||
}
|
||||
dbg->sz = sizeof(DBTerm)+2*sizeof(CELL);
|
||||
Yap_LUClauseSpace += sizeof(DBTerm)+2*sizeof(CELL);
|
||||
pp = (DBRef)ppt;
|
||||
} else {
|
||||
pp = AllocDBSpace(DBLength(2*sizeof(DBRef)));
|
||||
if (pp == NULL) {
|
||||
return generate_dberror_msg(OUT_OF_HEAP_ERROR, 0, "could not allocate space");
|
||||
}
|
||||
Yap_LUClauseSpace += DBLength(2*sizeof(DBRef));
|
||||
pp->id = FunctorDBRef;
|
||||
pp->Flags = DBNoVars|DBComplex|DBWithRefs;
|
||||
INIT_LOCK(pp->lock);
|
||||
|
@ -1259,7 +1264,7 @@ CreateDBWithDBRef(Term Tm, DBProp p)
|
|||
}
|
||||
|
||||
static DBTerm *
|
||||
CreateDBTermForAtom(Term Tm, UInt extra_size) {
|
||||
CreateDBTermForAtom(Term Tm, UInt extra_size, struct db_globs *dbg) {
|
||||
DBTerm *ppt;
|
||||
ADDR ptr;
|
||||
|
||||
|
@ -1267,6 +1272,8 @@ CreateDBTermForAtom(Term Tm, UInt extra_size) {
|
|||
if (ptr == NULL) {
|
||||
return (DBTerm *)generate_dberror_msg(OUT_OF_HEAP_ERROR, 0, "could not allocate space");
|
||||
}
|
||||
Yap_LUClauseSpace += extra_size+sizeof(DBTerm);
|
||||
dbg->sz = extra_size+sizeof(DBTerm);
|
||||
ppt = (DBTerm *)(ptr+extra_size);
|
||||
ppt->NOfCells = 0;
|
||||
ppt->DBRefs = NULL;
|
||||
|
@ -1279,7 +1286,7 @@ CreateDBTermForAtom(Term Tm, UInt extra_size) {
|
|||
}
|
||||
|
||||
static DBTerm *
|
||||
CreateDBTermForVar(UInt extra_size)
|
||||
CreateDBTermForVar(UInt extra_size, struct db_globs *dbg)
|
||||
{
|
||||
DBTerm *ppt;
|
||||
ADDR ptr;
|
||||
|
@ -1288,6 +1295,8 @@ CreateDBTermForVar(UInt extra_size)
|
|||
if (ptr == NULL) {
|
||||
return (DBTerm *)generate_dberror_msg(OUT_OF_HEAP_ERROR, 0, "could not allocate space");
|
||||
}
|
||||
Yap_LUClauseSpace += extra_size+sizeof(DBTerm);
|
||||
dbg->sz = extra_size+sizeof(DBTerm);
|
||||
ppt = (DBTerm *)(ptr+extra_size);
|
||||
ppt->NOfCells = 0;
|
||||
ppt->DBRefs = NULL;
|
||||
|
@ -1311,6 +1320,8 @@ CreateDBRefForAtom(Term Tm, DBProp p, int InFlag, struct db_globs *dbg) {
|
|||
if (pp == NIL) {
|
||||
return generate_dberror_msg(OUT_OF_HEAP_ERROR, 0, "could not allocate space");
|
||||
}
|
||||
Yap_LUClauseSpace += DBLength(NIL);
|
||||
dbg->sz = DBLength(NIL);
|
||||
pp->id = FunctorDBRef;
|
||||
INIT_LOCK(pp->lock);
|
||||
INIT_DBREF_COUNT(pp);
|
||||
|
@ -1335,6 +1346,8 @@ CreateDBRefForVar(Term Tm, DBProp p, int InFlag, struct db_globs *dbg) {
|
|||
if (pp == NULL) {
|
||||
return generate_dberror_msg(OUT_OF_HEAP_ERROR, 0, "could not allocate space");
|
||||
}
|
||||
Yap_LUClauseSpace += DBLength(NULL);
|
||||
dbg->sz = DBLength(NULL);
|
||||
pp->id = FunctorDBRef;
|
||||
pp->Flags = DBVar;
|
||||
pp->DBT.Entry = (CELL) Tm;
|
||||
|
@ -1367,14 +1380,14 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat, UInt extra_size, struc
|
|||
#ifdef COROUTINING
|
||||
if (!SafeIsAttachedTerm(Tm)) {
|
||||
#endif
|
||||
DBRef out = (DBRef)CreateDBTermForVar(extra_size);
|
||||
DBRef out = (DBRef)CreateDBTermForVar(extra_size, dbg);
|
||||
*pstat = TRUE;
|
||||
return out;
|
||||
#ifdef COROUTINING
|
||||
}
|
||||
#endif
|
||||
} else if (IsAtomOrIntTerm(Tm)) {
|
||||
DBRef out = (DBRef)CreateDBTermForAtom(Tm, extra_size);
|
||||
DBRef out = (DBRef)CreateDBTermForAtom(Tm, extra_size, dbg);
|
||||
*pstat = FALSE;
|
||||
return out;
|
||||
}
|
||||
|
@ -1465,7 +1478,7 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat, UInt extra_size, struc
|
|||
break;
|
||||
case (CELL)FunctorDBRef:
|
||||
Yap_ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||
return CreateDBWithDBRef(Tm, p);
|
||||
return CreateDBWithDBRef(Tm, p, dbg);
|
||||
#ifdef USE_GMP
|
||||
case (CELL)FunctorBigInt:
|
||||
ntp = copy_big_int(ntp0, RepAppl(Tm));
|
||||
|
@ -1547,6 +1560,8 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat, UInt extra_size, struc
|
|||
Yap_ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||
return generate_dberror_msg(OUT_OF_HEAP_ERROR, (UInt)DBLength(CodeAbs), "heap crashed against stacks");
|
||||
}
|
||||
Yap_LUClauseSpace += (CELL)CodeAbs+extra_size+sizeof(DBTerm);
|
||||
dbg->sz = (CELL)CodeAbs+extra_size+sizeof(DBTerm);
|
||||
pp = (DBRef)ppt;
|
||||
} else {
|
||||
pp = AllocDBSpace(DBLength(CodeAbs));
|
||||
|
@ -1554,6 +1569,8 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat, UInt extra_size, struc
|
|||
Yap_ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||
return generate_dberror_msg(OUT_OF_HEAP_ERROR, (UInt)DBLength(CodeAbs), "heap crashed against stacks");
|
||||
}
|
||||
Yap_LUClauseSpace += DBLength(CodeAbs);
|
||||
dbg->sz = DBLength(CodeAbs);
|
||||
pp->id = FunctorDBRef;
|
||||
pp->Flags = flag;
|
||||
INIT_LOCK(pp->lock);
|
||||
|
@ -1806,7 +1823,7 @@ new_lu_db_entry(Term t, PredEntry *pe)
|
|||
cl->ClPred = pe;
|
||||
cl->ClExt = NULL;
|
||||
cl->ClPrev = cl->ClNext = NULL;
|
||||
cl->ClSize = ((CODEADDR)&(x->Contents)-(CODEADDR)cl)+x->NOfCells*sizeof(CELL);
|
||||
cl->ClSize = dbg.sz;
|
||||
/* Support for timestamps */
|
||||
if (pe && pe->LastCallOfPred != LUCALL_ASSERT) {
|
||||
++pe->TimeStampOfPred;
|
||||
|
@ -2487,6 +2504,7 @@ init_int_keys(void) {
|
|||
p[0] = NIL;
|
||||
p++;
|
||||
}
|
||||
Yap_LUClauseSpace += sizeof(Prop)*INT_KEYS_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2500,6 +2518,7 @@ init_int_lu_keys(void) {
|
|||
p[0] = NULL;
|
||||
p++;
|
||||
}
|
||||
Yap_LUClauseSpace += sizeof(Prop)*INT_KEYS_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2507,6 +2526,7 @@ static int
|
|||
resize_int_keys(UInt new_size) {
|
||||
Prop *new;
|
||||
UInt i;
|
||||
UInt old_size = INT_KEYS_SIZE;
|
||||
|
||||
YAPEnterCriticalSection();
|
||||
if (INT_KEYS == NULL) {
|
||||
|
@ -2522,6 +2542,7 @@ resize_int_keys(UInt new_size) {
|
|||
Yap_ErrorMessage = "could not allocate space";
|
||||
return(FALSE);
|
||||
}
|
||||
Yap_LUClauseSpace += sizeof(Prop)*new_size;
|
||||
for (i = 0; i < new_size; i++) {
|
||||
new[i] = NIL;
|
||||
}
|
||||
|
@ -2538,6 +2559,7 @@ resize_int_keys(UInt new_size) {
|
|||
}
|
||||
}
|
||||
}
|
||||
Yap_LUClauseSpace -= sizeof(Prop)*old_size;
|
||||
Yap_FreeCodeSpace((char *)INT_KEYS);
|
||||
INT_KEYS = new;
|
||||
INT_KEYS_SIZE = new_size;
|
||||
|
@ -3896,6 +3918,7 @@ RemoveDBEntry(DBRef entryref)
|
|||
entryref->n->p = entryref->p;
|
||||
else
|
||||
entryref->Parent->L0 = entryref->p;
|
||||
/* Yap_LUClauseSpace -= entryref->Size; */
|
||||
FreeDBSpace((char *) entryref);
|
||||
}
|
||||
|
||||
|
@ -4022,6 +4045,7 @@ complete_lu_erase(LogUpdClause *clau)
|
|||
}
|
||||
}
|
||||
Yap_InformOfRemoval((CODEADDR)clau);
|
||||
Yap_LUClauseSpace -= clau->ClSize;
|
||||
Yap_FreeCodeSpace((char *)clau);
|
||||
}
|
||||
|
||||
|
@ -4156,6 +4180,7 @@ MyEraseClause(DynamicClause *clau)
|
|||
}
|
||||
} else {
|
||||
Yap_InformOfRemoval((CODEADDR)clau);
|
||||
Yap_LUClauseSpace -= clau->ClSize;
|
||||
Yap_FreeCodeSpace((char *)clau);
|
||||
#ifdef DEBUG
|
||||
if (ref->NOfRefsTo)
|
||||
|
@ -4942,13 +4967,16 @@ Yap_StoreTermInDB(Term t, int nargs) {
|
|||
}
|
||||
|
||||
DBTerm *
|
||||
Yap_StoreTermInDBPlusExtraSpace(Term t, UInt extra_size) {
|
||||
Yap_StoreTermInDBPlusExtraSpace(Term t, UInt extra_size, UInt *sz) {
|
||||
int needs_vars;
|
||||
struct db_globs dbg;
|
||||
DBTerm *o;
|
||||
|
||||
s_dbg = &dbg;
|
||||
return (DBTerm *)CreateDBStruct(t, (DBProp)NULL,
|
||||
InQueue, &needs_vars, extra_size, &dbg);
|
||||
o = (DBTerm *)CreateDBStruct(t, (DBProp)NULL,
|
||||
InQueue, &needs_vars, extra_size, &dbg);
|
||||
*sz = dbg.sz;
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
|
@ -4964,6 +4992,7 @@ p_init_queue(void)
|
|||
return(FALSE);
|
||||
}
|
||||
}
|
||||
/* Yap_LUClauseSpace += sizeof(db_queue); */
|
||||
dbq->id = FunctorDBRef;
|
||||
dbq->Flags = DBClMask;
|
||||
dbq->FirstInQueue = dbq->LastInQueue = NULL;
|
||||
|
@ -4995,6 +5024,7 @@ p_enqueue(void)
|
|||
return FALSE;
|
||||
}
|
||||
}
|
||||
/* Yap_LUClauseSpace += sizeof(QueueEntry); */
|
||||
t = Deref(ARG1);
|
||||
x->DBT = StoreTermInDB(Deref(ARG2), 2);
|
||||
if (x->DBT == NULL) {
|
||||
|
|
59
C/grow.c
59
C/grow.c
|
@ -590,6 +590,7 @@ static_growglobal(long size, CELL **ptr, CELL *hsplit)
|
|||
UInt minimal_request = 0L;
|
||||
long size0, sz = size;
|
||||
char vb_msg1 = '\0', *vb_msg2;
|
||||
int do_grow = TRUE;
|
||||
|
||||
if (hsplit) {
|
||||
/* just a little bit of sanity checking */
|
||||
|
@ -598,25 +599,31 @@ static_growglobal(long size, CELL **ptr, CELL *hsplit)
|
|||
return FALSE;
|
||||
else if (hsplit == (CELL *)omax)
|
||||
hsplit = NULL;
|
||||
if (size+H < ASP+4096) {
|
||||
/* don't need to expand stacks */
|
||||
do_grow = FALSE;
|
||||
}
|
||||
}
|
||||
/* adjust to a multiple of 256) */
|
||||
Yap_PrologMode |= GrowStackMode;
|
||||
if (size < ((char *)H0-omax)/8)
|
||||
size = ((char *)H0-omax)/8;
|
||||
size0 = size = AdjustPageSize(size);
|
||||
/* adjust to a multiple of 256) */
|
||||
Yap_ErrorMessage = NULL;
|
||||
if (!Yap_ExtendWorkSpace(size)) {
|
||||
Yap_PrologMode |= GrowStackMode;
|
||||
start_growth_time = Yap_cputime();
|
||||
if (do_grow) {
|
||||
if (!Yap_ExtendWorkSpace(size)) {
|
||||
|
||||
Yap_ErrorMessage = NULL;
|
||||
size += AdjustPageSize(((CELL)Yap_TrailTop-(CELL)Yap_GlobalBase)+MinHeapGap); minimal_request = size;
|
||||
size = Yap_ExtendWorkSpaceThroughHole(size);
|
||||
if (size < 0) {
|
||||
Yap_ErrorMessage = "Global Stack crashed against Local Stack";
|
||||
Yap_PrologMode &= ~GrowStackMode;
|
||||
return FALSE;
|
||||
Yap_ErrorMessage = NULL;
|
||||
size += AdjustPageSize(((CELL)Yap_TrailTop-(CELL)Yap_GlobalBase)+MinHeapGap); minimal_request = size;
|
||||
size = Yap_ExtendWorkSpaceThroughHole(size);
|
||||
if (size < 0) {
|
||||
Yap_ErrorMessage = "Global Stack crashed against Local Stack";
|
||||
Yap_PrologMode &= ~GrowStackMode;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
start_growth_time = Yap_cputime();
|
||||
gc_verbose = Yap_is_gc_verbose();
|
||||
delay_overflows++;
|
||||
if (gc_verbose) {
|
||||
|
@ -640,10 +647,18 @@ static_growglobal(long size, CELL **ptr, CELL *hsplit)
|
|||
#if USE_SYSTEM_MALLOC
|
||||
/* we always run the risk of shifting memory */
|
||||
size0 = Yap_GlobalBase-old_GlobalBase;
|
||||
DelayDiff = size0;
|
||||
TrDiff = LDiff = GDiff = size+size0;
|
||||
if (do_grow) {
|
||||
DelayDiff = size0;
|
||||
TrDiff = LDiff = GDiff = size+size0;
|
||||
} else {
|
||||
TrDiff = DelayDiff = LDiff = 0;
|
||||
GDiff = size;
|
||||
}
|
||||
#else
|
||||
if (minimal_request) {
|
||||
if (!do_grow) {
|
||||
TrDiff = DelayDiff = LDiff = 0;
|
||||
GDiff = size;
|
||||
} else if (minimal_request) {
|
||||
DelayDiff = size-size0;
|
||||
TrDiff = LDiff = GDiff = size;
|
||||
} else {
|
||||
|
@ -661,11 +676,13 @@ static_growglobal(long size, CELL **ptr, CELL *hsplit)
|
|||
XDiff = HDiff = 0;
|
||||
Yap_GlobalBase = old_GlobalBase;
|
||||
SetHeapRegs();
|
||||
MoveLocalAndTrail();
|
||||
if (hsplit) {
|
||||
MoveGlobalWithHole();
|
||||
} else {
|
||||
MoveExpandedGlobal();
|
||||
if (do_grow) {
|
||||
MoveLocalAndTrail();
|
||||
if (hsplit) {
|
||||
MoveGlobalWithHole();
|
||||
} else {
|
||||
MoveExpandedGlobal();
|
||||
}
|
||||
}
|
||||
AdjustStacksAndTrail();
|
||||
AdjustRegs(MaxTemps);
|
||||
|
@ -721,9 +738,9 @@ fix_compiler_instructions(PInstr *pcpc)
|
|||
case save_appl_op:
|
||||
case save_b_op:
|
||||
case commit_b_op:
|
||||
case fetch_args_vv_op:
|
||||
case fetch_args_cv_op:
|
||||
case fetch_args_vc_op:
|
||||
case fetch_args_vv_op:
|
||||
pcpc->rnd1 = GlobalAdjust(pcpc->rnd1);
|
||||
break;
|
||||
case get_float_op:
|
||||
|
@ -822,6 +839,8 @@ fix_compiler_instructions(PInstr *pcpc)
|
|||
case enter_lu_op:
|
||||
case empty_call_op:
|
||||
case blob_op:
|
||||
case fetch_args_vi_op:
|
||||
case fetch_args_iv_op:
|
||||
#ifdef TABLING
|
||||
case table_new_answer_op:
|
||||
case table_try_single_op:
|
||||
|
|
|
@ -2103,6 +2103,7 @@ CleanDeadClauses(void)
|
|||
while (cl) {
|
||||
if (!ref_in_use((DBRef)cl)) {
|
||||
char *ocl = (char *)cl;
|
||||
Yap_ClauseSpace -= cl->ClSize;
|
||||
cl = cl->ClNext;
|
||||
*cptr = cl;
|
||||
Yap_FreeCodeSpace(ocl);
|
||||
|
@ -2121,6 +2122,10 @@ CleanDeadClauses(void)
|
|||
while (cl) {
|
||||
if (!ref_in_use((DBRef)cl)) {
|
||||
char *ocl = (char *)cl;
|
||||
if (cl->ClFlags & SwitchTableMask)
|
||||
Yap_IndexSpace_SW -= cl->ClSize;
|
||||
else
|
||||
Yap_IndexSpace_Tree -= cl->ClSize;
|
||||
cl = cl->SiblingIndex;
|
||||
*cptr = cl;
|
||||
Yap_FreeCodeSpace(ocl);
|
||||
|
@ -2139,6 +2144,7 @@ CleanDeadClauses(void)
|
|||
while (cl) {
|
||||
if (!ref_in_use((DBRef)cl)) {
|
||||
char *ocl = (char *)cl;
|
||||
Yap_ClauseSpace -= cl->ClSize;
|
||||
cl = cl->ClNext;
|
||||
*cptr = cl;
|
||||
Yap_FreeCodeSpace(ocl);
|
||||
|
|
88
C/index.c
88
C/index.c
|
@ -11,8 +11,11 @@
|
|||
* File: index.c *
|
||||
* comments: Indexing a Prolog predicate *
|
||||
* *
|
||||
* Last rev: $Date: 2006-10-25 02:31:07 $,$Author: vsc $ *
|
||||
* Last rev: $Date: 2006-11-06 18:35:04 $,$Author: vsc $ *
|
||||
* $Log: not supported by cvs2svn $
|
||||
* Revision 1.174 2006/10/25 02:31:07 vsc
|
||||
* fix emulation of trust_logical
|
||||
*
|
||||
* Revision 1.173 2006/10/18 13:47:31 vsc
|
||||
* index.c implementation of trust_logical was decrementing the wrong
|
||||
* cp_tr
|
||||
|
@ -434,6 +437,11 @@ cleanup_sw_on_clauses(CELL larg, UInt sz, OPCODE ecls)
|
|||
#if DEBUG
|
||||
Yap_expand_clauses_sz -= (UInt)(NEXTOP((yamop *)NULL,sp))+xp->u.sp.s1*sizeof(yamop *);
|
||||
#endif
|
||||
if (xp->u.sp.p->PredFlags & LogUpdatePredFlag) {
|
||||
// fprintf(stderr,"VSC %p %d - %d\n",xp,(UInt)NEXTOP((yamop *)NULL,sp)+xp->u.sp.s1*sizeof(yamop *),Yap_LUIndexSpace_EXT);
|
||||
Yap_LUIndexSpace_EXT -= (UInt)NEXTOP((yamop *)NULL,sp)+xp->u.sp.s1*sizeof(yamop *);
|
||||
} else
|
||||
Yap_IndexSpace_EXT -= (UInt)(NEXTOP((yamop *)NULL,sp))+xp->u.sp.s1*sizeof(yamop *);
|
||||
Yap_FreeCodeSpace((char *)xp);
|
||||
return nsz;
|
||||
} else {
|
||||
|
@ -482,10 +490,12 @@ recover_from_failed_susp_on_cls(struct intermediates *cint, UInt sz)
|
|||
if (log_upd_pred) {
|
||||
LogUpdIndex *lcl = ClauseCodeToLogUpdIndex(cpc->rnd2);
|
||||
sz += sizeof(LogUpdIndex)+cases*sizeof(AtomSwiEntry);
|
||||
Yap_LUIndexSpace_SW -= sizeof(LogUpdIndex)+cases*sizeof(AtomSwiEntry);
|
||||
Yap_FreeCodeSpace((char *)lcl);
|
||||
} else {
|
||||
StaticIndex *scl = ClauseCodeToStaticIndex(cpc->rnd2);
|
||||
sz += sizeof(StaticIndex)+cases*sizeof(AtomSwiEntry);
|
||||
Yap_IndexSpace_SW -= sizeof(StaticIndex)+cases*sizeof(AtomSwiEntry);
|
||||
Yap_FreeCodeSpace((char *)scl);
|
||||
}
|
||||
}
|
||||
|
@ -502,9 +512,11 @@ recover_from_failed_susp_on_cls(struct intermediates *cint, UInt sz)
|
|||
if (log_upd_pred) {
|
||||
LogUpdIndex *lcl = ClauseCodeToLogUpdIndex(cpc->rnd2);
|
||||
sz += sizeof(LogUpdIndex)+cases*sizeof(FuncSwiEntry);
|
||||
Yap_LUIndexSpace_SW -= sizeof(LogUpdIndex)+cases*sizeof(FuncSwiEntry);
|
||||
Yap_FreeCodeSpace((char *)lcl);
|
||||
} else {
|
||||
StaticIndex *scl = ClauseCodeToStaticIndex(cpc->rnd2);
|
||||
Yap_IndexSpace_SW -= sizeof(StaticIndex)+cases*sizeof(FuncSwiEntry);
|
||||
sz += sizeof(StaticIndex)+cases*sizeof(FuncSwiEntry);
|
||||
Yap_FreeCodeSpace((char *)scl);
|
||||
}
|
||||
|
@ -3425,11 +3437,15 @@ static void
|
|||
emit_try(ClauseDef *cl, struct intermediates *cint, int var_group, int first, int clauses, int clleft, UInt nxtlbl)
|
||||
{
|
||||
PredEntry *ap = cint->CurrentPred;
|
||||
yamop *clcode = cl->CurrentCode;
|
||||
yamop *clcode;
|
||||
compiler_vm_op comp_op;
|
||||
|
||||
if (ap->PredFlags & TabledPredFlag) {
|
||||
if (ap->PredFlags & LogUpdatePredFlag) {
|
||||
clcode = cl->Code;
|
||||
} else if (ap->PredFlags & TabledPredFlag) {
|
||||
clcode = NEXTOP(cl->Code, ld);
|
||||
} else {
|
||||
clcode = cl->CurrentCode;
|
||||
}
|
||||
|
||||
comp_op = emit_optry(var_group, first, clauses, clleft, cint->CurrentPred);
|
||||
|
@ -3456,6 +3472,7 @@ emit_switch_space(UInt n, UInt item_size, struct intermediates *cint)
|
|||
save_machine_regs();
|
||||
longjmp(cint->CompilerBotch,2);
|
||||
}
|
||||
Yap_LUIndexSpace_SW += sz;
|
||||
cl->ClFlags = SwitchTableMask|LogUpdMask;
|
||||
cl->ClSize = sz;
|
||||
cl->ClPred = cint->CurrentPred;
|
||||
|
@ -3475,6 +3492,7 @@ emit_switch_space(UInt n, UInt item_size, struct intermediates *cint)
|
|||
save_machine_regs();
|
||||
longjmp(cint->CompilerBotch,2);
|
||||
}
|
||||
Yap_IndexSpace_SW += sz;
|
||||
cl->ClFlags = SwitchTableMask;
|
||||
cl->ClSize = sz;
|
||||
cl->ClPred = cint->CurrentPred;
|
||||
|
@ -3809,6 +3827,12 @@ suspend_indexing(ClauseDef *min, ClauseDef *max, PredEntry *ap, struct intermedi
|
|||
save_machine_regs();
|
||||
longjmp(cint->CompilerBotch, 2);
|
||||
}
|
||||
if (ap->PredFlags & LogUpdatePredFlag) {
|
||||
// fprintf(stderr,"VSC %p %d + %d\n",ncode,sz,Yap_LUIndexSpace_EXT);
|
||||
Yap_LUIndexSpace_EXT += sz;
|
||||
} else {
|
||||
Yap_IndexSpace_EXT += sz;
|
||||
}
|
||||
#ifdef LOW_PROF
|
||||
if (ProfilerOn &&
|
||||
Yap_OffLineProfiler) {
|
||||
|
@ -3867,6 +3891,10 @@ recover_ecls_block(yamop *ipc)
|
|||
#endif
|
||||
/* no dangling pointers for gprof */
|
||||
Yap_InformOfRemoval((CODEADDR)ipc);
|
||||
if (ipc->u.sp.p->PredFlags & LogUpdatePredFlag) {
|
||||
Yap_LUIndexSpace_EXT -= (UInt)NEXTOP((yamop *)NULL,sp)+ipc->u.sp.s1*sizeof(yamop *);
|
||||
} else
|
||||
Yap_IndexSpace_EXT -= (UInt)NEXTOP((yamop *)NULL,sp)+ipc->u.sp.s1*sizeof(yamop *);
|
||||
Yap_FreeCodeSpace((char *)ipc);
|
||||
}
|
||||
}
|
||||
|
@ -4416,23 +4444,18 @@ do_compound_index(ClauseDef *min0, ClauseDef* max0, Term* sreg, struct intermedi
|
|||
cl++;
|
||||
}
|
||||
group = (GroupDef *)top;
|
||||
ngroups = groups_in(min, max, group);
|
||||
ngroups = groups_in(min, max, group);
|
||||
if (ngroups == 1 && group->VarClauses == 0) {
|
||||
/* ok, we are doing a sub-argument */
|
||||
/* process groups */
|
||||
*newlabp = new_label(cint);
|
||||
/* process group */
|
||||
|
||||
found_index = TRUE;
|
||||
ret_lab = new_label(cint);
|
||||
top = (CELL *)(group+1);
|
||||
newlabp = do_nonvar_group(group, (sreg == NULL ? 0L : Deref(sreg[i])), i+1, (isvt ? NULL : sreg), arity, *newlabp, cint, argno, argno == 1, (last_arg && i+1 == arity), fail_l, clleft, top);
|
||||
if (newlabp == NULL) {
|
||||
found_index = TRUE;
|
||||
if (do_nonvar_group(group, (sreg == NULL ? 0L : Deref(sreg[i])), i+1, (isvt ? NULL : sreg), arity, *newlabp, cint, argno, argno == 1, (last_arg && i+1 == arity), fail_l, clleft, top) == NULL) {
|
||||
top = top0;
|
||||
break;
|
||||
}
|
||||
if (sreg == NULL || !isvt) {
|
||||
found_index = TRUE;
|
||||
} else {
|
||||
done_work |= TRUE;
|
||||
}
|
||||
}
|
||||
top = top0;
|
||||
i++;
|
||||
|
@ -5624,8 +5647,9 @@ expand_index(struct intermediates *cint) {
|
|||
lab = do_index(cls, max, cint, argno+1, fail_l, isfirstcl, clleft, top);
|
||||
}
|
||||
}
|
||||
if (labp && !(lab & 1))
|
||||
if (labp && !(lab & 1)) {
|
||||
*labp = (yamop *)lab; /* in case we have a single clause */
|
||||
}
|
||||
return labp;
|
||||
}
|
||||
|
||||
|
@ -5722,9 +5746,17 @@ ExpandIndex(PredEntry *ap, int ExtraArgs) {
|
|||
}
|
||||
#endif
|
||||
if ((labp = expand_index(&cint)) == NULL) {
|
||||
if (expand_clauses) {
|
||||
P = FAILCODE;
|
||||
recover_ecls_block(expand_clauses);
|
||||
}
|
||||
return FAILCODE;
|
||||
}
|
||||
if (*labp == FAILCODE) {
|
||||
if (expand_clauses) {
|
||||
P = FAILCODE;
|
||||
recover_ecls_block(expand_clauses);
|
||||
}
|
||||
return FAILCODE;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
|
@ -5744,9 +5776,17 @@ ExpandIndex(PredEntry *ap, int ExtraArgs) {
|
|||
}
|
||||
} else {
|
||||
/* single case */
|
||||
if (expand_clauses) {
|
||||
P = *labp;
|
||||
recover_ecls_block(expand_clauses);
|
||||
}
|
||||
return *labp;
|
||||
}
|
||||
if (indx_out == NULL) {
|
||||
if (expand_clauses) {
|
||||
P = FAILCODE;
|
||||
recover_ecls_block(expand_clauses);
|
||||
}
|
||||
return FAILCODE;
|
||||
}
|
||||
*labp = indx_out;
|
||||
|
@ -5958,6 +5998,7 @@ replace_index_block(ClauseUnion *parent_block, yamop *cod, yamop *ncod, PredEntr
|
|||
c = c->SiblingIndex;
|
||||
}
|
||||
Yap_InformOfRemoval((CODEADDR)cl);
|
||||
Yap_LUIndexSpace_SW -= cl->ClSize;
|
||||
Yap_FreeCodeSpace((char *)cl);
|
||||
} else {
|
||||
StaticIndex
|
||||
|
@ -5975,6 +6016,7 @@ replace_index_block(ClauseUnion *parent_block, yamop *cod, yamop *ncod, PredEntr
|
|||
c->SiblingIndex = ncl;
|
||||
}
|
||||
Yap_InformOfRemoval((CODEADDR)cl);
|
||||
Yap_IndexSpace_SW -= cl->ClSize;
|
||||
Yap_FreeCodeSpace((char *)cl);
|
||||
}
|
||||
}
|
||||
|
@ -6154,17 +6196,18 @@ remove_clause_from_index(yamop **prevp, yamop *curp, LogUpdClause *cl)
|
|||
{
|
||||
if (curp->u.lld.d == cl) {
|
||||
yamop *newp = curp->u.lld.n;
|
||||
*prevp = newp;
|
||||
newp->opc = curp->opc;
|
||||
*prevp = newp;
|
||||
} else {
|
||||
yamop *ocurp;
|
||||
yamop *ocurp, *ocurp0 = curp;
|
||||
|
||||
while (curp->u.lld.d != cl) {
|
||||
ocurp = curp;
|
||||
curp = curp->u.lld.n;
|
||||
}
|
||||
/* in case we were the last */
|
||||
ocurp->opc = curp->opc;
|
||||
if (ocurp != ocurp0)
|
||||
ocurp->opc = curp->opc;
|
||||
ocurp->u.lld.n = curp->u.lld.n;
|
||||
ocurp->u.lld.t.block = curp->u.lld.t.block;
|
||||
}
|
||||
|
@ -6173,6 +6216,7 @@ remove_clause_from_index(yamop **prevp, yamop *curp, LogUpdClause *cl)
|
|||
Yap_FreedCps++;
|
||||
#endif
|
||||
clean_ref_to_clause(cl);
|
||||
Yap_LUIndexSpace_CP -= (UInt)NEXTOP((yamop*)NULL,lld);
|
||||
Yap_FreeCodeSpace((ADDR)curp);
|
||||
}
|
||||
|
||||
|
@ -6219,11 +6263,13 @@ remove_dirty_clauses_from_index(yamop **prevp, yamop *curp)
|
|||
previouscurp->opc = endop;
|
||||
previouscurp->u.lld.t.block = curp->u.lld.t.block;
|
||||
previouscurp->u.lld.n = NULL;
|
||||
Yap_LUIndexSpace_CP -= (UInt)NEXTOP((yamop*)NULL,lld);
|
||||
Yap_FreeCodeSpace((ADDR)curp);
|
||||
return;
|
||||
}
|
||||
previouscurp->u.lld.n = curp->u.lld.n;
|
||||
curp = curp->u.lld.n;
|
||||
Yap_LUIndexSpace_CP -= (UInt)NEXTOP((yamop*)NULL,lld);
|
||||
Yap_FreeCodeSpace((ADDR)ocurp);
|
||||
} else {
|
||||
previouscurp = curp;
|
||||
|
@ -6534,13 +6580,14 @@ add_try(PredEntry *ap, ClauseDef *cls, yamop *next, struct intermediates *cint)
|
|||
{
|
||||
yamop *newcp;
|
||||
UInt size = (UInt)NEXTOP((yamop *)NULL,lld);
|
||||
LogUpdClause *lcl = ClauseCodeToLogUpdClause(cls->CurrentCode);
|
||||
LogUpdClause *lcl = ClauseCodeToLogUpdClause(cls->Code);
|
||||
|
||||
if ((newcp = (yamop *)Yap_AllocCodeSpace(size)) == NULL) {
|
||||
/* OOOPS, got in trouble, must do a longjmp and recover space */
|
||||
save_machine_regs();
|
||||
longjmp(cint->CompilerBotch,2);
|
||||
}
|
||||
Yap_LUIndexSpace_CP += size;
|
||||
#ifdef DEBUG
|
||||
Yap_NewCps++;
|
||||
Yap_LiveCps++;
|
||||
|
@ -6558,7 +6605,7 @@ add_trust(LogUpdIndex *icl, ClauseDef *cls, struct intermediates *cint)
|
|||
{
|
||||
yamop *newcp;
|
||||
UInt size = (UInt)NEXTOP((yamop *)NULL,lld);
|
||||
LogUpdClause *lcl = ClauseCodeToLogUpdClause(cls->CurrentCode);
|
||||
LogUpdClause *lcl = ClauseCodeToLogUpdClause(cls->Code);
|
||||
PredEntry *ap = lcl->ClPred;
|
||||
|
||||
if ((newcp = (yamop *)Yap_AllocCodeSpace(size)) == NULL) {
|
||||
|
@ -6566,6 +6613,7 @@ add_trust(LogUpdIndex *icl, ClauseDef *cls, struct intermediates *cint)
|
|||
save_machine_regs();
|
||||
longjmp(cint->CompilerBotch,2);
|
||||
}
|
||||
Yap_LUIndexSpace_CP += size;
|
||||
#ifdef DEBUG
|
||||
Yap_NewCps++;
|
||||
Yap_LiveCps++;
|
||||
|
|
18
C/init.c
18
C/init.c
|
@ -485,6 +485,7 @@ Yap_InitCPred(char *Name, unsigned long int Arity, CPredicate code, int flags)
|
|||
/* already exists */
|
||||
cl = ClauseCodeToStaticClause(pe->CodeOfPred);
|
||||
if ((flags | StandardPredFlag | CPredFlag) != pe->PredFlags) {
|
||||
Yap_ClauseSpace -= cl->ClSize;
|
||||
Yap_FreeCodeSpace((ADDR)cl);
|
||||
cl = NULL;
|
||||
}
|
||||
|
@ -505,6 +506,7 @@ Yap_InitCPred(char *Name, unsigned long int Arity, CPredicate code, int flags)
|
|||
return;
|
||||
}
|
||||
} else {
|
||||
Yap_ClauseSpace += sz;
|
||||
cl->ClFlags = StaticMask;
|
||||
cl->ClNext = NULL;
|
||||
cl->ClSize = sz;
|
||||
|
@ -567,6 +569,7 @@ Yap_InitCmpPred(char *Name, unsigned long int Arity, CmpPredicate cmp_code, int
|
|||
return;
|
||||
}
|
||||
} else {
|
||||
Yap_ClauseSpace += sz;
|
||||
cl->ClFlags = StaticMask;
|
||||
cl->ClNext = NULL;
|
||||
cl->ClSize = sz;
|
||||
|
@ -615,6 +618,7 @@ Yap_InitAsmPred(char *Name, unsigned long int Arity, int code, CPredicate def,
|
|||
Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"No Heap Space in InitAsmPred");
|
||||
return;
|
||||
}
|
||||
Yap_ClauseSpace += (CELL)NEXTOP(NEXTOP(NEXTOP(((yamop *)p_code),sla),p),l);
|
||||
cl->ClFlags = StaticMask;
|
||||
cl->ClNext = NULL;
|
||||
cl->ClSize = (CELL)NEXTOP(NEXTOP(NEXTOP(((yamop *)p_code),sla),e),e);
|
||||
|
@ -751,9 +755,11 @@ Yap_InitCPredBack(char *Name, unsigned long int Arity,
|
|||
cl->ClFlags = StaticMask;
|
||||
cl->ClNext = NULL;
|
||||
#ifdef CUT_C
|
||||
Yap_ClauseSpace += (CELL)NEXTOP(NEXTOP(NEXTOP(NEXTOP(code,lds),lds),lds),l);
|
||||
cl->ClSize =
|
||||
(CELL)NEXTOP(NEXTOP(NEXTOP(NEXTOP(code,lds),lds),lds),e);
|
||||
#else
|
||||
Yap_ClauseSpace += (CELL)NEXTOP(NEXTOP(NEXTOP(code,lds),lds),l);
|
||||
cl->ClSize =
|
||||
(CELL)NEXTOP(NEXTOP(NEXTOP(code,lds),lds),e);
|
||||
#endif
|
||||
|
@ -1249,6 +1255,7 @@ InitCodes(void)
|
|||
#endif /* YAPOR */
|
||||
Yap_heap_regs->db_erased_marker =
|
||||
(DBRef)Yap_AllocCodeSpace(sizeof(DBStruct));
|
||||
Yap_LUClauseSpace += sizeof(DBStruct);
|
||||
Yap_heap_regs->db_erased_marker->id = FunctorDBRef;
|
||||
Yap_heap_regs->db_erased_marker->Flags = ErasedMask;
|
||||
Yap_heap_regs->db_erased_marker->Code = NULL;
|
||||
|
@ -1256,6 +1263,7 @@ InitCodes(void)
|
|||
Yap_heap_regs->db_erased_marker->Parent = NULL;
|
||||
Yap_heap_regs->logdb_erased_marker =
|
||||
(LogUpdClause *)Yap_AllocCodeSpace(sizeof(LogUpdClause)+(UInt)NEXTOP((yamop*)NULL,e));
|
||||
Yap_LUClauseSpace += sizeof(LogUpdClause)+(UInt)NEXTOP((yamop*)NULL,e);
|
||||
Yap_heap_regs->logdb_erased_marker->Id = FunctorDBRef;
|
||||
Yap_heap_regs->logdb_erased_marker->ClFlags = ErasedMask|LogUpdMask;
|
||||
Yap_heap_regs->logdb_erased_marker->ClSource = NULL;
|
||||
|
@ -1329,7 +1337,15 @@ Yap_InitWorkspace(int Heap, int Stack, int Trail, int max_table_size,
|
|||
#else
|
||||
Yap_InitMemory (Trail, Heap, Stack);
|
||||
#endif /* YAPOR */
|
||||
|
||||
Yap_ClauseSpace = 0;
|
||||
Yap_IndexSpace_Tree = 0;
|
||||
Yap_IndexSpace_EXT = 0;
|
||||
Yap_IndexSpace_SW = 0;
|
||||
Yap_LUClauseSpace = 0;
|
||||
Yap_LUIndexSpace_Tree = 0;
|
||||
Yap_LUIndexSpace_CP = 0;
|
||||
Yap_LUIndexSpace_EXT = 0;
|
||||
Yap_LUIndexSpace_SW = 0;
|
||||
#if defined(YAPOR) || defined(TABLING)
|
||||
Yap_init_global(max_table_size, n_workers, sch_loop, delay_load);
|
||||
#endif /* YAPOR || TABLING */
|
||||
|
|
43
C/stdpreds.c
43
C/stdpreds.c
|
@ -11,8 +11,11 @@
|
|||
* File: stdpreds.c *
|
||||
* comments: General-purpose C implemented system predicates *
|
||||
* *
|
||||
* Last rev: $Date: 2006-10-10 14:08:17 $,$Author: vsc $ *
|
||||
* Last rev: $Date: 2006-11-06 18:35:04 $,$Author: vsc $ *
|
||||
* $Log: not supported by cvs2svn $
|
||||
* Revision 1.110 2006/10/10 14:08:17 vsc
|
||||
* small fixes on threaded implementation.
|
||||
*
|
||||
* Revision 1.109 2006/09/15 19:32:47 vsc
|
||||
* ichanges for QSAR
|
||||
*
|
||||
|
@ -2510,6 +2513,7 @@ p_statistics_stacks_info(void)
|
|||
}
|
||||
|
||||
|
||||
|
||||
static Int
|
||||
p_statistics_trail_info(void)
|
||||
{
|
||||
|
@ -2551,6 +2555,41 @@ p_statistics_atom_info(void)
|
|||
}
|
||||
|
||||
|
||||
static Int
|
||||
p_statistics_db_size(void)
|
||||
{
|
||||
Term t = MkIntegerTerm(Yap_ClauseSpace);
|
||||
Term tit = MkIntegerTerm(Yap_IndexSpace_Tree);
|
||||
Term tis = MkIntegerTerm(Yap_IndexSpace_SW);
|
||||
Term tie = MkIntegerTerm(Yap_IndexSpace_EXT);
|
||||
|
||||
return
|
||||
Yap_unify(t, ARG1) &&
|
||||
Yap_unify(tit, ARG2) &&
|
||||
Yap_unify(tis, ARG3) &&
|
||||
Yap_unify(tie, ARG4);
|
||||
|
||||
}
|
||||
|
||||
static Int
|
||||
p_statistics_lu_db_size(void)
|
||||
{
|
||||
Term t = MkIntegerTerm(Yap_LUClauseSpace);
|
||||
Term tit = MkIntegerTerm(Yap_LUIndexSpace_Tree);
|
||||
Term tic = MkIntegerTerm(Yap_LUIndexSpace_CP);
|
||||
Term tix = MkIntegerTerm(Yap_LUIndexSpace_EXT);
|
||||
Term tis = MkIntegerTerm(Yap_LUIndexSpace_SW);
|
||||
|
||||
return
|
||||
Yap_unify(t, ARG1) &&
|
||||
Yap_unify(tit, ARG2) &&
|
||||
Yap_unify(tic, ARG3) &&
|
||||
Yap_unify(tix, ARG4) &&
|
||||
Yap_unify(tis, ARG5);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static Term
|
||||
mk_argc_list(void)
|
||||
{
|
||||
|
@ -3030,6 +3069,8 @@ Yap_InitCPreds(void)
|
|||
Yap_InitCPred("$statistics_stacks_info", 3, p_statistics_stacks_info, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred("$statistics_trail_info", 2, p_statistics_trail_info, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred("$statistics_atom_info", 2, p_statistics_atom_info, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred("$statistics_db_size", 4, p_statistics_db_size, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred("$statistics_lu_db_size", 5, p_statistics_lu_db_size, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred("$argv", 1, p_argv, SafePredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred("$runtime", 2, p_runtime, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred("$cputime", 2, p_cputime, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
|
|
|
@ -161,6 +161,8 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
|
|||
LOCK(Yap_heap_regs->low_level_trace_lock);
|
||||
sc = Yap_heap_regs;
|
||||
vsc_count++;
|
||||
if (vsc_count < 59000)
|
||||
return;
|
||||
#ifdef COMMENTED
|
||||
if (worker_id != 04 || worker_id != 03) return;
|
||||
// if (vsc_count == 218280)
|
||||
|
|
14
H/Heap.h
14
H/Heap.h
|
@ -10,7 +10,7 @@
|
|||
* File: Heap.h *
|
||||
* mods: *
|
||||
* comments: Heap Init Structure *
|
||||
* version: $Id: Heap.h,v 1.107 2006-10-11 14:53:57 vsc Exp $ *
|
||||
* version: $Id: Heap.h,v 1.108 2006-11-06 18:35:05 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
|
||||
/* information that can be stored in Code Space */
|
||||
|
@ -197,6 +197,9 @@ typedef struct various_codes {
|
|||
special_functors funcs;
|
||||
UInt hole_size;
|
||||
struct malloc_state *av_;
|
||||
|
||||
UInt clause_space, index_space_Tree, index_space_EXT, index_space_SW;
|
||||
UInt lu_clause_space, lu_index_space_Tree, lu_index_space_CP, lu_index_space_EXT, lu_index_space_SW;
|
||||
#if USE_DL_MALLOC
|
||||
struct memory_hole memory_holes[MAX_DLMALLOC_HOLES];
|
||||
UInt nof_memory_holes;
|
||||
|
@ -554,6 +557,15 @@ struct various_codes *Yap_heap_regs;
|
|||
|
||||
#define Yap_HoleSize Yap_heap_regs->hole_size
|
||||
#define Yap_av Yap_heap_regs->av_
|
||||
#define Yap_ClauseSpace Yap_heap_regs->clause_space
|
||||
#define Yap_IndexSpace_Tree Yap_heap_regs->index_space_Tree
|
||||
#define Yap_IndexSpace_EXT Yap_heap_regs->index_space_EXT
|
||||
#define Yap_IndexSpace_SW Yap_heap_regs->index_space_SW
|
||||
#define Yap_LUClauseSpace Yap_heap_regs->lu_clause_space
|
||||
#define Yap_LUIndexSpace_Tree Yap_heap_regs->lu_index_space_Tree
|
||||
#define Yap_LUIndexSpace_CP Yap_heap_regs->lu_index_space_CP
|
||||
#define Yap_LUIndexSpace_EXT Yap_heap_regs->lu_index_space_EXT
|
||||
#define Yap_LUIndexSpace_SW Yap_heap_regs->lu_index_space_SW
|
||||
#define Yap_MemoryHoles Yap_heap_regs->memory_holes
|
||||
#define Yap_NOfMemoryHoles Yap_heap_regs->nof_memory_holes
|
||||
#if USE_DL_MALLOC || (USE_SYSTEM_MALLOC && HAVE_MALLINFO)
|
||||
|
|
|
@ -1197,7 +1197,7 @@ int STD_PROTO (Yap_RemoveIndexation, (PredEntry *));
|
|||
/* dbase.c */
|
||||
void STD_PROTO (Yap_ErDBE, (DBRef));
|
||||
DBTerm *STD_PROTO (Yap_StoreTermInDB, (Term, int));
|
||||
DBTerm *STD_PROTO (Yap_StoreTermInDBPlusExtraSpace, (Term, UInt));
|
||||
DBTerm *STD_PROTO (Yap_StoreTermInDBPlusExtraSpace, (Term, UInt, UInt *));
|
||||
Term STD_PROTO (Yap_FetchTermFromDB, (DBTerm *));
|
||||
void STD_PROTO (Yap_ReleaseTermFromDB, (DBTerm *));
|
||||
|
||||
|
|
|
@ -124,6 +124,8 @@ typedef enum compiler_op {
|
|||
fetch_args_vv_op,
|
||||
fetch_args_cv_op,
|
||||
fetch_args_vc_op,
|
||||
fetch_args_iv_op,
|
||||
fetch_args_vi_op,
|
||||
f_var_op,
|
||||
f_val_op,
|
||||
enter_profiling_op,
|
||||
|
|
|
@ -16,6 +16,10 @@
|
|||
|
||||
<h2>Yap-5.1.2:</h2>
|
||||
<ul>
|
||||
<li> FIXED: more fixes for new dynamic code and stack shifting.</li>
|
||||
<li> FIXED: if we can generate index on an sub-argument and the
|
||||
argument is unbound we should generate the code, suspend
|
||||
on it, and then call the system again.</li>
|
||||
<li> FIXED: avl_new/1 (obs from Miguel Filgueiras).</li>
|
||||
<li> FIXED: broken all/3 (obs from Miguel Filgueiras).</li>
|
||||
<li> FIXED: make 128 maximum disjunction depth (obs from Nicos Angelopoulos).</li>
|
||||
|
|
|
@ -114,6 +114,12 @@ statistics(atoms,[NOf,SizeOf]) :-
|
|||
'$statistics_atom_info'(NOf,SizeOf),
|
||||
'$inform_stack_overflows'(NOfSO,_),
|
||||
'$inform_trail_overflows'(NOfTO,_).
|
||||
statistics(static_code,[ClauseSize, IndexSize, TreeIndexSize, ExtIndexSize, SWIndexSize]) :-
|
||||
'$statistics_db_size'(ClauseSize, TreeIndexSize, ExtIndexSize, SWIndexSize),
|
||||
IndexSize is TreeIndexSize+ ExtIndexSize+ SWIndexSize.
|
||||
statistics(dynamic_code,[ClauseSize,IndexSize, TreeIndexSize, CPIndexSize, ExtIndexSize, SWIndexSize]) :-
|
||||
'$statistics_lu_db_size'(ClauseSize, TreeIndexSize, CPIndexSize, ExtIndexSize, SWIndexSize),
|
||||
IndexSize is TreeIndexSize+CPIndexSize+ ExtIndexSize+ SWIndexSize.
|
||||
|
||||
key_statistics(Key, NOfEntries, TotalSize) :-
|
||||
key_statistics(Key, NOfEntries, ClSize, IndxSize),
|
||||
|
|
Reference in New Issue