tr_utils.c File Reference

#include "xsb_config.h"
#include "xsb_debug.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "debugs/debug_tries.h"
#include "auxlry.h"
#include "cell_xsb.h"
#include "cinterf.h"
#include "binding.h"
#include "psc_xsb.h"
#include "heap_xsb.h"
#include "memory_xsb.h"
#include "register.h"
#include "deref.h"
#include "flags_xsb.h"
#include "trie_internals.h"
#include "tst_aux.h"
#include "cut_xsb.h"
#include "macro_xsb.h"
#include "sw_envs.h"
#include "choice.h"
#include "inst_xsb.h"
#include "error_xsb.h"
#include "io_builtins_xsb.h"
#include "trassert.h"
#include "tr_utils.h"
#include "tst_utils.h"
#include "subp.h"
#include "rw_lock.h"
#include "debug_xsb.h"
#include "thread_xsb.h"
#include "storage_xsb.h"
#include "hash_xsb.h"
#include "tables.h"
#include "ptoc_tag_xsb_i.h"
#include "term_psc_xsb_i.h"

Defines

#define MAX_VAR_SIZE   200
#define freeing_stack_increment   1000
#define push_node(node)
#define pop_node(node)
#define DELETE_TRIE_STACK_INIT   100
#define MAX_DELETE_TRIE_STACK_SIZE   1000
#define DT_NODE   0
#define DT_DS   1
#define DT_HT   2
#define push_delete_trie_node(node, op)
#define push_delete_trie_hh(hh)
#define ADJUST_SIZE   100
#define DELETED_SET   1
#define is_trie_instruction(cp_inst)
#define check_insert_private_deltf_pred(tif)   check_insert_global_deltf_pred(tif)
#define check_insert_private_deltf_subgoal(subgoal)   check_insert_global_deltf_subgoal(subgoal)

Functions

xsbBool has_unconditional_answers (VariantSF subg)
VariantSF get_variant_sf (CTXTdeclc Cell callTerm, TIFptr pTIF, Cell *retTerm)
SubProdSF get_subsumer_sf (CTXTdeclc Cell callTerm, TIFptr pTIF, Cell *retTerm)
BTNptr get_trie_root (BTNptr node)
Cell build_ret_term (CTXTdeclc int arity, Cell termVector[])
void construct_answer_template (CTXTdeclc Cell callTerm, SubProdSF producer, Cell templ[])
VariantSF get_call (CTXTdeclc Cell callTerm, Cell *retTerm)
static void free_trie_ht (CTXTdeclc BTHTptr ht)
void delete_variant_sf_and_answers (CTXTdeclc VariantSF pSF)
static void delete_variant_table (CTXTdeclc BTNptr x)
void delete_predicate_table (CTXTdeclc TIFptr tif)
void reclaim_deleted_subsumptive_table (CTXTdeclc DelTFptr)
void reclaim_deleted_predicate_table (CTXTdeclc DelTFptr deltf_ptr)
static int is_hash (BTNptr x)
static void set_parent_and_node_hook (BTNptr current, BTNptr *root_hook, BTNptr *parent, BTNptr **cur_hook)
static BTNptr get_prev_sibl (BTNptr node)
void delete_branch (CTXTdeclc BTNptr lowest_node_in_branch, BTNptr *hook)
void safe_delete_branch (BTNptr lowest_node_in_branch)
void undelete_branch (BTNptr lowest_node_in_branch)
void delete_trie (CTXTdeclc BTNptr iroot)
void delete_return (CTXTdeclc BTNptr l, VariantSF sg_frame)
void reclaim_del_ret_list (CTXTdeclc VariantSF sg_frame)
void breg_retskel (CTXTdecl)
void init_newtrie (CTXTdecl)
Integer newtrie (CTXTdecl)
void trie_intern (CTXTdecl)
int trie_interned (CTXTdecl)
void trie_dispose (CTXTdecl)
void delete_interned_trie (CTXTdeclc Integer tmpval)
static IGRptr newIGR (long root)
static IGLptr newIGL (BTNptr leafn)
static IGRptr getIGRnode (CTXTdeclc long rootn)
static IGRptr getAndRemoveIGRnode (CTXTdeclc long rootn)
static void insertLeaf (IGRptr r, BTNptr leafn)
void trie_dispose_nr (CTXTdecl)
void reclaim_uninterned_nr (CTXTdeclc long rootidx)
void trie_undispose (CTXTdeclc long rootIdx, BTNptr leafn)
xsbBool is_completed_table (TIFptr tif)
Psc get_psc_for_answer_trie_cp (CTXTdeclc BTNptr pLeaf)
VariantSF get_subgoal_frame_for_answer_trie_cp (CTXTdeclc BTNptr pLeaf)
TIFptr get_tif_for_answer_trie_cp (CTXTdeclc BTNptr pLeaf)
void check_insert_global_deltf_pred (CTXTdeclc TIFptr tif)
void check_insert_global_deltf_subgoal (CTXTdeclc VariantSF subgoal)
int fast_abolish_table_predicate (CTXTdeclc Psc psc)
void mark_cp_tables (CTXTdecl)
void unmark_cp_tables (CTXTdecl)
int abolish_table_call_cps_check (CTXTdeclc VariantSF subgoal)
int abolish_table_call (CTXTdeclc VariantSF subgoal)
int abolish_table_pred_cps_check (CTXTdeclc Psc psc)
int abolish_table_predicate (CTXTdeclc Psc psc)
void mark_tabled_preds (CTXTdecl)
void mark_private_tabled_preds (CTXTdecl)
int sweep_tabled_preds (CTXTdecl)
int gc_tabled_preds (CTXTdecl)
int abolish_usermod_tables (CTXTdecl)
int abolish_module_tables (CTXTdeclc const char *module_name)
void release_all_tabling_resources (CTXTdecl)
void abolish_all_tables_cps_check (CTXTdecl)
void abolish_table_info (CTXTdecl)

Variables

BTNptrSet_ArrayPtr
Integer first_free_set
int Set_ArraySz
int num_sets
static IGRptr IGRhead = NULL
DelTFptr deltf_chain_begin = (DelTFptr) NULL

Define Documentation

#define ADJUST_SIZE   100
 

#define check_insert_private_deltf_pred tif   )     check_insert_global_deltf_pred(tif)
 

#define check_insert_private_deltf_subgoal subgoal   )     check_insert_global_deltf_subgoal(subgoal)
 

#define DELETE_TRIE_STACK_INIT   100
 

#define DELETED_SET   1
 

#define DT_DS   1
 

#define DT_HT   2
 

#define DT_NODE   0
 

#define freeing_stack_increment   1000
 

#define is_trie_instruction cp_inst   ) 
 

Value:

((int) cp_inst >= 0x5c && (int) cp_inst < 0x80) \
           || ((int) cp_inst >= 0x90 && (int) cp_inst < 0x94)

#define MAX_DELETE_TRIE_STACK_SIZE   1000
 

#define MAX_VAR_SIZE   200
 

#define pop_node node   ) 
 

Value:

{\
  node_stk_top--;\
  node = freeing_stack[node_stk_top];\
}

#define push_delete_trie_hh hh   ) 
 

Value:

{\
  trie_op_top++;\
  if (trie_op_top >= trie_op_size) {\
    trie_op_size = 2*trie_op_size;\
    delete_trie_op = (char *)mem_realloc(delete_trie_op,(trie_op_size/2)*sizeof(char),trie_op_size*sizeof(char),TABLE_SPACE);\
    if (!delete_trie_op) xsb_exit("out of space for deleting trie");\
    /*xsb_dbgmsg((LOG_DEBUG,"realloc delete_trie_op to %d",trie_op_size));*/\
  }\
  delete_trie_op[trie_op_top] = DT_HT;\
  trie_hh_top++;\
  if (trie_hh_top >= trie_hh_size) {\
    trie_hh_size = 2*trie_hh_size;\
    delete_trie_hh = (BTHTptr *)mem_realloc(delete_trie_hh,(trie_hh_size/2)*sizeof(BTHTptr),trie_hh_size*sizeof(BTHTptr),TABLE_SPACE);\
    if (!delete_trie_hh) xsb_exit("out of space for deleting trie");\
    /*xsb_dbgmsg((LOG_DEBUG,"realloc delete_trie_hh to %d",trie_hh_size));*/\
  }\
  delete_trie_hh[trie_hh_top] = hh;\
}

#define push_delete_trie_node node,
op   ) 
 

Value:

{\
  trie_op_top++;\
  if (trie_op_top >= trie_op_size) {\
    trie_op_size = 2*trie_op_size;\
    delete_trie_op = (char *)mem_realloc(delete_trie_op,(trie_op_size/2)*sizeof(char),trie_op_size*sizeof(char),TABLE_SPACE);\
    if (!delete_trie_op) xsb_exit("out of space for deleting trie");\
    /*xsb_dbgmsg((LOG_DEBUG,"realloc delete_trie_op to %d",trie_op_size));*/\
  }\
  delete_trie_op[trie_op_top] = op;\
  trie_node_top++;\
  if (trie_node_top >= trie_node_size) {\
    trie_node_size = 2*trie_node_size;\
    delete_trie_node = (BTNptr *)mem_realloc(delete_trie_node,(trie_node_size/2)*sizeof(BTNptr),trie_node_size*sizeof(BTNptr),TABLE_SPACE);\
    if (!delete_trie_node) xsb_exit("out of space for deleting trie");\
    /*xsb_dbgmsg((LOG_DEBUG,"realloc delete_trie_node to %d",trie_node_size));*/\
  }\
  delete_trie_node[trie_node_top] = node;\
}

#define push_node node   ) 
 

Value:

{\
  if (node_stk_top >= freeing_stack_size) {\
    unsigned long old_freeing_stack_size = freeing_stack_size; \
    freeing_stack_size = freeing_stack_size + freeing_stack_increment;\
    freeing_stack = (BTNptr *)mem_realloc(freeing_stack,old_freeing_stack_size*sizeof(BTNptr),\
                                          freeing_stack_size*sizeof(BTNptr),TABLE_SPACE);\
  }\
  freeing_stack[node_stk_top] = node;\
  node_stk_top++;\
  }


Function Documentation

void abolish_all_tables_cps_check CTXTdecl   ) 
 

int abolish_module_tables CTXTdeclc const char *  module_name  ) 
 

int abolish_table_call CTXTdeclc VariantSF  subgoal  ) 
 

int abolish_table_call_cps_check CTXTdeclc VariantSF  subgoal  ) 
 

void abolish_table_info CTXTdecl   )  [inline]
 

int abolish_table_pred_cps_check CTXTdeclc Psc  psc  ) 
 

int abolish_table_predicate CTXTdeclc Psc  psc  )  [inline]
 

int abolish_usermod_tables CTXTdecl   ) 
 

void breg_retskel CTXTdecl   ) 
 

Cell build_ret_term CTXTdeclc int  arity,
Cell  termVector[]
 

void check_insert_global_deltf_pred CTXTdeclc TIFptr  tif  ) 
 

void check_insert_global_deltf_subgoal CTXTdeclc VariantSF  subgoal  ) 
 

void construct_answer_template CTXTdeclc Cell  callTerm,
SubProdSF  producer,
Cell  templ[]
 

void delete_branch CTXTdeclc BTNptr  lowest_node_in_branch,
BTNptr hook
 

void delete_interned_trie CTXTdeclc Integer  tmpval  ) 
 

void delete_predicate_table CTXTdeclc TIFptr  tif  ) 
 

void delete_return CTXTdeclc BTNptr  l,
VariantSF  sg_frame
 

void delete_trie CTXTdeclc BTNptr  iroot  ) 
 

void delete_variant_sf_and_answers CTXTdeclc VariantSF  pSF  ) 
 

static void delete_variant_table CTXTdeclc BTNptr  x  )  [static]
 

Remove the subgoal frame and its dependent structures

int fast_abolish_table_predicate CTXTdeclc Psc  psc  ) 
 

static void free_trie_ht CTXTdeclc BTHTptr  ht  )  [static]
 

int gc_tabled_preds CTXTdecl   ) 
 

VariantSF get_call CTXTdeclc Cell  callTerm,
Cell retTerm
 

static BTNptr get_prev_sibl BTNptr  node  )  [static]
 

Psc get_psc_for_answer_trie_cp CTXTdeclc BTNptr  pLeaf  ) 
 

VariantSF get_subgoal_frame_for_answer_trie_cp CTXTdeclc BTNptr  pLeaf  ) 
 

SubProdSF get_subsumer_sf CTXTdeclc Cell  callTerm,
TIFptr  pTIF,
Cell retTerm
 

TIFptr get_tif_for_answer_trie_cp CTXTdeclc BTNptr  pLeaf  ) 
 

BTNptr get_trie_root BTNptr  node  ) 
 

VariantSF get_variant_sf CTXTdeclc Cell  callTerm,
TIFptr  pTIF,
Cell retTerm
 

static IGRptr getAndRemoveIGRnode CTXTdeclc long  rootn  )  [static]
 

static IGRptr getIGRnode CTXTdeclc long  rootn  )  [static]
 

xsbBool has_unconditional_answers VariantSF  subg  ) 
 

void init_newtrie CTXTdecl   ) 
 

static void insertLeaf IGRptr  r,
BTNptr  leafn
[static]
 

xsbBool is_completed_table TIFptr  tif  ) 
 

static int is_hash BTNptr  x  )  [static]
 

void mark_cp_tables CTXTdecl   ) 
 

void mark_private_tabled_preds CTXTdecl   ) 
 

void mark_tabled_preds CTXTdecl   ) 
 

static IGLptr newIGL BTNptr  leafn  )  [static]
 

static IGRptr newIGR long  root  )  [static]
 

Integer newtrie CTXTdecl   ) 
 

void reclaim_del_ret_list CTXTdeclc VariantSF  sg_frame  ) 
 

void reclaim_deleted_predicate_table CTXTdeclc DelTFptr  deltf_ptr  ) 
 

void reclaim_deleted_subsumptive_table CTXTdeclc  DelTFptr  ) 
 

void reclaim_uninterned_nr CTXTdeclc long  rootidx  ) 
 

void release_all_tabling_resources CTXTdecl   ) 
 

void safe_delete_branch BTNptr  lowest_node_in_branch  ) 
 

static void set_parent_and_node_hook BTNptr  current,
BTNptr root_hook,
BTNptr parent,
BTNptr **  cur_hook
[static]
 

int sweep_tabled_preds CTXTdecl   ) 
 

void trie_dispose CTXTdecl   ) 
 

void trie_dispose_nr CTXTdecl   ) 
 

void trie_intern CTXTdecl   ) 
 

int trie_interned CTXTdecl   ) 
 

void trie_undispose CTXTdeclc long  rootIdx,
BTNptr  leafn
 

void undelete_branch BTNptr  lowest_node_in_branch  ) 
 

void unmark_cp_tables CTXTdecl   ) 
 


Variable Documentation

DelTFptr deltf_chain_begin = (DelTFptr) NULL
 

Integer first_free_set
 

IGRptr IGRhead = NULL [static]
 

int num_sets
 

BTNptr* Set_ArrayPtr
 

int Set_ArraySz
 


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