biassert.c File Reference

#include "xsb_config.h"
#include "xsb_debug.h"
#include "debugs/debug_biassert.h"
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include "setjmp_xsb.h"
#include "auxlry.h"
#include "cell_xsb.h"
#include "psc_xsb.h"
#include "error_xsb.h"
#include "cinterf.h"
#include "memory_xsb.h"
#include "heap_xsb.h"
#include "register.h"
#include "flags_xsb.h"
#include "deref.h"
#include "inst_xsb.h"
#include "token_xsb.h"
#include "loader_xsb.h"
#include "trie_internals.h"
#include "choice.h"
#include "macro_xsb.h"
#include "tr_utils.h"
#include "trassert.h"
#include "context.h"
#include "thread_xsb.h"
#include "debug_xsb.h"
#include "biassert_defs.h"

Data Structures

struct  DispBlk_t
struct  DispBlkHdr_t
struct  flatten_elt
struct  flatten_q
struct  instruction
struct  instruction_q
struct  RegStat_t
struct  ClRefHdrI

Defines

#define MARKED_FOR_DELETION   66
#define write_word(Buff, Loc, w)
#define write_byte(Buff, Loc, w)   { *(pb)((pb)Buff + *(Loc)) = (byte)(w); *(Loc) += 1; }
#define pad64bits(Loc)   {}
#define dbgen_printinst3_macro(Opcode, Arg1, Arg2, Arg3)   dbgen_printinst3(Opcode, Arg1, Arg2, Arg3)
#define dbgen_printinst_macro(Opcode, Arg1, Arg2)   dbgen_printinst(Opcode, Arg1, Arg2)
#define dbgen_inst3_tv(Opcode, Arg1, Arg2, Arg3, Buff, Loc)
#define dbgen_inst3_sob(Opcode, Arg1, Arg2, Arg3, Buff, Loc)
#define dbgen_inst_pvv(Opcode, Arg1, Arg2, Buff, Loc)
#define dbgen_inst_ppv(Opcode, Arg1, Buff, Loc)
#define dbgen_inst_ppvw(Opcode, Arg1, Arg2, Buff, Loc)
#define dbgen_inst_ppvw_safe(Opcode, Arg1, Arg2, Buff, Loc)
#define dbgen_inst_ppvww(Opcode, Arg1, Arg2, Arg3, Buff, Loc)
#define dbgen_inst_pppw(Opcode, Arg1, Buff, Loc)
#define dbgen_inst_ppp(Opcode, Buff, Loc)
#define dbgen_instB3_tv(Opcode, Arg1, Arg2, Arg3)
#define dbgen_instB3_sob(Opcode, Arg1, Arg2, Arg3)
#define dbgen_instB_pvv(Opcode, Arg1, Arg2)
#define dbgen_instB_ppv(Opcode, Arg1)
#define dbgen_instB_ppvw(Opcode, Arg1, Arg2)
#define dbgen_instB_pppw(Opcode, Arg1)
#define dbgen_instB_ppp(Opcode)
#define FLATTEN_STACK_SIZE   512
#define INST_QUEUE_SIZE   512
#define ERR_FUNCTOR   1
#define ERR_REGISTER   2
#define RVAR   -1
#define TVAR   -2
#define HIGHBIT   0x80000000
#define PredOpCode(P)   (cell_opcode(&(P)->Instr))
#define ClRefAddr(Cl)   ((CPtr)((ClRef)(Cl)-1))
#define ClRefSize(Cl)   (((ClRef)(Cl))[-1].buflen & ~0x3 & ~HIGHBIT)
#define ClRefType(Cl)   (((ClRef)(Cl))[-1].buflen & 0x3)
#define SetClRefSize(Cl, len)
#define SetClRefType(Cl, type)
#define ClRefPrev(Cl)   (((ClRef)(Cl))[-1].prev)
#define ClRefWord(Cl, pos)   (((CPtr)(Cl))[(pos)])
#define SetClRefPrev(Cl, Prv)   (((ClRef)(Cl))[-1].prev = (ClRef)(Prv))
#define UNINDEXED_CL   0
#define SOB_RECORD   1
#define TRIE_CL   2
#define INDEXED_CL   3
#define MakeClRef(ptr, Type, NCells)
#define ClRefTryInstr(Cl)   (ClRefWord((Cl),0))
#define ClRefTryOpCode(Cl)   (cell_opcode(&ClRefTryInstr(Cl)))
#define ClRefNext(Cl)   ((ClRef)ClRefWord((Cl),1))
#define SetClRefNext(Cl, Nxt)   (ClRefWord((Cl),1)=(Cell)(Nxt))
#define ClRefEntryPoint(Cl)   (&ClRefWord((Cl),2))
#define ClRefCompiledCode(Cl)   (ClRefWord((Cl),3))
#define ClRefSOBInstr(Cl)   (ClRefWord((Cl),2))
#define ClRefHashSize(Cl)   (ClRefWord((Cl),4))
#define ClRefJumpInstr(Cl)   (ClRefWord((Cl),5))
#define ClRefFirstIndex(Cl)   (ClRefWord((Cl),6))
#define ClRefLastIndex(Cl)   (ClRefWord((Cl),7))
#define ClRefNumNonemptyBuckets(Cl)   (ClRefWord((Cl),8))
#define ClRefHashTable(Cl)   (&ClRefWord((Cl),9))
#define ClRefHashBucket(Cl, b)   ((CPtr)(ClRefHashTable(Cl)[(b)]))
#define ClRefSOBArg(Cl, n)   (cell_operandn(&ClRefWord((Cl),2),(n)))
#define ClRefPrRef(Cl)   ((PrRef)&ClRefWord((Cl),5))
#define PrRefClRef(Pr)   ((ClRef)((CPtr)(Pr)-5))
#define ClRefUpSOB(Cl)   (PrRefClRef(ClRefNext(Cl)))
#define ClRefNumInds(Cl)   ( (cell_operand3(&ClRefWord((Cl),2))/(sizeof(Cell)/2) + 1)/4 )
#define ClRefIndPtr(Cl, Ind)   (&ClRefWord((Cl),(Ind)*4))
#define IndPtrClRef(IP, Ind)   ((ClRef)((CPtr)(IP)-(Ind)*4))
#define IndRefNoop(IndPtr)   ((IndPtr)[-2])
#define IndRefPrev(IndPtr)   (((CPtr *)(IndPtr))[-1])
#define IndRefTryInstr(IndPtr)   ((IndPtr)[0])
#define IndRefNext(IndPtr)   (((CPtr *)(IndPtr))[1])
#define IC_CELLS(NI)   (4*(NI)+2)
#define ClRefIEntryPoint(Cl, NI)   (&ClRefWord((Cl),IC_CELLS(NI)))
#define ClRefEntryAny(Cl)
#define ClRefNotRetracted(Cl)
#define NUMHASHSIZES   16
#define CheckSOBClause(H, Ind, sob, Level)
#define NextSOB(sob, curLevel, IndLevel, Ind, Head)
#define FirstClauseSOB(sob, curLevel, IndLevel, Head, Ind)
#define delete_from_chain(c, PC, Displ)
#define is_dynamic_clause_inst(inst)   ((int) inst == dynretrymeelse || (int) inst == dyntrustmeelsefail)
#define mark_clref(pClRef)   (ClRef_Buflen(pClRef -1) = ClRef_Buflen(pClRef - 1) | HIGHBIT)
#define unmark_clref(pClRef)   (ClRef_Buflen(pClRef -1) = ClRef_Buflen(pClRef - 1 ) & (~HIGHBIT))
#define clref_is_marked(pClRef)   (ClRef_Buflen(pClRef -1 ) & HIGHBIT)
#define Free_DelCF(pDCF, pPRREF, chain_begin)
#define check_insert_private_delcf_pred(prref, psc)   check_insert_global_delcf_pred(prref,psc)
#define check_insert_private_delcf_clause(prref, psc, clref)   check_insert_global_delcf_clause(prref,psc,clref)
#define FIXED_BLOCK_SIZE_FOR_TABLED_PRED   (8 * sizeof(Cell))
#define clref_fld(x)   ((CPtr) *(x +1))
#define next_clref(x)   ((CPtr) *(x +1))
#define last_clref(PRREF)   ((CPtr)((PrRef)(PRREF))->LastClRef)
#define try_type_instr_fld(x)   (ClRefTryOpCode(x))
#define code_to_run(x)   (cell_opcode(ClRefEntryPoint(x)))
#define first_instr_to_run(x)   (cell_opcode(ClRefWord(x,3)))
#define MAXDYNFREEBUFF   200

Typedefs

typedef RegStat_tRegStat
typedef ClRefHdrIClRefI
typedef ClRef SOBRef

Functions

Cell val_to_hash (Cell)
void add_prog_seg (Psc, byte *, long)
void remove_prog_seg (byte *)
PrRef clref_to_prref (ClRef clref)
PrRef dynpredep_to_prref (CTXTdeclc void *pred_ep)
static void dbgen_printinst3 (Opcode, Arg1, Arg2, Arg3)
static void dbgen_printinst (Opcode, Arg1, Arg2)
static void assertcmp_throw (CTXTdeclc int num)
static int arity (CTXTdeclc prolog_term T0)
static void assertcmp_printerror (CTXTdeclc int num)
static Integer p2c_float_as_int (prolog_term T0)
static int is_frozen_var (prolog_term T0)
static void flatten_stack_init (struct flatten_q *flatten_stackq)
static int flatten_stack_size (struct flatten_q *flatten_stackq)
static void flatten_stack_push (struct flatten_q *flatten_stackq, int argno, Cell term)
static void flatten_stack_pop (struct flatten_q *flatten_stackq, int *argnop, Cell *termp)
static void inst_queue_init (struct instruction_q *inst_queue)
static int inst_queue_empty (struct instruction_q *inst_queue)
static void inst_queue_push (struct instruction_q *inst_queue, Cell opcode, Cell arg1, Cell arg2)
static void inst_queue_pop (struct instruction_q *inst_queue, Cell *opcodep, Cell *arg1p, Cell *arg2p)
static void inst_queue_rem (struct instruction_q *inst_queue, Cell *opcodep, Cell *arg1p, Cell *arg2p)
static void inst_queue_add (struct instruction_q *inst_queue, Cell opcodep, Cell arg1p, Cell arg2p)
static void inst_queue_rotate (struct instruction_q *inst_queue)
static void reg_init (RegStat Reg, int Size)
static int reg_get (CTXTdeclc RegStat Reg, int Type)
static void reg_release (RegStat Reg, int R0)
static char * buff_realloc (CTXTdecl)
static void db_genmvs (CTXTdeclc struct instruction_q *, RegStat)
static void db_putterm (CTXTdeclc int, prolog_term, RegStat, struct flatten_q *)
static void db_gentopinst (CTXTdeclc prolog_term, int, RegStat)
static void db_genterms (CTXTdeclc struct instruction_q *, RegStat)
static void db_geninst (CTXTdeclc prolog_term, RegStat, struct instruction_q *)
static void db_bldsubs (CTXTdeclc prolog_term, RegStat, struct flatten_q *)
static void db_genaput (CTXTdeclc prolog_term, int, struct instruction_q *, RegStat)
int assert_code_to_buff_p (CTXTdeclc prolog_term)
int assert_code_to_buff (CTXTdecl)
static xsbBool target_is_not_source (struct instruction_q *inst_queue, int Reg)
static xsbBool source_is_not_target (struct instruction_q *inst_queue, int Reg)
static void db_addbuff (byte, ClRef, PrRef, int, int, int)
static void db_addbuff_i (byte, ClRef, PrRef, int, int *, int, prolog_term, int)
static void get_indexes (prolog_term prolog_ind, int *Index, int *NI)
xsbBool assert_buff_to_clref_p (CTXTdeclc prolog_term, byte, PrRef, int, prolog_term, int, ClRef *)
xsbBool assert_buff_to_clref (CTXTdecl)
static void prefix_to_chain (int ifSOB, byte Arity, ClRef FirstClause, ClRef NewClause)
static void append_to_chain (byte Arity, ClRef LastClause, ClRef NewClause)
static int hash_resize (PrRef Pred, SOBRef SOBrec, unsigned int OldTabSize)
static int hash_val (int Ind, prolog_term Head, int TabSize)
static SOBRef new_SOBblock (int ThisTabSize, int Ind, Psc psc)
static void addto_hashchain (int AZ, int Hashval, SOBRef SOBrec, CPtr NewInd, int Arity)
static void addto_allchain (int AZ, ClRef Clause, SOBRef SOBrec, byte Arity)
static void find_usable_index (prolog_term Head, ClRef *s, int *ILevel, int *Index)
ClRef first_clref (PrRef Pred, prolog_term Head, int *ILevel, int *Index)
ClRef next_clref (PrRef Pred, ClRef Clause, prolog_term Head, int *IndexLevel, int *Ind)
static void delete_from_hashchain (ClRef Clause, int Ind, int NI)
static void delete_from_allchain (ClRef Clause)
static void delete_from_sobchain (ClRef Clause)
ClRef clref_from_try_addr (ClRef code_addr)
int mark_cpstack_retract (CTXTdeclc ClRef clref)
void unmark_cpstack_retract (CTXTdecl)
int mark_cpstack_retractall (CTXTdecl)
static int dyntabled_incomplete (CTXTdeclc Psc psc)
int check_cpstack_retractall (CTXTdeclc PrRef prref)
DelCFptr new_DelCF_pred (CTXTdeclc PrRef pPrRef, Psc pPSC, DelCFptr *chain_begin)
DelCFptr new_DelCF_clause (PrRef pPrRef, Psc pPSC, ClRef pClRef, DelCFptr *chain_begin)
void check_insert_global_delcf_pred (CTXTdeclc PrRef prref, Psc psc)
void check_insert_global_delcf_clause (CTXTdeclc PrRef prref, Psc psc, ClRef clref)
void mark_delcf_subchain (CTXTdeclc DelCFptr delcf, ClRef clref)
int mark_dynamic (CTXTdecl)
void gc_retractall (CTXTdeclc ClRef)
int determine_if_safe_to_delete (ClRef)
static int really_delete_clause (ClRef)
int sweep_dynamic (CTXTdeclc DelCFptr *chain_begin)
int gc_dynamic (CTXTdecl)
static void mark_for_deletion (CTXTdeclc ClRef Clause)
static void retract_clause (CTXTdeclc ClRef Clause, Psc psc)
ClRef previous_clref (ClRef Clause)
CPtr get_ClRefEntryPoint (ClRef Clause)
ClRef db_get_clause_code_space (PrRef Pred, ClRef Clause, CPtr *CodeBegAddr, CPtr *CodeEndAddr)
xsbBool db_get_last_clause (CTXTdecl)
xsbBool db_get_clause (CTXTdecl)
xsbBool db_reclaim0 (CTXTdecl)
xsbBool db_retract0 (CTXTdecl)
static void allocate_prref_tab (CTXTdeclc Psc psc, PrRef *prref, pb *new_ep)
PrRef build_prref (CTXTdeclc Psc psc)
xsbBool db_build_prref (CTXTdecl)
PrRef get_prref (CTXTdeclc Psc psc)
xsbBool db_get_prref (CTXTdecl)
void free_prref (CTXTdeclc CPtr *p, Psc psc)
PrRef sob_to_prref (ClRef clref)
static int clref_trie_asserted (CPtr Clref)
static void abolish_trie_asserted_stuff (CTXTdeclc PrRef prref)
static int another_buff (Cell Instr)
void retractall_prref (CTXTdeclc PrRef prref)
int gen_retract_all (CTXTdecl)
void db_remove_prref_1 (CTXTdeclc Psc psc)
xsbBool db_abolish0 (CTXTdecl)
static void retractall_clause (CTXTdeclc ClRef Clause, Psc psc, int flag)
void db_retractall0 (CTXTdecl)
void init_dbclause_cgc_blocks (void)
void init_standard_cgc_blocks (void)
xsbBool dynamic_code_function (CTXTdecl)
static CPtr trie_asserted_clref (CPtr prref)
static void print_bytes (CPtr x, int lo, int hi)
BTNptr trie_asserted_trienode (CPtr clref)
int trie_assert (CTXTdecl)
int trie_retract (CTXTdecl)
int trie_retract_safe (CTXTdecl)

Variables

int xsb_profiling_enabled
CPtr dbclause_cgc_block_gl = NULL
CPtr standard_cgc_block_begin_gl = NULL
CPtr standard_cgc_block_end_gl = NULL
DispBlkHdr_t DispBlkHdr
static jmp_buf assertcmp_env
asrtBuff_t asrtBuffB = {NULL,512,NULL,0,0}
asrtBuff_tasrtBuff = &asrtBuffB
static int hashsizes_table [NUMHASHSIZES]
DelCFptr delcf_chain_begin = (DelCFptr) NULL

Define Documentation

#define check_insert_private_delcf_clause prref,
psc,
clref   )     check_insert_global_delcf_clause(prref,psc,clref)
 

#define check_insert_private_delcf_pred prref,
psc   )     check_insert_global_delcf_pred(prref,psc)
 

#define CheckSOBClause H,
Ind,
sob,
Level   ) 
 

Value:

{    int h, t ;                                                 \
     ClRef cl ;                                                 \
     t = ClRefHashSize(sob);                                    \
     h = hash_val( (Ind), (H), t ) ;                            \
     cl = (ClRef) ClRefHashTable(sob)[h] ;                      \
     if ((pb)cl != (pb)&dynfail_inst)                           \
        return IndPtrClRef(cl,Level) ;                          \
}

#define clref_fld  )     ((CPtr) *(x +1))
 

#define clref_is_marked pClRef   )     (ClRef_Buflen(pClRef -1 ) & HIGHBIT)
 

#define ClRefAddr Cl   )     ((CPtr)((ClRef)(Cl)-1))
 

#define ClRefCompiledCode Cl   )     (ClRefWord((Cl),3))
 

#define ClRefEntryAny Cl   ) 
 

Value:

((CPtr)                                                         \
                ((ClRefType(Cl)&1) == UNINDEXED_CL ? ClRefEntryPoint(Cl) :\
                                ClRefIEntryPoint((Cl),ClRefNumInds(Cl)) \
        ))

#define ClRefEntryPoint Cl   )     (&ClRefWord((Cl),2))
 

#define ClRefFirstIndex Cl   )     (ClRefWord((Cl),6))
 

#define ClRefHashBucket Cl,
b   )     ((CPtr)(ClRefHashTable(Cl)[(b)]))
 

#define ClRefHashSize Cl   )     (ClRefWord((Cl),4))
 

#define ClRefHashTable Cl   )     (&ClRefWord((Cl),9))
 

#define ClRefIEntryPoint Cl,
NI   )     (&ClRefWord((Cl),IC_CELLS(NI)))
 

#define ClRefIndPtr Cl,
Ind   )     (&ClRefWord((Cl),(Ind)*4))
 

#define ClRefJumpInstr Cl   )     (ClRefWord((Cl),5))
 

#define ClRefLastIndex Cl   )     (ClRefWord((Cl),7))
 

#define ClRefNext Cl   )     ((ClRef)ClRefWord((Cl),1))
 

#define ClRefNotRetracted Cl   ) 
 

Value:

#define ClRefNumInds Cl   )     ( (cell_operand3(&ClRefWord((Cl),2))/(sizeof(Cell)/2) + 1)/4 )
 

#define ClRefNumNonemptyBuckets Cl   )     (ClRefWord((Cl),8))
 

#define ClRefPrev Cl   )     (((ClRef)(Cl))[-1].prev)
 

#define ClRefPrRef Cl   )     ((PrRef)&ClRefWord((Cl),5))
 

#define ClRefSize Cl   )     (((ClRef)(Cl))[-1].buflen & ~0x3 & ~HIGHBIT)
 

#define ClRefSOBArg Cl,
 )     (cell_operandn(&ClRefWord((Cl),2),(n)))
 

#define ClRefSOBInstr Cl   )     (ClRefWord((Cl),2))
 

#define ClRefTryInstr Cl   )     (ClRefWord((Cl),0))
 

#define ClRefTryOpCode Cl   )     (cell_opcode(&ClRefTryInstr(Cl)))
 

#define ClRefType Cl   )     (((ClRef)(Cl))[-1].buflen & 0x3)
 

#define ClRefUpSOB Cl   )     (PrRefClRef(ClRefNext(Cl)))
 

#define ClRefWord Cl,
pos   )     (((CPtr)(Cl))[(pos)])
 

#define code_to_run  )     (cell_opcode(ClRefEntryPoint(x)))
 

#define dbgen_inst3_sob Opcode,
Arg1,
Arg2,
Arg3,
Buff,
Loc   ) 
 

Value:

{       \
  dbgen_printinst3_macro(Opcode, Arg1, Arg2, Arg3);             \
  write_byte(Buff,Loc,Opcode); write_byte(Buff,Loc,Arg1>>16);   \
  write_byte(Buff,Loc,Arg1>>8); write_byte(Buff,Loc,Arg1);      \
  pad64bits(Loc);                                               \
  write_word(Buff,Loc,Arg2); write_word(Buff,Loc,Arg3);         \
}

#define dbgen_inst3_tv Opcode,
Arg1,
Arg2,
Arg3,
Buff,
Loc   ) 
 

Value:

{       \
  dbgen_printinst3_macro(Opcode, Arg1, Arg2, Arg3);             \
  write_byte(Buff,Loc,Opcode); write_byte(Buff,Loc,Arg1);       \
  write_byte(Buff,Loc,Arg2); write_byte(Buff,Loc,Arg3);         \
  pad64bits(Loc);                                               \
}

#define dbgen_inst_ppp Opcode,
Buff,
Loc   ) 
 

Value:

{               \
  dbgen_printinst_macro(Opcode, 0, 0);                  \
  write_byte(Buff,Loc,Opcode); write_byte(Buff,Loc,0);  \
  write_byte(Buff,Loc,0); write_byte(Buff,Loc,0);       \
  pad64bits(Loc);                                       \
}

#define dbgen_inst_pppw Opcode,
Arg1,
Buff,
Loc   ) 
 

Value:

{               \
    dbgen_printinst_macro(Opcode, (Integer)Arg1, 0);    \
    write_byte(Buff,Loc,Opcode); write_byte(Buff,Loc,0);        \
    write_byte(Buff,Loc,0); write_byte(Buff,Loc,0);             \
    pad64bits(Loc);                                             \
    write_word(Buff,Loc,Arg1);                                  \
}

#define dbgen_inst_ppv Opcode,
Arg1,
Buff,
Loc   ) 
 

Value:

{               \
  dbgen_printinst_macro(Opcode, Arg1, 0);               \
  write_byte(Buff,Loc,Opcode); write_byte(Buff,Loc,0);  \
  write_byte(Buff,Loc,0); write_byte(Buff,Loc,Arg1);    \
  pad64bits(Loc);                                       \
}

#define dbgen_inst_ppvw Opcode,
Arg1,
Arg2,
Buff,
Loc   ) 
 

Value:

{       \
    dbgen_printinst_macro(Opcode, Arg1, (Integer)Arg2); \
    write_byte(Buff,Loc,Opcode); write_byte(Buff,Loc,0);        \
    write_byte(Buff,Loc,0); write_byte(Buff,Loc,Arg1);          \
    pad64bits(Loc);                                             \
    write_word(Buff,Loc,Arg2);                                  \
}

#define dbgen_inst_ppvw_safe Opcode,
Arg1,
Arg2,
Buff,
Loc   ) 
 

Value:

{       \
    int tLoc = 0, tempLoc = *Loc; char tBuff[4];                \
    dbgen_printinst_macro(Opcode, Arg1, (Integer)Arg2);         \
    *Loc += 4;                                                  \
    pad64bits(Loc);                                             \
    write_word(Buff,Loc,Arg2);                                  \
    write_byte(tBuff,&tLoc,Opcode); write_byte(tBuff,&tLoc,0);  \
    write_byte(tBuff,&tLoc,0); write_byte(tBuff,&tLoc,Arg1);    \
    memmove(Buff+tempLoc,tBuff,4);                              \
}

#define dbgen_inst_ppvww Opcode,
Arg1,
Arg2,
Arg3,
Buff,
Loc   ) 
 

Value:

{       \
    dbgen_printinst_macro(Opcode, Arg1, (Integer)Arg2);         \
    write_byte(Buff,Loc,Opcode); write_byte(Buff,Loc,0);        \
    write_byte(Buff,Loc,0); write_byte(Buff,Loc,Arg1);          \
    pad64bits(Loc);                                             \
    write_word(Buff,Loc,Arg2);                                  \
    write_word(Buff,Loc,Arg3);                                  \
}

#define dbgen_inst_pvv Opcode,
Arg1,
Arg2,
Buff,
Loc   ) 
 

Value:

{       \
    dbgen_printinst_macro(Opcode, Arg1, (Integer)Arg2); \
  write_byte(Buff,Loc,Opcode); write_byte(Buff,Loc,0);  \
  write_byte(Buff,Loc,Arg1); write_byte(Buff,Loc,Arg2); \
  pad64bits(Loc);                                       \
}

#define dbgen_instB3_sob Opcode,
Arg1,
Arg2,
Arg3   ) 
 

Value:

#define dbgen_instB3_tv Opcode,
Arg1,
Arg2,
Arg3   ) 
 

Value:

#define dbgen_instB_ppp Opcode   ) 
 

Value:

#define dbgen_instB_pppw Opcode,
Arg1   ) 
 

Value:

#define dbgen_instB_ppv Opcode,
Arg1   ) 
 

Value:

#define dbgen_instB_ppvw Opcode,
Arg1,
Arg2   ) 
 

Value:

#define dbgen_instB_pvv Opcode,
Arg1,
Arg2   ) 
 

Value:

#define dbgen_printinst3_macro Opcode,
Arg1,
Arg2,
Arg3   )     dbgen_printinst3(Opcode, Arg1, Arg2, Arg3)
 

#define dbgen_printinst_macro Opcode,
Arg1,
Arg2   )     dbgen_printinst(Opcode, Arg1, Arg2)
 

#define delete_from_chain c,
PC,
Displ   ) 
 

#define ERR_FUNCTOR   1
 

#define ERR_REGISTER   2
 

#define first_instr_to_run  )     (cell_opcode(ClRefWord(x,3)))
 

#define FirstClauseSOB sob,
curLevel,
IndLevel,
Head,
Ind   ) 
 

Value:

{   for(;;)                                                     \
        if( curLevel < *IndLevel ) /* sob node */               \
        {   sob = ClRefPrRef(sob)->FirstClRef; /* go down */    \
            curLevel++ ;                                        \
        }                                                       \
        else /* curLevel == *IndLevel -> sob leaf */            \
        {   CheckSOBClause(Head,*Ind,sob,curLevel) ;            \
            NextSOB(sob,curLevel,IndLevel,Ind,Head) ;           \
        }                                                       \
}

#define FIXED_BLOCK_SIZE_FOR_TABLED_PRED   (8 * sizeof(Cell))
 

#define FLATTEN_STACK_SIZE   512
 

#define Free_DelCF pDCF,
pPRREF,
chain_begin   ) 
 

Value:

{                               \
  if (DCF_PrevDCF(pDCF) == 0) {                                         \
    chain_begin = DCF_NextDCF(pDCF);                                    \
  }                                                                     \
  else {                                                                \
    DCF_NextDCF(DCF_PrevDCF(pDCF)) = DCF_NextDCF(pDCF);                 \
  }                                                                     \
  if (DCF_NextDCF(pDCF) != 0) {                                         \
    DCF_PrevDCF(DCF_NextDCF(pDCF)) = DCF_PrevDCF(pDCF);                 \
  }                                                                     \
  if (DCF_PrevPredDCF(pDCF) == 0 && pPRREF) {                           \
    PrRef_DelCF(pPRREF) = DCF_NextPredDCF(pDCF);                        \
  }                                                                     \
  else {                                                                \
    DCF_NextPredDCF(DCF_PrevPredDCF(pDCF)) = DCF_NextPredDCF(pDCF);     \
  }                                                                     \
  if (DCF_NextPredDCF(pDCF) != 0) {                                     \
    DCF_PrevPredDCF(DCF_NextPredDCF(pDCF)) = DCF_PrevPredDCF(pDCF);     \
  }                                                                     \
  mem_dealloc(pDCF,sizeof(DeletedTableFrame),ASSERT_SPACE);             \
}

#define HIGHBIT   0x80000000
 

#define IC_CELLS NI   )     (4*(NI)+2)
 

#define INDEXED_CL   3
 

#define IndPtrClRef IP,
Ind   )     ((ClRef)((CPtr)(IP)-(Ind)*4))
 

#define IndRefNext IndPtr   )     (((CPtr *)(IndPtr))[1])
 

#define IndRefNoop IndPtr   )     ((IndPtr)[-2])
 

#define IndRefPrev IndPtr   )     (((CPtr *)(IndPtr))[-1])
 

#define IndRefTryInstr IndPtr   )     ((IndPtr)[0])
 

#define INST_QUEUE_SIZE   512
 

#define is_dynamic_clause_inst inst   )     ((int) inst == dynretrymeelse || (int) inst == dyntrustmeelsefail)
 

#define last_clref PRREF   )     ((CPtr)((PrRef)(PRREF))->LastClRef)
 

#define MakeClRef ptr,
Type,
NCells   ) 
 

Value:

{       long sz = (((NCells)*sizeof(Cell)+sizeof(ClRefHdr) + 7) & ~0x7);        \
        (ptr) = (ClRef)mem_calloc(sz,1,ASSERT_SPACE);\
        (ptr)->buflen = ((Type)&3)+sz;\
        (ptr)++;\
}

#define mark_clref pClRef   )     (ClRef_Buflen(pClRef -1) = ClRef_Buflen(pClRef - 1) | HIGHBIT)
 

#define MARKED_FOR_DELETION   66
 

#define MAXDYNFREEBUFF   200
 

#define next_clref  )     ((CPtr) *(x +1))
 

#define NextSOB sob,
curLevel,
IndLevel,
Ind,
Head   ) 
 

Value:

{   while( ClRefTryOpCode(sob) == dyntrustmeelsefail            \
        || ClRefTryOpCode(sob) == noop ) /* end of sob chain */ \
        if( curLevel-- == 1 ) /* root of sob tree */            \
                return 0 ;                                      \
        else sob = ClRefUpSOB(sob) ; /* go up */                \
    sob = ClRefNext(sob) ; /* follow sob chain */               \
    if (curLevel == 1) { /* may have changed indexes?!? */      \
        find_usable_index(Head,&sob,IndLevel,Ind);              \
        curLevel = *IndLevel;                                   \
        }                                                       \
    if( ClRefType(sob) != SOB_RECORD ) return sob;              \
}

#define NUMHASHSIZES   16
 

#define pad64bits Loc   )     {}
 

#define PredOpCode  )     (cell_opcode(&(P)->Instr))
 

#define PrRefClRef Pr   )     ((ClRef)((CPtr)(Pr)-5))
 

#define RVAR   -1
 

#define SetClRefNext Cl,
Nxt   )     (ClRefWord((Cl),1)=(Cell)(Nxt))
 

#define SetClRefPrev Cl,
Prv   )     (((ClRef)(Cl))[-1].prev = (ClRef)(Prv))
 

#define SetClRefSize Cl,
len   ) 
 

Value:

(((ClRef)(Cl))[-1].buflen |= \
                (((ClRef)(Cl))[-1].buflen & 0x3) | ((len) & ~0x3))

#define SetClRefType Cl,
type   ) 
 

Value:

(((ClRef)(Cl))[-1].buflen = \
                (((ClRef)(Cl))[-1].buflen & ~0x3) | ((type) & 0x3))

#define SOB_RECORD   1
 

#define TRIE_CL   2
 

#define try_type_instr_fld  )     (ClRefTryOpCode(x))
 

#define TVAR   -2
 

#define UNINDEXED_CL   0
 

#define unmark_clref pClRef   )     (ClRef_Buflen(pClRef -1) = ClRef_Buflen(pClRef - 1 ) & (~HIGHBIT))
 

#define write_byte Buff,
Loc,
 )     { *(pb)((pb)Buff + *(Loc)) = (byte)(w); *(Loc) += 1; }
 

#define write_word Buff,
Loc,
 ) 
 

Value:

{ *(CPtr)((pb)Buff + *(Loc)) = (Cell)(w); *(Loc) += 4; \
                                pad64bits(Loc); }


Typedef Documentation

typedef struct ClRefHdrI* ClRefI
 

typedef struct RegStat_t* RegStat
 

typedef ClRef SOBRef
 


Function Documentation

static void abolish_trie_asserted_stuff CTXTdeclc PrRef  prref  )  [static]
 

void add_prog_seg Psc  ,
byte ,
long 
 

static void addto_allchain int  AZ,
ClRef  Clause,
SOBRef  SOBrec,
byte  Arity
[static]
 

static void addto_hashchain int  AZ,
int  Hashval,
SOBRef  SOBrec,
CPtr  NewInd,
int  Arity
[static]
 

static void allocate_prref_tab CTXTdeclc Psc  psc,
PrRef prref,
pb new_ep
[inline, static]
 

static int another_buff Cell  Instr  )  [static]
 

static void append_to_chain byte  Arity,
ClRef  LastClause,
ClRef  NewClause
[static]
 

static int arity CTXTdeclc prolog_term  T0  )  [static]
 

xsbBool assert_buff_to_clref CTXTdecl   ) 
 

xsbBool assert_buff_to_clref_p CTXTdeclc  prolog_term,
byte  ,
PrRef  ,
int  ,
prolog_term  ,
int  ,
ClRef
 

int assert_code_to_buff CTXTdecl   ) 
 

int assert_code_to_buff_p CTXTdeclc  prolog_term  ) 
 

static void assertcmp_printerror CTXTdeclc int  num  )  [static]
 

static void assertcmp_throw CTXTdeclc int  num  )  [static]
 

static char* buff_realloc CTXTdecl   )  [static]
 

PrRef build_prref CTXTdeclc Psc  psc  ) 
 

int check_cpstack_retractall CTXTdeclc PrRef  prref  ) 
 

void check_insert_global_delcf_clause CTXTdeclc PrRef  prref,
Psc  psc,
ClRef  clref
 

void check_insert_global_delcf_pred CTXTdeclc PrRef  prref,
Psc  psc
 

ClRef clref_from_try_addr ClRef  code_addr  ) 
 

PrRef clref_to_prref ClRef  clref  ) 
 

static int clref_trie_asserted CPtr  Clref  )  [inline, static]
 

xsbBool db_abolish0 CTXTdecl   ) 
 

static void db_addbuff byte  ,
ClRef  ,
PrRef  ,
int  ,
int  ,
int 
[static]
 

static void db_addbuff_i byte  ,
ClRef  ,
PrRef  ,
int  ,
int ,
int  ,
prolog_term  ,
int 
[static]
 

static void db_bldsubs CTXTdeclc  prolog_term,
RegStat  ,
struct flatten_q
[static]
 

xsbBool db_build_prref CTXTdecl   ) 
 

static void db_genaput CTXTdeclc  prolog_term,
int  ,
struct instruction_q ,
RegStat 
[static]
 

static void db_geninst CTXTdeclc  prolog_term,
RegStat  ,
struct instruction_q
[static]
 

static void db_genmvs CTXTdeclc struct instruction_q ,
RegStat 
[static]
 

static void db_genterms CTXTdeclc struct instruction_q ,
RegStat 
[static]
 

static void db_gentopinst CTXTdeclc  prolog_term,
int  ,
RegStat 
[static]
 

xsbBool db_get_clause CTXTdecl   ) 
 

ClRef db_get_clause_code_space PrRef  Pred,
ClRef  Clause,
CPtr CodeBegAddr,
CPtr CodeEndAddr
 

xsbBool db_get_last_clause CTXTdecl   ) 
 

xsbBool db_get_prref CTXTdecl   ) 
 

static void db_putterm CTXTdeclc  int,
prolog_term  ,
RegStat  ,
struct flatten_q
[static]
 

xsbBool db_reclaim0 CTXTdecl   ) 
 

void db_remove_prref_1 CTXTdeclc Psc  psc  ) 
 

xsbBool db_retract0 CTXTdecl   ) 
 

void db_retractall0 CTXTdecl   ) 
 

static void dbgen_printinst Opcode  ,
Arg1  ,
Arg2 
[inline, static]
 

static void dbgen_printinst3 Opcode  ,
Arg1  ,
Arg2  ,
Arg3 
[inline, static]
 

static void delete_from_allchain ClRef  Clause  )  [static]
 

static void delete_from_hashchain ClRef  Clause,
int  Ind,
int  NI
[static]
 

else if( cell_opcode(PI) == noop) IndRefPrev(PI) = (Cell) &dynfail_inst ;

|| cell_opcode(PI) == trymeelse

static void delete_from_sobchain ClRef  Clause  )  [static]
 

int determine_if_safe_to_delete ClRef   ) 
 

xsbBool dynamic_code_function CTXTdecl   ) 
 

PrRef dynpredep_to_prref CTXTdeclc void *  pred_ep  ) 
 

static int dyntabled_incomplete CTXTdeclc Psc  psc  )  [inline, static]
 

static void find_usable_index prolog_term  Head,
ClRef s,
int ILevel,
int Index
[static]
 

The following macros traverse the SOB chains/trees and pick the first (next) clause since a given sob

ClRef first_clref PrRef  Pred,
prolog_term  Head,
int ILevel,
int Index
 

static void flatten_stack_init struct flatten_q flatten_stackq  )  [static]
 

static void flatten_stack_pop struct flatten_q flatten_stackq,
int argnop,
Cell termp
[static]
 

static void flatten_stack_push struct flatten_q flatten_stackq,
int  argno,
Cell  term
[static]
 

static int flatten_stack_size struct flatten_q flatten_stackq  )  [static]
 

void free_prref CTXTdeclc CPtr p,
Psc  psc
 

int gc_dynamic CTXTdecl   ) 
 

void gc_retractall CTXTdeclc  ClRef  ) 
 

int gen_retract_all CTXTdecl   ) 
 

CPtr get_ClRefEntryPoint ClRef  Clause  ) 
 

static void get_indexes prolog_term  prolog_ind,
int Index,
int NI
[static]
 

PrRef get_prref CTXTdeclc Psc  psc  ) 
 

static int hash_resize PrRef  Pred,
SOBRef  SOBrec,
unsigned int  OldTabSize
[static]
 

static int hash_val int  Ind,
prolog_term  Head,
int  TabSize
[static]
 

void init_dbclause_cgc_blocks void   ) 
 

void init_standard_cgc_blocks void   ) 
 

static void inst_queue_add struct instruction_q inst_queue,
Cell  opcodep,
Cell  arg1p,
Cell  arg2p
[static]
 

static int inst_queue_empty struct instruction_q inst_queue  )  [static]
 

static void inst_queue_init struct instruction_q inst_queue  )  [static]
 

static void inst_queue_pop struct instruction_q inst_queue,
Cell opcodep,
Cell arg1p,
Cell arg2p
[static]
 

static void inst_queue_push struct instruction_q inst_queue,
Cell  opcode,
Cell  arg1,
Cell  arg2
[static]
 

static void inst_queue_rem struct instruction_q inst_queue,
Cell opcodep,
Cell arg1p,
Cell arg2p
[static]
 

static void inst_queue_rotate struct instruction_q inst_queue  )  [static]
 

static int is_frozen_var prolog_term  T0  )  [static]
 

int mark_cpstack_retract CTXTdeclc ClRef  clref  ) 
 

int mark_cpstack_retractall CTXTdecl   ) 
 

void mark_delcf_subchain CTXTdeclc DelCFptr  delcf,
ClRef  clref
 

int mark_dynamic CTXTdecl   ) 
 

static void mark_for_deletion CTXTdeclc ClRef  Clause  )  [static]
 

DelCFptr new_DelCF_clause PrRef  pPrRef,
Psc  pPSC,
ClRef  pClRef,
DelCFptr chain_begin
 

DelCFptr new_DelCF_pred CTXTdeclc PrRef  pPrRef,
Psc  pPSC,
DelCFptr chain_begin
 

static SOBRef new_SOBblock int  ThisTabSize,
int  Ind,
Psc  psc
[static]
 

ClRef next_clref PrRef  Pred,
ClRef  Clause,
prolog_term  Head,
int IndexLevel,
int Ind
 

static Integer p2c_float_as_int prolog_term  T0  )  [static]
 

static void prefix_to_chain int  ifSOB,
byte  Arity,
ClRef  FirstClause,
ClRef  NewClause
[static]
 

ClRef previous_clref ClRef  Clause  ) 
 

static void print_bytes CPtr  x,
int  lo,
int  hi
[inline, static]
 

static int really_delete_clause ClRef   )  [static]
 

static int reg_get CTXTdeclc RegStat  Reg,
int  Type
[static]
 

static void reg_init RegStat  Reg,
int  Size
[static]
 

static void reg_release RegStat  Reg,
int  R0
[static]
 

void remove_prog_seg byte  ) 
 

static void retract_clause CTXTdeclc ClRef  Clause,
Psc  psc
[static]
 

static void retractall_clause CTXTdeclc ClRef  Clause,
Psc  psc,
int  flag
[static]
 

void retractall_prref CTXTdeclc PrRef  prref  ) 
 

PrRef sob_to_prref ClRef  clref  ) 
 

static xsbBool source_is_not_target struct instruction_q inst_queue,
int  Reg
[static]
 

int sweep_dynamic CTXTdeclc DelCFptr chain_begin  ) 
 

static xsbBool target_is_not_source struct instruction_q inst_queue,
int  Reg
[static]
 

int trie_assert CTXTdecl   ) 
 

static CPtr trie_asserted_clref CPtr  prref  )  [inline, static]
 

BTNptr trie_asserted_trienode CPtr  clref  ) 
 

int trie_retract CTXTdecl   ) 
 

int trie_retract_safe CTXTdecl   ) 
 

void unmark_cpstack_retract CTXTdecl   ) 
 

Cell val_to_hash Cell   ) 
 


Variable Documentation

struct asrtBuff_t* asrtBuff = &asrtBuffB
 

struct asrtBuff_t asrtBuffB = {NULL,512,NULL,0,0}
 

jmp_buf assertcmp_env [static]
 

CPtr dbclause_cgc_block_gl = NULL
 

DelCFptr delcf_chain_begin = (DelCFptr) NULL
 

struct DispBlkHdr_t DispBlkHdr
 

int hashsizes_table[NUMHASHSIZES] [static]
 

Initial value:

 {17,503,5003,49999,200003,400009,700001,1000003,
        1000033,1000037,1000039,1000081,1000099,1000117,1000121,1000133}

CPtr standard_cgc_block_begin_gl = NULL
 

CPtr standard_cgc_block_end_gl = NULL
 

int xsb_profiling_enabled
 


Generated on Wed Jul 26 13:26:53 2006 for XSB by  doxygen 1.4.5