recover space after portray

This commit is contained in:
Vitor Santos Costa 2014-10-23 02:10:55 +01:00
parent 4844e43704
commit 130d28ceb3
3 changed files with 49 additions and 0 deletions

View File

@ -1206,6 +1206,51 @@ Yap_exec_absmi(bool top, yap_reset_t has_reset)
}
void
Yap_fail_all( choiceptr bb USES_REGS )
{
yamop *saved_p, *saved_cp;
saved_p = P;
saved_cp = CP;
/* prune away choicepoints */
while (B && B->cp_b != bb) {
B = B->cp_b;
#ifdef YAPOR
CUT_prune_to(B);
#endif
}
P = FAILCODE;
Yap_exec_absmi( true, YAP_EXEC_ABSMI);
/* recover stack space */
HR = B->cp_h;
TR = B->cp_tr;
#ifdef DEPTH_LIMIT
DEPTH = B->cp_depth;
#endif /* DEPTH_LIMIT */
YENV = ENV = B->cp_env;
/* recover local stack */
#ifdef DEPTH_LIMIT
DEPTH= ENV[E_DEPTH];
#endif
/* make sure we prune C-choicepoints */
if (POP_CHOICE_POINT(B->cp_b))
{
POP_EXECUTE();
}
ENV = (CELL *)(ENV[E_E]);
/* ASP should be set to the top of the local stack when we
did the call */
ASP = B->cp_env;
/* YENV should be set to the current environment */
YENV = ENV = (CELL *)((B->cp_env)[E_E]);
B = B->cp_b;
//SET_BB(B);
HB = PROTECT_FROZEN_H(B);
CP = saved_cp;
P = saved_p;
}
int
Yap_execute_pred(PredEntry *ppe, CELL *pt USES_REGS)
{

View File

@ -87,13 +87,16 @@ static bool
callPortray(Term t, struct DB_TERM **old_EXp USES_REGS)
{
PredEntry *pe;
Int b0 = LCL0-(CELL*)B;
EX = NULL;
if ( (pe = RepPredProp(Yap_GetPredPropByFunc(FunctorPortray, USER_MODULE) ) ) &&
pe->OpcodeOfPred != FAIL_OPCODE &&
pe->OpcodeOfPred != UNDEF_OPCODE &&
Yap_execute_pred(pe, &t PASS_REGS) ) {
choiceptr B0 = (choiceptr)(LCL0-b0);
if (EX && !*old_EXp) *old_EXp = EX;
Yap_fail_all(B0 PASS_REGS);
return true;
}
if (EX && !*old_EXp) *old_EXp = EX;

View File

@ -176,6 +176,7 @@ int Yap_SWIHandleError( const char *, ... );
void Yap_InitEval(void);
/* exec.c */
void Yap_fail_all( choiceptr bb USES_REGS);
Term Yap_ExecuteCallMetaCall(Term);
void Yap_InitExecFs(void);
Int Yap_JumpToEnv(Term);