tightenn conditions on JumpExec
This commit is contained in:
parent
dd6426b3b9
commit
15519fa3cd
10
C/exec.c
10
C/exec.c
@ -1439,7 +1439,7 @@ suspended_on_current_execution(Term t, Term t0)
|
||||
attvar_record *susp = (attvar_record *)VarOfTerm(t);
|
||||
Term t1 = susp->Atts;
|
||||
/* should be prolog(_,Something) */
|
||||
if(IsVarTerm(t1) || !IsApplTerm(t1))
|
||||
if(IsVarTerm(t1) || !IsApplTerm(t1) || FunctorOfTerm(t1) != FunctorPrologConstraint)
|
||||
return FALSE;
|
||||
t1 = ArgOfTerm(2, t1);
|
||||
/* Something = [Goal] */
|
||||
@ -1449,15 +1449,15 @@ suspended_on_current_execution(Term t, Term t0)
|
||||
return FALSE;
|
||||
t1 = HeadOfTerm(t1);
|
||||
/* Goal = $redo_freeze(_,_,Suspended) */
|
||||
if(IsVarTerm(t1) || !IsApplTerm(t1))
|
||||
if(IsVarTerm(t1) || !IsApplTerm(t1) || FunctorOfTerm(t1) != FunctorRedoFreeze)
|
||||
return FALSE;
|
||||
t1 = ArgOfTerm(3,t1);
|
||||
/* Suspended = Mod:Cod */
|
||||
if(IsVarTerm(t1) || !IsApplTerm(t1))
|
||||
if(IsVarTerm(t1) || !IsApplTerm(t1) || FunctorOfTerm(t1) != FunctorModule)
|
||||
return FALSE;
|
||||
t1 = ArgOfTerm(2,t1);
|
||||
/* Cod = $clean_call(t0,_) */
|
||||
if(IsVarTerm(t1) || !IsApplTerm(t1))
|
||||
if(IsVarTerm(t1) || !IsApplTerm(t1) || FunctorOfTerm(t1) != FunctorCleanCall)
|
||||
return FALSE;
|
||||
/* we found what was on the cp */
|
||||
return t0 == ArgOfTerm(1, t1);
|
||||
@ -1526,7 +1526,7 @@ JumpToEnv(Term t) {
|
||||
CELL *env;
|
||||
choiceptr first_func = NULL, B0 = B;
|
||||
|
||||
if (!(t = Yap_SetGlobalVal(AtomHandleThrow,t)))
|
||||
if (!(t = Yap_SaveTerm(t)))
|
||||
return FALSE;
|
||||
do {
|
||||
/* find the first choicepoint that may be a catch */
|
||||
|
40
C/globals.c
40
C/globals.c
@ -387,7 +387,7 @@ CopyAttVar(CELL *orig, struct cp_frame **to_visit_ptr, CELL *res, Term *att_aren
|
||||
#endif
|
||||
|
||||
static int
|
||||
copy_complex_term(register CELL *pt0, register CELL *pt0_end, int share, CELL *ptf, CELL *HLow, Term *att_arenap)
|
||||
copy_complex_term(register CELL *pt0, register CELL *pt0_end, int share, int copy_att_vars, CELL *ptf, CELL *HLow, Term *att_arenap)
|
||||
{
|
||||
|
||||
struct cp_frame *to_visit0, *to_visit = (struct cp_frame *)Yap_PreAllocCodeSpace();
|
||||
@ -571,7 +571,7 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, int share, CELL *p
|
||||
*ptf++ = (CELL) ptd0;
|
||||
} else {
|
||||
#if COROUTINING
|
||||
if (IsAttachedTerm((CELL)ptd0)) {
|
||||
if (IsAttachedTerm((CELL)ptd0) && copy_att_vars) {
|
||||
/* if unbound, call the standard copy term routine */
|
||||
struct cp_frame *bp[1];
|
||||
|
||||
@ -708,7 +708,7 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, int share, CELL *p
|
||||
}
|
||||
|
||||
static Term
|
||||
CopyTermToArena(Term t, Term arena, int share, UInt arity, Term *newarena, Term *att_arenap, UInt min_grow)
|
||||
CopyTermToArena(Term t, Term arena, int share, int copy_att_vars, UInt arity, Term *newarena, Term *att_arenap, UInt min_grow)
|
||||
{
|
||||
UInt old_size = ArenaSz(arena);
|
||||
CELL *oldH = H;
|
||||
@ -735,7 +735,7 @@ CopyTermToArena(Term t, Term arena, int share, UInt arity, Term *newarena, Term
|
||||
*H = t;
|
||||
Hi = H+1;
|
||||
H += 2;
|
||||
if ((res = copy_complex_term(Hi-2, Hi-1, share, Hi, Hi, att_arenap)) < 0)
|
||||
if ((res = copy_complex_term(Hi-2, Hi-1, share, copy_att_vars, Hi, Hi, att_arenap)) < 0)
|
||||
goto error_handler;
|
||||
CloseArena(oldH, oldHB, oldASP, newarena, old_size);
|
||||
return Hi[0];
|
||||
@ -768,7 +768,7 @@ CopyTermToArena(Term t, Term arena, int share, UInt arity, Term *newarena, Term
|
||||
Hi = H;
|
||||
tf = AbsPair(H);
|
||||
H += 2;
|
||||
if ((res = copy_complex_term(ap-1, ap+1, share, Hi, Hi, att_arenap)) < 0) {
|
||||
if ((res = copy_complex_term(ap-1, ap+1, share, copy_att_vars, Hi, Hi, att_arenap)) < 0) {
|
||||
goto error_handler;
|
||||
}
|
||||
CloseArena(oldH, oldHB, oldASP, newarena, old_size);
|
||||
@ -838,7 +838,7 @@ CopyTermToArena(Term t, Term arena, int share, UInt arity, Term *newarena, Term
|
||||
res = -1;
|
||||
goto error_handler;
|
||||
}
|
||||
if ((res = copy_complex_term(ap, ap+ArityOfFunctor(f), share, HB0+1, HB0, att_arenap)) < 0) {
|
||||
if ((res = copy_complex_term(ap, ap+ArityOfFunctor(f), share, copy_att_vars, HB0+1, HB0, att_arenap)) < 0) {
|
||||
goto error_handler;
|
||||
}
|
||||
}
|
||||
@ -1071,7 +1071,7 @@ p_nb_setarg(void)
|
||||
}
|
||||
if (pos < 1 || pos > arity)
|
||||
return FALSE;
|
||||
to = CopyTermToArena(ARG3, GlobalArena, FALSE, 2, &GlobalArena, &GlobalDelayArena, garena_overflow_size(ArenaPt(GlobalArena)));
|
||||
to = CopyTermToArena(ARG3, GlobalArena, FALSE, TRUE, 2, &GlobalArena, &GlobalDelayArena, garena_overflow_size(ArenaPt(GlobalArena)));
|
||||
if (to == 0L)
|
||||
return FALSE;
|
||||
destp[pos] = to;
|
||||
@ -1111,7 +1111,7 @@ p_nb_set_shared_arg(void)
|
||||
}
|
||||
if (pos < 1 || pos > arity)
|
||||
return FALSE;
|
||||
to = CopyTermToArena(ARG3, GlobalArena, TRUE, 2, &GlobalArena, &GlobalDelayArena, garena_overflow_size(ArenaPt(GlobalArena)));
|
||||
to = CopyTermToArena(ARG3, GlobalArena, TRUE, TRUE, 2, &GlobalArena, &GlobalDelayArena, garena_overflow_size(ArenaPt(GlobalArena)));
|
||||
if (to == 0L)
|
||||
return FALSE;
|
||||
destp[pos] = to;
|
||||
@ -1180,7 +1180,7 @@ Yap_SetGlobalVal(Atom at, Term t0)
|
||||
Term to;
|
||||
GlobalEntry *ge;
|
||||
ge = GetGlobalEntry(at);
|
||||
to = CopyTermToArena(t0, GlobalArena, FALSE, 2, &GlobalArena, &GlobalDelayArena, garena_overflow_size(ArenaPt(GlobalArena)));
|
||||
to = CopyTermToArena(t0, GlobalArena, FALSE, TRUE, 2, &GlobalArena, &GlobalDelayArena, garena_overflow_size(ArenaPt(GlobalArena)));
|
||||
if (to == 0L)
|
||||
return to;
|
||||
WRITE_LOCK(ge->GRWLock);
|
||||
@ -1189,6 +1189,16 @@ Yap_SetGlobalVal(Atom at, Term t0)
|
||||
return to;
|
||||
}
|
||||
|
||||
Term
|
||||
Yap_SaveTerm(Term t0)
|
||||
{
|
||||
Term to;
|
||||
to = CopyTermToArena(t0, GlobalArena, FALSE, TRUE, 2, &GlobalArena, &GlobalDelayArena, garena_overflow_size(ArenaPt(GlobalArena)));
|
||||
if (to == 0L)
|
||||
return to;
|
||||
return to;
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_setval(void)
|
||||
{
|
||||
@ -1216,7 +1226,7 @@ p_nb_set_shared_val(void)
|
||||
return (FALSE);
|
||||
}
|
||||
ge = GetGlobalEntry(AtomOfTerm(t));
|
||||
to = CopyTermToArena(ARG2, GlobalArena, TRUE, 2, &GlobalArena, &GlobalDelayArena, garena_overflow_size(ArenaPt(GlobalArena)));
|
||||
to = CopyTermToArena(ARG2, GlobalArena, TRUE, TRUE, 2, &GlobalArena, &GlobalDelayArena, garena_overflow_size(ArenaPt(GlobalArena)));
|
||||
if (to == 0L)
|
||||
return FALSE;
|
||||
WRITE_LOCK(ge->GRWLock);
|
||||
@ -1627,7 +1637,7 @@ p_nb_queue_enqueue(void)
|
||||
} else {
|
||||
min_size = 0L;
|
||||
}
|
||||
to = CopyTermToArena(ARG2, arena, FALSE, 2, qd+QUEUE_ARENA, qd+QUEUE_DELAY_ARENA, min_size);
|
||||
to = CopyTermToArena(ARG2, arena, FALSE, TRUE, 2, qd+QUEUE_ARENA, qd+QUEUE_DELAY_ARENA, min_size);
|
||||
if (to == 0L)
|
||||
return FALSE;
|
||||
qd = GetQueue(ARG1,"enqueue");
|
||||
@ -1959,9 +1969,9 @@ p_nb_heap_add_to_heap(void)
|
||||
if (arena == 0L)
|
||||
return FALSE;
|
||||
mingrow = garena_overflow_size(ArenaPt(arena));
|
||||
key = CopyTermToArena(ARG2, arena, FALSE, 3, qd+HEAP_ARENA, qd+HEAP_DELAY_ARENA, mingrow);
|
||||
key = CopyTermToArena(ARG2, arena, FALSE, TRUE, 3, qd+HEAP_ARENA, qd+HEAP_DELAY_ARENA, mingrow);
|
||||
arena = qd[HEAP_ARENA];
|
||||
to = CopyTermToArena(ARG3, arena, FALSE, 3, qd+HEAP_ARENA, qd+HEAP_DELAY_ARENA, mingrow);
|
||||
to = CopyTermToArena(ARG3, arena, FALSE, TRUE, 3, qd+HEAP_ARENA, qd+HEAP_DELAY_ARENA, mingrow);
|
||||
if (key == 0 || to == 0L)
|
||||
return FALSE;
|
||||
qd = GetHeap(ARG1,"add_to_heap");
|
||||
@ -2362,9 +2372,9 @@ p_nb_beam_add_to_beam(void)
|
||||
if (arena == 0L)
|
||||
return FALSE;
|
||||
mingrow = garena_overflow_size(ArenaPt(arena));
|
||||
key = CopyTermToArena(ARG2, qd[HEAP_ARENA], FALSE, 3, qd+HEAP_ARENA, qd+HEAP_DELAY_ARENA, mingrow);
|
||||
key = CopyTermToArena(ARG2, qd[HEAP_ARENA], FALSE, TRUE, 3, qd+HEAP_ARENA, qd+HEAP_DELAY_ARENA, mingrow);
|
||||
arena = qd[HEAP_ARENA];
|
||||
to = CopyTermToArena(ARG3, arena, FALSE, 3, qd+HEAP_ARENA, qd+HEAP_DELAY_ARENA, mingrow);
|
||||
to = CopyTermToArena(ARG3, arena, FALSE, TRUE, 3, qd+HEAP_ARENA, qd+HEAP_DELAY_ARENA, mingrow);
|
||||
if (key == 0 || to == 0L)
|
||||
return FALSE;
|
||||
qd = GetHeap(ARG1,"add_to_beam");
|
||||
|
@ -188,6 +188,7 @@ void STD_PROTO(Yap_inform_profiler_of_clause,(struct yami *,struct yami *,struct
|
||||
/* globals.c */
|
||||
Term STD_PROTO(Yap_NewArena,(UInt,CELL *));
|
||||
void STD_PROTO(Yap_InitGlobals,(void));
|
||||
Term STD_PROTO(Yap_SaveTerm, (Term));
|
||||
Term STD_PROTO(Yap_SetGlobalVal, (Atom, Term));
|
||||
void STD_PROTO(Yap_AllocateDefaultArena, (Int, Int));
|
||||
|
||||
|
@ -41,6 +41,7 @@
|
||||
AtomCharsio = Yap_LookupAtom("charsio");
|
||||
AtomCharacter = Yap_LookupAtom("character");
|
||||
AtomCharacterCode = Yap_LookupAtom("character_code");
|
||||
AtomCleanCall = Yap_FullLookupAtom("$clean_call");
|
||||
AtomColomn = Yap_LookupAtom(":");
|
||||
AtomCodeSpace = Yap_LookupAtom("code_space");
|
||||
AtomComma = Yap_LookupAtom(",");
|
||||
@ -209,6 +210,7 @@
|
||||
AtomReadutil = Yap_LookupAtom("readutil");
|
||||
AtomRecordedP = Yap_FullLookupAtom("$recordep");
|
||||
AtomRecordedWithKey = Yap_FullLookupAtom("$recorded_with_key");
|
||||
AtomRedoFreeze = Yap_FullLookupAtom("$redo_freeze");
|
||||
AtomRefoundVar = Yap_FullLookupAtom("$I_FOUND_THE_VARIABLE_AGAIN");
|
||||
AtomRepeat = Yap_LookupAtom("repeat");
|
||||
AtomRepeatSpace = Yap_LookupAtom("repeat ");
|
||||
@ -309,6 +311,7 @@
|
||||
FunctorCall = Yap_MkFunctor(AtomCall,1);
|
||||
FunctorCatch = Yap_MkFunctor(AtomCatch,3);
|
||||
FunctorChangeModule = Yap_MkFunctor(AtomChangeModule,1);
|
||||
FunctorCleanCall = Yap_MkFunctor(AtomCleanCall,2);
|
||||
FunctorClist = Yap_MkFunctor(AtomWhen,4);
|
||||
FunctorComma = Yap_MkFunctor(AtomComma,2);
|
||||
FunctorContext2 = Yap_MkFunctor(AtomContext,2);
|
||||
@ -371,8 +374,10 @@
|
||||
FunctorOr = Yap_MkFunctor(AtomSemic,2);
|
||||
FunctorPermissionError = Yap_MkFunctor(AtomPermissionError,3);
|
||||
FunctorPortray = Yap_MkFunctor(AtomPortray,1);
|
||||
FunctorPrologConstraint = Yap_MkFunctor(AtomProlog,2);
|
||||
FunctorQuery = Yap_MkFunctor(AtomQuery,1);
|
||||
FunctorRecordedWithKey = Yap_MkFunctor(AtomRecordedWithKey,6);
|
||||
FunctorRedoFreeze = Yap_MkFunctor(AtomRedoFreeze,3);
|
||||
FunctorRepresentationError = Yap_MkFunctor(AtomRepresentationError,1);
|
||||
FunctorResourceError = Yap_MkFunctor(AtomResourceError,1);
|
||||
FunctorRestoreRegs = Yap_MkFunctor(AtomRestoreRegs,2);
|
||||
|
@ -41,6 +41,7 @@
|
||||
AtomCharsio = AtomAdjust(AtomCharsio);
|
||||
AtomCharacter = AtomAdjust(AtomCharacter);
|
||||
AtomCharacterCode = AtomAdjust(AtomCharacterCode);
|
||||
AtomCleanCall = AtomAdjust(AtomCleanCall);
|
||||
AtomColomn = AtomAdjust(AtomColomn);
|
||||
AtomCodeSpace = AtomAdjust(AtomCodeSpace);
|
||||
AtomComma = AtomAdjust(AtomComma);
|
||||
@ -211,6 +212,7 @@
|
||||
AtomReadutil = AtomAdjust(AtomReadutil);
|
||||
AtomRecordedP = AtomAdjust(AtomRecordedP);
|
||||
AtomRecordedWithKey = AtomAdjust(AtomRecordedWithKey);
|
||||
AtomRedoFreeze = AtomAdjust(AtomRedoFreeze);
|
||||
AtomRefoundVar = AtomAdjust(AtomRefoundVar);
|
||||
AtomRepeat = AtomAdjust(AtomRepeat);
|
||||
AtomRepeatSpace = AtomAdjust(AtomRepeatSpace);
|
||||
@ -311,6 +313,7 @@
|
||||
FunctorCall = FuncAdjust(FunctorCall);
|
||||
FunctorCatch = FuncAdjust(FunctorCatch);
|
||||
FunctorChangeModule = FuncAdjust(FunctorChangeModule);
|
||||
FunctorCleanCall = FuncAdjust(FunctorCleanCall);
|
||||
FunctorClist = FuncAdjust(FunctorClist);
|
||||
FunctorComma = FuncAdjust(FunctorComma);
|
||||
FunctorContext2 = FuncAdjust(FunctorContext2);
|
||||
@ -373,8 +376,10 @@
|
||||
FunctorOr = FuncAdjust(FunctorOr);
|
||||
FunctorPermissionError = FuncAdjust(FunctorPermissionError);
|
||||
FunctorPortray = FuncAdjust(FunctorPortray);
|
||||
FunctorPrologConstraint = FuncAdjust(FunctorPrologConstraint);
|
||||
FunctorQuery = FuncAdjust(FunctorQuery);
|
||||
FunctorRecordedWithKey = FuncAdjust(FunctorRecordedWithKey);
|
||||
FunctorRedoFreeze = FuncAdjust(FunctorRedoFreeze);
|
||||
FunctorRepresentationError = FuncAdjust(FunctorRepresentationError);
|
||||
FunctorResourceError = FuncAdjust(FunctorResourceError);
|
||||
FunctorRestoreRegs = FuncAdjust(FunctorRestoreRegs);
|
||||
|
10
H/tatoms.h
10
H/tatoms.h
@ -84,6 +84,8 @@
|
||||
#define AtomCharacter Yap_heap_regs->AtomCharacter_
|
||||
Atom AtomCharacterCode_;
|
||||
#define AtomCharacterCode Yap_heap_regs->AtomCharacterCode_
|
||||
Atom AtomCleanCall_;
|
||||
#define AtomCleanCall Yap_heap_regs->AtomCleanCall_
|
||||
Atom AtomColomn_;
|
||||
#define AtomColomn Yap_heap_regs->AtomColomn_
|
||||
Atom AtomCodeSpace_;
|
||||
@ -424,6 +426,8 @@
|
||||
#define AtomRecordedP Yap_heap_regs->AtomRecordedP_
|
||||
Atom AtomRecordedWithKey_;
|
||||
#define AtomRecordedWithKey Yap_heap_regs->AtomRecordedWithKey_
|
||||
Atom AtomRedoFreeze_;
|
||||
#define AtomRedoFreeze Yap_heap_regs->AtomRedoFreeze_
|
||||
Atom AtomRefoundVar_;
|
||||
#define AtomRefoundVar Yap_heap_regs->AtomRefoundVar_
|
||||
Atom AtomRepeat_;
|
||||
@ -624,6 +628,8 @@
|
||||
#define FunctorCatch Yap_heap_regs->FunctorCatch_
|
||||
Functor FunctorChangeModule_;
|
||||
#define FunctorChangeModule Yap_heap_regs->FunctorChangeModule_
|
||||
Functor FunctorCleanCall_;
|
||||
#define FunctorCleanCall Yap_heap_regs->FunctorCleanCall_
|
||||
Functor FunctorClist_;
|
||||
#define FunctorClist Yap_heap_regs->FunctorClist_
|
||||
Functor FunctorComma_;
|
||||
@ -748,10 +754,14 @@
|
||||
#define FunctorPermissionError Yap_heap_regs->FunctorPermissionError_
|
||||
Functor FunctorPortray_;
|
||||
#define FunctorPortray Yap_heap_regs->FunctorPortray_
|
||||
Functor FunctorPrologConstraint_;
|
||||
#define FunctorPrologConstraint Yap_heap_regs->FunctorPrologConstraint_
|
||||
Functor FunctorQuery_;
|
||||
#define FunctorQuery Yap_heap_regs->FunctorQuery_
|
||||
Functor FunctorRecordedWithKey_;
|
||||
#define FunctorRecordedWithKey Yap_heap_regs->FunctorRecordedWithKey_
|
||||
Functor FunctorRedoFreeze_;
|
||||
#define FunctorRedoFreeze Yap_heap_regs->FunctorRedoFreeze_
|
||||
Functor FunctorRepresentationError_;
|
||||
#define FunctorRepresentationError Yap_heap_regs->FunctorRepresentationError_
|
||||
Functor FunctorResourceError_;
|
||||
|
Reference in New Issue
Block a user