fixes for YapRunGoal

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@541 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2002-06-18 02:27:53 +00:00
parent b48f1264b9
commit 944d2e8aed
4 changed files with 29 additions and 24 deletions

View File

@ -5701,6 +5701,7 @@ absmi(int inp)
save_machine_regs(); save_machine_regs();
SREG = (CELL *) YapExecute(p, (CPredicate)(p->TrueCodeOfPred)); SREG = (CELL *) YapExecute(p, (CPredicate)(p->TrueCodeOfPred));
EX = 0L;
} }
restore_machine_regs(); restore_machine_regs();
@ -5829,6 +5830,7 @@ absmi(int inp)
saveregs(); saveregs();
save_machine_regs(); save_machine_regs();
SREG = (CELL *) YapExecute(PREG->u.lds.p, (CPredicate)(PREG->u.lds.d)); SREG = (CELL *) YapExecute(PREG->u.lds.p, (CPredicate)(PREG->u.lds.d));
EX = 0L;
restore_machine_regs(); restore_machine_regs();
setregs(); setregs();
if (!SREG) { if (!SREG) {

View File

@ -689,17 +689,21 @@ static void myputc (int ch)
putc(ch,stderr); putc(ch,stderr);
} }
static Term told;
X_API int X_API int
YapRunGoal(Term t) YapRunGoal(Term t)
{ {
int out; int out;
yamop *old_CP = CP;
BACKUP_MACHINE_REGS(); BACKUP_MACHINE_REGS();
do_putcf = myputc;
out = RunTopGoal(t); out = RunTopGoal(t);
told = t; if (out) {
P = (yamop *)ENV[E_CP];
ENV = (CELL *)ENV[E_E];
CP = old_CP;
} else {
B = B->cp_b;
}
RECOVER_MACHINE_REGS(); RECOVER_MACHINE_REGS();
return(out); return(out);
@ -743,6 +747,7 @@ YapPruneGoal(void)
while (B->cp_ap != NOCODE) { while (B->cp_ap != NOCODE) {
B = B->cp_b; B = B->cp_b;
} }
B = B->cp_b;
RECOVER_B(); RECOVER_B();
} }

View File

@ -924,22 +924,14 @@ do_goal(CODEADDR CodeAdr, int arity, CELL *pt, int args_to_save, int top)
#ifdef DEPTH_LIMIT #ifdef DEPTH_LIMIT
B->cp_depth = DEPTH; B->cp_depth = DEPTH;
#endif /* DEPTH_LIMIT */ #endif /* DEPTH_LIMIT */
if (top) {
#if COROUTINING
RESET_VARIABLE((CELL *)GlobalBase);
DelayedVars = NewTimedVar((CELL)GlobalBase);
WokenGoals = NewTimedVar(TermNil);
MutableList = NewTimedVar(TermNil);
AttsMutableList = NewTimedVar(TermNil);
#endif
}
YENV = ASP = (CELL *)B; YENV = ASP = (CELL *)B;
HB = H; HB = H;
YENV[E_CB] = Unsigned (B); YENV[E_CB] = Unsigned (B);
P = (yamop *) CodeAdr; P = (yamop *) CodeAdr;
CP = YESCODE;
S = CellPtr (RepPredProp (PredPropByFunc (MkFunctor(AtomCall, 1),0))); /* A1 mishaps */ S = CellPtr (RepPredProp (PredPropByFunc (MkFunctor(AtomCall, 1),0))); /* A1 mishaps */
return(exec_absmi(top)); return(exec_absmi(top));
} }
@ -1073,6 +1065,7 @@ RunTopGoal(Term t)
CELL *pt; CELL *pt;
UInt arity; UInt arity;
SMALLUNSGN mod = CurrentModule; SMALLUNSGN mod = CurrentModule;
int goal_out = 0;
restart_runtopgoal: restart_runtopgoal:
if (IsAtomTerm(t)) { if (IsAtomTerm(t)) {
@ -1109,23 +1102,21 @@ RunTopGoal(Term t)
if (pe != NIL) { if (pe != NIL) {
READ_LOCK(ppe->PRWLock); READ_LOCK(ppe->PRWLock);
} }
if (pe == NIL || if (pe == NIL) {
ppe->OpcodeOfPred == UNDEF_OPCODE || if (pe != NIL) {
ppe->PredFlags & (UserCPredFlag|CPredFlag|AsmPredFlag) ) READ_UNLOCK(ppe->PRWLock);
{
if (pe != NIL) {
READ_UNLOCK(ppe->PRWLock);
}
/* we must always start the emulator with Prolog code */
return(FALSE);
} }
/* we must always start the emulator with Prolog code */
return(FALSE);
}
CodeAdr = ppe->CodeOfPred; CodeAdr = ppe->CodeOfPred;
if (TrailTop - HeapTop < 2048) { if (TrailTop - HeapTop < 2048) {
PrologMode = BootMode; PrologMode = BootMode;
Error(SYSTEM_ERROR,TermNil, Error(SYSTEM_ERROR,TermNil,
"unable to boot because of too little heap space"); "unable to boot because of too little heap space");
} }
return(do_goal(CodeAdr, arity, pt, 0, TRUE)); goal_out = do_goal(CodeAdr, arity, pt, 0, TRUE);
return(goal_out);
} }
static void static void

View File

@ -1123,6 +1123,13 @@ InitYaamRegs(void)
EX = 0L; EX = 0L;
/* for slots to work */ /* for slots to work */
*--ASP = MkIntTerm(0); *--ASP = MkIntTerm(0);
#if COROUTINING
RESET_VARIABLE((CELL *)GlobalBase);
DelayedVars = NewTimedVar((CELL)GlobalBase);
WokenGoals = NewTimedVar(TermNil);
MutableList = NewTimedVar(TermNil);
AttsMutableList = NewTimedVar(TermNil);
#endif
} }