emuloop_aux.h

00001 /* File:      emuloop_aux.h
00002 ** Author(s): Luis Castro
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: emuloop_aux.h,v 1.9 2005/12/12 00:19:12 tswift Exp $
00023 ** 
00024 */
00025 
00026 #ifndef __EMULOOP_AUX_H__
00027 #define __EMULOOP_AUX_H__
00028 
00029 /*----------------------------------------------------------------------*/
00030 /* Shared code transformed into macros in order to allow for            */
00031 /* local operand-variables in emulator loop                             */
00032 /* lfcastro, 10102000                                                   */
00033 /*----------------------------------------------------------------------*/
00034 
00035 #ifdef SLG_GC
00036 #define SUBTRYME                                                          \
00037 {                                                                         \
00038   CPtr cps_top;                 /* cps_top only needed for efficiency */  \
00039   CPtr old_top;                                                           \
00040                                                                           \
00041   save_find_locx(ereg);         /* sets ebreg to the top of the E-stack */\
00042   check_tcpstack_overflow;                                                \
00043   old_top = cps_top = top_of_cpstack;                                     \
00044   save_registers(cps_top, (Cell)op1, rreg);                               \
00045   save_choicepoint(cps_top, ereg, (byte *)op2, breg);                     \
00046   cp_prevtop(cps_top) = old_top;                                          \
00047   breg = cps_top;                                                         \
00048   hbreg = hreg;                                                           \
00049 /*  XSB_Next_Instr();  */                                                     \
00050 } 
00051 #else
00052 #define SUBTRYME                                                          \
00053 {                                                                         \
00054   CPtr cps_top;                 /* cps_top only needed for efficiency */  \
00055                                                                           \
00056   save_find_locx(ereg);         /* sets ebreg to the top of the E-stack */\
00057   check_tcpstack_overflow;                                                \
00058   cps_top = top_of_cpstack;                                               \
00059   save_registers(cps_top, (Cell)op1, rreg);                               \
00060   save_choicepoint(cps_top, ereg, (byte *)op2, breg);                     \
00061   breg = cps_top;                                                         \
00062   hbreg = hreg;                                                           \
00063 /*  XSB_Next_Instr(); */                                                      \
00064 } 
00065 #endif
00066 /*----------------------------------------------------------------------*/
00067 
00068 #if defined(PROFILE) && !defined(MULTI_THREAD)
00069 #define RESTORE_SUB                                                       \
00070 {                                                                         \
00071   CPtr tbreg;                                                             \
00072                                                                           \
00073   tbreg = breg;                                                           \
00074   /*  switch_envs(tbreg); */                                              \
00075   undo_bindings(tbreg);                                                   \
00076   ptcpreg = cp_ptcp(tbreg);                                               \
00077   delayreg = cp_pdreg(tbreg);                                             \
00078   restore_some_wamregs(tbreg, ereg);                                      \
00079   restore_registers(tbreg, (int)op1, rreg);                               \
00080   if (restore_type == 1) { /* trust */                                    \
00081     if (breg > bfreg) {                                                   \
00082       trapped_prolog_cps = trapped_prolog_cps                             \
00083                     + sizeof(struct choice_point)                         \
00084                     + ((int)op1 * sizeof(CPtr));}                         \
00085     breg = cp_prevbreg(breg);                                             \
00086     restore_trail_condition_registers(breg);                              \
00087   }                                                                       \
00088   XSB_Next_Instr();                                                       \
00089 } 
00090 #else
00091 #define RESTORE_SUB                                                       \
00092 {                                                                         \
00093   CPtr tbreg;                                                             \
00094                                                                           \
00095   tbreg = breg;                                                           \
00096   /*  switch_envs(tbreg); */                                              \
00097   undo_bindings(tbreg);                                                   \
00098   ptcpreg = cp_ptcp(tbreg);                                               \
00099   delayreg = cp_pdreg(tbreg);                                             \
00100   restore_some_wamregs(tbreg, ereg);                                      \
00101   restore_registers(tbreg, (int)op1, rreg);                               \
00102   if (restore_type == 1) { /* trust */                                    \
00103     breg = cp_prevbreg(breg);                                             \
00104     restore_trail_condition_registers(breg);                              \
00105   }                                                                       \
00106   XSB_Next_Instr();                                                       \
00107 } 
00108 #endif
00109 /*----------------------------------------------------------------------*/
00110 
00111 #define TABLE_RESTORE_SUB  {                                              \
00112   CPtr tbreg;                                                             \
00113   CPtr xtemp1;                                                            \
00114                                                                           \
00115   tbreg = breg;                                                           \
00116   switch_envs(tbreg);                                                     \
00117   /* This CP should be used for the dependency graph */                   \
00118   ptcpreg = tcp_subgoal_ptr(tbreg);                                       \
00119   delayreg = NULL;                                                        \
00120   restore_some_wamregs(tbreg, ereg);                                      \
00121   table_restore_registers(tbreg, (int)op1, rreg);                         \
00122   if (restore_type == 1) {                                                \
00123     xtemp1 = tcp_prevbreg(breg);                                          \
00124     restore_trail_condition_registers(xtemp1);                            \
00125   }                                                                       \
00126   XSB_Next_Instr();                                                       \
00127 } 
00128 
00129 #endif

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