From 442e5e0b81c143a5c5dc7a47dc5a6e634bed509b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Fri, 15 Apr 2011 23:04:23 +0100 Subject: [PATCH 1/5] make sure we always allocate aligned quantities. --- C/alloc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/C/alloc.c b/C/alloc.c index e5796a14d..4d0b5362a 100755 --- a/C/alloc.c +++ b/C/alloc.c @@ -153,6 +153,7 @@ call_malloc(unsigned long int size) char * Yap_AllocCodeSpace(unsigned long int size) { + size = AdjustSize(size); return call_malloc(size); } @@ -186,6 +187,7 @@ call_realloc(char *p, unsigned long int size) char * Yap_ReallocCodeSpace(char *p, unsigned long int size) { + size = AdjustSize(size); return call_realloc(p, size); } @@ -211,6 +213,7 @@ Yap_FreeCodeSpace(char *p) char * Yap_AllocAtomSpace(unsigned long int size) { + size = AdjustSize(size); return call_malloc(size); } From 7a78d5c200d59f8205fd27ccc2b8c70812361a41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Fri, 15 Apr 2011 23:05:03 +0100 Subject: [PATCH 2/5] initialise initial ENV fully. --- C/exec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/C/exec.c b/C/exec.c index 935f35793..2bf6ea74c 100644 --- a/C/exec.c +++ b/C/exec.c @@ -1018,6 +1018,9 @@ init_stack(int arity, CELL *pt, int top, choiceptr saved_b USES_REGS) YENV[E_CP] = (CELL)P; YENV[E_CB] = (CELL)B; YENV[E_E] = (CELL)ENV; +#ifdef TABLING + YENV[E_B] = (CELL)B; +#endif #ifdef DEPTH_LIMIT YENV[E_DEPTH] = DEPTH; #endif From 0b0d8872759465c2fc6171810635d83df7827c72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Fri, 15 Apr 2011 23:07:56 +0100 Subject: [PATCH 3/5] initialise H0[-1]: avoid complaints from valgrind during gc. --- C/exec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/C/exec.c b/C/exec.c index 2bf6ea74c..8024fb95f 100644 --- a/C/exec.c +++ b/C/exec.c @@ -1624,6 +1624,7 @@ Yap_InitYaamRegs(void) if (Yap_AttsSize > (Yap_LocalBase-Yap_GlobalBase)/8) Yap_AttsSize = (Yap_LocalBase-Yap_GlobalBase)/8; H = H0 = ((CELL *) Yap_GlobalBase)+ Yap_AttsSize/sizeof(CELL); + RESET_VARIABLE(H0-1); LCL0 = ASP = (CELL *) Yap_LocalBase; /* notice that an initial choice-point and environment *must* be created since for the garbage collector to work */ From a7079bd770be62239963d3160c90da7d1413e2f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Sat, 16 Apr 2011 00:31:25 +0100 Subject: [PATCH 4/5] don't reset frozen refernces to clauses. --- C/absmi.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/C/absmi.c b/C/absmi.c index 2bea1c218..d120ea521 100755 --- a/C/absmi.c +++ b/C/absmi.c @@ -2068,6 +2068,11 @@ Yap_absmi(int inp) #endif /* FROZEN_STACKS */ if (IN_BETWEEN(H0,pt1,H) && IsAttVar(pt1)) goto failloop; +#ifdef FROZEN_STACKS /* TRAIL */ + /* don't reset frozen variables */ + if (pt0 < TR_FZ) + goto failloop; +#endif flags = *pt1; #if MULTIPLE_STACKS if (FlagOn(DBClMask, flags)) { From 5946c111f5e20f0f91594b5fc8398a97bec0d845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Sat, 16 Apr 2011 00:31:51 +0100 Subject: [PATCH 5/5] can't tryst Yap_HeapTop in malloc memory manager. --- C/arrays.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/C/arrays.c b/C/arrays.c index 2114aa77d..43f103ed9 100644 --- a/C/arrays.c +++ b/C/arrays.c @@ -170,8 +170,10 @@ CloseMmappedArray(StaticArrayEntry *pp, void *area USES_REGS) optr = ptr; } if (ptr == NULL) { +#if !defined(USE_SYSTEM_MALLOC) Yap_Error(SYSTEM_ERROR,ARG1,"close_mmapped_array (array chain incoherent)", strerror(errno)); - return(FALSE); +#endif + return FALSE; } if (munmap(ptr->start, ptr->size) == -1) { Yap_Error(SYSTEM_ERROR,ARG1,"close_mmapped_array (munmap: %s)", strerror(errno)); @@ -1240,7 +1242,11 @@ p_close_static_array( USES_REGS1 ) #if HAVE_MMAP if (ptr->ValueOfVE.chars < (char *)Yap_HeapBase || ptr->ValueOfVE.chars > (char *)HeapTop) { - return(CloseMmappedArray(ptr, (void *)ptr->ValueOfVE.chars PASS_REGS)); + Int val = CloseMmappedArray(ptr, (void *)ptr->ValueOfVE.chars PASS_REGS); +#if USE_SYSTEM_MALLOC + if (val) +#endif + return(val); } #endif Yap_FreeAtomSpace((char *)(ptr->ValueOfVE.ints));