more handles and fix exit from a backtrackable user c-pred
This commit is contained in:
parent
5f3ff4fc73
commit
61e78d9963
2
H/Regs.h
2
H/Regs.h
@ -92,7 +92,6 @@ INLINE_ONLY inline EXTERN void save_B(void);
|
|||||||
|
|
||||||
typedef struct regstore_t
|
typedef struct regstore_t
|
||||||
{
|
{
|
||||||
Int CurSlot_;
|
|
||||||
CELL CreepFlag_; /* 13 */
|
CELL CreepFlag_; /* 13 */
|
||||||
CELL *HB_; /* 4 heap (global) stack top at latest c.p. */
|
CELL *HB_; /* 4 heap (global) stack top at latest c.p. */
|
||||||
#if defined(YAPOR_SBA) || defined(TABLING)
|
#if defined(YAPOR_SBA) || defined(TABLING)
|
||||||
@ -634,7 +633,6 @@ INLINE_ONLY EXTERN inline void restore_B(void) {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CurSlot Yap_REGS.CurSlot_
|
|
||||||
#define AuxBase Yap_REGS.AuxBase_
|
#define AuxBase Yap_REGS.AuxBase_
|
||||||
#define AuxSp Yap_REGS.AuxSp_
|
#define AuxSp Yap_REGS.AuxSp_
|
||||||
#define AuxTop Yap_REGS.AuxTop_
|
#define AuxTop Yap_REGS.AuxTop_
|
||||||
|
76
H/Yap.h
76
H/Yap.h
@ -747,81 +747,7 @@ extern struct worker_local Yap_local;
|
|||||||
|
|
||||||
#include "YapCompoundTerm.h"
|
#include "YapCompoundTerm.h"
|
||||||
|
|
||||||
|
#include "YapHandles.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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* YAP_H */
|
#endif /* YAP_H */
|
||||||
|
|
||||||
|
@ -55,9 +55,6 @@ Term Yap_NWideStringToDiffListOfAtoms(wchar_t *, Term, size_t);
|
|||||||
int Yap_AtomIncreaseHold(Atom);
|
int Yap_AtomIncreaseHold(Atom);
|
||||||
int Yap_AtomDecreaseHold(Atom);
|
int Yap_AtomDecreaseHold(Atom);
|
||||||
struct operator_entry *Yap_OpPropForModule(Atom, Term);
|
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
|
#ifdef SFUNC
|
||||||
|
@ -39,9 +39,7 @@ struct cut_c_str{
|
|||||||
cut_c_str_ptr TOP = Yap_REGS.CUT_C_TOP; \
|
cut_c_str_ptr TOP = Yap_REGS.CUT_C_TOP; \
|
||||||
CPredicate func = (CPredicate)((yamop *)TOP->try_userc_cut_yamop)->u.OtapFs.f; \
|
CPredicate func = (CPredicate)((yamop *)TOP->try_userc_cut_yamop)->u.OtapFs.f; \
|
||||||
PredEntry *pred = (PredEntry *)((yamop *)TOP->try_userc_cut_yamop)->u.OtapFs.p; \
|
PredEntry *pred = (PredEntry *)((yamop *)TOP->try_userc_cut_yamop)->u.OtapFs.p; \
|
||||||
Yap_StartSlots( PASS_REGS1 ); \
|
|
||||||
YAP_ExecuteOnCut(pred, func, TOP); \
|
YAP_ExecuteOnCut(pred, func, TOP); \
|
||||||
Yap_CloseSlots( PASS_REGS1 ); \
|
|
||||||
cut_c_pop();
|
cut_c_pop();
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,6 +71,7 @@
|
|||||||
#define LOCKPRED_OPCODE Yap_heap_regs->lockpred_op
|
#define LOCKPRED_OPCODE Yap_heap_regs->lockpred_op
|
||||||
#define ORLAST_OPCODE Yap_heap_regs->orlast_op
|
#define ORLAST_OPCODE Yap_heap_regs->orlast_op
|
||||||
#define UNDEF_OPCODE Yap_heap_regs->undef_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 NOfAtoms Yap_heap_regs->n_of_atoms
|
||||||
#define AtomHashTableSize Yap_heap_regs->atom_hash_table_size
|
#define AtomHashTableSize Yap_heap_regs->atom_hash_table_size
|
||||||
|
@ -412,6 +412,9 @@
|
|||||||
|
|
||||||
#define LOCAL_search_atoms LOCAL->search_atoms_
|
#define LOCAL_search_atoms LOCAL->search_atoms_
|
||||||
#define REMOTE_search_atoms(wid) REMOTE(wid)->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 LOCAL_SourceModule LOCAL->SourceModule_
|
||||||
#define REMOTE_SourceModule(wid) REMOTE(wid)->SourceModule_
|
#define REMOTE_SourceModule(wid) REMOTE(wid)->SourceModule_
|
||||||
|
|
||||||
|
@ -232,5 +232,7 @@ typedef struct worker_local {
|
|||||||
UInt exo_arg_;
|
UInt exo_arg_;
|
||||||
|
|
||||||
struct scan_atoms* search_atoms_;
|
struct scan_atoms* search_atoms_;
|
||||||
|
|
||||||
|
Int CurSlot_;
|
||||||
Term SourceModule_;
|
Term SourceModule_;
|
||||||
} w_local;
|
} w_local;
|
||||||
|
@ -71,6 +71,7 @@
|
|||||||
OPCODE lockpred_op;
|
OPCODE lockpred_op;
|
||||||
OPCODE orlast_op;
|
OPCODE orlast_op;
|
||||||
OPCODE undef_op;
|
OPCODE undef_op;
|
||||||
|
OPCODE retry_userc_op;
|
||||||
|
|
||||||
UInt n_of_atoms;
|
UInt n_of_atoms;
|
||||||
UInt atom_hash_table_size;
|
UInt atom_hash_table_size;
|
||||||
@ -228,7 +229,6 @@
|
|||||||
UInt dirty_cps;
|
UInt dirty_cps;
|
||||||
UInt freed_cps;
|
UInt freed_cps;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
UInt expand_clauses_sz;
|
UInt expand_clauses_sz;
|
||||||
|
|
||||||
struct udi_info *udi_control_blocks;
|
struct udi_info *udi_control_blocks;
|
||||||
|
@ -71,6 +71,7 @@
|
|||||||
LOCKPRED_OPCODE = Yap_opcode(_lock_pred);
|
LOCKPRED_OPCODE = Yap_opcode(_lock_pred);
|
||||||
ORLAST_OPCODE = Yap_opcode(_or_last);
|
ORLAST_OPCODE = Yap_opcode(_or_last);
|
||||||
UNDEF_OPCODE = Yap_opcode(_undef_p);
|
UNDEF_OPCODE = Yap_opcode(_undef_p);
|
||||||
|
RETRY_USERC_OPCODE = Yap_opcode(_retry_userc);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -232,5 +232,7 @@ static void InitWorker(int wid) {
|
|||||||
REMOTE_exo_arg(wid) = 0;
|
REMOTE_exo_arg(wid) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
REMOTE_CurSlot(wid) = 0;
|
||||||
REMOTE_SourceModule(wid) = 0;
|
REMOTE_SourceModule(wid) = 0;
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ void PL_license(const char *license, const char *module);
|
|||||||
|
|
||||||
#define arityFunctor(f) YAP_PLArityOfSWIFunctor(f)
|
#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 isInteger(A) (!IsVarTerm(A) && ( IsIntegerTerm((A)) || YAP_IsBigNumTerm((A)) ))
|
||||||
#define isString(A) (!IsVarTerm(A) && Yap_IsStringTerm(A) )
|
#define isString(A) (!IsVarTerm(A) && Yap_IsStringTerm(A) )
|
||||||
#define isAtom(A) (!IsVarTerm(A) && IsAtomTerm((A)) )
|
#define isAtom(A) (!IsVarTerm(A) && IsAtomTerm((A)) )
|
||||||
|
@ -71,6 +71,7 @@
|
|||||||
LOCKPRED_OPCODE = Yap_opcode(_lock_pred);
|
LOCKPRED_OPCODE = Yap_opcode(_lock_pred);
|
||||||
ORLAST_OPCODE = Yap_opcode(_or_last);
|
ORLAST_OPCODE = Yap_opcode(_or_last);
|
||||||
UNDEF_OPCODE = Yap_opcode(_undef_p);
|
UNDEF_OPCODE = Yap_opcode(_undef_p);
|
||||||
|
RETRY_USERC_OPCODE = Yap_opcode(_retry_userc);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -230,6 +230,8 @@ static void RestoreWorker(int wid USES_REGS) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,6 +70,7 @@ OPCODE index_op INDEX_OPCODE MkOp _index_pred
|
|||||||
OPCODE lockpred_op LOCKPRED_OPCODE MkOp _lock_pred
|
OPCODE lockpred_op LOCKPRED_OPCODE MkOp _lock_pred
|
||||||
OPCODE orlast_op ORLAST_OPCODE MkOp _or_last
|
OPCODE orlast_op ORLAST_OPCODE MkOp _or_last
|
||||||
OPCODE undef_op UNDEF_OPCODE MkOp _undef_p
|
OPCODE undef_op UNDEF_OPCODE MkOp _undef_p
|
||||||
|
OPCODE retry_userc_op RETRY_USERC_OPCODE MkOp _retry_userc
|
||||||
|
|
||||||
/* atom tables */
|
/* atom tables */
|
||||||
UInt n_of_atoms NOfAtoms void void
|
UInt n_of_atoms NOfAtoms void void
|
||||||
|
@ -265,6 +265,10 @@ UInt exo_arg =0
|
|||||||
// atom completion
|
// atom completion
|
||||||
struct scan_atoms* search_atoms void
|
struct scan_atoms* search_atoms void
|
||||||
|
|
||||||
|
// Slots
|
||||||
|
Int CurSlot =0
|
||||||
|
|
||||||
|
|
||||||
Term SourceModule =0
|
Term SourceModule =0
|
||||||
|
|
||||||
END_WORKER_LOCAL
|
END_WORKER_LOCAL
|
||||||
|
Reference in New Issue
Block a user