27 const unsigned char *f_name;
36#define ASSEMBLING_CLAUSE 0
37#define ASSEMBLING_INDEX 1
38#define ASSEMBLING_EINDEX 2
40#define NextDynamicClause(X) (((yamop *)X)->y_u.Otapl.d)
42#define PredFirstClause 0
43#define PredMiddleClause 1
44#define PredLastClause 2
49#if defined(YAPOR) || defined(THREADS)
60 yamop ClCode[MIN_ARRAY];
70#if defined(YAPOR) || defined(THREADS)
88 UInt ClTimeStart, ClTimeEnd;
90 yamop ClCode[MIN_ARRAY];
93#include "inline-only.h"
96INLINE_ONLY
int VALID_TIMESTAMP(UInt timestamp,
98 return IN_BETWEEN(cl->ClTimeStart, timestamp, cl->ClTimeEnd);
104#if defined(YAPOR) || defined(THREADS)
113 yamop ClCode[MIN_ARRAY];
124 yamop ClCode[MIN_ARRAY];
137 yamop ClCode[MIN_ARRAY];
149 yamop ClCode[MIN_ARRAY];
189 void *udi_first, *udi_next;
194INLINE_ONLY BITS32 EXO_ADDRESS_TO_OFFSET(
struct index_t *it,
197INLINE_ONLY BITS32 EXO_ADDRESS_TO_OFFSET(
struct index_t *it,
199 return (ptr - it->cls) / it->arity + 1;
202INLINE_ONLY CELL *EXO_OFFSET_TO_ADDRESS(
struct index_t *it,
205INLINE_ONLY CELL *EXO_OFFSET_TO_ADDRESS(
struct index_t *it,
209 return (it->cls) + (off - 1) * it->arity;
213INLINE_ONLY BITS32 ADDRESS_TO_LINK(
struct index_t *it,
215 return ptr - it->links;
219INLINE_ONLY BITS32 *LINK_TO_ADDRESS(
struct index_t *it,
221 return it->links + off;
224typedef void (*CRefitExoIndex)(
struct index_t **ip, UInt b[] USES_REGS);
225typedef yamop *(*CEnterExoIndex)(
struct index_t *it USES_REGS);
226typedef int (*CRetryExoIndex)(
struct index_t *it USES_REGS);
236#define ClauseCodeToDynamicClause(p) \
237 ((DynamicClause *)((CODEADDR)(p) - (CELL)(((DynamicClause *)NULL)->ClCode)))
238#define ClauseCodeToStaticClause(p) \
239 ((StaticClause *)((CODEADDR)(p) - (CELL)(((StaticClause *)NULL)->ClCode)))
240#define ClauseCodeToLogUpdClause(p) \
241 ((LogUpdClause *)((CODEADDR)(p) - (CELL)(((LogUpdClause *)NULL)->ClCode)))
242#define ClauseCodeToMegaClause(p) \
243 ((MegaClause *)((CODEADDR)(p) - (CELL)(((MegaClause *)NULL)->ClCode)))
244#define ClauseCodeToLogUpdIndex(p) \
245 ((LogUpdIndex *)((CODEADDR)(p) - (CELL)(((LogUpdIndex *)NULL)->ClCode)))
246#define ClauseCodeToStaticIndex(p) \
247 ((StaticIndex *)((CODEADDR)(p) - (CELL)(((StaticIndex *)NULL)->ClCode)))
249#define ClauseFlagsToDynamicClause(p) ((DynamicClause *)(p))
250#define ClauseFlagsToLogUpdClause(p) \
251 ((LogUpdClause *)((CODEADDR)(p) - (CELL)(&(((LogUpdClause *)NULL)->ClFlags))))
252#define ClauseFlagsToLogUpdIndex(p) \
253 ((LogUpdIndex *)((CODEADDR)(p) - (CELL)(&(((LogUpdIndex *)NULL)->ClFlags))))
254#define ClauseFlagsToStaticClause(p) ((StaticClause *)(p))
256#define DynamicFlags(X) (ClauseCodeToDynamicClause(X)->ClFlags)
258#define DynamicLock(X) (ClauseCodeToDynamicClause(X)->ClLock)
261#define INIT_CLREF_COUNT(X) (X)->ClRefCount = 0
262#define INC_CLREF_COUNT(X) (X)->ClRefCount++
263#define DEC_CLREF_COUNT(X) (X)->ClRefCount--
265#define CL_IN_USE(X) ((X)->ClRefCount)
267#define INIT_CLREF_COUNT(X)
268#define INC_CLREF_COUNT(X)
269#define DEC_CLREF_COUNT(X)
270#define CL_IN_USE(X) ((X)->ClFlags & InUseMask || (X)->ClRefCount)
274wamreg Yap_emit_x(CELL);
276void Yap_InitComma(
void);
281bool Yap_addclause(Term,
yamop *, Term, Term, Term *);
291Int Yap_Recordz(
Atom, Term);
292Int Yap_db_nth_recorded(
PredEntry *, Int USES_REGS);
293Int Yap_unify_immediate_ref(
DBRef ref USES_REGS);
316#define OP_HASH_SIZE 2048
323typedef struct opcode_optab_entry {
329INLINE_ONLY
int rtable_hash_op(OPCODE opc,
int hash_mask) {
330 return ((((CELL)opc) >> 3) & hash_mask);
336INLINE_ONLY op_numbers Yap_op_from_opcode(OPCODE opc) {
337 int j = rtable_hash_op(opc, OP_HASH_SIZE - 1);
339 while (OP_RTABLE[j].opc != opc) {
340 if (!OP_RTABLE[j].opc)
342 if (j == OP_HASH_SIZE - 1) {
348 return OP_RTABLE[j].opnum;
351static inline op_numbers Yap_op_from_opcode(OPCODE opc) {
352 return ((op_numbers)opc);
356#if defined(YAPOR) || defined(THREADS)
357static inline int same_lu_block(
yamop **,
yamop *);
359static inline int same_lu_block(
yamop **paddr,
yamop *p) {
362 OPCODE jmp_op = Yap_opcode(_jump_if_nonvar);
364 while (np->opc == jmp_op) {
365 np = NEXTOP(np, xll);
376#define Yap_MkStaticRefTerm(cp, ap) __Yap_MkStaticRefTerm((cp), (ap)PASS_REGS)
378static inline Term __Yap_MkStaticRefTerm(
StaticClause *cp,
381 t[0] = MkIntegerTerm((Int)cp);
382 t[1] = MkIntegerTerm((Int)ap);
383 return Yap_MkApplTerm(FunctorStaticClause, 2, t);
390#define Yap_MkMegaRefTerm(ap, ipc) __Yap_MkMegaRefTerm((ap), (ipc)PASS_REGS)
392static inline Term __Yap_MkMegaRefTerm(
PredEntry *ap,
yamop *ipc USES_REGS) {
394 t[0] = MkIntegerTerm((Int)ap);
395 t[1] = MkIntegerTerm((Int)ipc);
396 return Yap_MkApplTerm(FunctorMegaClause, 2, t);
399static inline yamop *Yap_MegaClauseFromTerm(Term t) {
400 return (
yamop *)IntegerOfTerm(ArgOfTerm(2, t));
403static inline PredEntry *Yap_MegaClausePredicateFromTerm(Term t) {
404 return (
PredEntry *)IntegerOfTerm(ArgOfTerm(1, t));
407#define Yap_MkExoRefTerm(ap, i) __Yap_MkExoRefTerm((ap), (i)PASS_REGS)
409static inline Term __Yap_MkExoRefTerm(
PredEntry *ap, Int i USES_REGS) {
411 t[0] = MkIntegerTerm((Int)ap);
412 t[1] = MkIntegerTerm((Int)i);
413 return Yap_MkApplTerm(FunctorExoClause, 2, t);
416static inline Int Yap_ExoClauseFromTerm(Term t) {
417 return IntegerOfTerm(ArgOfTerm(2, t));
420static inline PredEntry *Yap_ExoClausePredicateFromTerm(Term t) {
421 return (
PredEntry *)IntegerOfTerm(ArgOfTerm(1, t));
430bool Yap_search_for_static_predicate_in_use(
PredEntry *p,
431 bool check_everything);
433static inline bool Yap_static_in_use(
PredEntry *p,
bool check_everything) {
434#if defined(YAPOR) || defined(THREADS)
437 pred_flags_t pflags = p->PredFlags;
438 if (pflags & (DynamicPredFlag | LogUpdatePredFlag)) {
441 if (STATIC_PREDICATES_MARKED) {
442 return (p->PredFlags & InUsePredFlag);
445 return Yap_search_for_static_predicate_in_use(p, check_everything);
449#define DEAD_REF(ref) FALSE
453 FIND_PRED_FROM_ANYWHERE,
459PredEntry *Yap_PredEntryForCode(
yamop *, find_pred_type,
void **,
void **);
469Term Yap_env_location(
yamop *p,
choiceptr b_ptr, CELL *env, Int ignore_first);
472void Yap_InformOfRemoval(
void *);
473void Yap_dump_code_area_for_profiler(
void);
475#define Yap_InformOfRemoval(X)
478static inline void clean_tr(tr_fr_ptr TR0 USES_REGS) {
481 Term p = TrailTerm(--pt0);
483 CELL *pt = RepAppl(p);
485 pt[0] = TrailVal(pt0);
487 pt[0] = TrailTerm(pt0 - 1);
500extern PredEntry * Yap_track_cpred( op_numbers opcode,
yamop *p,
size_t min,
void *i );
PredEntry * Yap_PredForCode(yamop *codeptr, find_pred_type hint, Int *cl)
given an arbitrary code point codeptr search the database for the owner predicate pp identifying the ...