cleanups
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1617 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
9101c18410
commit
720db316ce
4
C/grow.c
4
C/grow.c
@ -1307,6 +1307,10 @@ static int do_growtrail(long size, int contiguous_only, int in_parser, tr_fr_ptr
|
|||||||
UInt start_growth_time = Yap_cputime(), growth_time;
|
UInt start_growth_time = Yap_cputime(), growth_time;
|
||||||
int gc_verbose = Yap_is_gc_verbose();
|
int gc_verbose = Yap_is_gc_verbose();
|
||||||
|
|
||||||
|
#if USE_SYSTEM_MALLOC
|
||||||
|
if (contiguous_only)
|
||||||
|
return FALSE;
|
||||||
|
#endif
|
||||||
/* at least 64K for trail */
|
/* at least 64K for trail */
|
||||||
if (size < 64*1024)
|
if (size < 64*1024)
|
||||||
size = 64*1024;
|
size = 64*1024;
|
||||||
|
13
C/heapgc.c
13
C/heapgc.c
@ -149,18 +149,12 @@ static rb_red_blk_node *db_root, *db_nil;
|
|||||||
static void
|
static void
|
||||||
gc_growtrail(int committed)
|
gc_growtrail(int committed)
|
||||||
{
|
{
|
||||||
#if USE_SYSTEM_MALLOC
|
|
||||||
TR = OldTR;
|
|
||||||
save_machine_regs();
|
|
||||||
longjmp(Yap_gc_restore, 2);
|
|
||||||
#else
|
|
||||||
if (!Yap_growtrail(64 * 1024L, TRUE)) {
|
if (!Yap_growtrail(64 * 1024L, TRUE)) {
|
||||||
|
TR = OldTR;
|
||||||
/* could not find more trail */
|
/* could not find more trail */
|
||||||
save_machine_regs();
|
save_machine_regs();
|
||||||
longjmp(Yap_gc_restore, 2);
|
longjmp(Yap_gc_restore, 2);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static void
|
inline static void
|
||||||
@ -1600,8 +1594,9 @@ mark_trail(tr_fr_ptr trail_ptr, tr_fr_ptr trail_base, CELL *gc_H, choiceptr gc_B
|
|||||||
tr_fr_ptr nsTR = (tr_fr_ptr)cont_top0;
|
tr_fr_ptr nsTR = (tr_fr_ptr)cont_top0;
|
||||||
CELL *cptr = (CELL *)trail_cell;
|
CELL *cptr = (CELL *)trail_cell;
|
||||||
|
|
||||||
if ((ADDR)nsTR > Yap_TrailTop-1024)
|
if ((ADDR)nsTR > Yap_TrailTop-1024) {
|
||||||
Yap_growtrail(64 * 1024L, TRUE);
|
gc_growtrail(TRUE);
|
||||||
|
}
|
||||||
TrailTerm(nsTR) = (CELL)NULL;
|
TrailTerm(nsTR) = (CELL)NULL;
|
||||||
TrailTerm(nsTR+1) = *hp;
|
TrailTerm(nsTR+1) = *hp;
|
||||||
TrailTerm(nsTR+2) = trail_cell;
|
TrailTerm(nsTR+2) = trail_cell;
|
||||||
|
@ -128,13 +128,6 @@ typedef struct scanner_extra_alloc {
|
|||||||
void *filler;
|
void *filler;
|
||||||
} ScannerExtraBlock;
|
} ScannerExtraBlock;
|
||||||
|
|
||||||
/* Problem: we use realloc so we cannot guarantee beforehand pointers will shift or not */
|
|
||||||
#if USE_SYSTEM_MALLOC
|
|
||||||
#define EXPAND_TRAIL FALSE
|
|
||||||
#else
|
|
||||||
#define EXPAND_TRAIL TRUE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
AllocScannerMemory(unsigned int size)
|
AllocScannerMemory(unsigned int size)
|
||||||
{
|
{
|
||||||
@ -156,7 +149,7 @@ AllocScannerMemory(unsigned int size)
|
|||||||
|
|
||||||
if (size > alloc_size)
|
if (size > alloc_size)
|
||||||
alloc_size = size;
|
alloc_size = size;
|
||||||
if(!EXPAND_TRAIL || !Yap_growtrail(alloc_size, TRUE)) {
|
if(!Yap_growtrail(alloc_size, TRUE)) {
|
||||||
struct scanner_extra_alloc *ptr;
|
struct scanner_extra_alloc *ptr;
|
||||||
|
|
||||||
if (!(ptr = (struct scanner_extra_alloc *)malloc(size+sizeof(ScannerExtraBlock)))) {
|
if (!(ptr = (struct scanner_extra_alloc *)malloc(size+sizeof(ScannerExtraBlock)))) {
|
||||||
|
12
C/write.c
12
C/write.c
@ -453,12 +453,16 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb)
|
|||||||
#ifdef USE_GMP
|
#ifdef USE_GMP
|
||||||
case (CELL)FunctorBigInt:
|
case (CELL)FunctorBigInt:
|
||||||
{
|
{
|
||||||
char *s = (char *)TR;
|
|
||||||
MP_INT *big = Yap_BigIntOfTerm(t);
|
MP_INT *big = Yap_BigIntOfTerm(t);
|
||||||
while (s+2+mpz_sizeinbase(big, 10) > (char *)Yap_TrailTop) {
|
char *s = (char *)TR;
|
||||||
Yap_growtrail(2+mpz_sizeinbase(big, 10), TRUE);
|
if (s+2+mpz_sizeinbase(big, 10) >= Yap_TrailTop) {
|
||||||
big = Yap_BigIntOfTerm(t);
|
s = H;
|
||||||
|
if (s+2+mpz_sizeinbase(big, 10) >= ASP) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (!s)
|
||||||
|
return;
|
||||||
if (mpz_sgn(big) < 0) {
|
if (mpz_sgn(big) < 0) {
|
||||||
if (lastw == symbol)
|
if (lastw == symbol)
|
||||||
wrputc(' ', wglb->writech);
|
wrputc(' ', wglb->writech);
|
||||||
|
Reference in New Issue
Block a user