fix bug in growstack
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1718 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
feca28c235
commit
e112ce1a8a
@ -11,8 +11,11 @@
|
|||||||
* File: cdmgr.c *
|
* File: cdmgr.c *
|
||||||
* comments: Code manager *
|
* comments: Code manager *
|
||||||
* *
|
* *
|
||||||
* Last rev: $Date: 2006-11-06 18:35:03 $,$Author: vsc $ *
|
* Last rev: $Date: 2006-11-14 11:42:25 $,$Author: vsc $ *
|
||||||
* $Log: not supported by cvs2svn $
|
* $Log: not supported by cvs2svn $
|
||||||
|
* Revision 1.197 2006/11/06 18:35:03 vsc
|
||||||
|
* 1estranha
|
||||||
|
*
|
||||||
* Revision 1.196 2006/10/16 17:12:48 vsc
|
* Revision 1.196 2006/10/16 17:12:48 vsc
|
||||||
* fixes for threaded version.
|
* fixes for threaded version.
|
||||||
*
|
*
|
||||||
@ -5653,6 +5656,7 @@ p_choicepoint_info(void)
|
|||||||
pe = UndefCode;
|
pe = UndefCode;
|
||||||
t = MkVarTerm();
|
t = MkVarTerm();
|
||||||
break;
|
break;
|
||||||
|
#endif /* TABLING */
|
||||||
case _try_logical:
|
case _try_logical:
|
||||||
case _retry_logical:
|
case _retry_logical:
|
||||||
case _trust_logical:
|
case _trust_logical:
|
||||||
@ -5660,10 +5664,9 @@ p_choicepoint_info(void)
|
|||||||
case _count_trust_logical:
|
case _count_trust_logical:
|
||||||
case _profiled_retry_logical:
|
case _profiled_retry_logical:
|
||||||
case _profiled_trust_logical:
|
case _profiled_trust_logical:
|
||||||
pe = ipc->u.lld.n->ClPred;
|
pe = ipc->u.lld.d->ClPred;
|
||||||
t = BuildActivePred(pe, cptr->cp_args);
|
t = BuildActivePred(pe, cptr->cp_args);
|
||||||
break;
|
break;
|
||||||
#endif /* TABLING */
|
|
||||||
case _or_else:
|
case _or_else:
|
||||||
pe = ipc->u.sla.p0;
|
pe = ipc->u.sla.p0;
|
||||||
t = Yap_MkNewApplTerm(FunctorOr, 2);
|
t = Yap_MkNewApplTerm(FunctorOr, 2);
|
||||||
|
46
C/globals.c
46
C/globals.c
@ -95,6 +95,8 @@ CreateNewArena(CELL *ptr, UInt size)
|
|||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if COROUTINING
|
||||||
|
|
||||||
/* pointer to top of an arena */
|
/* pointer to top of an arena */
|
||||||
static inline attvar_record *
|
static inline attvar_record *
|
||||||
DelayArenaPt(Term arena)
|
DelayArenaPt(Term arena)
|
||||||
@ -181,6 +183,8 @@ GrowDelayArena(Term *arenap, UInt old_size, UInt size, UInt arity)
|
|||||||
return arena;
|
return arena;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
static Term
|
static Term
|
||||||
NewArena(UInt size, UInt arity, CELL *where)
|
NewArena(UInt size, UInt arity, CELL *where)
|
||||||
{
|
{
|
||||||
@ -247,7 +251,9 @@ p_allocate_default_arena(void)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
GlobalArena = NewArena(IntegerOfTerm(t), 2, NULL);
|
GlobalArena = NewArena(IntegerOfTerm(t), 2, NULL);
|
||||||
|
#if COROUTINING
|
||||||
GlobalDelayArena = NewDelayArena(2);
|
GlobalDelayArena = NewDelayArena(2);
|
||||||
|
#endif
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,6 +336,8 @@ clean_dirty_tr(tr_fr_ptr TR0) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if COROUTINING
|
||||||
|
|
||||||
static int
|
static int
|
||||||
CopyAttVar(CELL *orig, CELL ***to_visit_ptr, CELL *res, Term *att_arenap)
|
CopyAttVar(CELL *orig, CELL ***to_visit_ptr, CELL *res, Term *att_arenap)
|
||||||
{
|
{
|
||||||
@ -361,6 +369,7 @@ CopyAttVar(CELL *orig, CELL ***to_visit_ptr, CELL *res, Term *att_arenap)
|
|||||||
*att_arenap = (CELL)(newv);
|
*att_arenap = (CELL)(newv);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int
|
static int
|
||||||
copy_complex_term(register CELL *pt0, register CELL *pt0_end, CELL *ptf, CELL *HLow, Term *att_arenap)
|
copy_complex_term(register CELL *pt0, register CELL *pt0_end, CELL *ptf, CELL *HLow, Term *att_arenap)
|
||||||
@ -627,6 +636,7 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, CELL *ptf, CELL *H
|
|||||||
reset_trail(TR0);
|
reset_trail(TR0);
|
||||||
return -2;
|
return -2;
|
||||||
|
|
||||||
|
#if COROUTINING
|
||||||
delay_overflow:
|
delay_overflow:
|
||||||
/* oops, we're in trouble */
|
/* oops, we're in trouble */
|
||||||
H = HLow;
|
H = HLow;
|
||||||
@ -644,6 +654,7 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, CELL *ptf, CELL *H
|
|||||||
#endif
|
#endif
|
||||||
reset_trail(TR0);
|
reset_trail(TR0);
|
||||||
return -2;
|
return -2;
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -655,10 +666,14 @@ CopyTermToArena(Term t, Term arena, UInt arity, Term *newarena, Term *att_arenap
|
|||||||
CELL *oldHB = HB;
|
CELL *oldHB = HB;
|
||||||
CELL *oldASP = ASP;
|
CELL *oldASP = ASP;
|
||||||
int res;
|
int res;
|
||||||
|
#if COROUTINING
|
||||||
Term old_delay_arena;
|
Term old_delay_arena;
|
||||||
|
#endif
|
||||||
|
|
||||||
restart:
|
restart:
|
||||||
|
#if COROUTINING
|
||||||
old_delay_arena = *att_arenap;
|
old_delay_arena = *att_arenap;
|
||||||
|
#endif
|
||||||
t = Deref(t);
|
t = Deref(t);
|
||||||
if (IsVarTerm(t)) {
|
if (IsVarTerm(t)) {
|
||||||
ASP = ArenaLimit(arena);
|
ASP = ArenaLimit(arena);
|
||||||
@ -769,8 +784,10 @@ CopyTermToArena(Term t, Term arena, UInt arity, Term *newarena, Term *att_arenap
|
|||||||
error_handler:
|
error_handler:
|
||||||
H = HB;
|
H = HB;
|
||||||
CloseArena(oldH, oldHB, oldASP, newarena, old_size);
|
CloseArena(oldH, oldHB, oldASP, newarena, old_size);
|
||||||
|
#if COROUTINING
|
||||||
if (old_delay_arena != MkIntTerm(0))
|
if (old_delay_arena != MkIntTerm(0))
|
||||||
ResetDelayArena(old_delay_arena, att_arenap);
|
ResetDelayArena(old_delay_arena, att_arenap);
|
||||||
|
#endif
|
||||||
XREGS[arity+1] = t;
|
XREGS[arity+1] = t;
|
||||||
XREGS[arity+2] = arena;
|
XREGS[arity+2] = arena;
|
||||||
XREGS[arity+3] = (CELL)newarena;
|
XREGS[arity+3] = (CELL)newarena;
|
||||||
@ -788,6 +805,7 @@ CopyTermToArena(Term t, Term arena, UInt arity, Term *newarena, Term *att_arenap
|
|||||||
return 0L;
|
return 0L;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#if COROUTINING
|
||||||
case -2:
|
case -2:
|
||||||
/* handle delay arena overflow */
|
/* handle delay arena overflow */
|
||||||
old_size = DelayArenaSz(*att_arenap);
|
old_size = DelayArenaSz(*att_arenap);
|
||||||
@ -796,6 +814,7 @@ CopyTermToArena(Term t, Term arena, UInt arity, Term *newarena, Term *att_arenap
|
|||||||
return 0L;
|
return 0L;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
default: /* temporary space overflow */
|
default: /* temporary space overflow */
|
||||||
if (!Yap_ExpandPreAllocCodeSpace(0,NULL)) {
|
if (!Yap_ExpandPreAllocCodeSpace(0,NULL)) {
|
||||||
Yap_Error(OUT_OF_AUXSPACE_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(OUT_OF_AUXSPACE_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
@ -999,7 +1018,10 @@ p_nb_delete(void)
|
|||||||
static Int
|
static Int
|
||||||
p_nb_queue(void)
|
p_nb_queue(void)
|
||||||
{
|
{
|
||||||
Term queue_arena, delay_queue_arena, queue, ar[5], *nar;
|
Term queue_arena, queue, ar[5], *nar;
|
||||||
|
#if COROUTINING
|
||||||
|
Term delay_queue_arena;
|
||||||
|
#endif
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
UInt arena_sz = (H-H0)/16;
|
UInt arena_sz = (H-H0)/16;
|
||||||
|
|
||||||
@ -1018,6 +1040,7 @@ p_nb_queue(void)
|
|||||||
queue = Yap_MkApplTerm(FunctorNBQueue,5,ar);
|
queue = Yap_MkApplTerm(FunctorNBQueue,5,ar);
|
||||||
if (!Yap_unify(queue,ARG1))
|
if (!Yap_unify(queue,ARG1))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
#if COROUTINING
|
||||||
arena_sz = ((attvar_record *)H0- DelayTop())/16;
|
arena_sz = ((attvar_record *)H0- DelayTop())/16;
|
||||||
if (arena_sz <2)
|
if (arena_sz <2)
|
||||||
arena_sz = 2;
|
arena_sz = 2;
|
||||||
@ -1029,6 +1052,7 @@ p_nb_queue(void)
|
|||||||
}
|
}
|
||||||
nar = RepAppl(Deref(ARG1))+1;
|
nar = RepAppl(Deref(ARG1))+1;
|
||||||
nar[QUEUE_DELAY_ARENA] = delay_queue_arena;
|
nar[QUEUE_DELAY_ARENA] = delay_queue_arena;
|
||||||
|
#endif
|
||||||
if (arena_sz < 4*1024)
|
if (arena_sz < 4*1024)
|
||||||
arena_sz = 4*1024;
|
arena_sz = 4*1024;
|
||||||
queue_arena = NewArena(arena_sz,1,NULL);
|
queue_arena = NewArena(arena_sz,1,NULL);
|
||||||
@ -1080,6 +1104,7 @@ GetQueueArena(CELL *qd, char* caller)
|
|||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if COROUTINING
|
||||||
static void
|
static void
|
||||||
RecoverDelayArena(Term delay_arena)
|
RecoverDelayArena(Term delay_arena)
|
||||||
{
|
{
|
||||||
@ -1089,6 +1114,7 @@ RecoverDelayArena(Term delay_arena)
|
|||||||
if (max == pt-DelayArenaSz(delay_arena))
|
if (max == pt-DelayArenaSz(delay_arena))
|
||||||
SetDelayTop(pt);
|
SetDelayTop(pt);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RecoverArena(Term arena)
|
RecoverArena(Term arena)
|
||||||
@ -1116,8 +1142,10 @@ p_nb_queue_close(void)
|
|||||||
}
|
}
|
||||||
if (qp[QUEUE_ARENA] != MkIntTerm(0))
|
if (qp[QUEUE_ARENA] != MkIntTerm(0))
|
||||||
RecoverArena(qp[QUEUE_ARENA]);
|
RecoverArena(qp[QUEUE_ARENA]);
|
||||||
|
#if COROUTINING
|
||||||
if (qp[QUEUE_DELAY_ARENA] != MkIntTerm(0))
|
if (qp[QUEUE_DELAY_ARENA] != MkIntTerm(0))
|
||||||
RecoverDelayArena(qp[QUEUE_DELAY_ARENA]);
|
RecoverDelayArena(qp[QUEUE_DELAY_ARENA]);
|
||||||
|
#endif
|
||||||
if (qp[QUEUE_SIZE] == MkIntTerm(0)) {
|
if (qp[QUEUE_SIZE] == MkIntTerm(0)) {
|
||||||
return
|
return
|
||||||
Yap_unify(ARG3, ARG2);
|
Yap_unify(ARG3, ARG2);
|
||||||
@ -1293,7 +1321,10 @@ MkZeroApplTerm(Functor f, UInt sz)
|
|||||||
static Int
|
static Int
|
||||||
p_nb_heap(void)
|
p_nb_heap(void)
|
||||||
{
|
{
|
||||||
Term heap_arena, delay_heap_arena, heap, *ar, *nar;
|
Term heap_arena, heap, *ar, *nar;
|
||||||
|
#if COROUTINING
|
||||||
|
Term delay_heap_arena;
|
||||||
|
#endif
|
||||||
UInt hsize;
|
UInt hsize;
|
||||||
Term tsize = Deref(ARG1);
|
Term tsize = Deref(ARG1);
|
||||||
UInt arena_sz = (H-H0)/16;
|
UInt arena_sz = (H-H0)/16;
|
||||||
@ -1331,6 +1362,7 @@ p_nb_heap(void)
|
|||||||
}
|
}
|
||||||
nar = RepAppl(Deref(ARG2))+1;
|
nar = RepAppl(Deref(ARG2))+1;
|
||||||
nar[HEAP_ARENA] = heap_arena;
|
nar[HEAP_ARENA] = heap_arena;
|
||||||
|
#if COROUTINING
|
||||||
arena_sz = ((attvar_record *)H0- DelayTop())/16;
|
arena_sz = ((attvar_record *)H0- DelayTop())/16;
|
||||||
if (arena_sz <2)
|
if (arena_sz <2)
|
||||||
arena_sz = 2;
|
arena_sz = 2;
|
||||||
@ -1342,6 +1374,7 @@ p_nb_heap(void)
|
|||||||
}
|
}
|
||||||
nar = RepAppl(Deref(ARG2))+1;
|
nar = RepAppl(Deref(ARG2))+1;
|
||||||
nar[HEAP_DELAY_ARENA] = delay_heap_arena;
|
nar[HEAP_DELAY_ARENA] = delay_heap_arena;
|
||||||
|
#endif
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1355,8 +1388,10 @@ p_nb_heap_close(void)
|
|||||||
qp = RepAppl(t)+1;
|
qp = RepAppl(t)+1;
|
||||||
if (qp[HEAP_ARENA] != MkIntTerm(0))
|
if (qp[HEAP_ARENA] != MkIntTerm(0))
|
||||||
RecoverArena(qp[HEAP_ARENA]);
|
RecoverArena(qp[HEAP_ARENA]);
|
||||||
|
#if COROUTINING
|
||||||
if (qp[HEAP_DELAY_ARENA] != MkIntTerm(0))
|
if (qp[HEAP_DELAY_ARENA] != MkIntTerm(0))
|
||||||
RecoverDelayArena(qp[HEAP_DELAY_ARENA]);
|
RecoverDelayArena(qp[HEAP_DELAY_ARENA]);
|
||||||
|
#endif
|
||||||
qp[-1] = (CELL)Yap_MkFunctor(Yap_LookupAtom("heap"),1);
|
qp[-1] = (CELL)Yap_MkFunctor(Yap_LookupAtom("heap"),1);
|
||||||
qp[0] = MkIntegerTerm(0);
|
qp[0] = MkIntegerTerm(0);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -1582,7 +1617,10 @@ p_nb_heap_size(void)
|
|||||||
static Int
|
static Int
|
||||||
p_nb_beam(void)
|
p_nb_beam(void)
|
||||||
{
|
{
|
||||||
Term beam_arena, delay_beam_arena, beam, *ar, *nar;
|
Term beam_arena, beam, *ar, *nar;
|
||||||
|
#if COROUTINING
|
||||||
|
Term delay_beam_arena;
|
||||||
|
#endif
|
||||||
UInt hsize;
|
UInt hsize;
|
||||||
Term tsize = Deref(ARG1);
|
Term tsize = Deref(ARG1);
|
||||||
UInt arena_sz = (H-H0)/16;
|
UInt arena_sz = (H-H0)/16;
|
||||||
@ -1619,6 +1657,7 @@ p_nb_beam(void)
|
|||||||
}
|
}
|
||||||
nar = RepAppl(Deref(ARG2))+1;
|
nar = RepAppl(Deref(ARG2))+1;
|
||||||
nar[HEAP_ARENA] = beam_arena;
|
nar[HEAP_ARENA] = beam_arena;
|
||||||
|
#if COROUTINING
|
||||||
arena_sz = ((attvar_record *)H0- DelayTop())/16;
|
arena_sz = ((attvar_record *)H0- DelayTop())/16;
|
||||||
if (arena_sz <2)
|
if (arena_sz <2)
|
||||||
arena_sz = 2;
|
arena_sz = 2;
|
||||||
@ -1630,6 +1669,7 @@ p_nb_beam(void)
|
|||||||
}
|
}
|
||||||
nar = RepAppl(Deref(ARG2))+1;
|
nar = RepAppl(Deref(ARG2))+1;
|
||||||
nar[HEAP_DELAY_ARENA] = delay_beam_arena;
|
nar[HEAP_DELAY_ARENA] = delay_beam_arena;
|
||||||
|
#endif
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
3
C/grow.c
3
C/grow.c
@ -599,7 +599,8 @@ static_growglobal(long size, CELL **ptr, CELL *hsplit)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
else if (hsplit == (CELL *)omax)
|
else if (hsplit == (CELL *)omax)
|
||||||
hsplit = NULL;
|
hsplit = NULL;
|
||||||
if (size+H < ASP+4096) {
|
if (size+H < ASP+4096 &&
|
||||||
|
hsplit > H0) {
|
||||||
/* don't need to expand stacks */
|
/* don't need to expand stacks */
|
||||||
do_grow = FALSE;
|
do_grow = FALSE;
|
||||||
}
|
}
|
||||||
|
@ -337,10 +337,10 @@ write_var(CELL *t, struct write_globs *wglb)
|
|||||||
Yap_Portray_delays = TRUE;
|
Yap_Portray_delays = TRUE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
wrputc('D', wglb->writech);
|
wrputc('D', wglb->writech);
|
||||||
wrputn((Int) ((attvar_record *)H0-(attvar_record *)t),wglb->writech);
|
wrputn((Int) ((attvar_record *)H0-(attvar_record *)t),wglb->writech);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
wrputn(((Int) (t- H0)),wglb->writech);
|
wrputn(((Int) (t- H0)),wglb->writech);
|
||||||
}
|
}
|
||||||
|
@ -135,5 +135,4 @@ file_search_path(system, Dir) :-
|
|||||||
|
|
||||||
:- dynamic library_directory/1.
|
:- dynamic library_directory/1.
|
||||||
|
|
||||||
|
:- yap_flag(index,single).
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user