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
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 #ifndef opt_exc_INCLUDED
00057 #define opt_exc_INCLUDED "opt_exc.h"
00058 #ifdef _KEEP_RCS_ID
00059 static char *opt_excrcs_id = opt_exc_INCLUDED"$Revision: 1.5 $";
00060 #endif
00061
00062 #ifndef defs_INCLUDED
00063 #include "defs.h"
00064 #endif
00065 #ifndef tracing_INCLUDED
00066 #include "tracing.h"
00067 #endif
00068 #ifndef mempool_INCLUDED
00069 #include "mempool.h"
00070 #endif
00071 #ifndef cxx_memory_INCLUDED
00072 #include "cxx_memory.h"
00073 #endif
00074 #ifndef cxx_base_INCLUDED
00075 #include "cxx_base.h"
00076 #endif
00077 #ifndef cxx_template_INCLUDED
00078 #include "cxx_template.h"
00079 #endif
00080 #ifndef opt_defs_INCLUDED
00081 #include "opt_defs.h"
00082 #endif
00083 #ifndef opt_mu_chi_INCLUDED
00084 #include "opt_mu_chi.h"
00085 #endif
00086
00087 class CFG;
00088 class STMTREP;
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098 class EXC_SCOPE {
00099 EXC *_exc;
00100 EXC_SCOPE *_parent;
00101 WN *_begin_wn;
00102 WN *_vcall;
00103 DYN_ARRAY<WN*> *_call_list;
00104
00105
00106 EXC_SCOPE(void);
00107 EXC_SCOPE(const EXC_SCOPE&);
00108 EXC_SCOPE& operator = (const EXC_SCOPE&);
00109
00110 public:
00111 EXC_SCOPE(WN *begin_wn, EXC *exc);
00112 ~EXC_SCOPE(void) { }
00113
00114 EXC *Exc(void) const { return _exc; }
00115 void Set_parent(EXC_SCOPE *es) { _parent = es; }
00116 EXC_SCOPE *Parent(void) const { return _parent; }
00117 void Set_begin_wn(WN *wn) { _begin_wn = wn; }
00118 WN *Begin_wn(void) const { return _begin_wn; }
00119 BOOL Is_try_region(void) const;
00120 void Add_call(WN *wn) { _call_list->AddElement(wn); }
00121 mINT32 Call_count(void) const { return _call_list->Lastidx()+1; }
00122 WN *Get_call(INT i) { return (*_call_list)[i]; }
00123 };
00124
00125 class EXC_SCOPE_TRY_ITER {
00126 private:
00127 EXC_SCOPE *_exc_scope;
00128 CHI_LIST *_chi_list;
00129 CHI_LIST_ITER _chi_iter;
00130 MEM_POOL _mem_pool;
00131
00132
00133 EXC_SCOPE_TRY_ITER(void);
00134 EXC_SCOPE_TRY_ITER(const EXC_SCOPE_TRY_ITER&);
00135 EXC_SCOPE_TRY_ITER& operator = (const EXC_SCOPE_TRY_ITER&);
00136
00137
00138 AUX_ID Elem(CHI_NODE *chi);
00139
00140 public:
00141 EXC_SCOPE_TRY_ITER(EXC_SCOPE *exc_scope);
00142 ~EXC_SCOPE_TRY_ITER(void) {
00143 OPT_POOL_Pop(&_mem_pool, EXC_TRACE_FLAG);
00144 OPT_POOL_Delete(&_mem_pool, EXC_TRACE_FLAG);
00145 }
00146 void Init(void) { }
00147 BOOL Is_Empty(void) { return _chi_iter.Is_Empty();}
00148 AUX_ID First_elem(void) { return Elem(_chi_iter.First()); }
00149 AUX_ID Next_elem(void) { return Elem(_chi_iter.Next()); }
00150 };
00151
00152
00153 class EXC {
00154 CFG *_cfg;
00155 OPT_STAB *_opt_stab;
00156 MEM_POOL *_mem_pool;
00157 WN_MAP _exc_map;
00158 STACK<EXC_SCOPE*> *_exc_scope;
00159 DYN_ARRAY<EXC_SCOPE*>*_exc_scope_list;
00160 BOOL _tracing;
00161
00162
00163 EXC(void);
00164 EXC(const EXC&);
00165 EXC& operator = (const EXC&);
00166
00167
00168 void Push_exc_scope(EXC_SCOPE *scope) { _exc_scope->Push(scope); }
00169
00170 public:
00171 EXC(CFG *cfg, OPT_STAB *opt_stab, MEM_POOL *stack_pool) {
00172 _cfg = cfg;
00173 _opt_stab = opt_stab;
00174 _mem_pool = stack_pool;
00175 OPT_POOL_Push ( stack_pool, MEM_DUMP_FLAG+21 );
00176 _exc_map = WN_MAP_Create(stack_pool);
00177 _tracing = Get_Trace( TP_GLOBOPT, EXC_TRACE_FLAG );
00178 _exc_scope = CXX_NEW(STACK<EXC_SCOPE*>(stack_pool), stack_pool);
00179 _exc_scope_list = CXX_NEW(DYN_ARRAY<EXC_SCOPE*>(stack_pool), stack_pool);
00180 _exc_scope->Clear();
00181 }
00182 ~EXC(void) { WN_MAP_Delete(_exc_map);
00183 OPT_POOL_Pop ( _mem_pool,
00184 MEM_DUMP_FLAG+21);
00185 }
00186
00187 void Clear(void) { _exc_scope->Clear();
00188 _exc_scope_list->Resetidx();
00189 }
00190 CFG *Cfg(void) const { return _cfg; }
00191 OPT_STAB *Opt_stab(void) const { return _opt_stab; }
00192 MEM_POOL *Mem_pool(void) const { return _mem_pool; }
00193 mINT32 Elements(void) const { return _exc_scope->Elements();}
00194 EXC_SCOPE *Push_exc_scope(WN *scope_begin);
00195 EXC_SCOPE *Pop_exc_scope(void) { return (_exc_scope)?
00196 _exc_scope->Pop():NULL; }
00197 EXC_SCOPE *Top_exc_scope(void) const { return _exc_scope->Top(); }
00198 EXC_SCOPE *Bottom_nth_exc_scope(INT32 n)const{ return _exc_scope->Bottom_nth(n);}
00199 BOOL NULL_exc_scope(void) const { return _exc_scope->Is_Empty();}
00200 mINT32 Exc_scope_count(void) const { return _exc_scope_list->Lastidx()+1; }
00201 EXC_SCOPE *Get_exc_scope(INT i) const { return (*_exc_scope_list)[i];}
00202 void Link_top_es(WN *wn);
00203 void Link_wn_es(WN *wn, EXC_SCOPE *es) { WN_MAP_Set(_exc_map, wn, es);}
00204 EXC_SCOPE *Get_es_link(WN *wn) { return (EXC_SCOPE *)
00205 WN_MAP_Get(_exc_map, wn); }
00206 };
00207
00208 #endif // opt_exc_INCLUDED