more handles and fix exit from a backtrackable user c-pred

This commit is contained in:
Vitor Santos Costa 2013-11-20 22:27:46 +00:00
parent 5f3ff4fc73
commit 61e78d9963
15 changed files with 20 additions and 84 deletions

View File

@ -92,7 +92,6 @@ INLINE_ONLY inline EXTERN void save_B(void);
typedef struct regstore_t
{
Int CurSlot_;
CELL CreepFlag_; /* 13 */
CELL *HB_; /* 4 heap (global) stack top at latest c.p. */
#if defined(YAPOR_SBA) || defined(TABLING)
@ -634,7 +633,6 @@ INLINE_ONLY EXTERN inline void restore_B(void) {
#endif
#define CurSlot Yap_REGS.CurSlot_
#define AuxBase Yap_REGS.AuxBase_
#define AuxSp Yap_REGS.AuxSp_
#define AuxTop Yap_REGS.AuxTop_

76
H/Yap.h
View File

@ -747,81 +747,7 @@ extern struct worker_local Yap_local;
#include "YapCompoundTerm.h"
/*************************************************************************************************
slots
*************************************************************************************************/
static inline void
Yap_StartSlots( USES_REGS1 ) {
if (CurSlot == LCL0-ASP)
return;
*--ASP = MkIntegerTerm(CurSlot);
*--ASP = MkIntTerm(0);
CurSlot = LCL0-ASP;
}
/* pop slots when pruning */
static inline void
Yap_PopSlots( USES_REGS1 ) {
while (LCL0-CurSlot < ASP) {
Int old_slots;
CELL *ptr = LCL0-CurSlot;
old_slots = IntOfTerm(ptr[0]);
ptr += (old_slots+1);
CurSlot = IntOfTerm(*ptr);
}
}
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)
{
return(Deref(LCL0[slot]));
}
static inline Term
Yap_GetDerefedFromSlot(Int slot USES_REGS)
{
return LCL0[slot];;
}
static inline Term
Yap_GetPtrFromSlot(Int slot USES_REGS)
{
return(LCL0[slot]);
}
static inline Term *
Yap_AddressFromSlot(Int slot USES_REGS)
{
return(LCL0+slot);
}
static inline void
Yap_PutInSlot(Int slot, Term t USES_REGS)
{
LCL0[slot] = t;
}
#include "YapHandles.h"
#endif /* YAP_H */

View File

@ -55,9 +55,6 @@ Term Yap_NWideStringToDiffListOfAtoms(wchar_t *, Term, size_t);
int Yap_AtomIncreaseHold(Atom);
int Yap_AtomDecreaseHold(Atom);
struct operator_entry *Yap_OpPropForModule(Atom, Term);
Int Yap_InitSlot(Term CACHE_TYPE);
Int Yap_NewSlots(int CACHE_TYPE);
int Yap_RecoverSlots(int CACHE_TYPE);
#ifdef SFUNC

View File

@ -39,9 +39,7 @@ struct cut_c_str{
cut_c_str_ptr TOP = Yap_REGS.CUT_C_TOP; \
CPredicate func = (CPredicate)((yamop *)TOP->try_userc_cut_yamop)->u.OtapFs.f; \
PredEntry *pred = (PredEntry *)((yamop *)TOP->try_userc_cut_yamop)->u.OtapFs.p; \
Yap_StartSlots( PASS_REGS1 ); \
YAP_ExecuteOnCut(pred, func, TOP); \
Yap_CloseSlots( PASS_REGS1 ); \
cut_c_pop();

View File

@ -71,6 +71,7 @@
#define LOCKPRED_OPCODE Yap_heap_regs->lockpred_op
#define ORLAST_OPCODE Yap_heap_regs->orlast_op
#define UNDEF_OPCODE Yap_heap_regs->undef_op
#define RETRY_USERC_OPCODE Yap_heap_regs->retry_userc_op
#define NOfAtoms Yap_heap_regs->n_of_atoms
#define AtomHashTableSize Yap_heap_regs->atom_hash_table_size

View File

@ -412,6 +412,9 @@
#define LOCAL_search_atoms LOCAL->search_atoms_
#define REMOTE_search_atoms(wid) REMOTE(wid)->search_atoms_
#define LOCAL_CurSlot LOCAL->CurSlot_
#define REMOTE_CurSlot(wid) REMOTE(wid)->CurSlot_
#define LOCAL_SourceModule LOCAL->SourceModule_
#define REMOTE_SourceModule(wid) REMOTE(wid)->SourceModule_

View File

@ -232,5 +232,7 @@ typedef struct worker_local {
UInt exo_arg_;
struct scan_atoms* search_atoms_;
Int CurSlot_;
Term SourceModule_;
} w_local;

View File

@ -71,6 +71,7 @@
OPCODE lockpred_op;
OPCODE orlast_op;
OPCODE undef_op;
OPCODE retry_userc_op;
UInt n_of_atoms;
UInt atom_hash_table_size;
@ -228,7 +229,6 @@
UInt dirty_cps;
UInt freed_cps;
#endif
UInt expand_clauses_sz;
struct udi_info *udi_control_blocks;

View File

@ -71,6 +71,7 @@
LOCKPRED_OPCODE = Yap_opcode(_lock_pred);
ORLAST_OPCODE = Yap_opcode(_or_last);
UNDEF_OPCODE = Yap_opcode(_undef_p);
RETRY_USERC_OPCODE = Yap_opcode(_retry_userc);

View File

@ -232,5 +232,7 @@ static void InitWorker(int wid) {
REMOTE_exo_arg(wid) = 0;
REMOTE_CurSlot(wid) = 0;
REMOTE_SourceModule(wid) = 0;
}

View File

@ -124,7 +124,7 @@ void PL_license(const char *license, const char *module);
#define arityFunctor(f) YAP_PLArityOfSWIFunctor(f)
#define stringAtom(w) YAP_AtomName(YAP_AtomFromSWIAtom(w))
#define stringAtom(w) (YAP_AtomFromSWIAtom(w)->StrOfAE)
#define isInteger(A) (!IsVarTerm(A) && ( IsIntegerTerm((A)) || YAP_IsBigNumTerm((A)) ))
#define isString(A) (!IsVarTerm(A) && Yap_IsStringTerm(A) )
#define isAtom(A) (!IsVarTerm(A) && IsAtomTerm((A)) )

View File

@ -71,6 +71,7 @@
LOCKPRED_OPCODE = Yap_opcode(_lock_pred);
ORLAST_OPCODE = Yap_opcode(_or_last);
UNDEF_OPCODE = Yap_opcode(_undef_p);
RETRY_USERC_OPCODE = Yap_opcode(_retry_userc);

View File

@ -230,6 +230,8 @@ static void RestoreWorker(int wid USES_REGS) {

View File

@ -70,6 +70,7 @@ OPCODE index_op INDEX_OPCODE MkOp _index_pred
OPCODE lockpred_op LOCKPRED_OPCODE MkOp _lock_pred
OPCODE orlast_op ORLAST_OPCODE MkOp _or_last
OPCODE undef_op UNDEF_OPCODE MkOp _undef_p
OPCODE retry_userc_op RETRY_USERC_OPCODE MkOp _retry_userc
/* atom tables */
UInt n_of_atoms NOfAtoms void void

View File

@ -265,6 +265,10 @@ UInt exo_arg =0
// atom completion
struct scan_atoms* search_atoms void
// Slots
Int CurSlot =0
Term SourceModule =0
END_WORKER_LOCAL