static void atom_gc(void) { int gc_verbose = Yap_is_gc_verbose(); int gc_trace = 0; UInt time_start, agc_time; #if defined(YAPOR) || defined(THREADS) return; #endif if (Yap_GetValue(AtomGcTrace) != TermNil) gc_trace = 1; agc_calls++; agc_collected = 0; if (gc_trace) { fprintf(Yap_stderr, "%% agc:\n"); } else if (gc_verbose) { fprintf(Yap_stderr, "%% Start of atom garbage collection %d:\n", agc_calls); } time_start = Yap_cputime(); /* get the number of active registers */ YAPEnterCriticalSection(); init_reg_copies(); mark_stacks(); restore_codes(); clean_atoms(); AGcLastCall = NOfAtoms; YAPLeaveCriticalSection(); agc_time = Yap_cputime()-time_start; tot_agc_time += agc_time; tot_agc_recovered += agc_collected; if (gc_verbose) { #ifdef _WIN32 fprintf(Yap_stderr, "%% Collected %I64d bytes.\n", agc_collected); #else fprintf(Yap_stderr, "%% Collected %lld bytes.\n", agc_collected); #endif fprintf(Yap_stderr, "%% GC %d took %g sec, total of %g sec doing GC so far.\n", agc_calls, (double)agc_time/1000, (double)tot_agc_time/1000); } }
static void thread_die(int wid, int always_die) { #ifdef TABLING CACHE_REGS tab_ent_ptr tab_ent; tab_ent = GLOBAL_root_tab_ent; while (tab_ent) { abolish_table(tab_ent); tab_ent = TabEnt_next(tab_ent); } FREE_DEPENDENCY_FRAME(LOCAL_top_dep_fr); LOCAL_top_dep_fr = NULL; #ifdef USE_PAGES_MALLOC DETACH_PAGES(_pages_void); #endif /* USE_PAGES_MALLOC */ DETACH_PAGES(_pages_tab_ent); #if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING) DETACH_PAGES(_pages_sg_ent); #endif /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */ DETACH_PAGES(_pages_sg_fr); DETACH_PAGES(_pages_dep_fr); DETACH_PAGES(_pages_sg_node); DETACH_PAGES(_pages_sg_hash); DETACH_PAGES(_pages_ans_node); DETACH_PAGES(_pages_ans_hash); #if defined(THREADS_FULL_SHARING) DETACH_PAGES(_pages_ans_ref_node); #endif /* THREADS_FULL_SHARING */ DETACH_PAGES(_pages_gt_node); DETACH_PAGES(_pages_gt_hash); #ifdef OUTPUT_THREADS_TABLING fclose(LOCAL_thread_output); #endif /* OUTPUT_THREADS_TABLING */ #endif /* TABLING */ GLOBAL_NOfThreads--; if (!always_die) { /* called by thread itself */ GLOBAL_ThreadsTotalTime += Yap_cputime(); } kill_thread_engine(wid, always_die); }
static Term eval0(Int fi) { CACHE_REGS arith0_op fop = fi; switch (fop) { case op_pi: { RFLOAT(PI); } case op_e: { RFLOAT(M_E); } case op_epsilon: { RFLOAT(DBL_EPSILON); } case op_inf: { #ifdef _MSC_VER /* Microsoft's Visual C++ Compiler */ Yap_ArithError(TYPE_ERROR_EVALUABLE, TermNil, "evaluating infinity"); P = (yamop *)FAILCODE; RERROR(); #else if (isoLanguageFlag()) {/* iso */ Yap_ArithError(TYPE_ERROR_EVALUABLE, TermNil, "evaluating infinity"); P = (yamop *)FAILCODE; RERROR(); } else { RFLOAT(INFINITY); } #endif } case op_nan: { #ifdef _MSC_VER /* Microsoft's Visual C++ Compi<ler */ Yap_ArithError(TYPE_ERROR_EVALUABLE, TermNil, "evaluating infinity"); RERROR(); #else if (isoLanguageFlag()) {/* iso */ Yap_ArithError(TYPE_ERROR_EVALUABLE, TermNil, "evaluating not-a-number"); RERROR(); } else { RFLOAT(NAN); } #endif } case op_random: { RFLOAT(Yap_random()); } case op_cputime: { RFLOAT((Float)Yap_cputime()/1000.0); } case op_heapused: /// - heapused /// Heap (data-base) space used, in bytes. /// RINT(HeapUsed); case op_localsp: /// - local /// Local stack in use, in bytes /// #if YAPOR_SBA RINT((Int)ASP); #else RINT(LCL0 - ASP); #endif case op_b: /// - $b /// current choicepoint /// #if YAPOR_SBA RINT((Int)B); #else RINT(LCL0 - (CELL *)B); #endif case op_env: /// - $env /// Environment /// #if YAPOR_SBA RINT((Int)YENV); #else RINT(LCL0 - YENV); #endif case op_tr: /// - $tr /// Trail in use /// #if YAPOR_SBA RINT(TR); #else RINT(((CELL *)TR)-LCL0); #endif case op_stackfree: /// - $free_stack /// /// Not-a-number according to the IEEE Floating-Point standard. Note that evaluating this term will generate a domain error in the `iso` language mode. RINT(Unsigned(ASP) - Unsigned(HR)); case op_globalsp: /// - global /// Global stack in use, in bytes. /// #if YAPOR_SBA RINT((Int)HR); #else RINT(HR - H0); #endif } /// end of switch RERROR(); }