make gc work better with globals and even lots of globals
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1940 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
109b2a586f
commit
c7344ca385
20
C/globals.c
20
C/globals.c
@ -296,26 +296,28 @@ GrowArena(Term arena, CELL *pt, UInt old_size, UInt size, UInt arity)
|
||||
return FALSE;
|
||||
}
|
||||
arena = XREGS[arity+1];
|
||||
/* we don't know if the GC added junk on top of the global */
|
||||
pt = ArenaLimit(arena);
|
||||
return GrowArena(arena, pt, old_size, size, arity);
|
||||
}
|
||||
adjust_cps(size);
|
||||
H += size;
|
||||
} else {
|
||||
XREGS[arity+1] = arena;
|
||||
if ((size=Yap_InsertInGlobal(pt, size*sizeof(CELL)))==0) {
|
||||
return FALSE;
|
||||
}
|
||||
size = size/sizeof(CELL);
|
||||
arena = XREGS[arity+1];
|
||||
#if 0
|
||||
/* try to recover some room */
|
||||
if (arena == GlobalArena) {
|
||||
if (!Yap_gc(arity+1, ENV, P)) {
|
||||
if (arena == GlobalArena && 10*(pt-H0) > 8*(H-H0)) {
|
||||
if (!Yap_gcl(size*sizeof(CELL), arity+1, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR,TermNil,Yap_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
arena = XREGS[arity+1];
|
||||
#endif
|
||||
pt = ArenaLimit(arena);
|
||||
if ((size=Yap_InsertInGlobal(pt, size*sizeof(CELL)))==0) {
|
||||
return FALSE;
|
||||
}
|
||||
size = size/sizeof(CELL);
|
||||
arena = XREGS[arity+1];
|
||||
}
|
||||
CreateNewArena(ArenaPt(arena), size+old_size);
|
||||
return TRUE;
|
||||
|
26
C/heapgc.c
26
C/heapgc.c
@ -417,6 +417,17 @@ GC_NEW_MAHASH(gc_ma_hash_entry *top) {
|
||||
|
||||
/* find all accessible objects on the heap and squeeze out all the rest */
|
||||
|
||||
static void
|
||||
check_pr_trail(tr_fr_ptr trp)
|
||||
{
|
||||
if ((tr_fr_ptr)Yap_TrailTop-TR < 1024) {
|
||||
if (!Yap_growtrail(0, TRUE) || TRUE) {
|
||||
/* could not find more trail */
|
||||
save_machine_regs();
|
||||
longjmp(Yap_gc_restore, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* push the active registers onto the trail for inclusion during gc */
|
||||
|
||||
@ -432,10 +443,12 @@ push_registers(Int num_regs, yamop *nextop)
|
||||
TrailTerm(TR++) = GlobalArena;
|
||||
TrailTerm(TR++) = GlobalDelayArena;
|
||||
while (al) {
|
||||
check_pr_trail(TR);
|
||||
TrailTerm(TR++) = al->ValueOfVE;
|
||||
al = al->NextAE;
|
||||
}
|
||||
while (gl) {
|
||||
check_pr_trail(TR);
|
||||
TrailTerm(TR++) = gl->global;
|
||||
gl = gl->NextGE;
|
||||
}
|
||||
@ -445,12 +458,14 @@ push_registers(Int num_regs, yamop *nextop)
|
||||
for (i=0; i < arity; i++) {
|
||||
Term tlive = sal->ValueOfVE.lterms[i].tlive;
|
||||
if (!IsVarTerm(tlive) || !IsUnboundVar(&sal->ValueOfVE.lterms[i].tlive)) {
|
||||
check_pr_trail(TR);
|
||||
TrailTerm(TR++) = tlive;
|
||||
}
|
||||
}
|
||||
}
|
||||
sal = sal->NextAE;
|
||||
}
|
||||
check_pr_trail(TR);
|
||||
TrailTerm(TR) = GcGeneration;
|
||||
TR++;
|
||||
TrailTerm(TR) = GcPhase;
|
||||
@ -461,8 +476,10 @@ push_registers(Int num_regs, yamop *nextop)
|
||||
TrailTerm(TR+2) = DelayedVars;
|
||||
TR += 3;
|
||||
#endif
|
||||
for (i = 1; i <= num_regs; i++)
|
||||
for (i = 1; i <= num_regs; i++) {
|
||||
check_pr_trail(TR);
|
||||
TrailTerm(TR++) = (CELL) XREGS[i];
|
||||
}
|
||||
/* push any live registers we might have hanging around */
|
||||
if (nextop->opc == Yap_opcode(_move_back) ||
|
||||
nextop->opc == Yap_opcode(_skip)) {
|
||||
@ -478,6 +495,7 @@ push_registers(Int num_regs, yamop *nextop)
|
||||
lab++;
|
||||
}
|
||||
if (curr & 1) {
|
||||
check_pr_trail(TR);
|
||||
TrailTerm(TR++) = XREGS[i];
|
||||
}
|
||||
curr >>= 1;
|
||||
@ -3668,13 +3686,9 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop)
|
||||
|
||||
gc_phase = (UInt)IntegerOfTerm(Yap_ReadTimedVar(GcPhase));
|
||||
/* old HGEN are not very reliable, but still may have data to recover */
|
||||
#ifdef FIX
|
||||
if (gc_phase != GcCurrentPhase) {
|
||||
HGEN = H0;
|
||||
}
|
||||
#else
|
||||
HGEN = H0;
|
||||
#endif
|
||||
/* fprintf(stderr,"HGEN is %ld, %p, %p/%p\n", IntegerOfTerm(Yap_ReadTimedVar(GcGeneration)), HGEN, H,H0);*/
|
||||
OldTR = (tr_fr_ptr)(old_TR = TR);
|
||||
push_registers(predarity, nextop);
|
||||
@ -3724,10 +3738,8 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop)
|
||||
pop_registers(predarity, nextop);
|
||||
TR = new_TR;
|
||||
/* fprintf(Yap_stderr,"NEW HGEN %ld (%ld)\n", H-H0, HGEN-H0);*/
|
||||
#ifdef FIX
|
||||
Yap_UpdateTimedVar(GcGeneration, MkIntegerTerm(H-H0));
|
||||
Yap_UpdateTimedVar(GcPhase, MkIntegerTerm(GcCurrentPhase));
|
||||
#endif
|
||||
c_time = Yap_cputime();
|
||||
if (gc_verbose) {
|
||||
fprintf(Yap_stderr, "%% Compress: took %g sec\n", (double)(c_time-time_start)/1000);
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
<h2>Yap-5.1.3:</h2>
|
||||
<ul>
|
||||
<li> FIXED: overflow while gc was storing pointers in trail (obs from Angelika Kimmig).</li>
|
||||
<li> FIXED: implement directive encoding/1 (obs from Paulo Moura).</li>
|
||||
<li> UPGRADED: to current JPL.</li>
|
||||
<li> FIXED: incremental garbage collection conflicts with global variables (disable it for now).</li>
|
||||
|
Reference in New Issue
Block a user