Upgrade to new CHR (with Jan's changes).

Found out I need to add an extra field to allocate so that the
exception handling code knows where the clause is.
Protect creep_allowed from NULL pointers.
This commit is contained in:
Vitor Santos Costa
2008-08-30 16:24:44 +01:00
parent 2ae9677f4b
commit 2a84e259a2
11 changed files with 49 additions and 20 deletions

View File

@@ -557,11 +557,13 @@ static inline Term rbig(MP_INT *big)
static PredEntry *
creep_allowed(PredEntry *p, PredEntry *p0)
{
if (!p0)
return NULL;
if (p0 == PredMetaCall)
return p0;
if (!p0->ModuleOfPred &&
(!p->ModuleOfPred
||
(!p ||
!p->ModuleOfPred ||
p->PredFlags & StandardPredFlag))
return NULL;
return p;
@@ -2693,6 +2695,7 @@ Yap_absmi(int inp)
Yap_op_from_opcode(PREG->opc) != Yap_opcode(_cut_e)) {
GONext();
}
PP = PREG->u.p.p;
ASP = YREG+E_CB;
/* cut_e */
if (SREG <= ASP) {
@@ -2732,8 +2735,8 @@ Yap_absmi(int inp)
}
if (!(ActiveSignals & YAP_CREEP_SIGNAL)) {
SREG = (CELL *)RepPredProp(Yap_GetPredPropByFunc(Yap_MkFunctor(AtomRestoreRegs,2),0));
XREGS[0] = YREG[PREG->u.y.y];
PREG = NEXTOP(PREG,y);
XREGS[0] = YREG[PREG->u.yp.y];
PREG = NEXTOP(PREG,yp);
goto creep_either;
}
/* don't do debugging and friends here */
@@ -2763,8 +2766,8 @@ Yap_absmi(int inp)
#endif /* DEPTH_LIMIT */
ENDCACHE_Y_AS_ENV();
}
XREGS[0] = XREG(PREG->u.x.x);
PREG = NEXTOP(PREG,x);
XREGS[0] = XREG(PREG->u.xp.x);
PREG = NEXTOP(PREG,xp);
goto creep_either;
}
/* don't do debugging and friends here */
@@ -3106,9 +3109,9 @@ Yap_absmi(int inp)
GONext();
ENDOp();
Op(deallocate, e);
Op(deallocate, p);
CACHE_Y_AS_ENV(YREG);
PREG = NEXTOP(PREG, e);
PREG = NEXTOP(PREG, p);
/* other instructions do depend on S being set by deallocate
:-( */
SREG = YREG;

View File

@@ -517,6 +517,17 @@ a_e(op_numbers opcode, yamop *code_p, int pass_no)
return code_p;
}
inline static yamop *
a_p0(op_numbers opcode, yamop *code_p, int pass_no, PredEntry *p0)
{
if (pass_no) {
code_p->opc = emit_op(opcode);
code_p->u.p.p = p0;
}
GONEXT(p);
return code_p;
}
inline static yamop *
a_ue(op_numbers opcode, op_numbers opcodew, yamop *code_p, int pass_no)
{
@@ -2155,7 +2166,7 @@ a_deallocate(clause_info *clinfo, yamop *code_p, int pass_no, struct intermediat
cip->cpc = cip->cpc->nextInst;
code_p = a_p(_dexecute, clinfo, code_p, pass_no, cip);
} else
code_p = a_e(_deallocate, code_p, pass_no);
code_p = a_p0(_deallocate, code_p, pass_no, cip->CurrentPred);
clinfo->dealloc_found = TRUE;
}
return code_p;
@@ -3682,7 +3693,8 @@ Yap_InitComma(void)
code_p->u.sbpp.bmap = NULL;
GONEXT(sbpp);
code_p->opc = emit_op(_deallocate);
GONEXT(e);
code_p->u.p.p = PredMetaCall;
GONEXT(p);
code_p->opc = emit_op(_procceed);
code_p->u.p.p = PredMetaCall;
GONEXT(p);

View File

@@ -3919,11 +3919,13 @@ ClauseInfoForCode(yamop *codeptr, CODEADDR *startp, CODEADDR *endp) {
*endp = (CODEADDR)cl+cl->ClSize;
return cl->ClPred;
}
case _deallocate:
pc = NEXTOP(pc,p);
break;
case _cut:
case _cut_t:
case _cut_e:
case _allocate:
case _deallocate:
case _write_void:
case _write_list:
case _write_l_list:

View File

@@ -980,7 +980,6 @@ has_cut(yamop *pc)
case _trust_fail:
case _op_fail:
case _allocate:
case _deallocate:
case _write_void:
case _write_list:
case _write_l_list:
@@ -1298,7 +1297,8 @@ has_cut(yamop *pc)
pc = NEXTOP(pc,c);
break;
/* instructions type p */
case _procceed:
case _deallocate:
case _procceed:
pc = NEXTOP(pc,p);
break;
/* instructions type sc */
@@ -1479,8 +1479,10 @@ add_info(ClauseDef *clause, UInt regno)
case _cut_e:
clause->Tag = (CELL)NULL;
return;
case _allocate:
case _deallocate:
cl = NEXTOP(cl,p);
break;
case _allocate:
case _write_void:
case _write_list:
case _write_l_list:

View File

@@ -507,7 +507,7 @@ Yap_InitCPred(char *Name, unsigned long int Arity, CPredicate code, int flags)
if (flags & SafePredFlag) {
sz = (CELL)NEXTOP(NEXTOP(NEXTOP(p_code,sbpp),p),l);
} else {
sz = (CELL)NEXTOP(NEXTOP(NEXTOP(NEXTOP(NEXTOP(p_code,e),sbpp),e),p),l);
sz = (CELL)NEXTOP(NEXTOP(NEXTOP(NEXTOP(NEXTOP(p_code,e),sbpp),p),p),l);
}
cl = (StaticClause *)Yap_AllocCodeSpace(sz);
if (!cl) {
@@ -544,7 +544,8 @@ Yap_InitCPred(char *Name, unsigned long int Arity, CPredicate code, int flags)
p_code = NEXTOP(p_code,sbpp);
if (!(flags & SafePredFlag)) {
p_code->opc = Yap_opcode(_deallocate);
p_code = NEXTOP(p_code,e);
p_code->u.p.p = pe;
p_code = NEXTOP(p_code,p);
}
p_code->opc = Yap_opcode(_procceed);
p_code->u.p.p = pe;

View File

@@ -164,6 +164,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 < 2473000LL)
return;
if (vsc_count == 2473801LL)
jmp_deb(1);
#ifdef THREADS
Yap_heap_regs->thread_handle[worker_id].thread_inst_count++;
#endif