diff --git a/C/adtdefs.c b/C/adtdefs.c index 7608ced13..2a978cc0f 100755 --- a/C/adtdefs.c +++ b/C/adtdefs.c @@ -69,9 +69,9 @@ InlinedUnlockedMkFunctor(AtomEntry *ae, unsigned int arity) p->NameOfFE = AbsAtom(ae); p->ArityOfFE = arity; p->PropsOfFE = NIL; - p->NextOfPE = ae->PropsOfAE; INIT_RWLOCK(p->FRWLock); - ae->PropsOfAE = AbsProp((PropEntry *) p); + /* respect the first property, in case this is a wide atom */ + AddPropToAtom(ae, (PropEntry *)p); return ((Functor) p); } @@ -104,8 +104,7 @@ Yap_MkFunctorWithAddress(Atom ap, unsigned int arity, FunctorEntry *p) p->KindOfPE = FunctorProperty; p->NameOfFE = ap; p->ArityOfFE = arity; - p->NextOfPE = RepAtom(ap)->PropsOfAE; - ae->PropsOfAE = AbsProp((PropEntry *) p); + AddPropToAtom(ae, (PropEntry *)p); WRITE_UNLOCK(ae->ARWLock); } @@ -898,7 +897,6 @@ Yap_NewPredPropByAtom(AtomEntry *ae, Term cur_mod) p->beamTable = NULL; #endif /* careful that they don't cross MkFunctor */ - p->NextOfPE = ae->PropsOfAE; if (PRED_GOAL_EXPANSION_FUNC) { Prop p1 = ae->PropsOfAE; @@ -914,7 +912,8 @@ Yap_NewPredPropByAtom(AtomEntry *ae, Term cur_mod) p1 = pe->NextOfPE; } } - ae->PropsOfAE = p0 = AbsPredProp(p); + AddPropToAtom(ae, (PropEntry *)p); + p0 = AbsPredProp(p); p->FunctorOfPred = (Functor)AbsAtom(ae); WRITE_UNLOCK(ae->ARWLock); #ifdef LOW_PROF diff --git a/C/arith0.c b/C/arith0.c index bd0a1f718..1c780717f 100644 --- a/C/arith0.c +++ b/C/arith0.c @@ -198,8 +198,7 @@ Yap_InitConstExps(void) p->ArityOfEE = 0; p->ENoOfEE = 0; p->FOfEE = InitConstTab[i].f; - p->NextOfPE = ae->PropsOfAE; - ae->PropsOfAE = AbsExpProp(p); + AddPropToAtom(ae, (PropEntry *)p); WRITE_UNLOCK(ae->ARWLock); } } diff --git a/C/arith1.c b/C/arith1.c index 4c14bc5b7..6d7c7601a 100755 --- a/C/arith1.c +++ b/C/arith1.c @@ -835,8 +835,7 @@ Yap_InitUnaryExps(void) p->ArityOfEE = 1; p->ENoOfEE = 1; p->FOfEE = InitUnTab[i].f; - p->NextOfPE = ae->PropsOfAE; - ae->PropsOfAE = AbsExpProp(p); + AddPropToAtom(ae, (PropEntry *)p); WRITE_UNLOCK(ae->ARWLock); } Yap_InitCPred("is", 3, p_unary_is, TestPredFlag | SafePredFlag); diff --git a/C/arith2.c b/C/arith2.c index 23303e4ac..e6d9e9966 100755 --- a/C/arith2.c +++ b/C/arith2.c @@ -1217,8 +1217,7 @@ Yap_InitBinaryExps(void) p->ArityOfEE = 2; p->ENoOfEE = 2; p->FOfEE = InitBinTab[i].f; - p->NextOfPE = ae->PropsOfAE; - ae->PropsOfAE = AbsExpProp(p); + AddPropToAtom(ae, (PropEntry *)p); WRITE_UNLOCK(ae->ARWLock); } Yap_InitCPred("is", 4, p_binary_is, TestPredFlag | SafePredFlag); diff --git a/C/arrays.c b/C/arrays.c index 52af62739..fcf8f2b6c 100644 --- a/C/arrays.c +++ b/C/arrays.c @@ -566,9 +566,8 @@ CreateNamedArray(PropEntry * pp, Int dim, AtomEntry *ae USES_REGS) p = (ArrayEntry *) Yap_AllocAtomSpace(sizeof(*p)); p->KindOfPE = ArrayProperty; - p->NextOfPE = ae->PropsOfAE; + AddPropToAtom(ae, (PropEntry *)p); INIT_RWLOCK(p->ArRWLock); - ae->PropsOfAE = AbsArrayProp(p); #if THREADS p->owner_id = worker_id; #endif @@ -629,15 +628,14 @@ CreateStaticArray(AtomEntry *ae, Int dim, static_array_types type, CODEADDR star } } p->KindOfPE = ArrayProperty; - p->NextOfPE = ae->PropsOfAE; INIT_RWLOCK(p->ArRWLock); + AddPropToAtom(ae, (PropEntry *)p); p->NextAE = LOCAL_StaticArrays; LOCAL_StaticArrays = p; } WRITE_LOCK(p->ArRWLock); p->ArrayEArity = -dim; p->ArrayType = type; - ae->PropsOfAE = AbsArrayProp((ArrayEntry *)p); if (start_addr == NULL) { int i; diff --git a/C/bb.c b/C/bb.c index 38356f55d..a42034fba 100644 --- a/C/bb.c +++ b/C/bb.c @@ -43,8 +43,7 @@ PutBBProp(AtomEntry *ae, Term mod USES_REGS) /* get BBentry for at; */ Yap_Error(OUT_OF_HEAP_ERROR,ARG1,"could not allocate space in bb_put/2"); return(NULL); } - p->NextOfPE = ae->PropsOfAE; - ae->PropsOfAE = AbsBBProp(p); + AddPropToAtom(ae, (PropEntry *)p); p->ModuleOfBB = mod; p->Element = 0L; p->KeyOfBB = AbsAtom(ae); diff --git a/C/dbase.c b/C/dbase.c index 7b473b8a1..a755c2d54 100755 --- a/C/dbase.c +++ b/C/dbase.c @@ -2896,8 +2896,7 @@ FetchDBPropFromKey(Term twork, int flag, int new, char *error_mssg) p->FunctorOfDB = (Functor) At; else p->FunctorOfDB = Yap_UnlockedMkFunctor(ae,arity); - p->NextOfPE = ae->PropsOfAE; - ae->PropsOfAE = AbsDBProp(p); + AddPropToAtom(ae, (PropEntry *)p); } WRITE_UNLOCK(ae->ARWLock); return diff --git a/C/globals.c b/C/globals.c index 5c2851796..07769bdf5 100644 --- a/C/globals.c +++ b/C/globals.c @@ -858,8 +858,7 @@ GetGlobalEntry(Atom at USES_REGS) new->NextGE = LOCAL_GlobalVariables; LOCAL_GlobalVariables = new; new->AtomOfGE = ae; - new->NextOfPE = ae->PropsOfAE; - ae->PropsOfAE = AbsGlobalProp(new); + AddPropToAtom(ae, (PropEntry *)new); RESET_VARIABLE(&new->global); WRITE_UNLOCK(ae->ARWLock); return new; diff --git a/C/init.c b/C/init.c index 95336e9d6..2daa79290 100755 --- a/C/init.c +++ b/C/init.c @@ -151,14 +151,13 @@ OpDec(int p, char *type, Atom a, Term m) if (EndOfPAEntr(info)) { info = (OpEntry *) Yap_AllocAtomSpace(sizeof(OpEntry)); info->KindOfPE = Ord(OpProperty); - info->NextOfPE = RepAtom(a)->PropsOfAE; info->OpModule = m; info->OpName = a; LOCK(OpListLock); info->OpNext = OpList; OpList = info; UNLOCK(OpListLock); - RepAtom(a)->PropsOfAE = AbsOpProp(info); + AddPropToAtom(ae, (PropEntry *)info); INIT_RWLOCK(info->OpRWLock); WRITE_LOCK(info->OpRWLock); WRITE_UNLOCK(ae->ARWLock); diff --git a/C/modules.c b/C/modules.c index d588b5914..0c9e64b16 100644 --- a/C/modules.c +++ b/C/modules.c @@ -72,8 +72,7 @@ GetModuleEntry(Atom at) new->NextME = CurrentModules; CurrentModules = new; new->AtomOfME = ae; - new->NextOfPE = ae->PropsOfAE; - ae->PropsOfAE = AbsModProp(new); + AddPropToAtom(ae, (PropEntry *)new); return new; } diff --git a/H/Yatom.h b/H/Yatom.h index f79e1bb78..dbdb1d78c 100755 --- a/H/Yatom.h +++ b/H/Yatom.h @@ -1608,3 +1608,15 @@ PredPropByAtom (Atom at, Term cur_mod) #endif +static inline void +AddPropToAtom(AtomEntry *ae, PropEntry *p) +{ + if (ae->PropsOfAE != NIL) { + PropEntry *pp = RepProp(ae->PropsOfAE); + p->NextOfPE = pp->NextOfPE; + pp->NextOfPE = AbsProp( p); + } else { + p->NextOfPE = ae->PropsOfAE; + ae->PropsOfAE = AbsProp(p); + } +}