fix threads

This commit is contained in:
Vítor Santos Costa 2012-12-20 21:33:20 +00:00
parent 0ac9f6f436
commit 14b67dc76d
5 changed files with 28 additions and 13 deletions

View File

@ -851,9 +851,12 @@ Yap_NewPredPropByFunctor(FunctorEntry *fe, Term cur_mod)
} }
p->FunctorOfPred = fe; p->FunctorOfPred = fe;
WRITE_UNLOCK(fe->FRWLock); WRITE_UNLOCK(fe->FRWLock);
Yap_inform_profiler_of_clause(&(p->OpcodeOfPred), &(p->OpcodeOfPred)+1, p, GPROF_NEW_PRED_FUNC); {
if (!(p->PredFlags & (CPredFlag|AsmPredFlag))) { CACHE_REGS
Yap_inform_profiler_of_clause(&(p->cs.p_code.ExpandCode), &(p->cs.p_code.ExpandCode)+1, p, GPROF_NEW_PRED_FUNC); Yap_inform_profiler_of_clause(&(p->OpcodeOfPred), &(p->OpcodeOfPred)+1, p, GPROF_NEW_PRED_FUNC);
if (!(p->PredFlags & (CPredFlag|AsmPredFlag))) {
Yap_inform_profiler_of_clause(&(p->cs.p_code.ExpandCode), &(p->cs.p_code.ExpandCode)+1, p, GPROF_NEW_PRED_FUNC);
}
} }
return AbsPredProp(p); return AbsPredProp(p);
} }
@ -962,9 +965,12 @@ Yap_NewPredPropByAtom(AtomEntry *ae, Term cur_mod)
p0 = AbsPredProp(p); p0 = AbsPredProp(p);
p->FunctorOfPred = (Functor)AbsAtom(ae); p->FunctorOfPred = (Functor)AbsAtom(ae);
WRITE_UNLOCK(ae->ARWLock); WRITE_UNLOCK(ae->ARWLock);
Yap_inform_profiler_of_clause(&(p->OpcodeOfPred), &(p->OpcodeOfPred)+1, p, GPROF_NEW_PRED_ATOM); {
if (!(p->PredFlags & (CPredFlag|AsmPredFlag))) { CACHE_REGS
Yap_inform_profiler_of_clause(&(p->cs.p_code.ExpandCode), &(p->cs.p_code.ExpandCode)+1, p, GPROF_NEW_PRED_ATOM); Yap_inform_profiler_of_clause(&(p->OpcodeOfPred), &(p->OpcodeOfPred)+1, p, GPROF_NEW_PRED_ATOM);
if (!(p->PredFlags & (CPredFlag|AsmPredFlag))) {
Yap_inform_profiler_of_clause(&(p->cs.p_code.ExpandCode), &(p->cs.p_code.ExpandCode)+1, p, GPROF_NEW_PRED_ATOM);
}
} }
return p0; return p0;
} }

View File

@ -2056,7 +2056,10 @@ a_try(op_numbers opcode, CELL lab, CELL opr, int nofalts, int hascut, yamop *cod
save_machine_regs(); save_machine_regs();
siglongjmp(cip->CompilerBotch,2); siglongjmp(cip->CompilerBotch,2);
} }
Yap_inform_profiler_of_clause(newcp, (char *)(newcp)+size, ap, GPROF_INDEX); {
CACHE_REGS
Yap_inform_profiler_of_clause(newcp, (char *)(newcp)+size, ap, GPROF_INDEX);
}
Yap_LUIndexSpace_CP += size; Yap_LUIndexSpace_CP += size;
#ifdef DEBUG #ifdef DEBUG
Yap_NewCps++; Yap_NewCps++;

View File

@ -1892,7 +1892,10 @@ record_lu(PredEntry *pe, Term t, int position)
if ((cl = new_lu_db_entry(t, pe)) == NULL) { if ((cl = new_lu_db_entry(t, pe)) == NULL) {
return NULL; return NULL;
} }
Yap_inform_profiler_of_clause(cl, (char *)cl+cl->ClSize, pe, GPROF_NEW_LU_CLAUSE); {
CACHE_REGS
Yap_inform_profiler_of_clause(cl, (char *)cl+cl->ClSize, pe, GPROF_NEW_LU_CLAUSE);
}
Yap_add_logupd_clause(pe, cl, (position == MkFirst ? 2 : 0)); Yap_add_logupd_clause(pe, cl, (position == MkFirst ? 2 : 0));
return cl; return cl;
} }
@ -4429,7 +4432,7 @@ p_increase_reference_counter( USES_REGS1 )
cl = (LogUpdClause *)DBRefOfTerm(t1); cl = (LogUpdClause *)DBRefOfTerm(t1);
PELOCK(67,cl->ClPred); PELOCK(67,cl->ClPred);
cl->ClRefCount++; cl->ClRefCount++;
UNLOCK(cl->ClPred); UNLOCK(cl->ClPred->PELock);
return TRUE; return TRUE;
} }
@ -4452,10 +4455,10 @@ p_decrease_reference_counter( USES_REGS1 )
PELOCK(67,cl->ClPred); PELOCK(67,cl->ClPred);
if (cl->ClRefCount) { if (cl->ClRefCount) {
cl->ClRefCount--; cl->ClRefCount--;
UNLOCK(cl->ClPred); UNLOCK(cl->ClPred->PELock);
return TRUE; return TRUE;
} }
UNLOCK(cl->ClPred); UNLOCK(cl->ClPred->PELock);
return FALSE; return FALSE;
} }

View File

@ -1736,7 +1736,7 @@ Yap_InitYaamRegs( int myworker_id )
Yap_ResetExceptionTerm ( myworker_id ); Yap_ResetExceptionTerm ( myworker_id );
Yap_PutValue (AtomBreak, MkIntTerm (0)); Yap_PutValue (AtomBreak, MkIntTerm (0));
TR = (tr_fr_ptr)REMOTE_TrailBase(myworker_id); TR = (tr_fr_ptr)REMOTE_TrailBase(myworker_id);
H = H0 = ((CELL *) REMOTE_GlobalBase(myworker_id))+1; H = H0 = ((CELL *) REMOTE_GlobalBase(myworker_id))+1; // +1: hack to ensure the gc does not try to mark mistakenly
LCL0 = ASP = (CELL *) REMOTE_LocalBase(myworker_id); LCL0 = ASP = (CELL *) REMOTE_LocalBase(myworker_id);
CurrentTrailTop = (tr_fr_ptr)(REMOTE_TrailTop(myworker_id)-MinTrailGap); CurrentTrailTop = (tr_fr_ptr)(REMOTE_TrailTop(myworker_id)-MinTrailGap);
/* notice that an initial choice-point and environment /* notice that an initial choice-point and environment

View File

@ -1923,7 +1923,10 @@ suspend_indexing(ClauseDef *min, ClauseDef *max, PredEntry *ap, struct intermedi
} else { } else {
Yap_IndexSpace_EXT += sz; Yap_IndexSpace_EXT += sz;
} }
Yap_inform_profiler_of_clause(ncode, (CODEADDR)ncode+sz, ap, GPROF_NEW_EXPAND_BLOCK); {
CACHE_REGS
Yap_inform_profiler_of_clause(ncode, (CODEADDR)ncode+sz, ap, GPROF_NEW_EXPAND_BLOCK);
}
/* create an expand_block */ /* create an expand_block */
ncode->opc = Yap_opcode(_expand_clauses); ncode->opc = Yap_opcode(_expand_clauses);
ncode->u.sssllp.p = ap; ncode->u.sssllp.p = ap;