make some sense of the mess that was various_codes *
This commit is contained in:
parent
36a7e5c59e
commit
d373f23b50
383
H/YapHeap.h
383
H/YapHeap.h
@ -222,14 +222,10 @@ typedef struct thandle {
|
|||||||
typedef int (*Agc_hook)(Atom);
|
typedef int (*Agc_hook)(Atom);
|
||||||
|
|
||||||
typedef struct various_codes {
|
typedef struct various_codes {
|
||||||
|
/* memory allocation and management */
|
||||||
special_functors funcs;
|
special_functors funcs;
|
||||||
UInt hole_size;
|
UInt hole_size;
|
||||||
struct malloc_state *av_;
|
struct malloc_state *av_;
|
||||||
|
|
||||||
yap_exec_mode execution_mode;
|
|
||||||
UInt atts_size;
|
|
||||||
UInt clause_space, index_space_Tree, index_space_EXT, index_space_SW;
|
|
||||||
UInt lu_clause_space, lu_index_space_Tree, lu_index_space_CP, lu_index_space_EXT, lu_index_space_SW;
|
|
||||||
#if USE_DL_MALLOC
|
#if USE_DL_MALLOC
|
||||||
struct memory_hole memory_holes[MAX_DLMALLOC_HOLES];
|
struct memory_hole memory_holes[MAX_DLMALLOC_HOLES];
|
||||||
UInt nof_memory_holes;
|
UInt nof_memory_holes;
|
||||||
@ -240,34 +236,115 @@ typedef struct various_codes {
|
|||||||
ADDR heap_lim;
|
ADDR heap_lim;
|
||||||
struct FREEB *free_blocks;
|
struct FREEB *free_blocks;
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
lockvar heap_used_lock; /* protect HeapUsed */
|
||||||
|
lockvar heap_top_lock; /* protect HeapTop */
|
||||||
|
int heap_top_owner;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* multi-thread/ORP support */
|
||||||
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
unsigned int n_of_threads; /* number of threads and processes in system */
|
||||||
|
unsigned int n_of_threads_created; /* number of threads created since start */
|
||||||
|
UInt threads_total_time; /* total run time for dead threads */
|
||||||
lockvar bgl; /* protect long critical regions */
|
lockvar bgl; /* protect long critical regions */
|
||||||
lockvar free_blocks_lock; /* protect the list of free blocks */
|
lockvar free_blocks_lock; /* protect the list of free blocks */
|
||||||
worker_local wl[MAX_AGENTS];
|
worker_local wl[MAX_AGENTS];
|
||||||
#else
|
#else
|
||||||
worker_local wl;
|
worker_local wl;
|
||||||
#endif
|
#endif
|
||||||
#ifdef BEAM
|
#ifdef THREADS
|
||||||
yamop beam_retry_code;
|
lockvar thread_handles_lock; /* protect ThreadManipulation */
|
||||||
#endif /* BEAM */
|
struct thandle thread_handle[MAX_THREADS];
|
||||||
#ifdef YAPOR
|
|
||||||
int seq_def;
|
|
||||||
yamop getwork_code;
|
|
||||||
yamop getwork_seq_code;
|
|
||||||
yamop getwork_first_time_code;
|
|
||||||
#endif /* YAPOR */
|
|
||||||
#ifdef TABLING
|
|
||||||
yamop table_load_answer_code;
|
|
||||||
yamop table_try_answer_code;
|
|
||||||
yamop table_answer_resolution_code;
|
|
||||||
yamop table_completion_code;
|
|
||||||
#endif /* TABLING */
|
|
||||||
OPCODE execute_cpred_op_code, expand_op_code;
|
|
||||||
yamop *expand_clauses_first, *expand_clauses_last;
|
|
||||||
UInt expand_clauses;
|
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
|
||||||
lockvar expand_clauses_list_lock;
|
|
||||||
lockvar op_list_lock;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* atoms and functors */
|
||||||
|
UInt n_of_atoms;
|
||||||
|
UInt atom_hash_table_size;
|
||||||
|
UInt wide_atom_hash_table_size;
|
||||||
|
UInt n_of_wide_atoms;
|
||||||
|
AtomHashEntry invisiblechain;
|
||||||
|
AtomHashEntry *wide_hash_chain;
|
||||||
|
AtomHashEntry *hash_chain;
|
||||||
|
#include "tatoms.h"
|
||||||
|
|
||||||
|
/* Well-Known Terms, mostly modules */
|
||||||
|
#ifdef EUROTRA
|
||||||
|
Term term_dollar_u;
|
||||||
|
#endif
|
||||||
|
Term term_prolog;
|
||||||
|
Term term_refound_var;
|
||||||
|
Term user_module;
|
||||||
|
Term idb_module;
|
||||||
|
Term attributes_module;
|
||||||
|
Term charsio_module;
|
||||||
|
Term terms_module;
|
||||||
|
Term system_module;
|
||||||
|
Term readutil_module;
|
||||||
|
Term hacks_module;
|
||||||
|
Term arg_module;
|
||||||
|
Term globals_module;
|
||||||
|
Term swi_module;
|
||||||
|
|
||||||
|
/* Module List */
|
||||||
|
struct mod_entry *current_modules;
|
||||||
|
|
||||||
|
/* The Predicate Hash Table: fast access to predicates. */
|
||||||
|
struct pred_entry **pred_hash;
|
||||||
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
rwlock_t pred_hash_rw_lock;
|
||||||
|
#endif
|
||||||
|
UInt preds_in_hash_table, pred_hash_table_size;
|
||||||
|
|
||||||
|
/* Well-Known Predicates */
|
||||||
|
struct pred_entry *creep_code;
|
||||||
|
struct pred_entry *undef_code;
|
||||||
|
struct pred_entry *spy_code;
|
||||||
|
#ifdef COROUTINING
|
||||||
|
int num_of_atts; /* max. number of attributes we have for a variable */
|
||||||
|
struct pred_entry *wake_up_code;
|
||||||
|
#endif
|
||||||
|
struct pred_entry *pred_goal_expansion;
|
||||||
|
struct pred_entry *pred_meta_call;
|
||||||
|
struct pred_entry *pred_dollar_catch;
|
||||||
|
struct pred_entry *pred_recorded_with_key;
|
||||||
|
struct pred_entry *pred_log_upd_clause;
|
||||||
|
struct pred_entry *pred_log_upd_clause_erase;
|
||||||
|
struct pred_entry *pred_log_upd_clause0;
|
||||||
|
struct pred_entry *pred_static_clause;
|
||||||
|
struct pred_entry *pred_throw;
|
||||||
|
struct pred_entry *pred_handle_throw;
|
||||||
|
struct pred_entry *pred_is;
|
||||||
|
|
||||||
|
/* execution info */
|
||||||
|
/* OPCODE TABLE */
|
||||||
|
#if USE_THREADED_CODE
|
||||||
|
opentry *op_rtable;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Anderson's JIT */
|
||||||
|
yap_exec_mode execution_mode;
|
||||||
|
|
||||||
|
/* low-level tracer */
|
||||||
|
#ifdef LOW_LEVEL_TRACER
|
||||||
|
int yap_do_low_level_trace;
|
||||||
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
lockvar low_level_trace_lock;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* code management info */
|
||||||
|
UInt clause_space, index_space_Tree, index_space_EXT, index_space_SW;
|
||||||
|
UInt lu_clause_space, lu_index_space_Tree, lu_index_space_CP, lu_index_space_EXT, lu_index_space_SW;
|
||||||
|
|
||||||
|
/* popular opcodes */
|
||||||
|
OPCODE execute_cpred_op_code;
|
||||||
|
OPCODE expand_op_code;
|
||||||
|
OPCODE undef_op;
|
||||||
|
OPCODE index_op;
|
||||||
|
OPCODE lockpred_op;
|
||||||
|
OPCODE fail_op;
|
||||||
|
|
||||||
|
/* static code: may be shared by many predicate or may be used for meta-execution */
|
||||||
yamop comma_code[5];
|
yamop comma_code[5];
|
||||||
yamop failcode[1];
|
yamop failcode[1];
|
||||||
OPCODE failcode_1;
|
OPCODE failcode_1;
|
||||||
@ -276,6 +353,7 @@ typedef struct various_codes {
|
|||||||
OPCODE failcode_4;
|
OPCODE failcode_4;
|
||||||
OPCODE failcode_5;
|
OPCODE failcode_5;
|
||||||
OPCODE failcode_6;
|
OPCODE failcode_6;
|
||||||
|
OPCODE dummycode[1];
|
||||||
struct {
|
struct {
|
||||||
OPCODE op;
|
OPCODE op;
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
@ -309,21 +387,32 @@ typedef struct various_codes {
|
|||||||
struct yami *clause;
|
struct yami *clause;
|
||||||
Functor func;
|
Functor func;
|
||||||
} clausecode[1];
|
} clausecode[1];
|
||||||
#if HAVE_LIBREADLINE
|
/*
|
||||||
char *readline_buf, *readline_pos;
|
PREG just before we enter $spy. We use that to find out the clause which
|
||||||
#endif
|
was calling the debugged goal.
|
||||||
#if USE_THREADED_CODE
|
*/
|
||||||
opentry *op_rtable;
|
yamop *debugger_p_before_spy;
|
||||||
#endif
|
#ifdef BEAM
|
||||||
struct udi_info *udi_control_blocks;
|
yamop beam_retry_code;
|
||||||
#ifdef COROUTINING
|
#endif /* BEAM */
|
||||||
int num_of_atts; /* max. number of attributes we have for a variable */
|
#ifdef YAPOR
|
||||||
struct pred_entry *wake_up_code;
|
int seq_def;
|
||||||
#endif
|
yamop getwork_code;
|
||||||
struct pred_entry *creep_code;
|
yamop getwork_seq_code;
|
||||||
struct pred_entry *undef_code;
|
yamop getwork_first_time_code;
|
||||||
struct pred_entry *spy_code;
|
#endif /* YAPOR */
|
||||||
UInt new_cps, live_cps, dirty_cps, freed_cps;
|
#ifdef TABLING
|
||||||
|
yamop table_load_answer_code;
|
||||||
|
yamop table_try_answer_code;
|
||||||
|
yamop table_answer_resolution_code;
|
||||||
|
yamop table_completion_code;
|
||||||
|
#endif /* TABLING */
|
||||||
|
|
||||||
|
/* support recorded_k */
|
||||||
|
yamop *retry_recorded_k_code,
|
||||||
|
*retry_c_recordedp_code;
|
||||||
|
|
||||||
|
/* compiler flags */
|
||||||
int system_profiling;
|
int system_profiling;
|
||||||
int system_call_counting;
|
int system_call_counting;
|
||||||
int system_pred_goal_expansion_all;
|
int system_pred_goal_expansion_all;
|
||||||
@ -331,143 +420,139 @@ typedef struct various_codes {
|
|||||||
int system_pred_goal_expansion_on;
|
int system_pred_goal_expansion_on;
|
||||||
int compiler_optimizer_on;
|
int compiler_optimizer_on;
|
||||||
int compiler_compile_mode;
|
int compiler_compile_mode;
|
||||||
AtomHashEntry invisiblechain;
|
int compiler_profiling;
|
||||||
OPCODE dummycode[1];
|
int compiler_call_counting;
|
||||||
UInt maxdepth, maxlist, maxwriteargs;
|
/********* whether we should try to compile array references ******************/
|
||||||
int update_mode;
|
int compiler_compile_arrays;
|
||||||
Atom atprompt;
|
|
||||||
char prompt[MAX_PROMPT];
|
/* DBTerms: pre-compiled ground terms */
|
||||||
OPCODE undef_op;
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
OPCODE index_op;
|
lockvar dbterms_list_lock; /* protect DBTermList */
|
||||||
OPCODE lockpred_op;
|
#endif
|
||||||
OPCODE fail_op;
|
struct dbterm_list *dbterms_list;
|
||||||
yamop *retry_recorded_k_code,
|
|
||||||
*retry_c_recordedp_code;
|
/* JITI support */
|
||||||
|
yamop *expand_clauses_first, *expand_clauses_last;
|
||||||
|
UInt expand_clauses;
|
||||||
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
lockvar expand_clauses_list_lock;
|
||||||
|
lockvar op_list_lock;
|
||||||
|
#endif
|
||||||
|
/* instrumentation */
|
||||||
|
UInt new_cps, live_cps, dirty_cps, freed_cps;
|
||||||
|
UInt expand_clauses_sz;
|
||||||
|
|
||||||
|
/* UDI support */
|
||||||
|
struct udi_info *udi_control_blocks;
|
||||||
|
|
||||||
|
/* data-base statistics */
|
||||||
Int static_predicates_marked;
|
Int static_predicates_marked;
|
||||||
|
|
||||||
|
/* Internal Database */
|
||||||
|
Prop *IntKeys;
|
||||||
|
Prop *IntLUKeys;
|
||||||
|
Prop *IntBBKeys;
|
||||||
|
|
||||||
|
/* Internal Data-Base Control */
|
||||||
|
int update_mode;
|
||||||
|
|
||||||
|
/* Internal Database Statistics */
|
||||||
UInt int_keys_size;
|
UInt int_keys_size;
|
||||||
UInt int_keys_timestamp;
|
UInt int_keys_timestamp;
|
||||||
Prop *IntKeys;
|
|
||||||
UInt int_lu_keys_size;
|
UInt int_lu_keys_size;
|
||||||
UInt int_lu_keys_timestamp;
|
UInt int_lu_keys_timestamp;
|
||||||
Prop *IntLUKeys;
|
|
||||||
UInt int_bb_keys_size;
|
UInt int_bb_keys_size;
|
||||||
Prop *IntBBKeys;
|
|
||||||
Int yap_flags_field[NUMBER_OF_YAP_FLAGS];
|
/* nasty IDB stuff */
|
||||||
char *char_conversion_table;
|
struct DB_STRUCT *db_erased_marker;
|
||||||
char *char_conversion_table2;
|
struct logic_upd_clause *logdb_erased_marker;
|
||||||
#if defined(THREADS) || defined(YAPOR)
|
|
||||||
unsigned int n_of_threads; /* number of threads and processes in system */
|
/* Dead clauses and IDB entries */
|
||||||
unsigned int n_of_threads_created; /* number of threads created since start */
|
|
||||||
UInt threads_total_time; /* total run time for dead threads */
|
|
||||||
#endif
|
|
||||||
#ifdef LOW_LEVEL_TRACER
|
|
||||||
int yap_do_low_level_trace;
|
|
||||||
#endif
|
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
|
||||||
lockvar heap_used_lock; /* protect HeapUsed */
|
|
||||||
lockvar heap_top_lock; /* protect HeapTop */
|
|
||||||
lockvar dead_static_clauses_lock; /* protect DeadStaticClauses */
|
|
||||||
lockvar dead_mega_clauses_lock; /* protect DeadMegaClauses */
|
|
||||||
lockvar dead_static_indices_lock; /* protect DeadStaticIndices */
|
|
||||||
lockvar dbterms_list_lock; /* protect DBTermList */
|
|
||||||
int heap_top_owner;
|
|
||||||
#ifdef LOW_LEVEL_TRACER
|
|
||||||
lockvar low_level_trace_lock;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
int allow_local_expansion, allow_global_expansion, allow_trail_expansion;
|
|
||||||
unsigned int size_of_overflow;
|
|
||||||
struct mod_entry *current_modules;
|
|
||||||
struct operator_entry *op_list;
|
|
||||||
struct hold_entry *global_hold_entry;
|
|
||||||
struct static_clause *dead_static_clauses;
|
struct static_clause *dead_static_clauses;
|
||||||
struct static_mega_clause *dead_mega_clauses;
|
struct static_mega_clause *dead_mega_clauses;
|
||||||
struct static_index *dead_static_indices;
|
struct static_index *dead_static_indices;
|
||||||
struct dbterm_list *dbterms_list;
|
|
||||||
#include "tatoms.h"
|
|
||||||
Term
|
|
||||||
#ifdef EUROTRA
|
|
||||||
term_dollar_u,
|
|
||||||
#endif
|
|
||||||
term_prolog,
|
|
||||||
term_refound_var,
|
|
||||||
user_module,
|
|
||||||
idb_module,
|
|
||||||
attributes_module,
|
|
||||||
charsio_module,
|
|
||||||
terms_module,
|
|
||||||
system_module,
|
|
||||||
readutil_module,
|
|
||||||
hacks_module,
|
|
||||||
arg_module,
|
|
||||||
globals_module,
|
|
||||||
swi_module;
|
|
||||||
void *last_wtime;
|
|
||||||
struct pred_entry *pred_goal_expansion;
|
|
||||||
struct pred_entry *pred_meta_call;
|
|
||||||
struct pred_entry *pred_dollar_catch;
|
|
||||||
struct pred_entry *pred_recorded_with_key;
|
|
||||||
struct pred_entry *pred_log_upd_clause;
|
|
||||||
struct pred_entry *pred_log_upd_clause_erase;
|
|
||||||
struct pred_entry *pred_log_upd_clause0;
|
|
||||||
struct pred_entry *pred_static_clause;
|
|
||||||
struct pred_entry *pred_throw;
|
|
||||||
struct pred_entry *pred_handle_throw;
|
|
||||||
struct pred_entry *pred_is;
|
|
||||||
struct DB_STRUCT *db_erased_marker;
|
|
||||||
struct logic_upd_clause *logdb_erased_marker;
|
|
||||||
struct logic_upd_clause *db_erased_list;
|
struct logic_upd_clause *db_erased_list;
|
||||||
struct logic_upd_index *db_erased_ilist;
|
struct logic_upd_index *db_erased_ilist;
|
||||||
UInt expand_clauses_sz;
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
lockvar dead_static_clauses_lock; /* protect DeadStaticClauses */
|
||||||
|
lockvar dead_mega_clauses_lock; /* protect DeadMegaClauses */
|
||||||
|
lockvar dead_static_indices_lock; /* protect DeadStaticIndices */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* execution counters */
|
||||||
|
struct reduction_counters call_counters;
|
||||||
|
|
||||||
|
/* number of attribute modules */
|
||||||
|
UInt atts_size;
|
||||||
|
|
||||||
|
/* stack overflow expansion/gc control */
|
||||||
|
int allow_local_expansion, allow_global_expansion, allow_trail_expansion;
|
||||||
|
unsigned int size_of_overflow;
|
||||||
|
struct hold_entry *global_hold_entry;
|
||||||
|
UInt agc_last_call; /* amount of space recovered in all garbage collections */
|
||||||
|
UInt agc_threshold; /* amount of space recovered in all garbage collections */
|
||||||
|
Agc_hook agc_hook;
|
||||||
|
|
||||||
|
/* YAP control flags */
|
||||||
|
Int yap_flags_field[NUMBER_OF_YAP_FLAGS];
|
||||||
|
|
||||||
|
/* Operators */
|
||||||
|
struct operator_entry *op_list;
|
||||||
|
|
||||||
|
/* Input/Output */
|
||||||
|
|
||||||
|
/* stream array */
|
||||||
struct stream_desc *yap_streams;
|
struct stream_desc *yap_streams;
|
||||||
int debugger_output_msg;
|
|
||||||
|
/* stream aliases */
|
||||||
UInt n_of_file_aliases;
|
UInt n_of_file_aliases;
|
||||||
UInt sz_of_file_aliases;
|
UInt sz_of_file_aliases;
|
||||||
struct AliasDescS * file_aliases;
|
struct AliasDescS * file_aliases;
|
||||||
|
|
||||||
|
/* prompting */
|
||||||
|
Atom atprompt;
|
||||||
|
char prompt[MAX_PROMPT];
|
||||||
|
|
||||||
|
/* readline */
|
||||||
|
#if HAVE_LIBREADLINE
|
||||||
|
char *readline_buf, *readline_pos;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* ISO char conversion: I will make no comments */
|
||||||
|
char *char_conversion_table;
|
||||||
|
char *char_conversion_table2;
|
||||||
|
|
||||||
|
/* write depth */
|
||||||
|
UInt maxdepth, maxlist, maxwriteargs;
|
||||||
|
|
||||||
|
/* what to do when the parser gives an error: should be thread bound? */
|
||||||
|
int parser_error_style;
|
||||||
|
|
||||||
|
/* library location. */
|
||||||
|
char *yap_lib_dir;
|
||||||
|
|
||||||
|
/* time */
|
||||||
|
void *last_wtime;
|
||||||
|
|
||||||
|
/* profiling */
|
||||||
|
int debugger_output_msg;
|
||||||
#if LOW_PROF
|
#if LOW_PROF
|
||||||
int profiler_on;
|
int profiler_on;
|
||||||
int offline_profiler;
|
int offline_profiler;
|
||||||
FILE *f_prof, *f_preds;
|
FILE *f_prof, *f_preds;
|
||||||
UInt prof_preds;
|
UInt prof_preds;
|
||||||
#endif /* LOW_PROF */
|
#endif /* LOW_PROF */
|
||||||
struct reduction_counters call_counters;
|
|
||||||
char *yap_lib_dir;
|
/* foreign code loaded */
|
||||||
UInt agc_last_call; /* amount of space recovered in all garbage collections */
|
|
||||||
UInt agc_threshold; /* amount of space recovered in all garbage collections */
|
|
||||||
Agc_hook agc_hook;
|
|
||||||
void *foreign_code_loaded;
|
void *foreign_code_loaded;
|
||||||
ADDR foreign_code_base;
|
ADDR foreign_code_base;
|
||||||
ADDR foreign_code_top;
|
ADDR foreign_code_top;
|
||||||
ADDR foreign_code_max;
|
ADDR foreign_code_max;
|
||||||
struct pred_entry **pred_hash;
|
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
|
||||||
rwlock_t pred_hash_rw_lock;
|
|
||||||
#endif
|
|
||||||
UInt preds_in_hash_table, pred_hash_table_size;
|
|
||||||
int parser_error_style;
|
|
||||||
int compiler_profiling;
|
|
||||||
int compiler_call_counting;
|
|
||||||
/********* whether we should try to compile array references ******************/
|
|
||||||
int compiler_compile_arrays;
|
|
||||||
/*
|
|
||||||
PREG just before we enter $spy. We use that to find out the clause which
|
|
||||||
was calling the debugged goal.
|
|
||||||
*/
|
|
||||||
yamop *debugger_p_before_spy;
|
|
||||||
#if defined(YAPOR) || defined(TABLING)
|
#if defined(YAPOR) || defined(TABLING)
|
||||||
struct global_data global;
|
struct global_data global;
|
||||||
struct local_data remote[MAX_WORKERS];
|
struct local_data remote[MAX_WORKERS];
|
||||||
#endif /* YAPOR || TABLING */
|
#endif /* YAPOR || TABLING */
|
||||||
#ifdef THREADS
|
|
||||||
lockvar thread_handles_lock; /* protect ThreadManipulation */
|
|
||||||
struct thandle thread_handle[MAX_THREADS];
|
|
||||||
#endif
|
|
||||||
UInt n_of_atoms;
|
|
||||||
UInt atom_hash_table_size;
|
|
||||||
UInt wide_atom_hash_table_size;
|
|
||||||
UInt n_of_wide_atoms;
|
|
||||||
AtomHashEntry *wide_hash_chain;
|
|
||||||
AtomHashEntry *hash_chain;
|
|
||||||
} all_heap_codes;
|
} all_heap_codes;
|
||||||
|
|
||||||
#ifdef USE_SYSTEM_MALLOC
|
#ifdef USE_SYSTEM_MALLOC
|
||||||
|
Reference in New Issue
Block a user