From 30318bb60dfeaecc5775b7614e502a6e47327c00 Mon Sep 17 00:00:00 2001 From: vsc Date: Wed, 5 Apr 2006 00:16:55 +0000 Subject: [PATCH] Lots of fixes (check logfile for details git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1585 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/compiler.c | 20 ++++++++++++++++---- C/index.c | 26 ++++++++++++++----------- C/iopreds.c | 12 +++++++++--- OPTYap/tab.tries.c | 4 +--- changes-5.1.html | 9 ++++++++- docs/yap.tex | 47 +++++++++++++++++++++++++++++++++++++++++++++- pl/consult.yap | 2 +- pl/errors.yap | 13 ++++++++----- pl/modules.yap | 14 ++++++++++++++ pl/threads.yap | 18 +++++++++++++----- 10 files changed, 131 insertions(+), 34 deletions(-) diff --git a/C/compiler.c b/C/compiler.c index 377489686..e66cf0e2c 100644 --- a/C/compiler.c +++ b/C/compiler.c @@ -11,8 +11,12 @@ * File: compiler.c * * comments: Clause compiler * * * -* Last rev: $Date: 2006-03-24 17:13:41 $,$Author: rslopes $ * +* Last rev: $Date: 2006-04-05 00:16:54 $,$Author: vsc $ * * $Log: not supported by cvs2svn $ +* Revision 1.71 2006/03/24 17:13:41 rslopes +* New update to BEAM engine. +* BEAM now uses YAP Indexing (JITI) +* * Revision 1.70 2005/12/17 03:25:39 vsc * major changes to support online event-based profiling * improve error discovery and restart on scanner. @@ -706,6 +710,10 @@ c_arg(Int argno, Term t, unsigned int arity, unsigned int level, compiler_struct static void c_eq(Term t1, Term t2, compiler_struct *cglobs) { + if (t1 == t2) { + Yap_emit(nop_op, Zero, Zero, &cglobs->cint); + return; + } if (IsNonVarTerm(t1)) { if (IsVarTerm(t2)) { Term t = t1; @@ -733,6 +741,7 @@ c_eq(Term t1, Term t2, compiler_struct *cglobs) /* they might */ c_eq(HeadOfTerm(t1), HeadOfTerm(t2), cglobs); c_eq(TailOfTerm(t1), TailOfTerm(t2), cglobs); + return; } else if (IsRefTerm(t1)) { /* just check if they unify */ if (t1 != t2) { @@ -742,6 +751,7 @@ c_eq(Term t1, Term t2, compiler_struct *cglobs) } /* they do */ Yap_emit(nop_op, Zero, Zero, &cglobs->cint); + return; } else { /* compound terms */ Functor f = FunctorOfTerm(t1); @@ -3195,13 +3205,15 @@ Yap_cclause(volatile Term inp_clause, int NOfArgs, int mod, volatile Term src) #endif #ifdef BEAM - void codigo_eam(compiler_struct *); - if (EAM) codigo_eam(&cglobs); + { + void codigo_eam(compiler_struct *); + + if (EAM) codigo_eam(&cglobs); + } #endif /* phase 3: assemble code */ acode = Yap_assemble(ASSEMBLING_CLAUSE, src, cglobs.cint.CurrentPred, (cglobs.is_a_fact && !cglobs.hasdbrefs), &cglobs.cint); - /* check first if there was space for us */ if (acode == NULL) { return NULL; diff --git a/C/index.c b/C/index.c index 4836a5c3a..5fc8ff241 100644 --- a/C/index.c +++ b/C/index.c @@ -11,8 +11,12 @@ * File: index.c * * comments: Indexing a Prolog predicate * * * -* Last rev: $Date: 2006-03-24 17:13:41 $,$Author: rslopes $ * +* Last rev: $Date: 2006-04-05 00:16:54 $,$Author: vsc $ * * $Log: not supported by cvs2svn $ +* Revision 1.160 2006/03/24 17:13:41 rslopes +* New update to BEAM engine. +* BEAM now uses YAP Indexing (JITI) +* * Revision 1.159 2006/03/22 20:07:28 vsc * take better care of zombies * @@ -4908,10 +4912,18 @@ index_jmp(ClausePointer cur, ClausePointer parent, yamop *ipc, int is_lu, yamop cur.lui = ncur; return cur; } else { - StaticIndex *scur = cur.si; + StaticIndex *scur = parent.si, *ncur; /* check myself */ - if (ipc >= scur->ClCode && ipc <= (yamop *)((CODEADDR)scur+scur->ClSize)) + if (!scur) return cur; + if (ipc >= scur->ClCode && + ipc <= (yamop *)((CODEADDR)scur+scur->ClSize)) + return cur; + ncur = ClauseCodeToStaticIndex(ipc); + if (ncur->ClPred == scur->ClPred) { + cur.si = ncur; + return cur; + } /* if (parent.si != cur.si) { if (parent.si) { @@ -4920,14 +4932,6 @@ index_jmp(ClausePointer cur, ClausePointer parent, yamop *ipc, int is_lu, yamop return parent; } } - ncur = ClauseCodeToStaticIndex(ipc); - if (ncur->ClPred != scur->ClPred) { -#ifdef DEBUG - fprintf(stderr,"OOPS, bad parent in lu index\n"); -#endif - cur.si = NULL; - return cur; - } cur.si = ncur; return cur; */ diff --git a/C/iopreds.c b/C/iopreds.c index 3638a2646..d6c7db79f 100644 --- a/C/iopreds.c +++ b/C/iopreds.c @@ -3392,8 +3392,12 @@ p_show_stream_position (void) sargs[0] = MkIntTerm (Stream[sno].charcount); else if (Stream[sno].status & Null_Stream_f) sargs[0] = MkIntTerm (Stream[sno].charcount); - else - sargs[0] = MkIntTerm (YP_ftell (Stream[sno].u.file.file)); + else { + if (Stream[sno].stream_getc == PlUnGetc) + sargs[0] = MkIntTerm (YP_ftell (Stream[sno].u.file.file) - 1); + else + sargs[0] = MkIntTerm (YP_ftell (Stream[sno].u.file.file)); + } sargs[1] = MkIntTerm (Stream[sno].linecount); sargs[2] = MkIntTerm (Stream[sno].linepos); tout = Yap_MkApplTerm (FunctorStreamPos, 3, sargs); @@ -3439,7 +3443,7 @@ p_set_stream_position (void) } Stream[sno].charcount = char_pos; Stream[sno].linecount = IntOfTerm (tp); - if (IsVarTerm (tp = ArgOfTerm (2, tin))) { + if (IsVarTerm (tp = ArgOfTerm (3, tin))) { Yap_Error(INSTANTIATION_ERROR, tp, "set_stream_position/2"); return (FALSE); } else if (!IsIntTerm (tp)) { @@ -3452,6 +3456,7 @@ p_set_stream_position (void) "fseek failed for set_stream_position/2"); return(FALSE); } + Stream[sno].stream_getc = PlGetc; } else if (FunctorOfTerm (tin) == FunctorStreamEOS) { if (IsVarTerm (tp = ArgOfTerm (1, tin))) { Yap_Error(INSTANTIATION_ERROR, tp, "set_stream_position/2"); @@ -3469,6 +3474,7 @@ p_set_stream_position (void) "fseek failed for set_stream_position/2"); return(FALSE); } + Stream[sno].stream_getc = PlGetc; /* reset the counters */ Stream[sno].linepos = 0; Stream[sno].linecount = 0; diff --git a/OPTYap/tab.tries.c b/OPTYap/tab.tries.c index 67264b467..9d9b3d368 100644 --- a/OPTYap/tab.tries.c +++ b/OPTYap/tab.tries.c @@ -5,7 +5,7 @@ Copyright: R. Rocha and NCC - University of Porto, Portugal File: tab.tries.C - version: $Id: tab.tries.c,v 1.17 2005-11-04 01:17:17 vsc Exp $ + version: $Id: tab.tries.c,v 1.18 2006-04-05 00:16:54 vsc Exp $ **********************************************************************/ @@ -694,8 +694,6 @@ sg_fr_ptr subgoal_search(yamop *preg, CELL **Yaddr) { LOCK(TabEnt_lock(tab_ent)); #endif /* TABLE_LOCK_LEVEL */ for (i = 1; i <= arity; i++) { - extern long long vsc_count; - STACK_PUSH_UP(XREGS[i], stack_terms); STACK_CHECK_EXPAND(stack_terms, stack_terms_limit, stack_terms_base); do { diff --git a/changes-5.1.html b/changes-5.1.html index 1dcacce51..f00302016 100644 --- a/changes-5.1.html +++ b/changes-5.1.html @@ -15,7 +15,14 @@

Changes in YAP-5.1

Yap-5.1.0:

-