From f9ff6498d85399cc615e703c78ffb3153f1be3fd Mon Sep 17 00:00:00 2001 From: vsc Date: Wed, 30 Jan 2002 03:49:50 +0000 Subject: [PATCH] more simplifications on the catch and throw mechanism after having failed the ISO testset. git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@341 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/exec.c | 34 +++++++++++++++++++--------------- C/init.c | 2 +- C/save.c | 4 ++-- H/Heap.h | 6 +++--- 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/C/exec.c b/C/exec.c index 30e212fa4..15e6af8f8 100644 --- a/C/exec.c +++ b/C/exec.c @@ -1252,24 +1252,28 @@ p_clean_ifcp(void) { Int JumpToEnv(Term t) { - yamop *min = (yamop *)(PredCatch->CodeOfPred); - yamop *max = (yamop *)(PredThrow->CodeOfPred); - CELL *cur = ENV, *env; - yamop *cpe = (yamop *)(cur[E_CP]); + yamop *pos = (yamop *)(PredDollarCatch->LastClause); + CELL *env; - while (cpe < min || cpe > max) { - cur = (CELL *)cur[E_E]; - cpe = (yamop *)(cur[E_CP]); - } - CP = cpe; - env = (CELL *)cur[E_E]; - YENV = ENV = (CELL *)(env[E_E]); - while (B->cp_b < (choiceptr)env) { + do { + /* find the first choicepoint that may be a catch */ + while (B->cp_ap != pos) { + B = B->cp_b; + } + /* is it a continuation? */ + env = B->cp_env; + while (env > ENV) + ENV = (CELL *)ENV[E_E]; + /* yes, we found it ! */ + if (env == ENV) break; + /* oops, try next */ B = B->cp_b; - } - B->cp_cp = (yamop *)(env[E_CP]); + } while (TRUE); + /* step one environment above */ + B->cp_cp = (yamop *)env[E_CP]; B->cp_ap = (yamop *)(PredHandleThrow->LastClause); - B->cp_env = ENV; + B->cp_env = (CELL *)env[E_E]; + /* cannot recover Heap because of copy term :-( */ B->cp_h = H; /* I could backtrack here, but it is easier to leave the unwinding to the emulator */ diff --git a/C/init.c b/C/init.c index f28335598..a6c8269d9 100644 --- a/C/init.c +++ b/C/init.c @@ -1012,7 +1012,7 @@ InitCodes(void) CurrentModule = 0; heap_regs->dead_clauses = NULL; heap_regs->pred_meta_call = RepPredProp(PredPropByFunc(MkFunctor(heap_regs->atom_meta_call,4),0)); - heap_regs->pred_catch = RepPredProp(PredPropByFunc(MkFunctor(LookupAtom("catch"),3),0)); + heap_regs->pred_dollar_catch = RepPredProp(PredPropByFunc(MkFunctor(LookupAtom("$catch"),3),0)); heap_regs->pred_throw = RepPredProp(PredPropByFunc(FunctorThrow,0)); heap_regs->pred_handle_throw = RepPredProp(PredPropByFunc(MkFunctor(LookupAtom("$handle_throw"),3),0)); ReleaseAtom(AtomOfTerm(heap_regs->term_refound_var)); diff --git a/C/save.c b/C/save.c index 6e3fa7e1f..780cd7361 100644 --- a/C/save.c +++ b/C/save.c @@ -1122,8 +1122,8 @@ restore_codes(void) (PredEntry *)AddrAdjust((ADDR)heap_regs->pred_goal_expansion); heap_regs->pred_meta_call = (PredEntry *)AddrAdjust((ADDR)heap_regs->pred_meta_call); - heap_regs->pred_catch = - (PredEntry *)AddrAdjust((ADDR)heap_regs->pred_catch); + heap_regs->pred_dollar_catch = + (PredEntry *)AddrAdjust((ADDR)heap_regs->pred_dollar_catch); heap_regs->pred_throw = (PredEntry *)AddrAdjust((ADDR)heap_regs->pred_throw); heap_regs->pred_handle_throw = diff --git a/H/Heap.h b/H/Heap.h index 3da737635..90bbce9e2 100644 --- a/H/Heap.h +++ b/H/Heap.h @@ -10,7 +10,7 @@ * File: Heap.h * * mods: * * comments: Heap Init Structure * -* version: $Id: Heap.h,v 1.22 2002-01-28 04:30:40 vsc Exp $ * +* version: $Id: Heap.h,v 1.23 2002-01-30 03:49:50 vsc Exp $ * *************************************************************************/ /* information that can be stored in Code Space */ @@ -270,7 +270,7 @@ typedef struct various_codes { void *last_wtime; PredEntry *pred_goal_expansion; PredEntry *pred_meta_call; - PredEntry *pred_catch; + PredEntry *pred_dollar_catch; PredEntry *pred_throw; PredEntry *pred_handle_throw; UInt n_of_file_aliases; @@ -461,7 +461,7 @@ typedef struct various_codes { #define TermReFoundVar heap_regs->term_refound_var #define PredGoalExpansion heap_regs->pred_goal_expansion #define PredMetaCall heap_regs->pred_meta_call -#define PredCatch heap_regs->pred_catch +#define PredDollarCatch heap_regs->pred_dollar_catch #define PredThrow heap_regs->pred_throw #define PredHandleThrow heap_regs->pred_handle_throw #define NOfFileAliases heap_regs->n_of_file_aliases