try to improve slot allocation.

This commit is contained in:
Vitor Santos Costa 2012-12-10 12:14:24 +00:00
parent 9e63e83f1f
commit b34c8b1b2c
2 changed files with 19 additions and 19 deletions

View File

@ -2255,14 +2255,12 @@ YAP_AtomToPred(Atom at)
X_API PredEntry * X_API PredEntry *
YAP_FunctorToPredInModule(Functor func, Term mod) YAP_FunctorToPredInModule(Functor func, Term mod)
{ {
CACHE_REGS
return RepPredProp(PredPropByFunc(func, mod)); return RepPredProp(PredPropByFunc(func, mod));
} }
X_API PredEntry * X_API PredEntry *
YAP_AtomToPredInModule(Atom at, Term mod) YAP_AtomToPredInModule(Atom at, Term mod)
{ {
CACHE_REGS
return RepPredProp(PredPropByAtom(at, mod)); return RepPredProp(PredPropByAtom(at, mod));
} }
@ -2434,7 +2432,6 @@ YAP_RunGoal(Term t)
LOCAL_AllowRestart = FALSE; LOCAL_AllowRestart = FALSE;
} }
RECOVER_MACHINE_REGS(); RECOVER_MACHINE_REGS();
return out; return out;
} }
@ -2562,6 +2559,8 @@ YAP_RestartGoal(void)
if (LOCAL_AllowRestart) { if (LOCAL_AllowRestart) {
P = (yamop *)FAILCODE; P = (yamop *)FAILCODE;
LOCAL_PrologMode = UserMode; LOCAL_PrologMode = UserMode;
// exec_absmi destroys slots on top of stack....
Yap_CloseSlots( PASS_REGS1 );
out = Yap_exec_absmi(TRUE); out = Yap_exec_absmi(TRUE);
LOCAL_PrologMode = UserCCallMode; LOCAL_PrologMode = UserCCallMode;
if (out == FALSE) { if (out == FALSE) {

33
H/Yap.h
View File

@ -850,22 +850,6 @@ Yap_StartSlots( USES_REGS1 ) {
CurSlot = LCL0-ASP; CurSlot = LCL0-ASP;
} }
static inline void
Yap_CloseSlots( USES_REGS1 ) {
Int old_slots;
if (CurSlot < LCL0-ASP)
return;
old_slots = IntOfTerm(ASP[0]);
ASP += (old_slots+1);
CurSlot = IntOfTerm(*ASP);
ASP++;
}
static inline Int
Yap_CurrentSlot( USES_REGS1 ) {
return IntOfTerm(ASP[0]);
}
/* pop slots when pruning */ /* pop slots when pruning */
static inline void static inline void
Yap_PopSlots( USES_REGS1 ) { Yap_PopSlots( USES_REGS1 ) {
@ -878,6 +862,23 @@ Yap_PopSlots( USES_REGS1 ) {
} }
} }
static inline void
Yap_CloseSlots( USES_REGS1 ) {
Int old_slots;
Yap_PopSlots( PASS_REGS1 );
if (LCL0-CurSlot == ASP) {
old_slots = IntOfTerm(ASP[0]);
ASP += (old_slots+1);
CurSlot = IntOfTerm(*ASP);
ASP++;
}
}
static inline Int
Yap_CurrentSlot( USES_REGS1 ) {
return IntOfTerm(ASP[0]);
}
static inline Term static inline Term
Yap_GetFromSlot(Int slot USES_REGS) Yap_GetFromSlot(Int slot USES_REGS)
{ {