avoid _longjmp
This commit is contained in:
parent
4546a22101
commit
6e2947e8c4
92
C/compiler.c
92
C/compiler.c
@ -533,7 +533,7 @@ optimize_ce(Term t, unsigned int arity, unsigned int level, compiler_struct *cgl
|
||||
if (H >= (CELL *)cglobs->cint.freep0) {
|
||||
/* oops, too many new variables */
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
}
|
||||
p->NextCE = cglobs->common_exps;
|
||||
cglobs->common_exps = p;
|
||||
@ -568,7 +568,7 @@ compile_sf_term(Term t, int argno, int level)
|
||||
Yap_Error_Term = TermNil;
|
||||
Yap_ErrorMessage = "illegal argument of soft functor";
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||
siglongjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||
}
|
||||
else
|
||||
c_var(t, -argno, arity, level, cglobs);
|
||||
@ -595,7 +595,7 @@ c_args(Term app, unsigned int level, compiler_struct *cglobs)
|
||||
Yap_Error_Term = TermNil;
|
||||
Yap_ErrorMessage = "exceed maximum arity of compiled goal";
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||
siglongjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||
}
|
||||
if (Arity > cglobs->max_args)
|
||||
cglobs->max_args = Arity;
|
||||
@ -615,7 +615,7 @@ try_store_as_dbterm(Term t, Int argno, unsigned int arity, int level, compiler_s
|
||||
/* oops, too deep a term */
|
||||
save_machine_regs();
|
||||
Yap_Error_Size = 0;
|
||||
_longjmp(cglobs->cint.CompilerBotch, OUT_OF_AUX_BOTCH);
|
||||
siglongjmp(cglobs->cint.CompilerBotch, OUT_OF_AUX_BOTCH);
|
||||
}
|
||||
if (g < 16)
|
||||
return FALSE;
|
||||
@ -626,18 +626,18 @@ try_store_as_dbterm(Term t, Int argno, unsigned int arity, int level, compiler_s
|
||||
switch(Yap_Error_TYPE) {
|
||||
case OUT_OF_STACK_ERROR:
|
||||
Yap_Error_TYPE = YAP_NO_ERROR;
|
||||
_longjmp(cglobs->cint.CompilerBotch,OUT_OF_STACK_BOTCH);
|
||||
siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_STACK_BOTCH);
|
||||
case OUT_OF_TRAIL_ERROR:
|
||||
Yap_Error_TYPE = YAP_NO_ERROR;
|
||||
_longjmp(cglobs->cint.CompilerBotch,OUT_OF_TRAIL_BOTCH);
|
||||
siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_TRAIL_BOTCH);
|
||||
case OUT_OF_HEAP_ERROR:
|
||||
Yap_Error_TYPE = YAP_NO_ERROR;
|
||||
_longjmp(cglobs->cint.CompilerBotch,OUT_OF_HEAP_BOTCH);
|
||||
siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_HEAP_BOTCH);
|
||||
case OUT_OF_AUXSPACE_ERROR:
|
||||
Yap_Error_TYPE = YAP_NO_ERROR;
|
||||
_longjmp(cglobs->cint.CompilerBotch,OUT_OF_AUX_BOTCH);
|
||||
siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_AUX_BOTCH);
|
||||
default:
|
||||
_longjmp(cglobs->cint.CompilerBotch,COMPILER_ERR_BOTCH);
|
||||
siglongjmp(cglobs->cint.CompilerBotch,COMPILER_ERR_BOTCH);
|
||||
}
|
||||
}
|
||||
H = h0;
|
||||
@ -1004,7 +1004,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
Yap_bip_name(Op, s);
|
||||
sprintf(Yap_ErrorMessage, "compiling %s/2 with output bound", s);
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch,1);
|
||||
siglongjmp(cglobs->cint.CompilerBotch,1);
|
||||
}
|
||||
}
|
||||
} else { /* t1 is bound */
|
||||
@ -1019,7 +1019,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
Yap_bip_name(Op, s);
|
||||
sprintf(Yap_ErrorMessage, "compiling %s/3",s);
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch,1);
|
||||
siglongjmp(cglobs->cint.CompilerBotch,1);
|
||||
}
|
||||
} else {
|
||||
if (Op == _functor) {
|
||||
@ -1035,7 +1035,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
Yap_bip_name(Op, s);
|
||||
sprintf(Yap_ErrorMessage, "compiling functor/3");
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch,1);
|
||||
siglongjmp(cglobs->cint.CompilerBotch,1);
|
||||
}
|
||||
i2 = IntegerOfTerm(t2);
|
||||
if (i2 < 0) {
|
||||
@ -1047,7 +1047,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
Yap_bip_name(Op, s);
|
||||
sprintf(Yap_ErrorMessage, "compiling functor/3");
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch,1);
|
||||
siglongjmp(cglobs->cint.CompilerBotch,1);
|
||||
}
|
||||
if (IsNumTerm(t1)) {
|
||||
/* we will always fail */
|
||||
@ -1062,7 +1062,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
Yap_bip_name(Op, s);
|
||||
sprintf(Yap_ErrorMessage, "compiling functor/3");
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch,1);
|
||||
siglongjmp(cglobs->cint.CompilerBotch,1);
|
||||
}
|
||||
if (i2 == 0)
|
||||
c_eq(t1, t3, cglobs);
|
||||
@ -1074,7 +1074,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
if (H+2 >= (CELL *)cglobs->cint.freep0) {
|
||||
/* oops, too many new variables */
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
}
|
||||
RESET_VARIABLE(H);
|
||||
RESET_VARIABLE(H+1);
|
||||
@ -1086,7 +1086,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
if (H >= (CELL *)cglobs->cint.freep0) {
|
||||
/* oops, too many new variables */
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
}
|
||||
RESET_VARIABLE(H);
|
||||
H++;
|
||||
@ -1098,7 +1098,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
Prop p0 = PredPropByFunc(f, mod);
|
||||
if (EndOfPAEntr(p0)) {
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch, OUT_OF_HEAP_BOTCH);
|
||||
siglongjmp(cglobs->cint.CompilerBotch, OUT_OF_HEAP_BOTCH);
|
||||
}
|
||||
c_args(Goal, 0, cglobs);
|
||||
Yap_emit(safe_call_op, (CELL)p0 , Zero, &cglobs->cint);
|
||||
@ -1120,7 +1120,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
Yap_bip_name(Op, s);
|
||||
sprintf(Yap_ErrorMessage, "compiling %s/2", s);
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch,1);
|
||||
siglongjmp(cglobs->cint.CompilerBotch,1);
|
||||
}
|
||||
if (IsAtomicTerm(t2) ||
|
||||
(IsApplTerm(t2) && IsExtensionFunctor(FunctorOfTerm(t2)))) {
|
||||
@ -1132,7 +1132,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
Yap_bip_name(Op, s);
|
||||
sprintf(Yap_ErrorMessage, "compiling %s/2", s);
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch,1);
|
||||
siglongjmp(cglobs->cint.CompilerBotch,1);
|
||||
} else if (IsApplTerm(t2)) {
|
||||
Functor f = FunctorOfTerm(t2);
|
||||
if (i1 < 1 || i1 > ArityOfFunctor(f)) {
|
||||
@ -1163,7 +1163,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
Yap_bip_name(Op, s);
|
||||
sprintf(Yap_ErrorMessage, "compiling %s/2", s);
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch,1);
|
||||
siglongjmp(cglobs->cint.CompilerBotch,1);
|
||||
}
|
||||
}
|
||||
if (Op == _functor) {
|
||||
@ -1176,7 +1176,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
Yap_bip_name(Op, s);
|
||||
sprintf(Yap_ErrorMessage, "compiling %s/2", s);
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch,1);
|
||||
siglongjmp(cglobs->cint.CompilerBotch,1);
|
||||
} else {
|
||||
if (!IsVarTerm(t2)) {
|
||||
Int arity;
|
||||
@ -1191,7 +1191,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
Yap_bip_name(Op, s);
|
||||
sprintf(Yap_ErrorMessage, "compiling %s/2", s);
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch,1);
|
||||
siglongjmp(cglobs->cint.CompilerBotch,1);
|
||||
}
|
||||
arity = IntOfTerm(t2);
|
||||
if (arity < 0) {
|
||||
@ -1209,12 +1209,12 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
Yap_bip_name(Op, s);
|
||||
sprintf(Yap_ErrorMessage, "compiling %s/2", s);
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch,1);
|
||||
siglongjmp(cglobs->cint.CompilerBotch,1);
|
||||
}
|
||||
if (H+1+arity >= (CELL *)cglobs->cint.freep0) {
|
||||
/* oops, too many new variables */
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
}
|
||||
tnew = AbsAppl(H);
|
||||
*H++ = (CELL)Yap_MkFunctor(AtomOfTerm(t1),arity);
|
||||
@ -1253,7 +1253,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
Yap_bip_name(Op, s);
|
||||
sprintf(Yap_ErrorMessage, "compiling %s/2 with output bound", s);
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch,1);
|
||||
siglongjmp(cglobs->cint.CompilerBotch,1);
|
||||
}
|
||||
}
|
||||
/* then we compile the opcode/result */
|
||||
@ -1263,7 +1263,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
if (H == (CELL *)cglobs->cint.freep0) {
|
||||
/* oops, too many new variables */
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
}
|
||||
c_var(tmpvar,f_flag,(unsigned int)Op, 0, cglobs);
|
||||
c_eq(tmpvar,t3, cglobs);
|
||||
@ -1276,7 +1276,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
Yap_bip_name(Op, s);
|
||||
sprintf(Yap_ErrorMessage, "compiling %s/2 with input unbound", s);
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch,1);
|
||||
siglongjmp(cglobs->cint.CompilerBotch,1);
|
||||
}
|
||||
} else if (IsNewVar(t3) && cglobs->curbranch == 0 && cglobs->cint.CurrentPred->PredFlags & TabledPredFlag) {
|
||||
Term nv = MkVarTerm();
|
||||
@ -1342,7 +1342,7 @@ c_functor(Term Goal, Term mod, compiler_struct *cglobs)
|
||||
|
||||
if (EndOfPAEntr(p0)) {
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch, OUT_OF_HEAP_BOTCH);
|
||||
siglongjmp(cglobs->cint.CompilerBotch, OUT_OF_HEAP_BOTCH);
|
||||
}
|
||||
if (profiling)
|
||||
Yap_emit(enter_profiling_op, (CELL)RepPredProp(p0), Zero, &cglobs->cint);
|
||||
@ -1443,7 +1443,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
||||
Yap_Error_Term = M;
|
||||
Yap_ErrorMessage = "in module name";
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||
siglongjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||
}
|
||||
Goal = ArgOfTerm(2, Goal);
|
||||
mod = M;
|
||||
@ -1561,7 +1561,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
||||
p = RepPredProp(p0 = Yap_PredPropByAtomNonThreadLocal(atom, mod));
|
||||
if (EndOfPAEntr(p0)) {
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch, OUT_OF_HEAP_BOTCH);
|
||||
siglongjmp(cglobs->cint.CompilerBotch, OUT_OF_HEAP_BOTCH);
|
||||
}
|
||||
/* if we are profiling, make sure we register we entered this predicate */
|
||||
if (profiling)
|
||||
@ -1574,7 +1574,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
||||
p = RepPredProp(p0 = Yap_PredPropByFunctorNonThreadLocal(f, mod));
|
||||
if (EndOfPAEntr(p0)) {
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch, OUT_OF_HEAP_BOTCH);
|
||||
siglongjmp(cglobs->cint.CompilerBotch, OUT_OF_HEAP_BOTCH);
|
||||
}
|
||||
if (f == FunctorOr || f == FunctorVBar) {
|
||||
Term arg;
|
||||
@ -1649,7 +1649,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
||||
if (H == (CELL *)cglobs->cint.freep0) {
|
||||
/* oops, too many new variables */
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
}
|
||||
savecpc = cglobs->cint.cpc;
|
||||
savencpc = FirstP->nextInst;
|
||||
@ -1732,7 +1732,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
||||
if (H == (CELL *)cglobs->cint.freep0) {
|
||||
/* oops, too many new variables */
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
}
|
||||
push_branch(cglobs->onbranch, commitvar, cglobs);
|
||||
++cglobs->curbranch;
|
||||
@ -1767,7 +1767,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
||||
if (H == (CELL *)cglobs->cint.freep0) {
|
||||
/* oops, too many new variables */
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
}
|
||||
cglobs->onlast = FALSE;
|
||||
c_var(commitvar, save_b_flag, 1, 0, cglobs);
|
||||
@ -1882,7 +1882,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
||||
Yap_ErrorMessage = Yap_ErrorSay;
|
||||
sprintf(Yap_ErrorMessage, "compiling %s/2 with second arg unbound", RepAtom(NameOfFunctor(p->FunctorOfPred))->StrOfAE);
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch,1);
|
||||
siglongjmp(cglobs->cint.CompilerBotch,1);
|
||||
}
|
||||
c_var(a1, bt1_flag, 2, 0, cglobs);
|
||||
cglobs->current_p0 = p0;
|
||||
@ -1893,7 +1893,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
||||
if (H == (CELL *)cglobs->cint.freep0) {
|
||||
/* oops, too many new variables */
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
}
|
||||
c_eq(t2, a2, cglobs);
|
||||
c_var(a1, bt1_flag, 2, 0, cglobs);
|
||||
@ -1906,7 +1906,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
||||
if (H == (CELL *)cglobs->cint.freep0) {
|
||||
/* oops, too many new variables */
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
}
|
||||
c_eq(t1, a1, cglobs);
|
||||
|
||||
@ -1920,7 +1920,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
||||
if (H == (CELL *)cglobs->cint.freep0) {
|
||||
/* oops, too many new variables */
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
}
|
||||
c_eq(t2, a2, cglobs);
|
||||
c_var(t1, bt1_flag, 2, 0, cglobs);
|
||||
@ -2287,7 +2287,7 @@ clear_bvarray(int var, CELL *bvarray
|
||||
Yap_ErrorMessage = "compiler internal error: variable initialised twice";
|
||||
fprintf(stderr," vsc: compiling7\n");
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||
siglongjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||
}
|
||||
cglobs->pbvars++;
|
||||
#endif
|
||||
@ -2328,7 +2328,7 @@ push_bvmap(int label, PInstr *pcpc, compiler_struct *cglobs)
|
||||
Yap_Error_Term = TermNil;
|
||||
Yap_ErrorMessage = "Too many embedded disjunctions";
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||
siglongjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||
}
|
||||
/* the label instruction */
|
||||
bvstack[bvindex].lab = label;
|
||||
@ -2351,7 +2351,7 @@ reset_bvmap(CELL *bvarray, int nperm, compiler_struct *cglobs)
|
||||
Yap_Error_Term = TermNil;
|
||||
Yap_ErrorMessage = "No embedding in disjunctions";
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||
siglongjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||
}
|
||||
env_size = (bvstack[bvindex-1].pc)->rnd1;
|
||||
size = env_size/(8*sizeof(CELL));
|
||||
@ -2371,7 +2371,7 @@ pop_bvmap(CELL *bvarray, int nperm, compiler_struct *cglobs)
|
||||
Yap_Error_Term = TermNil;
|
||||
Yap_ErrorMessage = "Too few embedded disjunctions";
|
||||
/* save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch, OUT_OF_HEAP_BOTCH); */
|
||||
siglongjmp(cglobs->cint.CompilerBotch, OUT_OF_HEAP_BOTCH); */
|
||||
}
|
||||
reset_bvmap(bvarray, nperm, cglobs);
|
||||
bvindex--;
|
||||
@ -2641,7 +2641,7 @@ checktemp(Int arg, Int rn, compiler_vm_op ic, compiler_struct *cglobs)
|
||||
Yap_Error_Term = TermNil;
|
||||
Yap_ErrorMessage = "too many temporaries";
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||
siglongjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||
}
|
||||
v->NoOfVE = cglobs->vadr = vadr = TempVar | target1;
|
||||
v->KindOfVE = TempVar;
|
||||
@ -2774,7 +2774,7 @@ c_layout(compiler_struct *cglobs)
|
||||
Yap_Error_Term = TermNil;
|
||||
Yap_ErrorMessage = "wrong number of variables found in bitmap";
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs->cint.CompilerBotch, OUT_OF_HEAP_BOTCH);
|
||||
siglongjmp(cglobs->cint.CompilerBotch, OUT_OF_HEAP_BOTCH);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -3319,7 +3319,7 @@ Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, volatile Term src)
|
||||
|
||||
/* make sure we know there was no error yet */
|
||||
Yap_ErrorMessage = NULL;
|
||||
if ((botch_why = _setjmp(cglobs.cint.CompilerBotch))) {
|
||||
if ((botch_why = sigsetjmp(cglobs.cint.CompilerBotch, 0))) {
|
||||
restore_machine_regs();
|
||||
reset_vars(cglobs.vtable);
|
||||
Yap_ReleaseCMem(&cglobs.cint);
|
||||
@ -3420,7 +3420,7 @@ Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, volatile Term src)
|
||||
cglobs.vtable = NULL;
|
||||
Yap_Error_Size = (256+maxvnum)*sizeof(CELL);
|
||||
save_machine_regs();
|
||||
_longjmp(cglobs.cint.CompilerBotch,3);
|
||||
siglongjmp(cglobs.cint.CompilerBotch,3);
|
||||
}
|
||||
cglobs.Uses = (Int *)(H+maxvnum);
|
||||
cglobs.Contents = (Term *)(H+maxvnum+(sizeof(Int)/sizeof(CELL))*MaxTemps);
|
||||
|
@ -165,7 +165,7 @@ gc_growtrail(int committed, tr_fr_ptr begsTR, cont *old_cont_top0)
|
||||
#endif
|
||||
/* could not find more trail */
|
||||
save_machine_regs();
|
||||
_longjmp(Yap_gc_restore, 2);
|
||||
siglongjmp(Yap_gc_restore, 2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -425,7 +425,7 @@ check_pr_trail(tr_fr_ptr trp)
|
||||
if (!Yap_growtrail(0, TRUE) || TRUE) {
|
||||
/* could not find more trail */
|
||||
save_machine_regs();
|
||||
_longjmp(Yap_gc_restore, 2);
|
||||
siglongjmp(Yap_gc_restore, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3782,7 +3782,7 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop)
|
||||
}
|
||||
#endif
|
||||
time_start = Yap_cputime();
|
||||
if (_setjmp(Yap_gc_restore) == 2) {
|
||||
if (sigsetjmp(Yap_gc_restore, 0) == 2) {
|
||||
UInt sz;
|
||||
|
||||
/* we cannot recover, fail system */
|
||||
|
52
C/index.c
52
C/index.c
@ -188,7 +188,7 @@
|
||||
* Revision 1.150 2005/12/23 00:20:13 vsc
|
||||
* updates to gprof
|
||||
* support for __POWER__
|
||||
* Try to saveregs before _longjmp.
|
||||
* Try to saveregs before siglongjmp.
|
||||
*
|
||||
* Revision 1.149 2005/12/17 03:25:39 vsc
|
||||
* major changes to support online event-based profiling
|
||||
@ -832,14 +832,14 @@ sort_group(GroupDef *grp, CELL *top, struct intermediates *cint)
|
||||
if (!(base = (CELL *)Yap_AllocCodeSpace(2*max*sizeof(CELL)))) {
|
||||
save_machine_regs();
|
||||
Yap_Error_Size = 2*max*sizeof(CELL);
|
||||
_longjmp(cint->CompilerBotch,2);
|
||||
siglongjmp(cint->CompilerBotch,2);
|
||||
}
|
||||
#else
|
||||
base = top;
|
||||
while (top+2*max > (CELL *)Yap_TrailTop) {
|
||||
if (!Yap_growtrail(2*max*CellSize, TRUE)) {
|
||||
save_machine_regs();
|
||||
_longjmp(cint->CompilerBotch,4);
|
||||
siglongjmp(cint->CompilerBotch,4);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -2046,11 +2046,11 @@ groups_in(ClauseDef *min, ClauseDef *max, GroupDef *grp, struct intermediates *c
|
||||
Yap_Error_Size = sz;
|
||||
/* grow stack */
|
||||
save_machine_regs();
|
||||
_longjmp(cint->CompilerBotch,4);
|
||||
siglongjmp(cint->CompilerBotch,4);
|
||||
#else
|
||||
if (!Yap_growtrail(sz, TRUE)) {
|
||||
save_machine_regs();
|
||||
_longjmp(cint->CompilerBotch,4);
|
||||
siglongjmp(cint->CompilerBotch,4);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@ -2179,7 +2179,7 @@ emit_switch_space(UInt n, UInt item_size, struct intermediates *cint, CELL func_
|
||||
if (cl == NULL) {
|
||||
/* grow stack */
|
||||
save_machine_regs();
|
||||
_longjmp(cint->CompilerBotch,2);
|
||||
siglongjmp(cint->CompilerBotch,2);
|
||||
}
|
||||
Yap_LUIndexSpace_SW += sz;
|
||||
cl->ClFlags = SwitchTableMask|LogUpdMask|func_mask;
|
||||
@ -2199,7 +2199,7 @@ emit_switch_space(UInt n, UInt item_size, struct intermediates *cint, CELL func_
|
||||
if (cl == NULL) {
|
||||
/* grow stack */
|
||||
save_machine_regs();
|
||||
_longjmp(cint->CompilerBotch,2);
|
||||
siglongjmp(cint->CompilerBotch,2);
|
||||
}
|
||||
Yap_IndexSpace_SW += sz;
|
||||
cl->ClFlags = SwitchTableMask;
|
||||
@ -2518,7 +2518,7 @@ suspend_indexing(ClauseDef *min, ClauseDef *max, PredEntry *ap, struct intermedi
|
||||
sz = (UInt)NEXTOP((yamop *)NULL,sssllp)+tels*sizeof(yamop *);
|
||||
if ((ncode = (yamop *)Yap_AllocCodeSpace(sz)) == NULL) {
|
||||
save_machine_regs();
|
||||
_longjmp(cint->CompilerBotch, 2);
|
||||
siglongjmp(cint->CompilerBotch, 2);
|
||||
}
|
||||
#if DEBUG
|
||||
Yap_ExpandClauses++;
|
||||
@ -3130,7 +3130,7 @@ copy_clauses(ClauseDef *max0, ClauseDef *min0, CELL *top, struct intermediates *
|
||||
Yap_Error_Size = sz;
|
||||
/* grow stack */
|
||||
save_machine_regs();
|
||||
_longjmp(cint->CompilerBotch,4);
|
||||
siglongjmp(cint->CompilerBotch,4);
|
||||
}
|
||||
memcpy((void *)top, (void *)min0, sz);
|
||||
return (ClauseDef *)top;
|
||||
@ -3324,7 +3324,7 @@ compile_index(struct intermediates *cint)
|
||||
Yap_Error_Size += NClauses*sizeof(ClauseDef);
|
||||
/* grow stack */
|
||||
save_machine_regs();
|
||||
_longjmp(cint->CompilerBotch,2);
|
||||
siglongjmp(cint->CompilerBotch,2);
|
||||
}
|
||||
}
|
||||
cint->freep = (char *)H;
|
||||
@ -3336,7 +3336,7 @@ compile_index(struct intermediates *cint)
|
||||
Yap_Error_Size += NClauses*sizeof(ClauseDef);
|
||||
/* grow stack */
|
||||
save_machine_regs();
|
||||
_longjmp(cint->CompilerBotch,3);
|
||||
siglongjmp(cint->CompilerBotch,3);
|
||||
}
|
||||
cint->freep = (char *)(cint->cls+NClauses);
|
||||
#endif
|
||||
@ -3381,7 +3381,7 @@ Yap_PredIsIndexable(PredEntry *ap, UInt NSlots, yamop *next_pc)
|
||||
cint.cls = NULL;
|
||||
Yap_Error_Size = 0;
|
||||
|
||||
if ((setjres = _setjmp(cint.CompilerBotch)) == 3) {
|
||||
if ((setjres = sigsetjmp(cint.CompilerBotch, 0)) == 3) {
|
||||
restore_machine_regs();
|
||||
recover_from_failed_susp_on_cls(&cint, 0);
|
||||
if (!Yap_gcl(Yap_Error_Size, ap->ArityOfPE+NSlots, ENV, next_pc)) {
|
||||
@ -3463,7 +3463,7 @@ push_stack(istack_entry *sp, Int arg, Term Tag, Term extra, struct intermediates
|
||||
{
|
||||
if (sp+1 > (istack_entry *)Yap_TrailTop) {
|
||||
save_machine_regs();
|
||||
_longjmp(cint->CompilerBotch,4);
|
||||
siglongjmp(cint->CompilerBotch,4);
|
||||
}
|
||||
sp->pos = arg;
|
||||
sp->val = Tag;
|
||||
@ -4349,7 +4349,7 @@ expand_index(struct intermediates *cint) {
|
||||
Yap_Error_Size += NClauses*sizeof(ClauseDef);
|
||||
/* grow stack */
|
||||
save_machine_regs();
|
||||
_longjmp(cint->CompilerBotch,2);
|
||||
siglongjmp(cint->CompilerBotch,2);
|
||||
}
|
||||
}
|
||||
#else
|
||||
@ -4359,7 +4359,7 @@ expand_index(struct intermediates *cint) {
|
||||
Yap_Error_Size += 2*NClauses*sizeof(ClauseDef);
|
||||
/* grow stack */
|
||||
save_machine_regs();
|
||||
_longjmp(cint->CompilerBotch,3);
|
||||
siglongjmp(cint->CompilerBotch,3);
|
||||
}
|
||||
#endif
|
||||
if (ap->PredFlags & LogUpdatePredFlag) {
|
||||
@ -4377,7 +4377,7 @@ expand_index(struct intermediates *cint) {
|
||||
Yap_Error_Size += NClauses*sizeof(ClauseDef);
|
||||
/* grow stack */
|
||||
save_machine_regs();
|
||||
_longjmp(cint->CompilerBotch,2);
|
||||
siglongjmp(cint->CompilerBotch,2);
|
||||
}
|
||||
}
|
||||
#else
|
||||
@ -4386,7 +4386,7 @@ expand_index(struct intermediates *cint) {
|
||||
/* tell how much space we need (worst case) */
|
||||
Yap_Error_Size += 2*NClauses*sizeof(ClauseDef);
|
||||
save_machine_regs();
|
||||
_longjmp(cint->CompilerBotch,3);
|
||||
siglongjmp(cint->CompilerBotch,3);
|
||||
}
|
||||
#endif
|
||||
if (ap->PredFlags & LogUpdatePredFlag) {
|
||||
@ -4485,7 +4485,7 @@ ExpandIndex(PredEntry *ap, int ExtraArgs, yamop *nextop) {
|
||||
cint.cls = NULL;
|
||||
cint.code_addr = NULL;
|
||||
cint.label_offset = NULL;
|
||||
if ((cb = _setjmp(cint.CompilerBotch)) == 3) {
|
||||
if ((cb = sigsetjmp(cint.CompilerBotch, 0)) == 3) {
|
||||
restore_machine_regs();
|
||||
/* grow stack */
|
||||
recover_from_failed_susp_on_cls(&cint, 0);
|
||||
@ -4695,7 +4695,7 @@ push_path(path_stack_entry *sp, yamop **pipc, ClauseDef *clp, struct intermediat
|
||||
{
|
||||
if (sp+1 > (path_stack_entry *)Yap_TrailTop) {
|
||||
save_machine_regs();
|
||||
_longjmp(cint->CompilerBotch,4);
|
||||
siglongjmp(cint->CompilerBotch,4);
|
||||
}
|
||||
sp->flag = pc_entry;
|
||||
sp->u.pce.pi_pc = pipc;
|
||||
@ -4711,7 +4711,7 @@ fetch_new_block(path_stack_entry *sp, yamop **pipc, PredEntry *ap, struct interm
|
||||
{
|
||||
if (sp+1 > (path_stack_entry *)Yap_TrailTop) {
|
||||
save_machine_regs();
|
||||
_longjmp(cint->CompilerBotch,4);
|
||||
siglongjmp(cint->CompilerBotch,4);
|
||||
}
|
||||
/* add current position */
|
||||
sp->flag = block_entry;
|
||||
@ -5484,9 +5484,9 @@ add_try(PredEntry *ap, ClauseDef *cls, yamop *next, struct intermediates *cint)
|
||||
LogUpdClause *lcl = ClauseCodeToLogUpdClause(cls->Code);
|
||||
|
||||
if ((newcp = (yamop *)Yap_AllocCodeSpace(size)) == NULL) {
|
||||
/* OOOPS, got in trouble, must do a _longjmp and recover space */
|
||||
/* OOOPS, got in trouble, must do a siglongjmp and recover space */
|
||||
save_machine_regs();
|
||||
_longjmp(cint->CompilerBotch,2);
|
||||
siglongjmp(cint->CompilerBotch,2);
|
||||
}
|
||||
Yap_LUIndexSpace_CP += size;
|
||||
#ifdef DEBUG
|
||||
@ -5510,9 +5510,9 @@ add_trust(LogUpdIndex *icl, ClauseDef *cls, struct intermediates *cint)
|
||||
PredEntry *ap = lcl->ClPred;
|
||||
|
||||
if ((newcp = (yamop *)Yap_AllocCodeSpace(size)) == NULL) {
|
||||
/* OOOPS, got in trouble, must do a _longjmp and recover space */
|
||||
/* OOOPS, got in trouble, must do a siglongjmp and recover space */
|
||||
save_machine_regs();
|
||||
_longjmp(cint->CompilerBotch,2);
|
||||
siglongjmp(cint->CompilerBotch,2);
|
||||
}
|
||||
Yap_LUIndexSpace_CP += size;
|
||||
#ifdef DEBUG
|
||||
@ -6000,7 +6000,7 @@ Yap_AddClauseToIndex(PredEntry *ap, yamop *beg, int first) {
|
||||
cint.CurrentPred = ap;
|
||||
cint.expand_block = NULL;
|
||||
cint.CodeStart = cint.BlobsStart = cint.cpc = cint.icpc = NIL;
|
||||
if ((cb = _setjmp(cint.CompilerBotch)) == 3) {
|
||||
if ((cb = sigsetjmp(cint.CompilerBotch, 0)) == 3) {
|
||||
restore_machine_regs();
|
||||
Yap_gcl(Yap_Error_Size, ap->ArityOfPE, ENV, CP);
|
||||
save_machine_regs();
|
||||
@ -6476,7 +6476,7 @@ Yap_RemoveClauseFromIndex(PredEntry *ap, yamop *beg) {
|
||||
}
|
||||
cint.expand_block = NULL;
|
||||
cint.CodeStart = cint.BlobsStart = cint.cpc = cint.icpc = NULL;
|
||||
if ((cb = _setjmp(cint.CompilerBotch)) == 3) {
|
||||
if ((cb = sigsetjmp(cint.CompilerBotch, 0)) == 3) {
|
||||
restore_machine_regs();
|
||||
Yap_gcl(Yap_Error_Size, ap->ArityOfPE, ENV, CP);
|
||||
save_machine_regs();
|
||||
|
12
C/parser.c
12
C/parser.c
@ -65,7 +65,7 @@ static char SccsId[] = "%W% %G%";
|
||||
/* weak backtraking mechanism based on long_jump */
|
||||
|
||||
typedef struct jmp_buff_struct {
|
||||
jmp_buf JmpBuff;
|
||||
sigjmp_buf JmpBuff;
|
||||
} JMPBUFF;
|
||||
|
||||
STATIC_PROTO(void GNextToken, (void));
|
||||
@ -81,7 +81,7 @@ STATIC_PROTO(Term ParseTerm, (int, JMPBUFF *));
|
||||
Volatile CELL *saveH=H; \
|
||||
Volatile int savecurprio=curprio; \
|
||||
saveenv=FailBuff; \
|
||||
if(!_setjmp(newenv.JmpBuff)) { \
|
||||
if(!sigsetjmp(newenv.JmpBuff, 0)) { \
|
||||
FailBuff = &newenv; \
|
||||
S; \
|
||||
FailBuff=saveenv; \
|
||||
@ -99,7 +99,7 @@ STATIC_PROTO(Term ParseTerm, (int, JMPBUFF *));
|
||||
Volatile TokEntry *saveT=Yap_tokptr; \
|
||||
Volatile CELL *saveH=H; \
|
||||
saveenv=FailBuff; \
|
||||
if(!_setjmp(newenv.JmpBuff)) { \
|
||||
if(!sigsetjmp(newenv.JmpBuff, 0)) { \
|
||||
FailBuff = &newenv; \
|
||||
S; \
|
||||
FailBuff=saveenv; \
|
||||
@ -113,7 +113,7 @@ STATIC_PROTO(Term ParseTerm, (int, JMPBUFF *));
|
||||
}
|
||||
|
||||
|
||||
#define FAIL _longjmp(FailBuff->JmpBuff,1)
|
||||
#define FAIL siglongjmp(FailBuff->JmpBuff,1)
|
||||
|
||||
VarEntry *
|
||||
Yap_LookupVar(char *var) /* lookup variable in variables table */
|
||||
@ -181,7 +181,7 @@ VarNames(VarEntry *p,Term l)
|
||||
VarNames(p->VarLeft,l)));
|
||||
if (H > ASP-4096) {
|
||||
save_machine_regs();
|
||||
_longjmp(Yap_IOBotch,1);
|
||||
siglongjmp(Yap_IOBotch,1);
|
||||
}
|
||||
return(o);
|
||||
} else {
|
||||
@ -706,7 +706,7 @@ Yap_Parse(void)
|
||||
Volatile Term t;
|
||||
JMPBUFF FailBuff;
|
||||
|
||||
if (!_setjmp(FailBuff.JmpBuff)) {
|
||||
if (!sigsetjmp(FailBuff.JmpBuff, 0)) {
|
||||
t = ParseTerm(1200, &FailBuff);
|
||||
if (Yap_tokptr->Tok != Ord(eot_tok))
|
||||
return (0L);
|
||||
|
5
H/Yap.h
5
H/Yap.h
@ -245,11 +245,6 @@ typedef unsigned long int YAP_ULONG_LONG;
|
||||
#define LOW_PROF 1
|
||||
#endif
|
||||
|
||||
#if !HAVE__SETJMP
|
||||
#define _longjmp(A,B) longjmp(A,B)
|
||||
#define _setjmp(A) setjmp(A)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
extern char Yap_Option[20];
|
||||
#endif
|
||||
|
@ -263,7 +263,7 @@ typedef struct intermediates {
|
||||
Int *uses;
|
||||
Term *contents;
|
||||
struct pred_entry *CurrentPred;
|
||||
jmp_buf CompilerBotch;
|
||||
sigjmp_buf CompilerBotch;
|
||||
yamop *code_addr;
|
||||
yamop *expand_block;
|
||||
UInt i_labelno;
|
||||
|
@ -135,7 +135,7 @@ typedef struct worker_local {
|
||||
struct RB_red_blk_node* DB_root;
|
||||
struct RB_red_blk_node* DB_nil;
|
||||
#endif /* defined(YAPOR) || defined(THREADS) */
|
||||
jmp_buf gc_restore;
|
||||
sigjmp_buf gc_restore;
|
||||
struct array_entry* dynamic_arrays;
|
||||
struct static_array_entry* static_arrays;
|
||||
struct global_entry* global_variables;
|
||||
|
@ -167,7 +167,6 @@
|
||||
#undef RETSIGTYPE
|
||||
|
||||
#undef HAVE__NSGETENVIRON
|
||||
#undef HAVE__SETJMP
|
||||
#undef HAVE_ACCESS
|
||||
#undef HAVE_ACOSH
|
||||
#undef HAVE_ALARM
|
||||
|
20
configure.in
20
configure.in
@ -1567,26 +1567,6 @@ else
|
||||
AC_DEFINE(HAVE_SIGSETJMP,0)
|
||||
fi
|
||||
|
||||
dnl check for _setjmp
|
||||
AC_MSG_CHECKING(for _setjmp)
|
||||
AC_CACHE_VAL(yap_cv__setjmp,[
|
||||
AC_TRY_COMPILE(
|
||||
#include <setjmp.h>
|
||||
,
|
||||
jmp_buf RestartEnv;
|
||||
|
||||
_setjmp (RestartEnv);
|
||||
_longjmp (RestartEnv, 1);
|
||||
,
|
||||
yap_cv__setjmp=yes,yap_cv__setjmp=no)])
|
||||
AC_MSG_RESULT($yap_cv__setjmp)
|
||||
if test "$yap_cv__setjmp" = yes
|
||||
then
|
||||
AC_DEFINE(HAVE__SETJMP,1)
|
||||
else
|
||||
AC_DEFINE(HAVE__SETJMP,0)
|
||||
fi
|
||||
|
||||
dnl check for sigsegv
|
||||
AC_MSG_CHECKING(for sigsegv)
|
||||
AC_CACHE_VAL(yap_cv_sigsegv,[
|
||||
|
@ -144,7 +144,7 @@ struct RB_red_blk_node* DB_nil db_nil =NULL
|
||||
#endif /* defined(YAPOR) || defined(THREADS) */
|
||||
|
||||
|
||||
jmp_buf gc_restore Yap_gc_restore void
|
||||
sigjmp_buf gc_restore Yap_gc_restore void
|
||||
struct array_entry* dynamic_arrays DynamicArrays =NULL PtoArrayEAdjust
|
||||
struct static_array_entry* static_arrays StaticArrays =NULL PtoArraySAdjust
|
||||
struct global_entry* global_variables GlobalVariables =NULL PtoGlobalEAdjust
|
||||
|
Reference in New Issue
Block a user