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;
|
return FALSE;
|
||||||
}
|
}
|
||||||
arena = XREGS[arity+1];
|
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);
|
adjust_cps(size);
|
||||||
H += size;
|
H += size;
|
||||||
} else {
|
} else {
|
||||||
XREGS[arity+1] = arena;
|
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 */
|
/* try to recover some room */
|
||||||
if (arena == GlobalArena) {
|
if (arena == GlobalArena && 10*(pt-H0) > 8*(H-H0)) {
|
||||||
if (!Yap_gc(arity+1, ENV, P)) {
|
if (!Yap_gcl(size*sizeof(CELL), arity+1, ENV, P)) {
|
||||||
Yap_Error(OUT_OF_STACK_ERROR,TermNil,Yap_ErrorMessage);
|
Yap_Error(OUT_OF_STACK_ERROR,TermNil,Yap_ErrorMessage);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
arena = XREGS[arity+1];
|
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);
|
CreateNewArena(ArenaPt(arena), size+old_size);
|
||||||
return TRUE;
|
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 */
|
/* 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 */
|
/* 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++) = GlobalArena;
|
||||||
TrailTerm(TR++) = GlobalDelayArena;
|
TrailTerm(TR++) = GlobalDelayArena;
|
||||||
while (al) {
|
while (al) {
|
||||||
|
check_pr_trail(TR);
|
||||||
TrailTerm(TR++) = al->ValueOfVE;
|
TrailTerm(TR++) = al->ValueOfVE;
|
||||||
al = al->NextAE;
|
al = al->NextAE;
|
||||||
}
|
}
|
||||||
while (gl) {
|
while (gl) {
|
||||||
|
check_pr_trail(TR);
|
||||||
TrailTerm(TR++) = gl->global;
|
TrailTerm(TR++) = gl->global;
|
||||||
gl = gl->NextGE;
|
gl = gl->NextGE;
|
||||||
}
|
}
|
||||||
@ -445,12 +458,14 @@ push_registers(Int num_regs, yamop *nextop)
|
|||||||
for (i=0; i < arity; i++) {
|
for (i=0; i < arity; i++) {
|
||||||
Term tlive = sal->ValueOfVE.lterms[i].tlive;
|
Term tlive = sal->ValueOfVE.lterms[i].tlive;
|
||||||
if (!IsVarTerm(tlive) || !IsUnboundVar(&sal->ValueOfVE.lterms[i].tlive)) {
|
if (!IsVarTerm(tlive) || !IsUnboundVar(&sal->ValueOfVE.lterms[i].tlive)) {
|
||||||
|
check_pr_trail(TR);
|
||||||
TrailTerm(TR++) = tlive;
|
TrailTerm(TR++) = tlive;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sal = sal->NextAE;
|
sal = sal->NextAE;
|
||||||
}
|
}
|
||||||
|
check_pr_trail(TR);
|
||||||
TrailTerm(TR) = GcGeneration;
|
TrailTerm(TR) = GcGeneration;
|
||||||
TR++;
|
TR++;
|
||||||
TrailTerm(TR) = GcPhase;
|
TrailTerm(TR) = GcPhase;
|
||||||
@ -461,8 +476,10 @@ push_registers(Int num_regs, yamop *nextop)
|
|||||||
TrailTerm(TR+2) = DelayedVars;
|
TrailTerm(TR+2) = DelayedVars;
|
||||||
TR += 3;
|
TR += 3;
|
||||||
#endif
|
#endif
|
||||||
for (i = 1; i <= num_regs; i++)
|
for (i = 1; i <= num_regs; i++) {
|
||||||
|
check_pr_trail(TR);
|
||||||
TrailTerm(TR++) = (CELL) XREGS[i];
|
TrailTerm(TR++) = (CELL) XREGS[i];
|
||||||
|
}
|
||||||
/* push any live registers we might have hanging around */
|
/* push any live registers we might have hanging around */
|
||||||
if (nextop->opc == Yap_opcode(_move_back) ||
|
if (nextop->opc == Yap_opcode(_move_back) ||
|
||||||
nextop->opc == Yap_opcode(_skip)) {
|
nextop->opc == Yap_opcode(_skip)) {
|
||||||
@ -478,6 +495,7 @@ push_registers(Int num_regs, yamop *nextop)
|
|||||||
lab++;
|
lab++;
|
||||||
}
|
}
|
||||||
if (curr & 1) {
|
if (curr & 1) {
|
||||||
|
check_pr_trail(TR);
|
||||||
TrailTerm(TR++) = XREGS[i];
|
TrailTerm(TR++) = XREGS[i];
|
||||||
}
|
}
|
||||||
curr >>= 1;
|
curr >>= 1;
|
||||||
@ -3668,13 +3686,9 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop)
|
|||||||
|
|
||||||
gc_phase = (UInt)IntegerOfTerm(Yap_ReadTimedVar(GcPhase));
|
gc_phase = (UInt)IntegerOfTerm(Yap_ReadTimedVar(GcPhase));
|
||||||
/* old HGEN are not very reliable, but still may have data to recover */
|
/* old HGEN are not very reliable, but still may have data to recover */
|
||||||
#ifdef FIX
|
|
||||||
if (gc_phase != GcCurrentPhase) {
|
if (gc_phase != GcCurrentPhase) {
|
||||||
HGEN = H0;
|
HGEN = H0;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
HGEN = H0;
|
|
||||||
#endif
|
|
||||||
/* fprintf(stderr,"HGEN is %ld, %p, %p/%p\n", IntegerOfTerm(Yap_ReadTimedVar(GcGeneration)), HGEN, H,H0);*/
|
/* fprintf(stderr,"HGEN is %ld, %p, %p/%p\n", IntegerOfTerm(Yap_ReadTimedVar(GcGeneration)), HGEN, H,H0);*/
|
||||||
OldTR = (tr_fr_ptr)(old_TR = TR);
|
OldTR = (tr_fr_ptr)(old_TR = TR);
|
||||||
push_registers(predarity, nextop);
|
push_registers(predarity, nextop);
|
||||||
@ -3724,10 +3738,8 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop)
|
|||||||
pop_registers(predarity, nextop);
|
pop_registers(predarity, nextop);
|
||||||
TR = new_TR;
|
TR = new_TR;
|
||||||
/* fprintf(Yap_stderr,"NEW HGEN %ld (%ld)\n", H-H0, HGEN-H0);*/
|
/* fprintf(Yap_stderr,"NEW HGEN %ld (%ld)\n", H-H0, HGEN-H0);*/
|
||||||
#ifdef FIX
|
|
||||||
Yap_UpdateTimedVar(GcGeneration, MkIntegerTerm(H-H0));
|
Yap_UpdateTimedVar(GcGeneration, MkIntegerTerm(H-H0));
|
||||||
Yap_UpdateTimedVar(GcPhase, MkIntegerTerm(GcCurrentPhase));
|
Yap_UpdateTimedVar(GcPhase, MkIntegerTerm(GcCurrentPhase));
|
||||||
#endif
|
|
||||||
c_time = Yap_cputime();
|
c_time = Yap_cputime();
|
||||||
if (gc_verbose) {
|
if (gc_verbose) {
|
||||||
fprintf(Yap_stderr, "%% Compress: took %g sec\n", (double)(c_time-time_start)/1000);
|
fprintf(Yap_stderr, "%% Compress: took %g sec\n", (double)(c_time-time_start)/1000);
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
<h2>Yap-5.1.3:</h2>
|
<h2>Yap-5.1.3:</h2>
|
||||||
<ul>
|
<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> FIXED: implement directive encoding/1 (obs from Paulo Moura).</li>
|
||||||
<li> UPGRADED: to current JPL.</li>
|
<li> UPGRADED: to current JPL.</li>
|
||||||
<li> FIXED: incremental garbage collection conflicts with global variables (disable it for now).</li>
|
<li> FIXED: incremental garbage collection conflicts with global variables (disable it for now).</li>
|
||||||
|
Reference in New Issue
Block a user