2010-03-21 22:12:42 +00:00
|
|
|
//
|
|
|
|
// File defining fields in the Yap_GLOBAL global structure
|
|
|
|
//
|
|
|
|
// these fields used to spread all over the place, because they must be used in 3 ways:
|
|
|
|
// - they must be defined somewhere
|
|
|
|
// - they have an #ifdef to get a shorter name
|
|
|
|
// - they must be initialised somewhere
|
|
|
|
// - they may be of interest to restore
|
|
|
|
//
|
|
|
|
// The defs include 4+ components:
|
|
|
|
// Type
|
|
|
|
// name in structured
|
|
|
|
// global name
|
|
|
|
// init code (optional)
|
|
|
|
// restore code (optional)
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
// Stuff that must be considered local to a thread or worker
|
|
|
|
START_WORKER_LOCAL
|
|
|
|
|
2010-07-27 17:28:58 +01:00
|
|
|
// Streams
|
|
|
|
int c_input_stream Yap_c_input_stream =0
|
|
|
|
int c_output_stream Yap_c_output_stream =1
|
|
|
|
int c_error_stream Yap_c_error_stream =2
|
|
|
|
|
2010-03-21 22:12:42 +00:00
|
|
|
/* shifts and restore: per local data-structure */
|
|
|
|
restoreinfo rinfo
|
|
|
|
. rinfo.old_ASP OldASP =NULL
|
|
|
|
. rinfo.old_LCL0 OldLCL0 =NULL
|
|
|
|
. rinfo.old_TR OldTR =NULL
|
|
|
|
. rinfo.old_GlobalBase OldGlobalBase =NULL
|
|
|
|
. rinfo.old_H OldH =NULL
|
|
|
|
. rinfo.old_H0 OldH0 =NULL
|
|
|
|
. rinfo.old_TrailBase OldTrailBase =NULL
|
|
|
|
. rinfo.old_TrailTop OldTrailTop =NULL
|
|
|
|
. rinfo.old_HeapBase OldHeapBase =NULL
|
|
|
|
. rinfo.old_HeapTop OldHeapTop =NULL
|
|
|
|
. rinfo.cl_diff ClDiff =0L
|
|
|
|
. rinfo.g_diff GDiff =0L
|
|
|
|
. rinfo.h_diff HDiff =0L
|
|
|
|
. rinfo.g_diff0 GDiff0 =0L
|
|
|
|
. rinfo.g_split GSplit =NULL
|
|
|
|
. rinfo.l_diff LDiff =0L
|
|
|
|
. rinfo.tr_diff TrDiff =0L
|
|
|
|
. rinfo.x_diff XDiff =0L
|
|
|
|
. rinfo.delay_diff DelayDiff =0L
|
|
|
|
. rinfo.base_diff BaseDiff =0L
|
|
|
|
|
|
|
|
struct reduction_counters call_counters
|
|
|
|
. call_counters.reductions ReductionsCounter =0L
|
|
|
|
. call_counters.reductions_retries PredEntriesCounter =0L
|
|
|
|
. call_counters.retries RetriesCounter =0L
|
|
|
|
. call_counters.reductions_on ReductionsCounterOn =0L
|
|
|
|
. call_counters.reductions_retries_on PredEntriesCounterOn =0L
|
|
|
|
. call_counters.retries_on RetriesCounterOn =0L
|
|
|
|
|
|
|
|
int interrupts_disabled Yap_InterruptsDisabled =FALSE
|
|
|
|
|
|
|
|
// support for consulting files
|
|
|
|
/* current consult stack */
|
|
|
|
union CONSULT_OBJ* consultsp ConsultSp =NULL
|
|
|
|
/* current maximum number of cells in consult stack */
|
|
|
|
UInt consultcapacity ConsultCapacity void
|
|
|
|
/* top of consult stack */
|
|
|
|
union CONSULT_OBJ* consultbase ConsultBase =NULL
|
|
|
|
/* low-water mark for consult */
|
|
|
|
union CONSULT_OBJ* consultlow ConsultLow =NULL
|
|
|
|
|
|
|
|
//global variables
|
|
|
|
Term global_arena GlobalArena =0L TermToGlobalOrAtomAdjust
|
|
|
|
UInt global_arena_overflows GlobalArenaOverflows =0L
|
|
|
|
Int delay_arena_overflows DelayArenaOverflows =0L
|
|
|
|
Int arena_overflows ArenaOverflows =0L
|
|
|
|
Int depth_arenas DepthArenas =0
|
|
|
|
|
|
|
|
int arith_error ArithError =FALSE
|
|
|
|
struct pred_entry* last_asserted_pred LastAssertedPred =NULL
|
|
|
|
int debug_on DebugOn =FALSE
|
|
|
|
struct format_status* f_info FormatInfo =NULL
|
|
|
|
char* scanner_stack ScannerStack =NULL
|
|
|
|
struct scanner_extra_alloc* scanner_extra_blocks ScannerExtraBlocks =NULL
|
|
|
|
struct DB_TERM *ball_term BallTerm =NULL RestoreBallTerm(wid)
|
|
|
|
UInt active_signals ActiveSignals =0L
|
|
|
|
UInt i_pred_arity IPredArity =0L
|
|
|
|
yamop* prof_end ProfEnd =NULL
|
|
|
|
int uncaught_throw UncaughtThrow =FALSE
|
|
|
|
int doing_undefp DoingUndefp =FALSE
|
|
|
|
Int start_line StartLine =0L
|
|
|
|
scratch_block scratchpad ScratchPad InitScratchPad(wid)
|
|
|
|
#ifdef COROUTINING
|
|
|
|
Term woken_goals WokenGoals =0L TermToGlobalAdjust
|
|
|
|
Term atts_mutable_list AttsMutableList =0L TermToGlobalAdjust
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// gc_stuff
|
|
|
|
Term gc_generation GcGeneration =0L TermToGlobalAdjust
|
|
|
|
Term gc_phase GcPhase =0L TermToGlobalAdjust
|
|
|
|
UInt gc_current_phase GcCurrentPhase =0L
|
|
|
|
UInt gc_calls GcCalls =0L
|
|
|
|
Int tot_gc_time TotGcTime =0L
|
|
|
|
YAP_ULONG_LONG tot_gc_recovered TotGcRecovered =0L
|
|
|
|
Int last_gc_time LastGcTime =0L
|
|
|
|
Int last_ss_time LastSSTime =0L
|
|
|
|
|
|
|
|
// global variables that cannot be global in a thread/or-p implementation
|
|
|
|
#if defined(YAPOR) || defined(THREADS)
|
|
|
|
lockvar signal_lock SignalLock MkLock
|
|
|
|
struct pred_entry* wpp WPP =NULL
|
|
|
|
/* in a single gc */
|
|
|
|
Int tot_marked total_marked =0L
|
|
|
|
Int tot_oldies total_oldies =0L
|
|
|
|
#if DEBUG && COROUTINING
|
|
|
|
UInt tot_smarked total_smarked =0L
|
|
|
|
#endif
|
|
|
|
struct choicept *wl_current_B current_B =NULL
|
|
|
|
CELL* wl_prev_HB prev_HB =NULL
|
|
|
|
CELL* hgen HGEN =NULL
|
|
|
|
CELL** ip_top iptop =NULL
|
|
|
|
#if GC_NO_TAGS
|
|
|
|
char* b_p Yap_bp =NULL
|
|
|
|
#endif
|
|
|
|
#if defined(TABLING) || defined(SBA)
|
|
|
|
struct trail_frame* wl_sTR sTR =NULL
|
|
|
|
struct trail_frame* wl_sTR0 sTR0 =NULL
|
|
|
|
struct trail_frame* new_tr new_TR =NULL
|
|
|
|
#else
|
|
|
|
Term *wl_sTR sTR =NULL
|
|
|
|
Term *wl_sTR0 sTR0 =NULL
|
|
|
|
Term *new_tr new_TR =NULL
|
|
|
|
#endif
|
|
|
|
struct gc_mark_continuation* conttop0 cont_top0 =NULL
|
|
|
|
struct gc_mark_continuation* conttop cont_top =NULL
|
2010-06-19 14:38:04 +01:00
|
|
|
int disc_trail_entries discard_trail_entries =0
|
2010-03-21 22:12:42 +00:00
|
|
|
gc_ma_hash_entry Gc_ma_hash_table[GC_MAVARS_HASH_SIZE] gc_ma_hash_table void
|
|
|
|
gc_ma_hash_entry* Gc_ma_h_top gc_ma_h_top =NULL
|
|
|
|
gc_ma_hash_entry* Gc_ma_h_list gc_ma_h_list =NULL
|
|
|
|
UInt Gc_timestamp gc_timestamp =0L
|
|
|
|
ADDR DB_vec db_vec =NULL
|
|
|
|
ADDR DB_vec0 db_vec0 =NULL
|
|
|
|
struct RB_red_blk_node* DB_root db_root =NULL
|
|
|
|
struct RB_red_blk_node* DB_nil db_nil =NULL
|
|
|
|
#endif /* defined(YAPOR) || defined(THREADS) */
|
|
|
|
|
|
|
|
|
|
|
|
jmp_buf gc_restore Yap_gc_restore void
|
|
|
|
struct array_entry* dynamic_arrays DynamicArrays =NULL PtoArrayEAdjust
|
|
|
|
struct static_array_entry* static_arrays StaticArrays =NULL PtoArraySAdjust
|
|
|
|
struct global_entry* global_variables GlobalVariables =NULL PtoGlobalEAdjust
|
|
|
|
int allow_restart Yap_AllowRestart =FALSE
|
|
|
|
|
2010-04-15 22:23:54 +01:00
|
|
|
// Thread Local Area for Fast Storage of Intermediate Compiled Code.
|
|
|
|
struct mem_blk* cmem_first_block Yap_CMemFirstBlock =NULL
|
|
|
|
UInt cmem_first_block_sz Yap_CMemFirstBlockSz =0L
|
|
|
|
|
|
|
|
// Thread Local Area for Labels.
|
|
|
|
Int* label_first_array Yap_LabelFirstArray =NULL
|
|
|
|
UInt label_first_array_sz Yap_LabelFirstArraySz =0L
|
2010-04-29 23:04:04 +01:00
|
|
|
|
|
|
|
// Thread Local Area for SWI-Prolog emulation routines.
|
|
|
|
char* putc_curp_ putc_curp =NULL
|
|
|
|
char* putc_cur_buf_ putc_cur_buf =NULL
|
|
|
|
char* putc_cur_lim_ putc_cur_lim =NULL
|
|
|
|
UInt putc_cur_flags_ putc_cur_flags =0L
|
2010-08-04 11:37:12 +01:00
|
|
|
char* SWI_buffers_[1+SWI_BUF_RINGS] SWI_buffers InitSWIBuffers(wid)
|
|
|
|
size_t SWI_buffers_sz_[1+SWI_BUF_RINGS] SWI_buffers_sz void
|
|
|
|
int SWI_buf_index_ SWI_buf_index =0
|
|
|
|
|
2010-04-15 22:23:54 +01:00
|
|
|
|
2010-06-14 09:26:32 +01:00
|
|
|
struct open_query_struct* _execution execution =NULL
|
|
|
|
|
2010-03-21 22:12:42 +00:00
|
|
|
// Ricardo's stuff
|
|
|
|
#if (defined(YAPOR) || defined(TABLING)) && defined(THREADS)
|
|
|
|
struct worker worker WORKER void
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef THREADS
|
2010-06-19 14:38:04 +01:00
|
|
|
struct thandle thread_handle ThreadHandle InitThreadHandle(wid)
|
2010-03-21 22:12:42 +00:00
|
|
|
#define FOREIGN_ThreadHandle(wid) (Yap_WLocal[(wid)].thread_handle)
|
|
|
|
#define MY_ThreadHandle (Yap_WLocal[worker_id].thread_handle)
|
|
|
|
#endif
|
2010-06-14 09:26:32 +01:00
|
|
|
|
2010-03-21 22:12:42 +00:00
|
|
|
// END WORKER LOCAL STUFF
|
|
|
|
END_WORKER_LOCAL
|
|
|
|
|
|
|
|
// Stuff that must be shared by all threads or workers
|
|
|
|
START_WORKER_SHARED
|
|
|
|
|
|
|
|
/* multi-thread support */
|
|
|
|
#if THREADS
|
|
|
|
/* number of threads and processes in system */
|
|
|
|
UInt n_of_threads NOfThreads =1
|
|
|
|
/* number of threads created since start */
|
|
|
|
UInt n_of_threads_created NOfThreadsCreated =1
|
|
|
|
/* total run time for dead threads */
|
|
|
|
UInt threads_total_time ThreadsTotalTime =0L
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// multi-thread/ORP support
|
|
|
|
#if defined(YAPOR) || defined(THREADS)
|
|
|
|
// protect long critical regions
|
|
|
|
lockvar bgl BGL MkLock
|
|
|
|
#endif
|
|
|
|
|
2010-07-21 10:58:24 +01:00
|
|
|
Functor f_swi_stream FSWIStream =NULL
|
|
|
|
SWI_GetFunction swi_getc SWIGetc =NULL
|
|
|
|
SWI_PutFunction swi_putc SWIPutc =NULL
|
|
|
|
SWI_GetWideFunction swi_wgetc SWIWideGetc =NULL
|
|
|
|
SWI_PutWideFunction swi_wputc SWIWidePutc =NULL
|
|
|
|
SWI_CloseFunction swi_close SWIClose =NULL
|
2010-08-04 11:37:12 +01:00
|
|
|
SWI_FlushFunction swi_flush SWIFlush =NULL
|
2010-12-13 12:38:37 +00:00
|
|
|
SWI_PLGetStreamFunction swi_get_stream_f SWIGetStream =NULL
|
2010-07-21 10:58:24 +01:00
|
|
|
|
2010-03-21 22:12:42 +00:00
|
|
|
// stack overflow expansion/gc control
|
|
|
|
int allow_local_expansion Yap_AllowLocalExpansion =TRUE
|
|
|
|
int allow_global_expansion Yap_AllowGlobalExpansion =TRUE
|
|
|
|
int allow_trail_expansion Yap_AllowTrailExpansion =TRUE
|
|
|
|
UInt size_of_overflow SizeOfOverflow =0
|
|
|
|
// amount of space recovered in all garbage collections
|
|
|
|
UInt agc_last_call AGcLastCall =0
|
|
|
|
// amount of space recovered in all garbage collections
|
|
|
|
UInt agc_threshold AGcThreshold =10000
|
|
|
|
Agc_hook agc_hook AGCHook =NULL
|
|
|
|
|
|
|
|
// readline
|
|
|
|
#if HAVE_LIBREADLINE
|
|
|
|
char *readline_buf ReadlineBuf =NULL
|
|
|
|
char *readline_pos ReadlinePos =0L
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Threads Array
|
|
|
|
#ifdef THREADS
|
|
|
|
lockvar thread_handles_lock ThreadHandlesLock MkLock
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Ricardo's stuff
|
|
|
|
#if defined(YAPOR) || defined(TABLING)
|
|
|
|
struct global_data global GLOBAL void
|
|
|
|
struct local_data remote[MAX_WORKERS] REMOTE void
|
|
|
|
#endif
|
|
|
|
|
2010-04-13 00:31:48 +01:00
|
|
|
// initialization: tell whether the system has been initialised and by whom.
|
|
|
|
int initialised Yap_Initialised =FALSE
|
|
|
|
int initialised_from_pl Yap_InitialisedFromPL =FALSE
|
|
|
|
int pl_argc Yap_PL_Argc =0
|
|
|
|
char **pl_argv Yap_PL_Argv =NULL
|
|
|
|
|
2010-11-29 18:08:29 +00:00
|
|
|
// halt hooks
|
|
|
|
struct halt_hook *yap_halt_hook Yap_HaltHooks =NULL
|
|
|
|
|
2010-03-21 22:12:42 +00:00
|
|
|
END_WORKER_SHARED
|
|
|
|
|