diff --git a/C/c_interface.c b/C/c_interface.c index f3897b875..57ed3d60c 100644 --- a/C/c_interface.c +++ b/C/c_interface.c @@ -10,8 +10,12 @@ * File: c_interface.c * * comments: c_interface primitives definition * * * -* Last rev: $Date: 2007-04-18 23:01:16 $,$Author: vsc $ * +* Last rev: $Date: 2007-05-14 16:44:11 $,$Author: vsc $ * * $Log: not supported by cvs2svn $ +* Revision 1.92 2007/04/18 23:01:16 vsc +* fix deadlock when trying to create a module with the same name as a +* predicate (for now, just don't lock modules). obs Paulo Moura. +* * Revision 1.91 2007/03/30 16:47:22 vsc * fix gmpless blob handling * @@ -310,6 +314,7 @@ X_API Term STD_PROTO(YAP_BufferToAtomList, (char *)); X_API void STD_PROTO(YAP_Error,(int, Term, char *, ...)); X_API Term STD_PROTO(YAP_RunGoal,(Term)); X_API int STD_PROTO(YAP_RestartGoal,(void)); +X_API int STD_PROTO(YAP_ShutdownGoal,(void)); X_API int STD_PROTO(YAP_GoalHasException,(Term *)); X_API void STD_PROTO(YAP_ClearExceptions,(void)); X_API int STD_PROTO(YAP_ContinueGoal,(void)); @@ -318,18 +323,19 @@ X_API void STD_PROTO(YAP_InitConsult,(int, char *)); X_API void STD_PROTO(YAP_EndConsult,(void)); X_API Term STD_PROTO(YAP_Read, (int (*)(void))); X_API void STD_PROTO(YAP_Write, (Term, int (*)(wchar_t), int)); +X_API Term STD_PROTO(YAP_CopyTerm, (Term)); X_API Term STD_PROTO(YAP_WriteBuffer, (Term, char *, unsigned int, int)); X_API char *STD_PROTO(YAP_CompileClause, (Term)); X_API void STD_PROTO(YAP_PutValue, (Atom,Term)); X_API Term STD_PROTO(YAP_GetValue, (Atom)); X_API int STD_PROTO(YAP_CompareTerms, (Term,Term)); -X_API int STD_PROTO(YAP_Reset, (void)); X_API void STD_PROTO(YAP_Exit, (int)); X_API void STD_PROTO(YAP_InitSocks, (char *, long)); X_API void STD_PROTO(YAP_SetOutputMessage, (void)); X_API int STD_PROTO(YAP_StreamToFileNo, (Term)); X_API void STD_PROTO(YAP_CloseAllOpenStreams,(void)); X_API Term STD_PROTO(YAP_OpenStream,(void *, char *, Term, int)); +X_API long STD_PROTO(YAP_CurrentSlot,(void)); X_API long STD_PROTO(YAP_NewSlots,(int)); X_API long STD_PROTO(YAP_InitSlot,(Term)); X_API Term STD_PROTO(YAP_GetFromSlot,(long)); @@ -777,6 +783,12 @@ YAP_Unify(Term t1, Term t2) return out; } +X_API long +YAP_CurrentSlot(void) +{ + return Yap_CurrentSlot(); +} + X_API long YAP_NewSlots(int n) { @@ -1099,7 +1111,6 @@ YAP_RestartGoal(void) BACKUP_MACHINE_REGS(); if (Yap_AllowRestart) { - fprintf(stderr,"Allow restart\n"); P = (yamop *)FAILCODE; do_putcf = myputc; Yap_PrologMode = UserMode; @@ -1117,6 +1128,44 @@ YAP_RestartGoal(void) return(out); } +X_API int +YAP_ShutdownGoal(void) +{ + BACKUP_MACHINE_REGS(); + + if (Yap_AllowRestart) { + choiceptr cut_pt; + yamop *my_p = P; + + cut_pt = B; + while (cut_pt-> cp_ap != NOCODE) { + cut_pt = cut_pt->cp_b; + } +#ifdef YAPOR + CUT_prune_to(cut_pt); +#endif + /* just force backtrack */ + B = cut_pt; + P = FAILCODE; + Yap_exec_absmi(TRUE); + /* recover stack space */ + H = cut_pt->cp_h; + TR = cut_pt->cp_tr; + ENV = cut_pt->cp_env; + ASP = (CELL *)(cut_pt+1); + ASP += EnvSizeInCells; + P = my_p; + ENV = (CELL *)ASP[E_E]; + B = (choiceptr)ASP[E_CB]; +#ifdef DEPTH_LIMIT + DEPTH = ASP[E_DEPTH]; +#endif + Yap_AllowRestart = FALSE; + } + RECOVER_MACHINE_REGS(); + return TRUE; +} + X_API int YAP_ContinueGoal(void) { @@ -1229,6 +1278,20 @@ YAP_Write(Term t, int (*myputc)(wchar_t), int flags) RECOVER_MACHINE_REGS(); } + +X_API Term +YAP_CopyTerm(Term t) +{ + Term tn; + BACKUP_MACHINE_REGS(); + + tn = Yap_CopyTerm(t); + + RECOVER_MACHINE_REGS(); + + return tn; +} + X_API Term YAP_WriteBuffer(Term t, char *buf, unsigned int sze, int flags) { diff --git a/C/exec.c b/C/exec.c index fc8edc6d9..e14d6f8f3 100644 --- a/C/exec.c +++ b/C/exec.c @@ -366,7 +366,7 @@ do_execute_n(Term t, Term mod, unsigned int n) for (i = arity-n+1; i <= arity; i++,j++) { XREGS[i] = H[j]; } - return (CallPredicate(pen, B, pen->CodeOfPred)); + return CallPredicate(pen, B, pen->CodeOfPred); } static Int @@ -392,14 +392,20 @@ EnterCreepMode(Term t, Term mod) { CreepFlag = CalculateStackGap(); UNLOCK(SignalLock); P_before_spy = P; - return (CallPredicate(PredCreep, B, PredCreep->CodeOfPred)); + return CallPredicate(PredCreep, B, PredCreep->CodeOfPred); } static Int p_execute(void) { /* '$execute'(Goal) */ Term t = Deref(ARG1); - return(do_execute(t, CurrentModule)); + return do_execute(t, CurrentModule); +} + +static int +Yap_Execute(Term t) +{ /* '$execute'(Goal) */ + return do_execute(t, CurrentModule); } static void @@ -423,7 +429,7 @@ p_execute2(void) { /* '$execute'(Goal) */ Term t = Deref(ARG1); heap_store(Deref(ARG2)); - return(do_execute_n(t, CurrentModule, 1)); + return do_execute_n(t, CurrentModule, 1); } static Int @@ -432,7 +438,7 @@ p_execute3(void) Term t = Deref(ARG1); heap_store(Deref(ARG2)); heap_store(Deref(ARG3)); - return(do_execute_n(t, CurrentModule, 2)); + return do_execute_n(t, CurrentModule, 2); } static Int @@ -442,7 +448,7 @@ p_execute4(void) heap_store(Deref(ARG2)); heap_store(Deref(ARG3)); heap_store(Deref(ARG4)); - return(do_execute_n(t, CurrentModule, 3)); + return do_execute_n(t, CurrentModule, 3); } static Int @@ -453,7 +459,7 @@ p_execute5(void) heap_store(Deref(ARG3)); heap_store(Deref(ARG4)); heap_store(Deref(ARG5)); - return(do_execute_n(t, CurrentModule, 4)); + return do_execute_n(t, CurrentModule, 4); } static Int @@ -465,7 +471,7 @@ p_execute6(void) heap_store(Deref(ARG4)); heap_store(Deref(ARG5)); heap_store(Deref(ARG6)); - return(do_execute_n(t, CurrentModule, 5)); + return do_execute_n(t, CurrentModule, 5); } static Int @@ -478,7 +484,7 @@ p_execute7(void) heap_store(Deref(ARG5)); heap_store(Deref(ARG6)); heap_store(Deref(ARG7)); - return(do_execute_n(t, CurrentModule, 6)); + return do_execute_n(t, CurrentModule, 6); } static Int @@ -492,7 +498,7 @@ p_execute8(void) heap_store(Deref(ARG6)); heap_store(Deref(ARG7)); heap_store(Deref(ARG8)); - return(do_execute_n(t, CurrentModule, 7)); + return do_execute_n(t, CurrentModule, 7); } static Int @@ -507,7 +513,7 @@ p_execute9(void) heap_store(Deref(ARG7)); heap_store(Deref(ARG8)); heap_store(Deref(ARG9)); - return(do_execute_n(t, CurrentModule, 8)); + return do_execute_n(t, CurrentModule, 8); } static Int @@ -1966,11 +1972,13 @@ Yap_InitYaamRegs(void) EX = 0L; /* for slots to work */ Yap_StartSlots(); + GlobalArena = TermNil; #if COROUTINING h0var = MkVarTerm(); DelayedVars = Yap_NewTimedVar(h0var); WokenGoals = Yap_NewTimedVar(TermNil); AttsMutableList = Yap_NewTimedVar(h0var); + GlobalDelayArena = TermNil; #endif GcGeneration = Yap_NewTimedVar(MkIntTerm(0)); GcCurrentPhase = 0L; diff --git a/C/heapgc.c b/C/heapgc.c index 8bd92a1ca..30809cd4e 100644 --- a/C/heapgc.c +++ b/C/heapgc.c @@ -1449,8 +1449,9 @@ mark_regs(tr_fr_ptr old_TR) /* first, whatever we dumped on the trail. Easier just to do the registers separately? */ - for (trail_ptr = old_TR; trail_ptr < TR; trail_ptr++) + for (trail_ptr = old_TR; trail_ptr < TR; trail_ptr++) { mark_external_reference(&TrailTerm(trail_ptr)); + } } #ifdef COROUTINING diff --git a/C/tracer.c b/C/tracer.c index a5e583670..e077ccbc3 100644 --- a/C/tracer.c +++ b/C/tracer.c @@ -161,7 +161,6 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args) LOCK(Yap_heap_regs->low_level_trace_lock); sc = Yap_heap_regs; vsc_count++; - return; #ifdef COMMENTED if (vsc_count > 1388060LL && vsc_count < 1388070LL) { if (vsc_count==1388061LL) diff --git a/H/Yapproto.h b/H/Yapproto.h index 8c2be1f65..45ebe67c9 100644 --- a/H/Yapproto.h +++ b/H/Yapproto.h @@ -10,7 +10,7 @@ * File: Yap.proto * * mods: * * comments: Function declarations for YAP * -* version: $Id: Yapproto.h,v 1.78 2007-01-28 14:26:37 vsc Exp $ * +* version: $Id: Yapproto.h,v 1.79 2007-05-14 16:44:12 vsc Exp $ * *************************************************************************/ /* prototype file for Yap */ @@ -43,6 +43,7 @@ Term STD_PROTO(Yap_StringToDiffList,(char *,Term)); Term STD_PROTO(Yap_StringToListOfAtoms,(char *)); #define Yap_StartSlots() (*--ASP = MkIntTerm(0)) +#define Yap_CurrentSlot() IntOfTerm(ASP[0]) long STD_PROTO(Yap_InitSlot,(Term)); long STD_PROTO(Yap_NewSlots,(int)); Term STD_PROTO(Yap_GetFromSlot,(long)); diff --git a/changes-5.1.html b/changes-5.1.html index b4e774535..ef725f36b 100644 --- a/changes-5.1.html +++ b/changes-5.1.html @@ -16,6 +16,7 @@

Yap-5.1.2: