choice.h

00001 /* File:      choice.h
00002 ** Author(s): Xu, Swift, Sagonas, Freire, Johnson
00003 ** Contact:   xsb-contact@cs.sunysb.edu
00004 ** 
00005 ** Copyright (C) The Research Foundation of SUNY, 1986, 1993-1998
00006 ** Copyright (C) ECRC, Germany, 1990
00007 ** 
00008 ** XSB is free software; you can redistribute it and/or modify it under the
00009 ** terms of the GNU Library General Public License as published by the Free
00010 ** Software Foundation; either version 2 of the License, or (at your option)
00011 ** any later version.
00012 ** 
00013 ** XSB is distributed in the hope that it will be useful, but WITHOUT ANY
00014 ** WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00015 ** FOR A PARTICULAR PURPOSE.  See the GNU Library General Public License for
00016 ** more details.
00017 ** 
00018 ** You should have received a copy of the GNU Library General Public License
00019 ** along with XSB; if not, write to the Free Software Foundation,
00020 ** Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00021 **
00022 ** $Id: choice.h,v 1.28 2006/01/27 20:29:43 tswift Exp $
00023 ** 
00024 */
00025 #ifndef __CHOICE_H__
00026 #define __CHOICE_H__
00027 
00028 /* --- Types of Choice Points ----------------------------------------- */
00029 
00030 #define STANDARD_CP_FRAME       0
00031 #define GENERATOR_CP_FRAME      1
00032 #define CONSUMER_CP_FRAME       2
00033 #define COMPL_SUSP_CP_FRAME     3
00034 
00035 /* --- type definitions ----------------------------------------------- */
00036 
00037 typedef struct choice_point {
00038     byte *next_clause;  /* the entry of next choice */
00039 #ifdef SLG_GC
00040   CPtr prev_top;        /* previous top of CP stack */
00041 #endif
00042 #ifdef CP_DEBUG
00043   Psc  psc;             /* PSC of predicate that created this CP */
00044 #endif
00045     CPtr _ebreg;        /* environment backtrack -- top of env stack */
00046     CPtr _hreg;         /* current top of heap */
00047     CPtr *_trreg;       /* current top of trail stack */
00048     byte *_cpreg;       /* return point of the call to the procedure    */
00049     CPtr _ereg;         /* current top of stack */
00050     CPtr pdreg;         /* value of delay register for the parent subgoal */
00051     CPtr ptcp;          /* pointer to parent tabled CP (subgoal) */
00052     CPtr prev;          /* dynamic link */
00053 } *Choice;
00054 
00055 #define CP_SIZE (sizeof(struct choice_point)/sizeof(CPtr))
00056 
00057 #define cp_pcreg(b)             ((Choice)(b))->next_clause
00058 #define cp_ebreg(b)             ((Choice)(b))->_ebreg
00059 #define cp_hreg(b)              ((Choice)(b))->_hreg
00060 #define cp_trreg(b)             ((Choice)(b))->_trreg
00061 #define cp_cpreg(b)             ((Choice)(b))->_cpreg
00062 #define cp_ereg(b)              ((Choice)(b))->_ereg
00063 #define cp_prevbreg(b)          ((Choice)(b))->prev
00064 #define cp_pdreg(b)             ((Choice)(b))->pdreg
00065 #define cp_ptcp(b)              ((Choice)(b))->ptcp
00066 
00067 
00068 #ifdef SLG_GC
00069 #define cp_prevtop(b)              ((Choice)(b))->prev_top
00070 #endif
00071 #ifdef CP_DEBUG
00072 #define cp_psc(b)               ((Choice)(b))->psc
00073 #define SAVE_PSC(b) cp_psc(b) = pscreg
00074 #else
00075 #define SAVE_PSC(b)
00076 #endif
00077 
00078 #define save_choicepoint(t_breg, t_ereg, next_clause, prev) \
00079     t_breg -= CP_SIZE; \
00080     cp_ptcp(t_breg) = ptcpreg; \
00081     cp_pdreg(t_breg) = delayreg; \
00082     cp_prevbreg(t_breg) = prev; \
00083     cp_ereg(t_breg) = t_ereg; \
00084     cp_cpreg(t_breg) = cpreg; \
00085     cp_trreg(t_breg) = trreg; \
00086     cp_hreg(t_breg) = hreg; \
00087     cp_ebreg(t_breg) = ebreg; \
00088     SAVE_PSC(t_breg); \
00089     cp_pcreg(t_breg) = next_clause
00090 
00091 /*----------------------------------------------------------------------*/
00092 
00093 /*----------------------------------------------------------------------*/
00094 /* Table-Producer Choice Point                                          */
00095 /*----------------------------------------------------------------------*/
00096 
00097 typedef struct tabled_choice_point {
00098     byte *next_clause;  /* the entry of next choice */
00099 #if defined(SLG_GC)
00100   CPtr prev_top;
00101 #endif
00102 #ifdef CP_DEBUG
00103   Psc  psc;             /* PSC of predicate that created this CP */
00104 #endif
00105     CPtr _ebreg;        /* environment backtrack -- top of env stack */
00106     CPtr _hreg;         /* current top of heap */
00107     CPtr *_trreg;       /* current top of trail stack */
00108     byte *_cpreg;       /* return point of the call to the procedure */
00109     CPtr _ereg;         /* current top of stack */
00110     CPtr pdreg;         /* value of delay register for the parent subgoal */
00111     CPtr ptcp;          /* pointer to parent tabled CP (subgoal) */
00112     CPtr prev;          /* previous choicepoint */
00113     CPtr answer_template;
00114     CPtr subgoal_ptr;   /* pointer to the subgoal frame */
00115 #if defined(LOCAL_EVAL) && !defined(SLG_GC)
00116   CPtr prev_top;
00117 #endif
00118 /* The following are needed to reclaim frozen space at SCC completion time */
00119     CPtr _bfreg;
00120     CPtr _hfreg;
00121     CPtr *_trfreg;
00122     CPtr _efreg;
00123 #ifdef LOCAL_EVAL
00124     ALNptr trie_return;
00125 #endif
00126 #ifdef SHARED_COMPL_TABLES
00127     byte * reset_pcreg;
00128 #endif
00129 #ifdef CONC_COMPL
00130     CPtr compl_stack_ptr; 
00131 #endif
00132 } *TChoice;
00133 
00134 #define TCP_SIZE        (sizeof(struct tabled_choice_point)/sizeof(CPtr))
00135 
00136 #define tcp_pcreg(b)            ((TChoice)(b))->next_clause
00137 #define tcp_ebreg(b)            ((TChoice)(b))->_ebreg
00138 #define tcp_hreg(b)             ((TChoice)(b))->_hreg
00139 #define tcp_trreg(b)            ((TChoice)(b))->_trreg
00140 #define tcp_cpreg(b)            ((TChoice)(b))->_cpreg
00141 #define tcp_ereg(b)             ((TChoice)(b))->_ereg
00142 #define tcp_prevbreg(b)         ((TChoice)(b))->prev
00143 #define tcp_pdreg(b)            ((TChoice)(b))->pdreg
00144 #define tcp_ptcp(b)             ((TChoice)(b))->ptcp
00145 #define tcp_subgoal_ptr(b)      ((TChoice)(b))->subgoal_ptr
00146 #ifdef CONC_COMPL
00147 #define tcp_compl_stack_ptr(b)  ((TChoice)(b))->compl_stack_ptr
00148 #endif
00149 
00150 #ifdef CP_DEBUG
00151 #define tcp_psc(b)              ((TChoice)(b))->psc
00152 #define SAVE_TPSC(b)            tcp_psc(b) = pscreg
00153 #else
00154 #define SAVE_TPSC(b)
00155 #endif
00156 
00157 #if defined(SLG_GC) || defined(LOCAL_EVAL)
00158 #define tcp_prevtop(b)          ((TChoice)(b))->prev_top
00159 #endif
00160 
00161 #define tcp_template(b)         ((TChoice)(b))->answer_template
00162 
00163 #define tcp_bfreg(b)            ((TChoice)(b))->_bfreg
00164 #define tcp_hfreg(b)            ((TChoice)(b))->_hfreg
00165 #define tcp_trfreg(b)           ((TChoice)(b))->_trfreg
00166 #define tcp_efreg(b)            ((TChoice)(b))->_efreg
00167 
00168 #ifdef LOCAL_EVAL
00169 #define tcp_trie_return(b)      ((TChoice)(b))->trie_return
00170 #endif
00171 
00172 #ifdef MULTI_THREAD
00173 #define tcp_reset_pcreg(b)      ((TChoice)(b))->reset_pcreg
00174 #endif
00175 
00176 #define is_generator_choicepoint(b)                     \
00177     ((cp_pcreg(b) == (byte *) &check_complete_inst) ||  \
00178      (cell_opcode(cp_pcreg(b)) == tabletrust) ||        \
00179      (cell_opcode(cp_pcreg(b)) == tableretry))
00180 
00181 /* The following macro is used to perform early completion */
00182 #ifdef CONC_COMPL
00183 #define perform_early_completion(ProdSF,ProdCPF)
00184 #else
00185 #define perform_early_completion(ProdSF,ProdCPF)            \
00186     if (tcp_pcreg(ProdCPF) != (byte *) &answer_return_inst) \
00187       tcp_pcreg(ProdCPF) = (byte *) &check_complete_inst;   \
00188     mark_as_completed(ProdSF)
00189 #endif
00190 
00191 #define _SaveProducerCPF_common(TopCPS, Cont, pSF) {    \
00192    TopCPS -= TCP_SIZE;                                  \
00193    tcp_ptcp(TopCPS) = ptcpreg;                          \
00194    tcp_pdreg(TopCPS) = delayreg;                        \
00195    tcp_ereg(TopCPS) = ereg;                             \
00196    tcp_cpreg(TopCPS) = cpreg;                           \
00197    tcp_trreg(TopCPS) = trreg;                           \
00198    tcp_hreg(TopCPS) = hreg;                             \
00199    tcp_ebreg(TopCPS) = ebreg;                           \
00200    tcp_subgoal_ptr(TopCPS) = (CPtr)pSF;                 \
00201    SAVE_TPSC(TopCPS);                                   \
00202    tcp_prevbreg(TopCPS) = breg;                         \
00203    tcp_pcreg(TopCPS) = Cont;                            \
00204  }
00205 
00206 #define _SaveProducerCPF_slg(TopCPS, Cont, pSF, AT) {   \
00207    _SaveProducerCPF_common(TopCPS, Cont, pSF);          \
00208    tcp_bfreg(TopCPS) = bfreg;                           \
00209    tcp_efreg(TopCPS) = efreg;                           \
00210    tcp_trfreg(TopCPS) = trfreg;                         \
00211    tcp_hfreg(TopCPS) = hfreg;                           \
00212    tcp_template(TopCPS) = AT;                           \
00213  }
00214 
00215 #ifdef LOCAL_EVAL
00216 #define SaveProducerCPF(TopCPS, Cont, pSF, Arity, AT) { \
00217    _SaveProducerCPF_slg(TopCPS, Cont, pSF, AT);         \
00218    tcp_trie_return(TopCPS) = NULL;                      \
00219  }
00220 #else
00221 #define SaveProducerCPF(TopCPS, Cont, pSF, Arity, AT)   \
00222    _SaveProducerCPF_slg(TopCPS, Cont, pSF, AT)
00223 #endif
00224 
00225 /*----------------------------------------------------------------------*/
00226 /* Consumer Choice Point                                                */
00227 /*----------------------------------------------------------------------*/
00228 
00229 typedef struct consumer_choice_point {
00230     byte *next_clause;  /* the entry of next choice */
00231 #ifdef SLG_GC
00232   CPtr prev_top;
00233 #endif
00234 #ifdef CP_DEBUG
00235     Psc  psc;             /* PSC of predicate that created this CP */
00236 #endif    
00237     CPtr _ebreg;        /* environment backtrack -- top of env stack */
00238     CPtr _hreg;         /* current top of heap */
00239     CPtr *_trreg;       /* current top of trail stack */
00240     byte *_cpreg;       /* return point of the call to the procedure */
00241     CPtr _ereg;         /* current top of local stack */
00242     CPtr pdreg;         /* value of delay register for the parent subgoal */
00243     CPtr ptcp;          /* pointer to parent tabled CP (subgoal) */
00244     CPtr prev;          /* prev top of choice point stack */
00245     CPtr answer_template;
00246     CPtr subgoal_ptr;   /* where the answer list lives */
00247     CPtr prevlookup;    /* link for chain of consumer CPFs */
00248     ALNptr trie_return; /* last answer consumed by this consumer */
00249 #ifdef CONC_COMPL
00250     Cell tid ;          /* Thread whose stacks the cp resides in */
00251 #endif
00252 }
00253 *NLChoice;
00254 #define NLCP_SIZE       (sizeof(struct consumer_choice_point)/sizeof(CPtr))
00255 
00256 #define nlcp_pcreg(b)           ((NLChoice)(b))->next_clause
00257 #define nlcp_ebreg(b)           ((NLChoice)(b))->_ebreg
00258 #define nlcp_hreg(b)            ((NLChoice)(b))->_hreg
00259 #define nlcp_trreg(b)           ((NLChoice)(b))->_trreg
00260 #define nlcp_cpreg(b)           ((NLChoice)(b))->_cpreg
00261 #define nlcp_ereg(b)            ((NLChoice)(b))->_ereg
00262 #define nlcp_subgoal_ptr(b)     ((NLChoice)(b))->subgoal_ptr
00263 #define nlcp_pdreg(b)           ((NLChoice)(b))->pdreg
00264 #define nlcp_ptcp(b)            ((NLChoice)(b))->ptcp
00265 #define nlcp_prevbreg(b)        ((NLChoice)(b))->prev
00266 #define nlcp_prevlookup(b)      ((NLChoice)(b))->prevlookup
00267 #define nlcp_trie_return(b)     ((NLChoice)(b))->trie_return
00268 #define nlcp_template(b)        ((NLChoice)(b))->answer_template
00269 #ifdef SLG_GC
00270 #define nlcp_prevtop(b)         ((NLChoice)(b))->prev_top
00271 #endif
00272 #ifdef CONC_COMPL
00273 #define nlcp_tid(b)             ((NLChoice)(b))->tid
00274 #endif
00275 
00276 #define is_consumer_choicepoint(b) \
00277     (cp_pcreg(b) == (byte *) &answer_return_inst)
00278 
00279 #ifdef CP_DEBUG
00280 #define nlcp_psc(b)              ((NLChoice)(b))->psc
00281 #define SAVE_NLPSC(b)            nlcp_psc(b) = pscreg
00282 #else
00283 #define SAVE_NLPSC(b)
00284 #endif
00285 
00286 #define _SaveConsumerCPF_common(TopCPS,SF,PrevConsumer) {       \
00287    TopCPS -= NLCP_SIZE;                                         \
00288    nlcp_trie_return(TopCPS) = subg_ans_list_ptr(SF);            \
00289    nlcp_subgoal_ptr(TopCPS) = (CPtr)SF;                         \
00290    nlcp_prevlookup(TopCPS) = PrevConsumer;                      \
00291    nlcp_ptcp(TopCPS) = ptcpreg;                                 \
00292    nlcp_pdreg(TopCPS) = delayreg;                               \
00293    nlcp_prevbreg(TopCPS) = breg;                                \
00294    nlcp_ereg(TopCPS) = ereg;                                    \
00295    nlcp_cpreg(TopCPS) = cpreg;                                  \
00296    nlcp_trreg(TopCPS) = trreg;                                  \
00297    SAVE_NLPSC(TopCPS);                                          \
00298    nlcp_hreg(TopCPS) = hreg;                                    \
00299    nlcp_ebreg(TopCPS) = ebreg;                                  \
00300    nlcp_pcreg(TopCPS) = (pb) &answer_return_inst;               \
00301  }
00302 
00303 #define SaveConsumerCPF(TopCPS,ConsSF,PrevConsumer, AT) \
00304    _SaveConsumerCPF_common(TopCPS,ConsSF,PrevConsumer); \
00305    nlcp_template(TopCPS) = AT
00306 
00307 /*----------------------------------------------------------------------*/
00308 /* The following CP is used for a computation that has been suspended   */
00309 /* on completion of a subgoal.                                          */
00310 /*----------------------------------------------------------------------*/
00311 
00312 typedef struct compl_susp_frame {
00313   byte *next_clause;    /* the completion suspension instruction */
00314 #ifdef SLG_GC
00315   CPtr prev_top;
00316 #endif
00317 #ifdef CP_DEBUG
00318   Psc  psc;             /* PSC of predicate that created this CP */
00319 #endif    
00320   CPtr _ebreg;          /* environment backtrack -- top of env stack */
00321   CPtr _hreg;           /* current top of heap */
00322   CPtr *_trreg; /* current top of trail stack */
00323   byte *_cpreg; /* return point of the call to the procedure */
00324   CPtr _ereg;           /* current top of stack */
00325   CPtr pdreg;           /* value of delay register for the parent subgoal */
00326   CPtr ptcp;            /* pointer to parent tabled CP (subgoal) */
00327   CPtr subgoal_ptr;     /* pointer to the call structure */
00328   CPtr prevcsf; /* previous completion suspension frame */
00329   Cell neg_loop;        /* !0 if the suspension is not LRD stratified */
00330 } *ComplSuspFrame;
00331 
00332 #define CSF_SIZE        (sizeof(struct compl_susp_frame)/sizeof(CPtr))
00333 
00334 #define csf_pcreg(b)            ((ComplSuspFrame)(b))->next_clause
00335 #define csf_ebreg(b)            ((ComplSuspFrame)(b))->_ebreg
00336 #define csf_hreg(b)             ((ComplSuspFrame)(b))->_hreg
00337 #define csf_trreg(b)            ((ComplSuspFrame)(b))->_trreg
00338 #define csf_cpreg(b)            ((ComplSuspFrame)(b))->_cpreg
00339 #define csf_ereg(b)             ((ComplSuspFrame)(b))->_ereg
00340 #define csf_pdreg(b)            ((ComplSuspFrame)(b))->pdreg
00341 #define csf_ptcp(b)             ((ComplSuspFrame)(b))->ptcp
00342 #define csf_subgoal_ptr(b)      ((ComplSuspFrame)(b))->subgoal_ptr
00343 #define csf_prevcsf(b)          ((ComplSuspFrame)(b))->prevcsf
00344 #define csf_neg_loop(b)         ((ComplSuspFrame)(b))->neg_loop
00345 #ifdef SLG_GC
00346 #define csf_prevtop(b)          ((ComplSuspFrame)(b))->prev_top
00347 #endif
00348 
00349 #ifdef CP_DEBUG
00350 #define csf_psc(b)              ((ComplSuspFrame)(b))->psc
00351 #define SAVE_CSFPSC(b)            csf_psc(b) = pscreg
00352 #else
00353 #define SAVE_CSFPSC(b)
00354 #endif
00355 
00356 #define is_compl_susp_frame(b)                          \
00357      ((cp_pcreg(b) == (byte *) &resume_compl_suspension_inst) ||        \
00358     (cp_pcreg(b) == (byte *) &resume_compl_suspension_inst2))
00359 
00360 /*
00361 #define is_compl_susp_frame(b)                          \
00362   ((cp_pcreg(b) == (byte *) &resume_compl_suspension_inst))
00363 */
00364       
00365 #define save_compl_susp_frame(t_breg,t_ereg,subg,t_ptcp,CPREG) \
00366     t_breg -= CSF_SIZE; \
00367     csf_neg_loop(t_breg) = FALSE; \
00368     csf_prevcsf(t_breg) = subg_compl_susp_ptr(subg); \
00369     csf_ptcp(t_breg) = t_ptcp; \
00370     SAVE_CSFPSC(t_breg); \
00371     csf_pdreg(t_breg) = delayreg; \
00372     csf_subgoal_ptr(t_breg) = subg; \
00373     csf_ereg(t_breg) = t_ereg; \
00374     csf_cpreg(t_breg) = CPREG; \
00375     csf_trreg(t_breg) = trreg; \
00376     csf_hreg(t_breg) = hreg; \
00377     csf_ebreg(t_breg) = ebreg; \
00378     csf_pcreg(t_breg) = (pb) &resume_compl_suspension_inst
00379 
00380 /*----------------------------------------------------------------------*/
00381 /* The following CP is used to resume a set of computations that have   */
00382 /* been suspended on completion of a subgoal.  Only SLG-WAM uses this.  */
00383 /*----------------------------------------------------------------------*/
00384 
00385 
00386 typedef struct compl_susp_choice_point {
00387     byte *next_clause;  /* the completion suspension instruction */
00388 #ifdef SLG_GC
00389   CPtr prev_top;
00390 #endif
00391 #ifdef CP_DEBUG
00392   Psc  psc;             /* PSC of predicate that created this CP */
00393 #endif    
00394     CPtr _ebreg;        /* environment backtrack -- top of env stack */
00395     CPtr _hreg;         /* current top of heap */
00396 #ifdef SLG_GC
00397   CPtr *_trreg; /* current top of trail stack */
00398   byte *_cpreg; /* return point of the call to the procedure */
00399   CPtr _ereg;           /* current top of stack */
00400   CPtr pdreg;           /* value of delay register for the parent subgoal */
00401   CPtr ptcp;            /* pointer to parent tabled CP (subgoal) */
00402 #endif
00403     CPtr prev;          /* lookup: previous choicepoint */
00404     CPtr compsuspptr;   /* pointer to the completion_suspension_frame */
00405 } *ComplSuspChoice;
00406 
00407 #define COMPL_SUSP_CP_SIZE      \
00408         (sizeof(struct compl_susp_choice_point)/sizeof(CPtr))
00409 
00410 #define cs_pcreg(b)             ((ComplSuspChoice)(b))->next_clause
00411 #define cs_ebreg(b)             ((ComplSuspChoice)(b))->_ebreg
00412 #define cs_hreg(b)              ((ComplSuspChoice)(b))->_hreg
00413 #define cs_compsuspptr(b)       ((ComplSuspChoice)(b))->compsuspptr
00414 #define cs_prevbreg(b)          ((ComplSuspChoice)(b))->prev
00415 #ifdef SLG_GC
00416 #define SAVE_CSCP_EXTRA(t_breg) \
00417 ((ComplSuspChoice)(t_breg))->prev_top = t_breg + COMPL_SUSP_CP_SIZE; \
00418 ((ComplSuspChoice)(t_breg))->_trreg = trreg; \
00419 ((ComplSuspChoice)(t_breg))->_cpreg = cpreg; \
00420 ((ComplSuspChoice)(t_breg))->_ereg = ereg; \
00421 ((ComplSuspChoice)(t_breg))->pdreg = delayreg; \
00422 ((ComplSuspChoice)(t_breg))->ptcp = ptcpreg
00423 #else
00424 #define SAVE_CSCP_EXTRA(t_breg)
00425 #endif
00426 #ifdef CP_DEBUG
00427 #define cscp_psc(b)              ((ComplSuspChoice)(b))->psc
00428 #define SAVE_CSCPPSC(b)            cscp_psc(b) = pscreg
00429 #else
00430 #define SAVE_CSCPPSC(b)
00431 #endif
00432 
00433 #define save_compl_susp_cp(t_breg,prev,compsuspptr) \
00434     t_breg -= COMPL_SUSP_CP_SIZE; \
00435     cs_prevbreg(t_breg) = prev; \
00436     SAVE_CSCP_EXTRA(t_breg); \
00437     SAVE_CSCPPSC(t_breg); \
00438     cs_compsuspptr(t_breg) = compsuspptr;\
00439     cs_hreg(t_breg) = hreg; \
00440     cs_ebreg(t_breg) = ebreg; \
00441     cs_pcreg(t_breg) = (pb) &resume_compl_suspension_inst2
00442 
00443 /* -------------------------------------------------------------------- */
00444 
00445 /*
00446  *  Push on the CP Stack the arguments in the X reg's.  't_breg' gets the
00447  *  topmost Cell on the cpstack, 'arity' is the number of args to be pushed,
00448  *  'ii' is a variable supplied by the caller for macro use, and 'regbase'
00449  *  is a pointer to the "lowest" reg holding an argument.
00450  *
00451  *  On "exit", 't_breg' points to the topmost arg on the cpstack.
00452  */
00453 #define save_registers(t_breg, arity, regbase) {\
00454     byte ii;\
00455     for (ii = 1; ((int)ii) <= arity; ii++) \
00456         bld_copy(--t_breg, cell(regbase+ii));\
00457   }
00458 
00459 #define restore_registers(t_breg, arity, regbase) {\
00460     int ii;\
00461     t_breg += CP_SIZE; \
00462     for (ii = arity; ii >= 1; ii--) bld_copy(regbase+ii, cell(t_breg++));\
00463   }
00464 
00465 #define table_restore_registers(t_breg, arity, regbase) {\
00466     int ii;\
00467     t_breg += TCP_SIZE; \
00468     for (ii = arity; ii >= 1; ii--) bld_copy(regbase+ii, cell(t_breg++));\
00469   }
00470 
00471 
00472 /* Local (Environment) Stack
00473    ------------------------- */
00474 /*
00475  *  Structure of an Activation Record (Environment Frame) is
00476  *
00477  * low mem
00478  *   |   Block of Permanent Variables
00479  *   |   Continuation Pointer  (CPreg value at procedure invocation)
00480  *   V   Dynamic Link  (ptr to link field of prev frame)
00481  * high mem
00482  *
00483  *  Ereg always points to the Dynamic Link field of an AR, while EBreg and
00484  *  EFreg always point to the topmost Permanent Variable in the frame.
00485  */
00486 
00487 /*
00488  *  Set ebreg to the topmost env frame of those pointed to by ereg or efreg.
00489  */
00490 #define save_find_locx(t_ereg) \
00491     if (efreg_on_top(t_ereg)) ebreg = efreg;\
00492     else if (ereg_on_top(t_ereg)) ebreg = t_ereg - *(cpreg-2*sizeof(Cell)+3)+1;
00493 
00494 #define restore_some_wamregs(t_breg, t_ereg) \
00495     if (hbreg >= hfreg) hreg = hbreg; else hreg = hfreg; \
00496     cpreg = cp_cpreg(t_breg); \
00497     t_ereg = cp_ereg(t_breg)
00498 
00499 #endif

Generated on Wed Jul 26 13:30:40 2006 for XSB by  doxygen 1.4.5