diff --git a/C/absmi.c b/C/absmi.c index d8e3a2f17..2bea1c218 100755 --- a/C/absmi.c +++ b/C/absmi.c @@ -1086,7 +1086,7 @@ Yap_absmi(int inp) } /* HEY, leave indexing block alone!! */ /* check if we are the ones using this code */ -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS PELOCK(1, ap); PP = ap; DEC_CLREF_COUNT(cl); @@ -1387,7 +1387,7 @@ Yap_absmi(int inp) } /* HEY, leave indexing block alone!! */ /* check if we are the ones using this code */ -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS PELOCK(2, ap); PP = ap; DEC_CLREF_COUNT(cl); @@ -1480,7 +1480,7 @@ Yap_absmi(int inp) /* only meaningful with THREADS on! */ /* lock logical updates predicate. */ Op(lock_lu, p); -#if defined(YAPOR) || defined(THREADS) +#if PARALLEL_YAP if (PP) { GONext(); } @@ -1508,10 +1508,12 @@ Yap_absmi(int inp) check_trail(TR); /* say that an environment is using this clause */ /* we have our own copy for the clause */ -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS { LogUpdClause *cl = PREG->u.L.ClBase; +#if PARALLEL_YAP PredEntry *ap = cl->ClPred; +#endif /* always add an extra reference */ INC_CLREF_COUNT(cl); @@ -1581,7 +1583,7 @@ Yap_absmi(int inp) } setregs(); -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS /* always add an extra reference */ INC_CLREF_COUNT(cl); TRAIL_CLREF(cl); @@ -1633,7 +1635,7 @@ Yap_absmi(int inp) /* say that an environment is using this clause */ /* we have our own copy for the clause */ -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS /* always add an extra reference */ INC_CLREF_COUNT(cl); TRAIL_CLREF(cl); @@ -1746,7 +1748,7 @@ Yap_absmi(int inp) #endif /* YAPOR */ SET_BB(B_YREG); ENDCACHE_Y(); -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS INC_CLREF_COUNT(ClauseCodeToDynamicClause(PREG)); UNLOCK(DynamicLock(PREG)); TRAIL_CLREF(ClauseCodeToDynamicClause(PREG)); @@ -1808,7 +1810,7 @@ Yap_absmi(int inp) #endif /* FROZEN_STACKS */ SET_BB(B_YREG); ENDCACHE_Y(); -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS INC_CLREF_COUNT(ClauseCodeToDynamicClause(PREG)); TRAIL_CLREF(ClauseCodeToDynamicClause(PREG)); UNLOCK(DynamicLock(PREG)); @@ -2067,7 +2069,7 @@ Yap_absmi(int inp) if (IN_BETWEEN(H0,pt1,H) && IsAttVar(pt1)) goto failloop; flags = *pt1; -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS if (FlagOn(DBClMask, flags)) { DBRef dbr = DBStructFlagsToDBStruct(pt1); int erase; @@ -2086,7 +2088,9 @@ Yap_absmi(int inp) if (flags & IndexMask) { LogUpdIndex *cl = ClauseFlagsToLogUpdIndex(pt1); int erase; +#if PARALLEL_YAP PredEntry *ap = cl->ClPred; +#endif PELOCK(8,ap); DEC_CLREF_COUNT(cl); @@ -2110,7 +2114,9 @@ Yap_absmi(int inp) } else { LogUpdClause *cl = ClauseFlagsToLogUpdClause(pt1); int erase; +#if PARALLEL_YAP PredEntry *ap = cl->ClPred; +#endif PELOCK(9,ap); DEC_CLREF_COUNT(cl); @@ -7926,7 +7932,7 @@ Yap_absmi(int inp) /* fprintf(stderr,"> %p/%p %d %d\n",cl,ap,ap->TimeStampOfPred,PREG->u.Ills.s);*/ PREG = PREG->u.Ills.l1; /* indicate the indexing code is being used */ -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS /* just store a reference */ INC_CLREF_COUNT(cl); TRAIL_CLREF(cl); @@ -8032,7 +8038,7 @@ Yap_absmi(int inp) } /* HEY, leave indexing block alone!! */ /* check if we are the ones using this code */ -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS DEC_CLREF_COUNT(cl); /* clear the entry from the trail */ B->cp_tr--; diff --git a/C/amasm.c b/C/amasm.c index b0cc48c9b..ef9415126 100755 --- a/C/amasm.c +++ b/C/amasm.c @@ -3052,7 +3052,7 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp } cl_u->luc.ClExt = NULL; cl_u->luc.ClPrev = cl_u->luc.ClNext = NULL; -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS //INIT_LOCK(cl_u->luc.ClLock); INIT_CLREF_COUNT(&(cl_u->luc)); #endif @@ -3071,6 +3071,8 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp cl_u->ic.ClRefCount = 0; #if defined(YAPOR) || defined(THREADS) INIT_LOCK(cl_u->ic.ClLock); +#endif +#ifdef MULTIPLE_STACKS INIT_CLREF_COUNT(&(cl_u->ic)); #endif } @@ -3122,7 +3124,7 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp cl_u->lui.ClSize = size; cl_u->lui.ClRefCount = 0; // INIT_LOCK(cl_u->lui.ClLock); -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS INIT_CLREF_COUNT(&(cl_u->lui)); #endif } diff --git a/C/arrays.c b/C/arrays.c index 2fca5031e..2114aa77d 100644 --- a/C/arrays.c +++ b/C/arrays.c @@ -392,7 +392,7 @@ AccessNamedArray(Atom a, Int indx USES_REGS) if (TRef != 0L) { DBRef ref = DBRefOfTerm(TRef); -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS LOCK(ref->lock); INC_DBREF_COUNT(ref); TRAIL_REF(ref); /* So that fail will erase it */ @@ -2305,17 +2305,17 @@ p_static_array_to_term( USES_REGS1 ) if (TRef != 0L) { DBRef ref = DBRefOfTerm(TRef); -#if defined(YAPOR) || defined(THREADS) LOCK(ref->lock); +#if MULTIPLE_STACKS INC_DBREF_COUNT(ref); TRAIL_REF(ref); /* So that fail will erase it */ - UNLOCK(ref->lock); #else if (!(ref->Flags & InUseMask)) { ref->Flags |= InUseMask; TRAIL_REF(ref); /* So that fail will erase it */ } #endif + UNLOCK(ref->lock); } else { TRef = TermNil; } diff --git a/C/cdmgr.c b/C/cdmgr.c index ce34e43c6..6620385ae 100644 --- a/C/cdmgr.c +++ b/C/cdmgr.c @@ -1451,12 +1451,12 @@ Yap_kill_iblock(ClauseUnion *blk, ClauseUnion *parent_blk, PredEntry *ap) LogUpdIndex *c = (LogUpdIndex *)blk; if (parent_blk != NULL) { LogUpdIndex *cl = (LogUpdIndex *)parent_blk; -#if defined(THREADS) || defined(YAPOR) +#if MULTIPLE_STACKS /* protect against attempts at erasing */ cl->ClRefCount++; #endif kill_first_log_iblock(c, cl, ap); -#if defined(THREADS) || defined(YAPOR) +#if MULTIPLE_STACKS cl->ClRefCount--; #endif } else { @@ -1501,12 +1501,12 @@ Yap_ErLogUpdIndex(LogUpdIndex *clau) if (clau->ClFlags & SwitchRootMask) { kill_first_log_iblock(clau, NULL, clau->ClPred); } else { -#if defined(THREADS) || defined(YAPOR) +#if MULTIPLE_STACKS /* protect against attempts at erasing */ clau->ClRefCount++; #endif kill_first_log_iblock(clau, clau->ParentIndex, clau->ClPred); -#if defined(THREADS) || defined(YAPOR) +#if MULTIPLE_STACKS /* protect against attempts at erasing */ clau->ClRefCount--; #endif @@ -2274,7 +2274,7 @@ addclause(Term t, yamop *cp, int mode, Term mod, Term *t4ref) if (pflags & LogUpdatePredFlag) { LogUpdClause *cl = (LogUpdClause *)ClauseCodeToLogUpdClause(cp); tf = MkDBRefTerm((DBRef)cl); -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS TRAIL_CLREF(cl); /* So that fail will erase it */ INC_CLREF_COUNT(cl); #else @@ -4428,7 +4428,7 @@ fetch_next_lu_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr, ya return FALSE; } rtn = MkDBRefTerm((DBRef)cl); -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS TRAIL_CLREF(cl); /* So that fail will erase it */ INC_CLREF_COUNT(cl); #else @@ -4575,7 +4575,7 @@ fetch_next_lu_clause_erase(PredEntry *pe, yamop *i_code, Term th, Term tb, Term return FALSE; } rtn = MkDBRefTerm((DBRef)cl); -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS TRAIL_CLREF(cl); /* So that fail will erase it */ INC_CLREF_COUNT(cl); #else @@ -5071,7 +5071,7 @@ p_nth_clause( USES_REGS1 ) return FALSE; } if (pe->PredFlags & LogUpdatePredFlag) { -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS TRAIL_CLREF(cl); /* So that fail will erase it */ INC_CLREF_COUNT(cl); #else diff --git a/C/dbase.c b/C/dbase.c index c7272fc3f..efa76d597 100755 --- a/C/dbase.c +++ b/C/dbase.c @@ -113,7 +113,7 @@ typedef struct idb_queue { Functor id; /* identify this as being pointed to by a DBRef */ SMALLUNSGN Flags; /* always required */ -#if defined(YAPOR) || defined(THREADS) +#if PARALLEL_YAP rwlock_t QRWLock; /* a simple lock to protect this entry */ #endif QueueEntry *FirstInQueue, *LastInQueue; @@ -1670,7 +1670,7 @@ record(int Flag, Term key, Term t_data, Term t_code USES_REGS) else x->Flags |= DBNoCode; x->Parent = p; -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS x->Flags |= DBClMask; x->ref_count = 1; #else @@ -1742,7 +1742,7 @@ record_at(int Flag, DBRef r0, Term t_data, Term t_code USES_REGS) else x->Flags |= DBNoCode; x->Parent = p; -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS x->Flags |= DBClMask; x->ref_count = 1; #else @@ -1806,7 +1806,7 @@ new_lu_db_entry(Term t, PredEntry *pe) struct db_globs dbg; int d_flag = 0; -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS /* we cannot allow sharing between threads (for now) */ if (!(pe->PredFlags & ThreadLocalPredFlag)) d_flag |= InQueue; @@ -1838,7 +1838,7 @@ new_lu_db_entry(Term t, PredEntry *pe) cl->ClTimeStart = 0L; } cl->ClTimeEnd = TIMESTAMP_EOT; -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS // INIT_LOCK(cl->ClLock); INIT_CLREF_COUNT(cl); ipc->opc = Yap_opcode(_copy_idb_term); @@ -1960,7 +1960,7 @@ p_rcda( USES_REGS1 ) cl = record_lu(pe, Deref(ARG2), MkFirst); if (cl != NULL) { TRAIL_CLREF(cl); -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS INC_CLREF_COUNT(cl); #else cl->ClFlags |= InUseMask; @@ -2070,7 +2070,7 @@ p_rcdz( USES_REGS1 ) cl = record_lu(pe, t2, MkLast); if (cl != NULL) { TRAIL_CLREF(cl); -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS INC_CLREF_COUNT(cl); #else cl->ClFlags |= InUseMask; @@ -2917,7 +2917,7 @@ lu_nth_recorded(PredEntry *pe, Int Count USES_REGS) cl = Yap_NthClause(pe, Count); if (cl == NULL) return FALSE; -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS PELOCK(65,pe); TRAIL_CLREF(cl); /* So that fail will erase it */ INC_CLREF_COUNT(cl); @@ -2959,7 +2959,7 @@ nth_recorded(DBProp AtProp, Int Count USES_REGS) return FALSE; } } -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS LOCK(ref->lock); READ_UNLOCK(AtProp->DBRWLock); TRAIL_REF(ref); /* So that fail will erase it */ @@ -3276,7 +3276,7 @@ i_recorded(DBProp AtProp, Term t3 USES_REGS) /* This should be after any non-tagged terms, because the routines in grow.c go from upper to lower addresses */ TRef = MkDBRefTerm(ref); -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS LOCK(ref->lock); TRAIL_REF(ref); /* So that fail will erase it */ INC_DBREF_COUNT(ref); @@ -3421,7 +3421,7 @@ c_recorded(int flags USES_REGS) READ_UNLOCK(ref0->Parent->DBRWLock); TRef = MkDBRefTerm(ref); EXTRA_CBACK_ARG(3,1) = (CELL)ref; -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS LOCK(ref->lock); TRAIL_REF(ref); /* So that fail will erase it */ INC_DBREF_COUNT(ref); @@ -3664,17 +3664,17 @@ p_first_instance( USES_REGS1 ) } TRef = MkDBRefTerm(ref); /* we have a pointer to the term available */ -#if defined(YAPOR) || defined(THREADS) LOCK(ref->lock); +#if MULTIPLE_STACKS TRAIL_REF(ref); /* So that fail will erase it */ INC_DBREF_COUNT(ref); - UNLOCK(ref->lock); #else if (!(ref->Flags & InUseMask)) { ref->Flags |= InUseMask; TRAIL_REF(ref); /* So that fail will erase it */ } #endif + UNLOCK(ref->lock); while ((TermDB = GetDBTermFromDBEntry(ref PASS_REGS)) == (CELL)0) { /* oops, we are in trouble, not enough stack space */ if (Yap_Error_TYPE == OUT_OF_ATTVARS_ERROR) { @@ -3942,7 +3942,7 @@ RemoveDBEntry(DBRef entryref USES_REGS) || B->cp_ap == RETRY_C_RECORDEDP_CODE) && EXTRA_CBACK_ARG(3,1) == (CELL)entryref) { /* make it clear the entry has been released */ -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS DEC_DBREF_COUNT(entryref); #else entryref->Flags &= ~InUseMask; @@ -3993,7 +3993,7 @@ find_next_clause(DBRef ref0 USES_REGS) newp = ref->Code; /* and next let's tell the world this clause is being used, just like if we were executing a standard retry_and_mark */ -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS { DynamicClause *cl = ClauseCodeToDynamicClause(newp); @@ -4805,7 +4805,7 @@ Yap_LUInstance(LogUpdClause *cl, UInt arity) } } } -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS cl->ClRefCount++; TRAIL_CLREF(cl); /* So that fail will erase it */ #else @@ -5427,17 +5427,17 @@ p_fetch_reference_from_index( USES_REGS1 ) return FALSE; pos = IntOfTerm(t2); el = (DBRef)(table->DBT.Contents[pos]); -#if defined(YAPOR) || defined(THREADS) LOCK(el->lock); +#if MULTIPLE_STACKS TRAIL_REF(el); /* So that fail will erase it */ INC_DBREF_COUNT(el); - UNLOCK(el->lock); #else if (!(el->Flags & InUseMask)) { el->Flags |= InUseMask; TRAIL_REF(el); } #endif + UNLOCK(el->lock); return Yap_unify(ARG3, MkDBRefTerm(el)); } diff --git a/C/globals.c b/C/globals.c index 61afec71d..1e0b51d17 100644 --- a/C/globals.c +++ b/C/globals.c @@ -1024,7 +1024,7 @@ p_nb_linkval( USES_REGS1 ) static Int -p_nb_create_accumulator(void) +p_nb_create_accumulator( USES_REGS1 ) { Term t = Deref(ARG1), acct, to; CELL *destp; @@ -1041,7 +1041,7 @@ p_nb_create_accumulator(void) if (!Yap_unify(ARG2, acct)) { return FALSE; } - to = CopyTermToArena(t, GlobalArena, TRUE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena))); + to = CopyTermToArena(t, GlobalArena, TRUE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena) PASS_REGS) PASS_REGS); if (to == 0L) return FALSE; destp = RepAppl(Deref(ARG2)); @@ -1050,7 +1050,7 @@ p_nb_create_accumulator(void) } static Int -p_nb_add_to_accumulator(void) +p_nb_add_to_accumulator( USES_REGS1 ) { Term t = Deref(ARG1), t0, tadd; Functor f; @@ -1091,7 +1091,7 @@ p_nb_add_to_accumulator(void) target[1] = source[1]; } else { /* we need to create a new long int */ - new = CopyTermToArena(new, GlobalArena, TRUE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena))); + new = CopyTermToArena(new, GlobalArena, TRUE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena) PASS_REGS) PASS_REGS); destp = RepAppl(Deref(ARG1)); destp[1] = new; } @@ -1118,7 +1118,7 @@ p_nb_add_to_accumulator(void) new = Yap_MkApplTerm(FunctorPlus, 2, t2); new = Yap_Eval(new); - new = CopyTermToArena(new, GlobalArena, TRUE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena))); + new = CopyTermToArena(new, GlobalArena, TRUE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena) PASS_REGS) PASS_REGS); destp = RepAppl(Deref(ARG1)); destp[1] = new; @@ -1129,7 +1129,7 @@ p_nb_add_to_accumulator(void) static Int -p_nb_accumulator_value(void) +p_nb_accumulator_value( USES_REGS1 ) { Term t = Deref(ARG1), to; Functor f; diff --git a/C/grow.c b/C/grow.c index c4166c176..07e752eb9 100755 --- a/C/grow.c +++ b/C/grow.c @@ -214,7 +214,7 @@ MoveLocalAndTrail( USES_REGS1 ) #endif } -#ifdef THREADS +#ifdef YAPOR_THREADS static void CopyLocalAndTrail( USES_REGS1 ) @@ -401,14 +401,14 @@ AdjustTrail(int adjusting_heap, int thread_copying USES_REGS) { volatile tr_fr_ptr ptt, tr_base = (tr_fr_ptr)Yap_TrailBase; -#if defined(YAPOR) && defined(THREADS) +#if defined(YAPOR_THREADS) if (thread_copying == STACK_INCREMENTAL_COPYING) { ptt = (tr_fr_ptr)(LOCAL_end_trail_copy); tr_base = (tr_fr_ptr)(LOCAL_start_trail_copy); } else { #endif ptt = TR; -#if defined(YAPOR) && defined(THREADS) +#if defined(YAPOR_THREADS) } #endif /* moving the trail is simple */ @@ -462,7 +462,7 @@ AdjustLocal(int thread_copying USES_REGS) register CELL reg, *pt, *pt_bot; /* Adjusting the local */ -#if defined(YAPOR) && defined(THREADS) +#if defined(YAPOR_THREADS) if (thread_copying == STACK_INCREMENTAL_COPYING) { pt = (CELL *) (LOCAL_end_local_copy); pt_bot = (CELL *) (LOCAL_start_local_copy); @@ -470,7 +470,7 @@ AdjustLocal(int thread_copying USES_REGS) #endif pt = LCL0; pt_bot = ASP; -#if defined(YAPOR) && defined(THREADS) +#if defined(YAPOR_THREADS) } #endif while (pt > pt_bot) { @@ -551,7 +551,7 @@ AdjustGlobal(long sz, int thread_copying USES_REGS) * to clean the global now that functors are just variables pointing to * the code */ -#if defined(YAPOR) && defined(THREADS) +#if defined(YAPOR_THREADS) if (thread_copying == STACK_INCREMENTAL_COPYING) { pt = (CELL *) (LOCAL_start_global_copy); pt_max = (CELL *) (LOCAL_end_global_copy); @@ -559,7 +559,7 @@ AdjustGlobal(long sz, int thread_copying USES_REGS) #endif pt = H0; pt_max = (H-sz/CellSize); -#if defined(YAPOR) && defined(THREADS) +#if defined(YAPOR_THREADS) } #endif pt = H0; @@ -790,7 +790,7 @@ static_growheap(long size, int fix_code, struct intermediates *cip, tr_fr_ptr *o gc_verbose = Yap_is_gc_verbose(); heap_overflows++; if (gc_verbose) { -#if defined(YAPOR) || defined(THREADS) +#if defined(YAPOR_THREADS) fprintf(Yap_stderr, "%% Worker Id %d:\n", worker_id); #endif fprintf(Yap_stderr, "%% Database Overflow %d\n", heap_overflows); @@ -936,7 +936,7 @@ static_growglobal(long request, CELL **ptr, CELL *hsplit USES_REGS) vb_msg1 = 'D'; vb_msg2 = "Delay"; } -#if defined(YAPOR) || defined(THREADS) +#if defined(YAPOR_THREADS) fprintf(Yap_stderr, "%% Worker Id %d:\n", worker_id); #endif fprintf(Yap_stderr, "%% %cO %s Overflow %d\n", vb_msg1, vb_msg2, delay_overflows); @@ -1357,7 +1357,7 @@ growatomtable( USES_REGS1 ) } atom_table_overflows++; if (gc_verbose) { -#if defined(YAPOR) || defined(THREADS) +#if defined(YAPOR_THREADS) fprintf(Yap_stderr, "%% Worker Id %d:\n", worker_id); #endif fprintf(Yap_stderr, "%% Atom Table Overflow %d\n", atom_table_overflows); @@ -1441,7 +1441,7 @@ Yap_growglobal(CELL **ptr) CACHE_REGS unsigned long sz = sizeof(CELL) * K16; -#if defined(YAPOR) && !defined(THREADS) +#if defined(YAPOR_THREADS) if (Yap_number_workers != 1) { Yap_Error(OUT_OF_STACK_ERROR,TermNil,"cannot grow Global: more than a worker/thread running"); return(FALSE); @@ -1837,7 +1837,7 @@ p_inform_heap_overflows( USES_REGS1 ) return(Yap_unify(tn, ARG1) && Yap_unify(tt, ARG2)); } -#if defined(THREADS) && defined(YAPOR) +#if defined(YAPOR_THREADS) void Yap_CopyThreadStacks(int worker_q, int worker_p, int incremental) { diff --git a/C/index.c b/C/index.c index 10ebf5263..eedfc0d02 100644 --- a/C/index.c +++ b/C/index.c @@ -2190,6 +2190,7 @@ emit_type_switch(compiler_vm_op op, struct intermediates *cint) static yamop * emit_switch_space(UInt n, UInt item_size, struct intermediates *cint, CELL func_mask) { + CACHE_REGS PredEntry *ap = cint->CurrentPred; if (ap->PredFlags & LogUpdatePredFlag) { @@ -5218,7 +5219,7 @@ kill_clause(yamop *ipc, yamop *bg, yamop *lt, path_stack_entry *sp0, PredEntry * return sp; } else { if ( -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS blk->ClRefCount == 0 #else !(blk->ClFlags & InUseMask) @@ -6821,7 +6822,7 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y } *--ASP = MkIntegerTerm(ap->TimeStampOfPred); /* indicate the indexing code is being used */ -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS /* just store a reference */ INC_CLREF_COUNT(cl); TRAIL_CLREF(cl); @@ -6883,7 +6884,7 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y } else { newpc = ipc->u.OtILl.d; } -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS B->cp_tr--; TR--; DEC_CLREF_COUNT(cl); diff --git a/C/tracer.c b/C/tracer.c index bab8c7c37..9874ca225 100755 --- a/C/tracer.c +++ b/C/tracer.c @@ -163,6 +163,10 @@ 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++; + if (vsc_count < 45000LL) + return; + if (vsc_count == 47456LL) + jmp_deb(1); #ifdef THREADS MY_ThreadHandle.thread_inst_count++; #endif diff --git a/C/utilpreds.c b/C/utilpreds.c index 543db8b2e..8684cc32c 100644 --- a/C/utilpreds.c +++ b/C/utilpreds.c @@ -146,7 +146,7 @@ copy_complex_term(CELL *pt0, CELL *pt0_end, int share, int newattvs, CELL *ptf, f = (Functor)(*ap2); if (IsExtensionFunctor(f)) { -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS if (f == FunctorDBRef) { DBRef entryref = DBRefOfTerm(d0); if (entryref->Flags & LogUpdMask) { diff --git a/H/Yap.h b/H/Yap.h index 9d320f73f..bd06fd5e7 100755 --- a/H/Yap.h +++ b/H/Yap.h @@ -43,7 +43,7 @@ #error Do not define multiple or-parallel models #endif /* (YAPOR_COPY && (YAPOR_COW || YAPOR_SBA)) || (YAPOR_COW && YAPOR_SBA) */ -#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA) || defined(THREADS) +#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA) || defined(YAPOR_THREADS) #define YAPOR 1 #endif /* YAPOR_COPY || YAPOR_COW || YAPOR_SBA */ @@ -60,6 +60,14 @@ #endif #endif /* YAPOR */ +#if defined(YAPOR) || defined(THREADS) || defined(TABLING) +#define MULTIPLE_STACKS 1 +#endif + +#if defined(YAPOR) || defined(THREADS) +#define PARALLEL_YAP 1 +#endif + #if defined(YAPOR) || defined(TABLING) #undef TRAILING_REQUIRES_BRANCH #endif /* YAPOR || TABLING */ @@ -76,7 +84,7 @@ #endif #endif -#if defined(SUPPORT_THREADS) || defined(SUPPORT_CONDOR) +#if defined(THREADS) || defined(SUPPORT_CONDOR) #define USE_SYSTEM_MALLOC 1 #endif diff --git a/H/Yatom.h b/H/Yatom.h index 751ab0ecb..95f7ca01f 100755 --- a/H/Yatom.h +++ b/H/Yatom.h @@ -863,6 +863,8 @@ typedef struct DB_STRUCT CELL Flags; /* Term Flags */ #if defined(YAPOR) || defined(THREADS) lockvar lock; /* a simple lock to protect this entry */ +#endif +#if MULTIPLE_STACKS Int ref_count; /* how many branches are using this entry */ #endif CELL NOfRefsTo; /* Number of references pointing here */ @@ -880,7 +882,7 @@ typedef struct DB_STRUCT #define DBStructFlagsToDBStruct(X) ((DBRef)((char *)(X) - (CELL) &(((DBRef) NULL)->Flags))) -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STAACKS #define INIT_DBREF_COUNT(X) (X)->ref_count = 0 #define INC_DBREF_COUNT(X) (X)->ref_count++ #define DEC_DBREF_COUNT(X) (X)->ref_count-- diff --git a/H/amiops.h b/H/amiops.h index ec4818797..d58cfb0f1 100644 --- a/H/amiops.h +++ b/H/amiops.h @@ -267,9 +267,15 @@ Binding Macros for Multiple Assignment Variables. #define REF_TO_TRENTRY(REF) AbsPair(((CELL *)&((REF)->Flags))) #define CLREF_TO_TRENTRY(REF) AbsPair(((CELL *)&((REF)->ClFlags))) +#if FROZEN_STACKS #define TRAIL_REF(REF) RESET_VARIABLE(&TrailVal(TR)), TrailTerm(TR++) = REF_TO_TRENTRY(REF) #define TRAIL_CLREF(REF) RESET_VARIABLE(&TrailVal(TR)), TrailTerm(TR++) = CLREF_TO_TRENTRY(REF) #define TRAIL_LINK(REF) RESET_VARIABLE(&TrailVal(TR)), TrailTerm(TR++) = AbsPair((CELL *)(REF)) +#else +#define TRAIL_REF(REF) TrailTerm(TR++) = REF_TO_TRENTRY(REF) +#define TRAIL_CLREF(REF) TrailTerm(TR++) = CLREF_TO_TRENTRY(REF) +#define TRAIL_LINK(REF) TrailTerm(TR++) = AbsPair((CELL *)(REF)) +#endif #define TRAIL_FRAME(FR) DO_TRAIL(AbsPair((CELL *)(Yap_TrailBase)), FR) extern void Yap_WakeUp(CELL *v); diff --git a/H/clause.h b/H/clause.h index 09a7aa5aa..a4a5212e6 100644 --- a/H/clause.h +++ b/H/clause.h @@ -182,7 +182,7 @@ typedef struct dbterm_list { #define DynamicLock(X) (ClauseCodeToDynamicClause(X)->ClLock) -#if defined(YAPOR) || defined(THREADS) +#if MULTIPLE_STACKS #define INIT_CLREF_COUNT(X) (X)->ClRefCount = 0 #define INC_CLREF_COUNT(X) (X)->ClRefCount++ #define DEC_CLREF_COUNT(X) (X)->ClRefCount-- diff --git a/config.h.in b/config.h.in index cd2a85c5d..b6c216c59 100755 --- a/config.h.in +++ b/config.h.in @@ -48,7 +48,6 @@ #undef HOST_ALIAS #undef SUPPORT_CONDOR -#undef SUPPORT_THREADS #undef USE_PTHREAD_LOCKING #undef HAVE_SYS_WAIT_H diff --git a/misc/LOCALS b/misc/LOCALS index b16b4c798..1f1c205a6 100644 --- a/misc/LOCALS +++ b/misc/LOCALS @@ -149,7 +149,7 @@ struct PL_local_data *Yap_ld_ PL_local_data_p =Yap_InitThreadIO(wid) struct open_query_struct* _execution execution =NULL // Ricardo's stuff -#if (defined(YAPOR) || defined(TABLING)) && defined(THREADS) +#if MULTIPLE_STACKS struct worker worker WORKER void #endif