make sure that YAP_Restart does not restart a failed goal.

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1855 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2007-03-22 11:12:22 +00:00
parent a8409c5f52
commit 0b7083adb2
7 changed files with 36 additions and 16 deletions

View File

@ -10,8 +10,11 @@
* File: c_interface.c *
* comments: c_interface primitives definition *
* *
* Last rev: $Date: 2007-01-28 14:26:36 $,$Author: vsc $ *
* Last rev: $Date: 2007-03-22 11:12:20 $,$Author: vsc $ *
* $Log: not supported by cvs2svn $
* Revision 1.89 2007/01/28 14:26:36 vsc
* WIN32 support
*
* Revision 1.88 2007/01/08 08:27:19 vsc
* fix restore (Trevor)
* make indexing a bit faster on IDB
@ -1063,6 +1066,7 @@ YAP_RunGoal(Term t)
yamop *old_CP = CP;
BACKUP_MACHINE_REGS();
Yap_AllowRestart = FALSE;
Yap_PrologMode = UserMode;
out = Yap_RunTopGoal(t);
Yap_PrologMode = UserCCallMode;
@ -1070,11 +1074,13 @@ YAP_RunGoal(Term t)
P = (yamop *)ENV[E_CP];
ENV = (CELL *)ENV[E_E];
CP = old_CP;
Yap_AllowRestart = TRUE;
} else {
if (B != NULL) /* restore might have destroyed B */
B = B->cp_b;
Yap_AllowRestart = FALSE;
}
RECOVER_MACHINE_REGS();
return(out);
}
@ -1084,17 +1090,22 @@ YAP_RestartGoal(void)
{
int out;
BACKUP_MACHINE_REGS();
P = (yamop *)FAILCODE;
do_putcf = myputc;
Yap_PrologMode = UserMode;
out = Yap_exec_absmi(TRUE);
Yap_PrologMode = UserCCallMode;
if (out == FALSE) {
/* cleanup */
Yap_trust_last();
if (Yap_AllowRestart) {
fprintf(stderr,"Allow restart\n");
P = (yamop *)FAILCODE;
do_putcf = myputc;
Yap_PrologMode = UserMode;
out = Yap_exec_absmi(TRUE);
Yap_PrologMode = UserCCallMode;
if (out == FALSE) {
/* cleanup */
Yap_trust_last();
Yap_AllowRestart = FALSE;
}
} else {
out = FALSE;
}
RECOVER_MACHINE_REGS();
return(out);
}

View File

@ -986,6 +986,7 @@ InitCodes(void)
Yap_heap_regs->wl[i].global_variables = NULL;
Yap_heap_regs->wl[i].global_arena = 0L;
Yap_heap_regs->wl[i].global_delay_arena = 0L;
Yap_heap_regs->wl[i].allow_restart = FALSE;
Yap_heap_regs->wl[i].consultlow = (consult_obj *)Yap_AllocCodeSpace(sizeof(consult_obj)*InitialConsultCapacity);
if (Yap_heap_regs->wl[i].consultlow == NULL) {
Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"No Heap Space in InitCodes");
@ -1001,6 +1002,7 @@ InitCodes(void)
Yap_heap_regs->wl.static_arrays = NULL;
Yap_heap_regs->wl.global_variables = NULL;
Yap_heap_regs->wl.global_arena = 0L;
Yap_heap_regs->wl.allow_restart = FALSE;
Yap_heap_regs->wl.global_delay_arena = 0L;
Yap_heap_regs->wl.consultlow = (consult_obj *)Yap_AllocCodeSpace(sizeof(consult_obj)*InitialConsultCapacity);
if (Yap_heap_regs->wl.consultlow == NULL) {

View File

@ -10,7 +10,7 @@
* File: Heap.h *
* mods: *
* comments: Heap Init Structure *
* version: $Id: Heap.h,v 1.113 2007-02-18 00:26:36 vsc Exp $ *
* version: $Id: Heap.h,v 1.114 2007-03-22 11:12:21 vsc Exp $ *
*************************************************************************/
/* information that can be stored in Code Space */
@ -166,6 +166,7 @@ typedef struct worker_local_struct {
struct array_entry *dynamic_arrays;
struct static_array_entry *static_arrays;
struct global_entry *global_variables;
int allow_restart;
Term global_arena;
Term global_delay_arena;
yamop trust_lu_code[3];
@ -919,6 +920,7 @@ struct various_codes *Yap_heap_regs;
#define StaticArrays Yap_heap_regs->WL.static_arrays
#define GlobalVariables Yap_heap_regs->WL.global_variables
#define GlobalArena Yap_heap_regs->WL.global_arena
#define Yap_AllowRestart Yap_heap_regs->WL.allow_restart
#define GlobalDelayArena Yap_heap_regs->WL.global_delay_arena
#define profiling Yap_heap_regs->compiler_profiling
#define call_counting Yap_heap_regs->compiler_call_counting

View File

@ -11,8 +11,12 @@
* File: rheap.h *
* comments: walk through heap code *
* *
* Last rev: $Date: 2007-02-18 00:26:36 $,$Author: vsc $ *
* Last rev: $Date: 2007-03-22 11:12:21 $,$Author: vsc $ *
* $Log: not supported by cvs2svn $
* Revision 1.73 2007/02/18 00:26:36 vsc
* fix atom garbage collector (although it is still off by default)
* make valgrind feel better
*
* Revision 1.72 2007/01/08 08:27:19 vsc
* fix restore (Trevor)
* make indexing a bit faster on IDB
@ -773,6 +777,7 @@ restore_codes(void)
Yap_heap_regs->wl.global_delay_arena =
GlobalAdjust(Yap_heap_regs->wl.global_delay_arena);
}
Yap_heap_regs->wl.allow_restart = FALSE;
#endif
#endif
if (Yap_heap_regs->last_wtime != NULL)

View File

@ -676,7 +676,7 @@ exec_top_level(int BootMode, YAP_init_args *iap)
YAP_PutValue(livegoal, YAP_MkAtomTerm (YAP_FullLookupAtom("$true")));
}
/* the top-level is now ready */
/* the top-level is now ready */
/* read it before case someone, that is, Ashwin, hides
the atom false away ;-).

View File

@ -120,4 +120,3 @@ getrand(rand(X,Y,Z)) :-

View File

@ -1075,3 +1075,4 @@ throw(Ball) :-
nb_setval('$system_mode',off),
( nb_getval('$trace',on) -> '$creep' ; true).