small changes

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@270 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc
2002-01-05 04:04:14 +00:00
parent 91476a8e78
commit 1012146c28
10 changed files with 92 additions and 122 deletions

View File

@@ -449,6 +449,7 @@ inline EXTERN PropFlags IsValProperty(int flags)
CodeOfPred holds the address of the correspondent C-function.
*/
typedef enum {
CutTransparentPredFlag = 0x800000L, /* ! should ! across */
SourcePredFlag = 0x400000L, /* static predicate with source declaration */
MetaPredFlag = 0x200000L, /* predicate subject to a meta declaration */
SyncPredFlag = 0x100000L, /* has to synch before it can execute*/
@@ -486,27 +487,28 @@ typedef struct {
was retried */
} profile_data;
typedef struct {
Prop NextOfPE; /* used to chain properties */
PropFlags KindOfPE; /* kind of property */
unsigned int ArityOfPE; /* arity of property */
SMALLUNSGN StateOfPred; /* actual state of predicate */
CODEADDR CodeOfPred; /* code address */
CODEADDR TrueCodeOfPred; /* if needing to spy or to lock */
Functor FunctorOfPred; /* functor for Predicate */
CODEADDR FirstClause, LastClause;
CELL PredFlags;
Atom OwnerFile; /* File where the predicate was defined */
typedef struct pred_entry {
Prop NextOfPE; /* used to chain properties */
PropFlags KindOfPE; /* kind of property */
unsigned int ArityOfPE; /* arity of property */
int ModuleOfPred; /* module for this definition */
CELL PredFlags;
CODEADDR CodeOfPred; /* code address */
CODEADDR TrueCodeOfPred; /* if needing to spy or to lock */
Functor FunctorOfPred; /* functor for Predicate */
CODEADDR FirstClause, LastClause;
Atom OwnerFile; /* File where the predicate was defined */
struct pred_entry *NextPredOfModule; /* next pred for same module */
#if defined(YAPOR) || defined(THREADS)
rwlock_t PRWLock; /* a simple lock to protect this entry */
rwlock_t PRWLock; /* a simple lock to protect this entry */
#endif
#ifdef TABLING
tab_ent_ptr TableOfPred;
tab_ent_ptr TableOfPred;
#endif /* TABLING */
OPCODE OpcodeOfPred; /* undefcode, indexcode, spycode, .... */
profile_data StatisticsForPred; /* enable profiling for predicate */
SMALLUNSGN ModuleOfPred; /* module for this definition */
} PredEntry;
OPCODE OpcodeOfPred; /* undefcode, indexcode, spycode, .... */
profile_data StatisticsForPred; /* enable profiling for predicate */
SMALLUNSGN StateOfPred; /* actual state of predicate */
} PredEntry;
#define PEProp ((PropFlags)(0x0000))
#if USE_OFFSETS_IN_PROPS
@@ -612,6 +614,9 @@ typedef struct DB_STRUCT {
Int age; /* entry's age, negative if from recorda,
positive if it was recordz */
#endif /* KEEP_ENTRY_AGE */
#ifdef COROUTINING
CELL attachments; /* attached terms */
#endif
CELL Mask; /* parts that should be cleared */
CELL Key; /* A mask that can be used to check before
you unify */
@@ -1019,85 +1024,51 @@ CODEADDR STD_PROTO(PredIsIndexable,(PredEntry *));
/* init.c */
Atom STD_PROTO(GetOp,(OpEntry *,int *,int));
#ifdef XX_ADTDEFS_C
#ifndef inline
/* look property list of atom a for kind */
EXTERN inline Prop GetAProp(a,kind)
Atom a;
PropFlags kind;
{ register PropEntry *pp = RepProp(RepAtom(a)->PropOfAE);
while( !EndOfPAEntr(pp) && pp->KindOfPE!=kind) pp=RepProp(pp->NextOfPE);
return(AbsProp(pp));
}
/* get predicate entry for ap/arity; create it if neccessary. */
EXTERN inline Prop PredProp(ap,arity)
Atom ap;
unsigned int arity;
{
Prop p0;
PredEntry *p = RepPredProp(p0=RepAtom(ap)->PropOfAE);
while(p0 && (p->KindOfPE != 00 || p->ArityOfPE != arity ||
(p->ModuleOfPred && p->ModuleOfPred != CurrentModule)))
p = RepPredProp(p0=p->NextOfPE);
if(p0) return(p0);
YAPEnterCriticalSection();
p = (PredEntry *) AllocAtomSpace(sizeof(*p));
p->KindOfPE = PEProp;
p->ArityOfPE = arity;
p->FirstClause = p->LastClause = NIL;
p->PredFlags = 0L;
p->StateOfPred = 0;
p->OwnerFile = AtomNil;
p->ModuleOfPred = CurrentModule;
p->OpcodeOfPred = opcode(_undef_p);
p->StatisticsForPred.NOfEntries = 0;
p->StatisticsForPred.NOfHeadSuccesses = 0;
p->StatisticsForPred.NOfRetries = 0;
p->TrueCodeOfPred = p->CodeOfPred = (CODEADDR)(&(p->DefaultCodeOfPred));
if (arity==0) p->FunctorOfPred = (Functor) ap;
else p->FunctorOfPred = MkFunctor(ap,arity);
p->NextOfPE = RepAtom(ap)->PropOfAE;
RepAtom(ap)->PropOfAE = p0 = AbsPredProp(p);
YAPLeaveCriticalSection();
return(p0);
}
EXTERN inline Term GetValue(a)
Atom a;
{
Prop p0 = GetAProp(a,ValProperty);
if(p0==0) return(MkAtomTerm(AtomNil));
return(RepValProp(p0)->ValueOfVE);
}
EXTERN inline void PutValue(a,v)
Atom a; Term v;
{
Prop p0 = GetAProp(a,ValProperty);
if(p0) RepValProp(p0)->ValueOfVE = v;
else {
ValEntry *p;
YAPEnterCriticalSection();
p = (ValEntry *) AllocAtomSpace(sizeof(ValEntry));
p->KindOfPE = ValProperty;
p->ValueOfVE = v;
p->NextOfPE = RepAtom(a)->PropOfAE;
RepAtom(a)->PropOfAE = AbsValProp(p);
YAPLeaveCriticalSection();
}
}
#endif /* inline */
#else
/* vsc: redefined to GetAProp to avoid conflicts with Windows header files */
Prop STD_PROTO(GetAProp,(Atom,PropFlags));
Prop STD_PROTO(LockedGetAProp,(AtomEntry *,PropFlags));
Prop STD_PROTO(PredProp,(Atom,unsigned int));
#endif /* ADTDEFS_C */
Prop STD_PROTO(GetAPropHavingLock,(AtomEntry *,PropFlags));
EXTERN inline Prop
PredPropByFunc(Functor f, SMALLUNSGN cur_mod)
/* get predicate entry for ap/arity; create it if neccessary. */
{
Prop p0;
FunctorEntry *fe = (FunctorEntry *)f;
WRITE_LOCK(fe->FRWLock);
p0 = fe->PropsOfFE;
while (p0) {
PredEntry *p = RepPredProp(p0);
if (/* p->KindOfPE != 0 || only props */
(p->ModuleOfPred == cur_mod || !(p->ModuleOfPred))) {
WRITE_UNLOCK(f->FRWLock);
return (p0);
}
p0 = p->NextOfPE;
}
return(NewPredPropByFunctor(fe,cur_mod));
}
EXTERN inline Prop
PredPropByAtom(Atom at, SMALLUNSGN cur_mod)
/* get predicate entry for ap/arity; create it if neccessary. */
{
Prop p0;
AtomEntry *ae = RepAtom(at);
WRITE_LOCK(ae->ARWLock);
p0 = ae->PropsOfAE;
while (p0) {
PredEntry *pe = RepPredProp(p0);
if ( pe->KindOfPE == PEProp &&
(pe->ModuleOfPred == cur_mod || !pe->ModuleOfPred)) {
WRITE_UNLOCK(ae->ARWLock);
return(p0);
}
p0 = pe->NextOfPE;
}
return(NewPredPropByAtom(ae,cur_mod));
}
#if defined(YAPOR) || defined(THREADS)
void STD_PROTO(ReleasePreAllocCodeSpace, (ADDR));