00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "xsb_config.h"
00028 #include "xsb_debug.h"
00029
00030 #include "auxlry.h"
00031 #include "cell_xsb.h"
00032 #include "inst_xsb.h"
00033 #include "subinst.h"
00034
00035 extern void init_builtin_table(void);
00036
00037
00038 #ifdef PROFILE
00039
00040
00041
00042
00043
00044
00045
00046
00047 Cell inst_table[BUILTIN_TBL_SZ][6];
00048
00049 unsigned long num_switch_envs;
00050 unsigned long num_switch_envs_iter;
00051
00052 Cell subinst_table[BUILTIN_TBL_SZ][2];
00053
00054 #define XSB_INST(inum, inst, label, op1type, op2type, op3type, op4type) \
00055 inst_table[inst][0] = (Cell)( #inst ); \
00056 inst_table[inst][1] = op1type; \
00057 inst_table[inst][2] = op2type; \
00058 inst_table[inst][3] = op3type; \
00059 inst_table[inst][4] = op4type; \
00060 inst_table[inst][5] = 0
00061
00062 #define profile_inst(inst) \
00063 inst_table[inst][5] = inst_table[inst][5] + 1
00064
00065 #define set_subinst_table(inst,instr) \
00066 subinst_table[inst][0] = (Cell)(instr); \
00067 subinst_table[inst][1] = 0
00068
00069
00070 int max_subgoals = 0;
00071 int max_completed = 0;
00072 int max_consumers_in_ascc = 0;
00073 int max_compl_susps_in_ascc = 0;
00074 int trapped_prolog_cps = 0;
00075
00076
00077 int sdg_sample_rate = 2000;
00078 int sdg_check_num = 0;
00079
00080 #else
00081 Cell inst_table[BUILTIN_TBL_SZ][5];
00082
00083 #define XSB_INST(inum, inst, label, op1type, op2type, op3type, op4type) \
00084 inst_table[inst][0] = (Cell)( #inst ); \
00085 inst_table[inst][1] = op1type; \
00086 inst_table[inst][2] = op2type; \
00087 inst_table[inst][3] = op3type; \
00088 inst_table[inst][4] = op4type
00089 #endif
00090
00091
00092
00093 int sizeof_inst(byte inst)
00094 {
00095 int i, size;
00096
00097 size = 1;
00098 for (i=2; i <= 4 && inst_table[inst][i] != X; i++) {
00099 size++;
00100 }
00101 size *= sizeof(byte *);
00102 return size;
00103 }
00104
00105 void init_instructions()
00106 {
00107 #include "xsb_inst_list.h"
00108 #undef XSB_INST
00109 }
00110
00111 #ifdef PROFILE
00112 void init_subinst_table(void)
00113 {
00114 set_subinst_table(OUTER_FIXPOINT,"outer_fixpoint");
00115 set_subinst_table(ITER_FIXPOINT,"inner_fixpoint");
00116 set_subinst_table(SCHED_ANSWERS,"sched_answers");
00117 set_subinst_table(SIMPL_REMOVE_DL,"simpl_remove_dl");
00118 set_subinst_table(SIMPL_REMOVE_DE,"simpl_remove_de");
00119 set_subinst_table(NEW_ANSWER_SIMPL_POS_UNS,"new_answer_simpl_pos_uns");
00120 set_subinst_table(NEW_ANSWER_SIMPL_POS_UNC,"new_answer_simpl_pos_unc");
00121 set_subinst_table(NEW_ANSWER_SIMPL_NEG_FAIL,"new_answer_simpl_neg_fail");
00122 set_subinst_table(NEW_ANSWER_SIMPL_NEG_SUC,"new_answer_simpl_neg_succ");
00123 num_switch_envs=0;
00124 num_switch_envs_iter=0;
00125 }
00126 #endif
00127
00128
00129
00130 void init_inst_table(void)
00131 {
00132 init_instructions();
00133 init_builtin_table();
00134 #ifdef PROFILE
00135 init_subinst_table();
00136 #endif
00137 }
00138
00139