From b34c8b1b2c02de9da1b48b9e7a27942a6223ba16 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Mon, 10 Dec 2012 12:14:24 +0000 Subject: [PATCH] try to improve slot allocation. --- C/c_interface.c | 5 ++--- H/Yap.h | 33 +++++++++++++++++---------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/C/c_interface.c b/C/c_interface.c index daf4462f9..1a00642ef 100644 --- a/C/c_interface.c +++ b/C/c_interface.c @@ -2255,14 +2255,12 @@ YAP_AtomToPred(Atom at) X_API PredEntry * YAP_FunctorToPredInModule(Functor func, Term mod) { - CACHE_REGS return RepPredProp(PredPropByFunc(func, mod)); } X_API PredEntry * YAP_AtomToPredInModule(Atom at, Term mod) { - CACHE_REGS return RepPredProp(PredPropByAtom(at, mod)); } @@ -2433,7 +2431,6 @@ YAP_RunGoal(Term t) B = B->cp_b; LOCAL_AllowRestart = FALSE; } - RECOVER_MACHINE_REGS(); return out; @@ -2562,6 +2559,8 @@ YAP_RestartGoal(void) if (LOCAL_AllowRestart) { P = (yamop *)FAILCODE; LOCAL_PrologMode = UserMode; + // exec_absmi destroys slots on top of stack.... + Yap_CloseSlots( PASS_REGS1 ); out = Yap_exec_absmi(TRUE); LOCAL_PrologMode = UserCCallMode; if (out == FALSE) { diff --git a/H/Yap.h b/H/Yap.h index a90c5f1e2..b5a23a0cb 100755 --- a/H/Yap.h +++ b/H/Yap.h @@ -850,22 +850,6 @@ Yap_StartSlots( USES_REGS1 ) { 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 */ static inline void 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 Yap_GetFromSlot(Int slot USES_REGS) {