diff --git a/C/absmi.c b/C/absmi.c index a15771613..6b5bb54c7 100644 --- a/C/absmi.c +++ b/C/absmi.c @@ -1086,6 +1086,19 @@ Yap_absmi(int inp) GONext(); ENDOp(); + /* only meaningful with THREADS on! */ + /* lock logical updates predicate. */ + Op(unlock_lu, e); + PREG = NEXTOP(PREG, e); +#if defined(YAPOR) || defined(THREADS) + if (PP) { + READ_UNLOCK(PP->PRWLock); + PP = NULL; + } +#endif + GONext(); + ENDOp(); + /* enter logical pred */ BOp(stale_lu_index, Ill); @@ -2552,12 +2565,6 @@ Yap_absmi(int inp) E_YREG = ENV; #ifdef DEPTH_LIMIT DEPTH = E_YREG[E_DEPTH]; -#endif -#if defined(YAPOR) || defined(THREADS) - if (PP) { - READ_UNLOCK(PP->PRWLock); - PP = NULL; - } #endif WRITEBACK_Y_AS_ENV(); JMPNext(); diff --git a/C/amasm.c b/C/amasm.c index 9db128efc..b9a5cf8a8 100644 --- a/C/amasm.c +++ b/C/amasm.c @@ -2426,10 +2426,16 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp break; case cutexit_op: code_p = a_cut(&clinfo, code_p, pass_no, cip); - if (cip->CurrentPred->PredFlags & LogUpdatePredFlag && + if (cip->CurrentPred->PredFlags & LogUpdatePredFlag && *clause_has_blobsp && !clinfo.alloc_found) code_p = a_cle(_alloc_for_logical_pred, code_p, pass_no, cip); +#if THREADS + else + if (cip->CurrentPred->PredFlags & LogUpdatePredFlag && + !(cip->CurrentPred->PredFlags & ThreadLocalPredFlag)) + code_p = a_e(_unlock_lu, code_p, pass_no); +#endif code_p = a_e(_procceed, code_p, pass_no); #ifdef YAPOR if (pass_no) @@ -2530,12 +2536,23 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp *clause_has_blobsp && !clinfo.alloc_found) code_p = a_cle(_alloc_for_logical_pred, code_p, pass_no, cip); +#if THREADS + else + if (cip->CurrentPred->PredFlags & LogUpdatePredFlag && + !(cip->CurrentPred->PredFlags & ThreadLocalPredFlag)) + code_p = a_e(_unlock_lu, code_p, pass_no); +#endif code_p = a_e(_procceed, code_p, pass_no); break; case call_op: code_p = a_p(_call, &clinfo, code_p, pass_no, cip); break; case execute_op: +#if THREADS + if (cip->CurrentPred->PredFlags & LogUpdatePredFlag && + !(cip->CurrentPred->PredFlags & ThreadLocalPredFlag)) + code_p = a_e(_unlock_lu, code_p, pass_no); +#endif code_p = a_p(_execute, &clinfo, code_p, pass_no, cip); break; case safe_call_op: diff --git a/C/attvar.c b/C/attvar.c index eee29bb0e..471e45443 100644 --- a/C/attvar.c +++ b/C/attvar.c @@ -648,6 +648,7 @@ void Yap_InitAttVarPreds(void) attas[attvars_ext].to_term_op = AttVarToTerm; attas[attvars_ext].term_to_op = TermToAttVar; attas[attvars_ext].mark_op = mark_attvar; + CurrentModule = ATTRIBUTES_MODULE; Yap_InitCPred("get_att", 3, p_get_att, SafePredFlag); Yap_InitCPred("get_all_atts", 2, p_get_all_atts, SafePredFlag); Yap_InitCPred("free_att", 2, p_free_att, SafePredFlag); @@ -657,6 +658,7 @@ void Yap_InitAttVarPreds(void) Yap_InitCPred("n_of_atts", 1, p_n_atts, SafePredFlag); Yap_InitCPred("bind_attvar", 1, p_bind_attvar, SafePredFlag); Yap_InitCPred("all_attvars", 1, p_all_attvars, SafePredFlag); + CurrentModule = PROLOG_MODULE; Yap_InitCPred("$is_att_variable", 1, p_is_attvar, SafePredFlag|TestPredFlag); Yap_InitCPred("$att_bound", 1, p_attvar_bound, SafePredFlag|TestPredFlag); } diff --git a/C/cdmgr.c b/C/cdmgr.c index 0873f2f4c..003b4ed50 100644 --- a/C/cdmgr.c +++ b/C/cdmgr.c @@ -276,6 +276,10 @@ cleanup_dangling_indices(yamop *ipc, yamop *beg, yamop *end, yamop *suspend_code /* just skip for now, but should worry about locking */ ipc = NEXTOP(ipc,p); break; + case _unlock_lu: + /* just skip for now, but should worry about locking */ + ipc = NEXTOP(ipc,e); + break; case _retry_profiled: case _count_retry: ipc = NEXTOP(ipc,p); diff --git a/C/dbase.c b/C/dbase.c index b802235a0..04edfa7c1 100644 --- a/C/dbase.c +++ b/C/dbase.c @@ -3309,32 +3309,38 @@ p_recorded(void) PredEntry *pe; if (!IsVarTerm(t3)) { + DBRef ref = DBRefOfTerm(t3); if (!IsDBRefTerm(t3)) { - return FALSE; - } else { - DBRef ref = DBRefOfTerm(t3); - if (ref == NULL) return FALSE; - if (DEAD_REF(ref)) { + if (IsIntegerTerm(t3)) { + ref = (DBRef)IntegerOfTerm(t3); + } else { return FALSE; } - if (ref->Flags & LogUpdMask) { - LogUpdClause *cl = (LogUpdClause *)ref; - PredEntry *ap; - if (Yap_op_from_opcode(cl->ClCode->opc) == _unify_idb_term) { - if (!Yap_unify(ARG2, cl->ClSource->Entry)) { - return FALSE; - } - } else if (!Yap_unify(ARG2,GetDBTerm(cl->ClSource))) { + } else { + ref = DBRefOfTerm(t3); + } + ref = DBRefOfTerm(t3); + if (ref == NULL) return FALSE; + if (DEAD_REF(ref)) { + return FALSE; + } + if (ref->Flags & LogUpdMask) { + LogUpdClause *cl = (LogUpdClause *)ref; + PredEntry *ap; + if (Yap_op_from_opcode(cl->ClCode->opc) == _unify_idb_term) { + if (!Yap_unify(ARG2, cl->ClSource->Entry)) { return FALSE; } - ap = cl->ClPred; - return Yap_unify(GetDBLUKey(ap), ARG1); - } else if (!Yap_unify(ARG2,GetDBTermFromDBEntry(ref)) - || !UnifyDBKey(ref,0,ARG1)) { + } else if (!Yap_unify(ARG2,GetDBTerm(cl->ClSource))) { return FALSE; - } else { - return TRUE; } + ap = cl->ClPred; + return Yap_unify(GetDBLUKey(ap), ARG1); + } else if (!Yap_unify(ARG2,GetDBTermFromDBEntry(ref)) + || !UnifyDBKey(ref,0,ARG1)) { + return FALSE; + } else { + return TRUE; } } if ((pe = find_lu_entry(twork)) != NULL) { @@ -4130,8 +4136,13 @@ p_erase(void) return (FALSE); } if (!IsDBRefTerm(t1)) { - Yap_Error(TYPE_ERROR_DBREF, t1, "erase"); - return (FALSE); + if (IsIntegerTerm(t1)) { + EraseEntry((DBRef)IntegerOfTerm(t1)); + return TRUE; + } else { + Yap_Error(TYPE_ERROR_DBREF, t1, "erase"); + return (FALSE); + } } EraseEntry(DBRefOfTerm(t1)); return (TRUE); @@ -4148,17 +4159,22 @@ p_erase_clause(void) return (FALSE); } if (!IsDBRefTerm(t1)) { - Yap_Error(TYPE_ERROR_DBREF, t1, "erase"); - return (FALSE); + if (IsIntegerTerm(t1)) { + entryref = (DBRef)IntegerOfTerm(t1); + } else { + Yap_Error(TYPE_ERROR_DBREF, t1, "erase"); + return (FALSE); + } + } else { + entryref = DBRefOfTerm(t1); } - entryref = DBRefOfTerm(t1); if (entryref->Flags & StaticMask) { if (entryref->Flags & ErasedMask) return FALSE; Yap_EraseStaticClause((StaticClause *)entryref, Yap_LookupModule(Deref(ARG2))); return TRUE; } - EraseEntry(DBRefOfTerm(t1)); + EraseEntry(entryref); return TRUE; } @@ -4243,8 +4259,12 @@ p_erased(void) return (FALSE); } if (!IsDBRefTerm(t)) { - Yap_Error(TYPE_ERROR_DBREF, t, "erased"); - return (FALSE); + if (IsIntegerTerm(t)) { + return (((DBRef)IntegerOfTerm(t))->Flags & ErasedMask); + } else { + Yap_Error(TYPE_ERROR_DBREF, t, "erased"); + return (FALSE); + } } return (DBRefOfTerm(t)->Flags & ErasedMask); } diff --git a/C/index.c b/C/index.c index e37a2b008..e5f84133f 100644 --- a/C/index.c +++ b/C/index.c @@ -1582,6 +1582,7 @@ add_info(ClauseDef *clause, UInt regno) case _jump_if_var: case _try_in: case _lock_lu: + case _unlock_lu: clause->Tag = (CELL)NULL; return; case _jump_if_nonvar: @@ -3822,6 +3823,9 @@ expand_index(struct intermediates *cint) { case _lock_lu: ipc = NEXTOP(ipc,p); break; + case _unlock_lu: + ipc = NEXTOP(ipc,e); + break; case _jump_if_var: if (IsVarTerm(Deref(ARG1))) { labp = &(ipc->u.l.l); @@ -5531,6 +5535,9 @@ add_to_index(struct intermediates *cint, int first, path_stack_entry *sp, Clause case _lock_lu: ipc = NEXTOP(ipc,p); break; + case _unlock_lu: + ipc = NEXTOP(ipc,e); + break; default: sp = kill_unsafe_block(sp, op, ap); ipc = pop_path(&sp, cls, ap); @@ -6034,6 +6041,9 @@ remove_from_index(PredEntry *ap, path_stack_entry *sp, ClauseDef *cls, yamop *bg case _lock_lu: ipc = NEXTOP(ipc,p); break; + case _unlock_lu: + ipc = NEXTOP(ipc,e); + break; default: if (IN_BETWEEN(bg,ipc,lt)) { sp = kill_unsafe_block(sp, op, ap); @@ -6543,6 +6553,9 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term t1, Term tb, Term tr, yam case _lock_lu: ipc = NEXTOP(ipc,p); break; + case _unlock_lu: + ipc = NEXTOP(ipc,e); + break; #if THREADS case _thread_local: break; diff --git a/C/init.c b/C/init.c index 98bc7fbd2..007ae12fc 100644 --- a/C/init.c +++ b/C/init.c @@ -839,8 +839,6 @@ InitCodes(void) don't initialise this here, this is initialised by Yap_InitModules!!!! heap_regs->no_of_modules = 1; */ - heap_regs->primitives_module = 0; - heap_regs->user_module = 1; heap_regs->atom_abol = Yap_FullLookupAtom("$abol"); AtomAltNot = Yap_LookupAtom("not"); heap_regs->atom_append = Yap_LookupAtom ("append"); diff --git a/C/iopreds.c b/C/iopreds.c index e6454db92..27d14e797 100644 --- a/C/iopreds.c +++ b/C/iopreds.c @@ -3789,7 +3789,7 @@ format(Term tail, Term args, int sno) { if (format_buf_size == -1) { Yap_FreeAtomSpace(format_base); - return(FALSE); + return FALSE; } ch = IntOfTerm (head); if (ch == '~') @@ -3801,22 +3801,22 @@ format(Term tail, Term args, int sno) if (IsVarTerm (tail = Deref (tail)) ) { Yap_FreeAtomSpace(format_base); Yap_Error(INSTANTIATION_ERROR,tail,"format/2"); - return(FALSE); + return FALSE; } else if (!IsPairTerm (tail)) { Yap_FreeAtomSpace(format_base); Yap_Error(TYPE_ERROR_LIST,tail,"format/2"); - return(FALSE); + return FALSE; } head = HeadOfTerm (tail); tail = TailOfTerm (tail); if (IsVarTerm (head)) { Yap_FreeAtomSpace(format_base); Yap_Error(INSTANTIATION_ERROR,tail,"format/2"); - return(FALSE); + return FALSE; } else if ( !IsIntTerm (head)) { Yap_FreeAtomSpace(format_base); Yap_Error(TYPE_ERROR_INTEGER,tail,"format/2"); - return(FALSE); + return FALSE; } else ch = IntOfTerm (head); if (ch == '*') @@ -3825,27 +3825,27 @@ format(Term tail, Term args, int sno) arg_size = GetArgSizeFromThirdArg (&ptr, &args); if (format_error) { Yap_FreeAtomSpace(format_base); - return(FALSE); + return FALSE; } if (IsVarTerm (tail = Deref (tail)) ) { Yap_FreeAtomSpace(format_base); Yap_Error(INSTANTIATION_ERROR,tail,"format/2"); - return(FALSE); + return FALSE; } else if (!IsPairTerm (tail)) { Yap_FreeAtomSpace(format_base); Yap_Error(TYPE_ERROR_LIST,tail,"format/2"); - return(FALSE); + return FALSE; } head = HeadOfTerm (tail); tail = TailOfTerm (tail); if (IsVarTerm (head)) { Yap_FreeAtomSpace(format_base); Yap_Error(INSTANTIATION_ERROR,tail,"format/2"); - return(FALSE); + return FALSE; } else if ( !IsIntTerm (head)) { Yap_FreeAtomSpace(format_base); Yap_Error(TYPE_ERROR_INTEGER,tail,"format/2"); - return(FALSE); + return FALSE; } else ch = IntOfTerm (head); } @@ -3856,7 +3856,7 @@ format(Term tail, Term args, int sno) ch = GetArgSizeFromChars (&ptr, &arg_size, &tail); if (format_error) { Yap_FreeAtomSpace(format_base); - return (FALSE); + return FALSE; } } else if (ch == '`') @@ -3865,7 +3865,7 @@ format(Term tail, Term args, int sno) arg_size = GetArgSizeFromChar(&tail); if (format_error) { Yap_FreeAtomSpace(format_base); - return(FALSE); + return FALSE; } ch = 't'; } @@ -3874,27 +3874,27 @@ format(Term tail, Term args, int sno) case 'a': if (size_args) { Yap_FreeAtomSpace(format_base); - return (FALSE); + return FALSE; } if (IsVarTerm (args)) { Yap_FreeAtomSpace(format_base); Yap_Error(INSTANTIATION_ERROR,args,"~a format/2"); - return(FALSE); + return FALSE; } else if (!IsPairTerm (args)) { Yap_FreeAtomSpace(format_base); Yap_Error(TYPE_ERROR_LIST,args,"~a format/2"); - return(FALSE); + return FALSE; } arghd = HeadOfTerm (args); args = TailOfTerm (args); if (IsVarTerm (arghd)) { Yap_FreeAtomSpace(format_base); Yap_Error(INSTANTIATION_ERROR,arghd,"~a in format/2"); - return(FALSE); + return FALSE; } else if (!IsAtomTerm (arghd)) { Yap_FreeAtomSpace(format_base); Yap_Error(TYPE_ERROR_ATOM,arghd,"~a in format/2"); - return(FALSE); + return FALSE; } Yap_plwrite (arghd, format_putc, Handle_vars_f|To_heap_f); break; @@ -3902,22 +3902,22 @@ format(Term tail, Term args, int sno) if (IsVarTerm (args)) { Yap_FreeAtomSpace(format_base); Yap_Error(INSTANTIATION_ERROR,args,"~c in format/2"); - return(FALSE); + return FALSE; } else if (!IsPairTerm (args)) { Yap_FreeAtomSpace(format_base); Yap_Error(TYPE_ERROR_LIST,args,"~c in format/2"); - return(FALSE); + return FALSE; } arghd = HeadOfTerm (args); args = TailOfTerm (args); if (IsVarTerm (arghd)) { Yap_FreeAtomSpace(format_base); Yap_Error(INSTANTIATION_ERROR,arghd,"~c in format/2"); - return(FALSE); + return FALSE; } else if (!IsIntTerm (arghd)) { Yap_FreeAtomSpace(format_base); Yap_Error(TYPE_ERROR_ATOM,arghd,"~a in format/2"); - return(FALSE); + return FALSE; } else int2= IntOfTerm(arghd); if (!size_args) arg_size = 1; @@ -3932,11 +3932,11 @@ format(Term tail, Term args, int sno) if (IsVarTerm (args)) { Yap_FreeAtomSpace(format_base); Yap_Error(INSTANTIATION_ERROR,args,"~%d in format/2", ch); - return(FALSE); + return FALSE; } else if (!IsPairTerm (args)) { Yap_FreeAtomSpace(format_base); Yap_Error(TYPE_ERROR_LIST,args,"~%d in format/2", ch); - return(FALSE); + return FALSE; } if (arg_size == 0 || arg_size > 6) arg_size = 6; @@ -3949,11 +3949,11 @@ format(Term tail, Term args, int sno) if (IsVarTerm(arghd)) { Yap_FreeAtomSpace(format_base); Yap_Error(INSTANTIATION_ERROR,arghd,"~%c in format/2", ch); - return(FALSE); + return FALSE; } else if (!IsNumTerm (arghd)) { Yap_FreeAtomSpace(format_base); Yap_Error(TYPE_ERROR_FLOAT,arghd,"~%c in format/2", ch); - return(FALSE); + return FALSE; } if (IsIntegerTerm(arghd)) { float_tmp = IntegerOfTerm(arghd); @@ -3973,7 +3973,7 @@ format(Term tail, Term args, int sno) if (IsVarTerm (args)) { Yap_FreeAtomSpace(format_base); Yap_Error(INSTANTIATION_ERROR,args,"~d format/2"); - return(FALSE); + return FALSE; } else if (!IsPairTerm (args)) { Yap_FreeAtomSpace(format_base); Yap_Error(TYPE_ERROR_LIST,args,"~d format/2"); @@ -5031,7 +5031,6 @@ Yap_InitIOPreds(void) Yap_InitCPred ("$check_stream", 1, p_check_if_stream, SafePredFlag|SyncPredFlag); Yap_InitCPred ("$stream_flags", 2, p_stream_flags, SafePredFlag|SyncPredFlag); Yap_InitCPred ("$close", 1, p_close, SafePredFlag|SyncPredFlag); - Yap_InitCPred ("peek_mem_write_stream", 3, p_peek_mem_write_stream, SyncPredFlag); Yap_InitCPred ("flush_output", 1, p_flush, SafePredFlag|SyncPredFlag); Yap_InitCPred ("$flush_all_streams", 0, p_flush_all_streams, SafePredFlag|SyncPredFlag); Yap_InitCPred ("$get", 2, p_get, SafePredFlag|SyncPredFlag); @@ -5042,8 +5041,11 @@ Yap_InitIOPreds(void) Yap_InitCPred ("$file_expansion", 2, p_file_expansion, SafePredFlag|SyncPredFlag); Yap_InitCPred ("$open_null_stream", 1, p_open_null_stream, SafePredFlag|SyncPredFlag); Yap_InitCPred ("$open_pipe_stream", 2, p_open_pipe_stream, SafePredFlag|SyncPredFlag); + CurrentModule = CHARSIO_MODULE; Yap_InitCPred ("open_mem_read_stream", 2, p_open_mem_read_stream, SyncPredFlag); Yap_InitCPred ("open_mem_write_stream", 1, p_open_mem_write_stream, SyncPredFlag); + Yap_InitCPred ("peek_mem_write_stream", 3, p_peek_mem_write_stream, SyncPredFlag); + CurrentModule = PROLOG_MODULE; Yap_InitCPred ("$put", 2, p_put, SafePredFlag|SyncPredFlag); Yap_InitCPred ("$put_byte", 2, p_put_byte, SafePredFlag|SyncPredFlag); Yap_InitCPred ("$set_read_error_handler", 1, p_set_read_error_handler, SafePredFlag|SyncPredFlag); diff --git a/C/modules.c b/C/modules.c index d71953545..31ef54c8e 100644 --- a/C/modules.c +++ b/C/modules.c @@ -148,12 +148,18 @@ Yap_InitModulesC(void) void Yap_InitModules(void) { - ModuleName[PrimitivesModule = 0] = + ModuleName[PROLOG_MODULE] = MkAtomTerm(Yap_LookupAtom("prolog")); - ModuleName[1] = + ModuleName[USER_MODULE] = MkAtomTerm(Yap_LookupAtom("user")); - ModuleName[2] = + ModuleName[IDB_MODULE] = MkAtomTerm(Yap_LookupAtom("idb")); - NoOfModules = 3; + ModuleName[ATTRIBUTES_MODULE] = + MkAtomTerm(Yap_LookupAtom("attributes")); + ModuleName[CHARSIO_MODULE] = + MkAtomTerm(Yap_LookupAtom("charsio")); + ModuleName[TERMS_MODULE] = + MkAtomTerm(Yap_LookupAtom("terms")); + NoOfModules = 6; CurrentModule = 0; } diff --git a/C/unify.c b/C/unify.c index 01fea45d7..cbc417622 100644 --- a/C/unify.c +++ b/C/unify.c @@ -616,8 +616,10 @@ void Yap_InitUnify(void) { Yap_InitCPred("unify_with_occurs_check", 2, p_ocunify, SafePredFlag); + CurrentModule = TERMS_MODULE; Yap_InitCPred("cyclic_term", 1, p_cyclic, SafePredFlag|TestPredFlag); Yap_InitCPred("acyclic_term", 1, p_acyclic, SafePredFlag|TestPredFlag); + CurrentModule = PROLOG_MODULE; } diff --git a/C/utilpreds.c b/C/utilpreds.c index 79f307ca6..218969454 100644 --- a/C/utilpreds.c +++ b/C/utilpreds.c @@ -31,7 +31,7 @@ typedef struct { STATIC_PROTO(int copy_complex_term, (CELL *, CELL *, CELL *, CELL *)); -STATIC_PROTO(CELL vars_in_complex_term, (CELL *, CELL *)); +STATIC_PROTO(CELL vars_in_complex_term, (CELL *, CELL *, Term)); STATIC_PROTO(Int p_non_singletons_in_term, (void)); STATIC_PROTO(CELL non_singletons_in_complex_term, (CELL *, CELL *)); STATIC_PROTO(Int p_variables_in_term, (void)); @@ -678,7 +678,7 @@ p_copy_term_no_delays(void) /* copy term t to a new instance */ } -static Term vars_in_complex_term(register CELL *pt0, register CELL *pt0_end) +static Term vars_in_complex_term(register CELL *pt0, register CELL *pt0_end, Term inp) { register CELL **to_visit0, **to_visit = (CELL **)Yap_PreAllocCodeSpace(); @@ -774,7 +774,7 @@ static Term vars_in_complex_term(register CELL *pt0, register CELL *pt0_end) Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0); if (H != InitialH) { /* close the list */ - Term t2 = Deref(ARG2); + Term t2 = Deref(inp); if (IsVarTerm(t2)) { RESET_VARIABLE(H-1); Yap_unify((CELL)(H-1),ARG2); @@ -783,7 +783,7 @@ static Term vars_in_complex_term(register CELL *pt0, register CELL *pt0_end) } return(output); } else { - return(ARG2); + return(inp); } } @@ -804,17 +804,40 @@ p_variables_in_term(void) /* variables in term t */ out = ARG2; else if (IsPairTerm(t)) { out = vars_in_complex_term(RepPair(t)-1, - RepPair(t)+1); + RepPair(t)+1, ARG2); } else { Functor f = FunctorOfTerm(t); out = vars_in_complex_term(RepAppl(t), RepAppl(t)+ - ArityOfFunctor(f)); + ArityOfFunctor(f), ARG2); } return(Yap_unify(ARG3,out)); } +static Int +p_term_variables(void) /* variables in term t */ +{ + Term t = Deref(ARG1); + Term out; + + if (IsVarTerm(t)) { + return Yap_unify(MkPairTerm(t,TermNil), ARG2); + } else if (IsPrimitiveTerm(t)) { + return Yap_unify(TermNil, ARG2); + } else if (IsPairTerm(t)) { + out = vars_in_complex_term(RepPair(t)-1, + RepPair(t)+1, TermNil); + } + else { + Functor f = FunctorOfTerm(t); + out = vars_in_complex_term(RepAppl(t), + RepAppl(t)+ + ArityOfFunctor(f), TermNil); + } + return Yap_unify(ARG2,out); +} + static Term non_singletons_in_complex_term(register CELL *pt0, register CELL *pt0_end) { @@ -1708,11 +1731,14 @@ void Yap_InitUtilCPreds(void) Yap_InitCPred("$copy_term_but_not_constraints", 2, p_copy_term_no_delays, 0); Yap_InitCPred("ground", 1, p_ground, SafePredFlag); Yap_InitCPred("$variables_in_term", 3, p_variables_in_term, SafePredFlag); - Yap_InitCPred("variable_in_term", 2, p_var_in_term, SafePredFlag); Yap_InitCPred("$non_singletons_in_term", 3, p_non_singletons_in_term, SafePredFlag); + CurrentModule = TERMS_MODULE; + Yap_InitCPred("term_variables", 2, p_term_variables, SafePredFlag); + Yap_InitCPred("variable_in_term", 2, p_var_in_term, SafePredFlag); Yap_InitCPred("term_hash", 4, GvNTermHash, SafePredFlag); Yap_InitCPred("variant", 2, p_variant, SafePredFlag); Yap_InitCPred("subsumes", 2, p_subsumes, SafePredFlag); + CurrentModule = PROLOG_MODULE; #ifdef DEBUG Yap_InitCPred("$force_trail_expansion", 1, p_force_trail_expansion, SafePredFlag); Yap_InitCPred("dum", 1, camacho_dum, SafePredFlag); diff --git a/H/Heap.h b/H/Heap.h index c9b5b2918..e153b1055 100644 --- a/H/Heap.h +++ b/H/Heap.h @@ -10,7 +10,7 @@ * File: Heap.h * * mods: * * comments: Heap Init Structure * -* version: $Id: Heap.h,v 1.52 2004-02-05 16:57:00 vsc Exp $ * +* version: $Id: Heap.h,v 1.53 2004-02-09 14:19:04 vsc Exp $ * *************************************************************************/ /* information that can be stored in Code Space */ @@ -200,8 +200,6 @@ typedef struct various_codes { struct pred_entry *module_pred[MaxModules]; SMALLUNSGN no_of_modules; struct dead_clause *dead_clauses; - int primitives_module; - int user_module; Atom atom_abol, atom_alarm, @@ -453,8 +451,6 @@ struct various_codes *heap_regs; #define CharConversionTable2 heap_regs->char_conversion_table2 #define ModuleName heap_regs->module_name #define ModulePred heap_regs->module_pred -#define PrimitivesModule heap_regs->primitives_module -#define UserModule heap_regs->user_module #define NoOfModules heap_regs->no_of_modules #define AtomAbol heap_regs->atom_abol #define AtomAlarm heap_regs->atom_alarm diff --git a/H/YapOpcodes.h b/H/YapOpcodes.h index d8dd71321..fbee7aa23 100644 --- a/H/YapOpcodes.h +++ b/H/YapOpcodes.h @@ -256,6 +256,7 @@ OPCODE(count_trust_me ,ld), OPCODE(count_retry_and_mark ,ld), OPCODE(lock_lu ,p), + OPCODE(unlock_lu ,e), OPCODE(enter_lu_pred ,Ill), OPCODE(stale_lu_index ,Ill), OPCODE(trust_logical_pred ,l), diff --git a/H/rheap.h b/H/rheap.h index 16f166fc0..a097a53cf 100644 --- a/H/rheap.h +++ b/H/rheap.h @@ -650,6 +650,7 @@ restore_opcodes(yamop *pc) case _count_a_call: case _index_dbref: case _index_blob: + case _unlock_lu: #ifdef YAPOR case _getwork_first_time: #endif diff --git a/library/terms.yap b/library/terms.yap index 4421400ef..54fd40ed4 100644 --- a/library/terms.yap +++ b/library/terms.yap @@ -18,7 +18,7 @@ :- module(terms, [ term_hash/2, term_hash/4, - term_variables/2, + term_variablesb/2, variant/2, subsumes/2, subsumes_chk/2, @@ -30,6 +30,9 @@ term_hash(T,H) :- term_hash(T, -1, 33554432, H). +%term_hash(X,Y) :- +% term_hash(X,-1,16'1000000,Y). + subsumes_chk(X,Y) :- \+ \+ subsumes(X,Y). diff --git a/m4/Yatom.h.m4 b/m4/Yatom.h.m4 index 00a3032a4..9f35a7139 100644 --- a/m4/Yatom.h.m4 +++ b/m4/Yatom.h.m4 @@ -567,7 +567,10 @@ PredPropByAtom(Atom at, SMALLUNSGN cur_mod) typedef enum { PROLOG_MODULE = 0, USER_MODULE = 1, - IDB_MODULE = 2 + IDB_MODULE = 2, + ATTRIBUTES_MODULE = 3, + CHARSIO_MODULE = 4, + TERMS_MODULE = 5 } default_modules; diff --git a/pl/init.yap b/pl/init.yap index 656bda6a8..f08a32aa8 100644 --- a/pl/init.yap +++ b/pl/init.yap @@ -89,30 +89,6 @@ system_mode(verbose,off) :- set_value('$verbose',off). :- default_sequential(off). -:- '$set_pred_module'(get_att(_,_,_), attributes), - '$set_pred_module'(get_all_atts(_,_), attributes), - '$set_pred_module'(free_att(_,_), attributes), - '$set_pred_module'(put_att(_,_,_), attributes), - '$set_pred_module'(rm_att(_,_), attributes), - '$set_pred_module'(inc_n_of_atts(_), attributes), - '$set_pred_module'(n_of_atts(_), attributes), - '$set_pred_module'(bind_attvar(_), attributes), - '$set_pred_module'(all_attvars(_), attributes). - - -:- '$set_pred_module'(open_mem_read_stream(_,_), charsio), - '$set_pred_module'(open_mem_write_stream(_), charsio), - '$set_pred_module'(peek_mem_write_stream(_,_,_), charsio). - -:- '$set_pred_module'(term_hash(_,_,_,_), terms), - '$set_pred_module'(term_hash(_,_), terms), - '$set_pred_module'(term_variables(_,_), terms), - '$set_pred_module'(variant(_,_), terms), - '$set_pred_module'(subsumes(_,_), terms), - '$set_pred_module'(cyclic_term(_), terms), - '$set_pred_module'(acyclic_term(_,_), terms), - '$set_pred_module'(variable_in_term(_,_), terms). - % % cleanup ensure loaded and recover some data-base space. % diff --git a/pl/utils.yap b/pl/utils.yap index 8764cacf9..73c8e7f45 100644 --- a/pl/utils.yap +++ b/pl/utils.yap @@ -774,9 +774,6 @@ version(T) :- '$assert_version'(T) :- recordz('$version',T,_), fail. '$assert_version'(_). -term_variables(Term, L) :- - '$variables_in_term'(Term, [], L). - term_hash(X,Y) :- term_hash(X,-1,16'1000000,Y).