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); } }
/* * Searches through the cached huffman_codeset_t tables looking for a stored * huffman code of type 'code_set'. * NB: only code_sets >= CODE_USER will be stored here. * * Returns codes on success, * NULL on failure */ ztr_hcode_t *ztr_find_hcode(ztr_t *ztr, int code_set) { int i; if (code_set < CODE_USER) return NULL; /* computed on-the-fly or use a hard-coded set */ /* Check through chunks for undecoded HUFF chunks */ if (!ztr->hcodes_checked) { for (i = 0; i < ztr->nchunks; i++) { if (ztr->chunk[i].type == ZTR_TYPE_HUFF) { block_t *blk; huffman_codeset_t *cs; uncompress_chunk(ztr, &ztr->chunk[i]); blk = block_create((unsigned char *)(ztr->chunk[i].data+2), ztr->chunk[i].dlength-2); cs = restore_codes(blk, NULL); if (!cs) { block_destroy(blk, 1); return NULL; } cs->code_set = (unsigned char)(ztr->chunk[i].data[1]); ztr_add_hcode(ztr, cs, 1); block_destroy(blk, 1); } } ztr->hcodes_checked = 1; } /* Check cached copies */ for (i = 0; i < ztr->nhcodes; i++) { if (ztr->hcodes[i].codes->code_set == code_set) return &ztr->hcodes[i]; } return NULL; }