handle blob overflows.

This commit is contained in:
Vítor Santos Costa
2011-12-22 10:27:56 +00:00
parent 32ebfe00fd
commit 551df1c70a
10 changed files with 83 additions and 16 deletions

View File

@@ -1421,15 +1421,17 @@ Yap_growheap(int fix_code, UInt in_size, void *cip)
{
CACHE_REGS
int res;
int blob_overflow = (NOfBlobs > NOfBlobsMax);
if (NOfAtoms > 2*AtomHashTableSize) {
if (NOfAtoms > 2*AtomHashTableSize || blob_overflow) {
UInt n = NOfAtoms;
if (GLOBAL_AGcThreshold)
Yap_atom_gc( PASS_REGS1 );
/* check if we have a significant improvement from agc */
if (n > NOfAtoms+ NOfAtoms/10 ||
/* +1 = make sure we didn't lose the current atom */
NOfAtoms+1 > 2*AtomHashTableSize) {
if (!blob_overflow &&
(n > NOfAtoms+ NOfAtoms/10 ||
/* +1 = make sure we didn't lose the current atom */
NOfAtoms+1 > 2*AtomHashTableSize)) {
res = growatomtable( PASS_REGS1 );
} else {
LOCK(LOCAL_SignalLock);
@@ -1444,7 +1446,12 @@ Yap_growheap(int fix_code, UInt in_size, void *cip)
if (res)
return res;
}
#if USE_SYSTEM_MALLOC
P = Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"malloc failed");
res = -1;
#else
res=do_growheap(fix_code, in_size, (struct intermediates *)cip, NULL, NULL, NULL PASS_REGS);
#endif
LeaveGrowMode(GrowHeapMode);
return res;
}