From 7b29ef15529f6850ba5710bee0c2b672b69c4f7b Mon Sep 17 00:00:00 2001 From: vsc Date: Fri, 29 Sep 2006 18:59:00 +0000 Subject: [PATCH] avoid doing full stack shifting when on top of stack. git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1699 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/globals.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/C/globals.c b/C/globals.c index 30843296d..0e4f7dd4a 100644 --- a/C/globals.c +++ b/C/globals.c @@ -265,8 +265,10 @@ GrowArena(Term arena, CELL *pt, UInt old_size, UInt size, UInt arity) if (size < 4096) { size = 4096; } - if (pt == H && ArenaPt(arena) >= B->cp_h) { + if (pt == H) { + choiceptr b_ptr; if (H+size > ASP-1024) { + XREGS[arity+1] = arena; if (!Yap_gcl(size*sizeof(CELL), arity+1, ENV, P)) { Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage); @@ -274,6 +276,12 @@ GrowArena(Term arena, CELL *pt, UInt old_size, UInt size, UInt arity) } arena = XREGS[arity+1]; } + /* adjust possible back pointers in choice-point stack */ + b_ptr = B; + while (b_ptr->cp_h == H) { + b_ptr->cp_h += size; + b_ptr = b_ptr->cp_b; + } H += size; } else { XREGS[arity+1] = arena;