OSDN Git Service

Move scheduling visualization code to separate file.
[pf3gnuchains/gcc-fork.git] / gcc / eh-common.h
1 /* EH stuff
2    Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
3
4 This file is part of GNU CC.
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
9 later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
19
20
21 /* This file contains the structures required for the language
22    independent exception handling model. Both the static compiler and
23    the runtime library share this file. */
24
25 /* The runtime flag flag_new_exceptions is used to determine whether the 
26    compiler supports the new runtime typechecking mechanism or not. Under
27    the new model, runtime info is contained in the exception table, and
28    the __throw() library routine determines which handler to call based
29    on the results of a call to a matching function provided by the expcetion
30    thrower.  Otherwise the old scheme of calling any handler which matches
31    an exception range is used, and the handler is responsible for all
32    checking of runtime conditions. If the handler wasn't suppose to
33    get the exception, it performs a re-throw. */
34
35
36 /* The handler_label field MUST be the first field in this structure. The 
37    __throw()  library routine expects uses __eh_stub() from except.c, which
38    simply dereferences the context pointer to get the handler.
39    The routine get_dynamic_handler_chain() also has a dependancy on
40    the location of 'dynamic_handler_chain'. If its location is changed, 
41    that routine must be modified as well. */
42 #ifndef EH_ALLOC_SIZE
43 /* 192 bytes means the entire eh_context plus malloc overhead fits in 256
44    bytes (assuming 8 byte pointers). 192 bytes gives an eh_info and object
45    size limit of 96 bytes. This should be sufficient for throwing bad_alloc. */
46 #define EH_ALLOC_SIZE 192
47 #endif
48 #ifndef EH_ALLOC_ALIGN
49 /* We can't use BIGGEST_ALIGNMENT, because on some systems, that expands to
50    a check on a compile time switch like
51    'target_flags & MASK_ALIGN_DOUBLE ? 64 : 32'. There's no macro for
52    'largest alignment for any code this compiler can build for', which is
53    really what is needed. */
54 #define EH_ALLOC_ALIGN 16
55 #endif
56
57 struct eh_context
58 {
59   void *handler_label;
60   void **dynamic_handler_chain;
61   /* This is language dependent part of the eh context. */
62   void *info;
63   /* This is used to remember where we threw for re-throws */
64   void *table_index;  /* address of exception table entry to rethrow from */
65   /* emergency fallback space, if malloc fails during handling */
66   char alloc_buffer[EH_ALLOC_SIZE]
67       __attribute__((__aligned__(EH_ALLOC_ALIGN)));
68   unsigned alloc_mask;
69 };
70
71 #ifndef EH_TABLE_LOOKUP
72
73 typedef struct old_exception_table 
74 {
75   void *start_region;
76   void *end_region;
77   void *exception_handler;
78 } old_exception_table;
79
80 typedef struct exception_table 
81 {
82   void *start_region;
83   void *end_region;
84   void *exception_handler;
85   void *match_info;              /* runtime type info */
86 } exception_table;
87
88
89 /* The language identifying portion of an exception table */
90
91 typedef struct exception_lang_info 
92 {
93   short language;
94   short version;  
95 } exception_lang_info;
96
97 /* This value in the first field of the exception descriptor 
98    identifies the descriptor as the new model format. This value would never
99    be present in this location under the old model */
100
101 #define NEW_EH_RUNTIME  ((void *) -2)
102
103 /* Each function has an exception_descriptor which contains the
104    language info, and a table of exception ranges and handlers */
105
106 typedef struct exception_descriptor 
107 {
108   void *runtime_id_field;    
109   exception_lang_info lang;
110   exception_table table[1];
111 } exception_descriptor;
112
113 struct __eh_info; /* forward declaration */
114
115 /* A pointer to a matching function is initialized at runtime by the 
116    specific language if run-time exceptions are supported. 
117    The function takes 3 parameters
118     1 - runtime exception that has been thrown info. (__eh_info *)
119     2 - Match info pointer from the region being considered (void *)
120     3 - exception table region is in (exception descriptor *)
121 */
122
123 typedef void * (*__eh_matcher)  PARAMS ((struct __eh_info *, void *,
124                                          struct exception_descriptor *));
125
126 /* This value is to be checked as a 'match all' case in the runtime field. */
127
128 #define CATCH_ALL_TYPE   ((void *) -1)
129
130 /* This is the runtime exception information. This forms the minimum required
131    information for an exception info pointer in an eh_context structure. */
132
133
134 typedef struct __eh_info 
135 {
136   __eh_matcher match_function;
137   short language;
138   short version;
139 } __eh_info;
140
141 /* Convienient language codes for ID the originating language. Similar
142    to the codes in dwarf2.h. */
143
144 enum exception_source_language
145   {
146     EH_LANG_C89 = 0x0001,
147     EH_LANG_C = 0x0002,
148     EH_LANG_Ada83 = 0x0003,
149     EH_LANG_C_plus_plus = 0x0004,
150     EH_LANG_Cobol74 = 0x0005,
151     EH_LANG_Cobol85 = 0x0006,
152     EH_LANG_Fortran77 = 0x0007,
153     EH_LANG_Fortran90 = 0x0008,
154     EH_LANG_Pascal83 = 0x0009,
155     EH_LANG_Modula2 = 0x000a,
156     EH_LANG_Java = 0x000b,
157     EH_LANG_Mips_Assembler = 0x8001
158   };
159
160 #endif  /* EH_TABLE_LOOKUP */
161
162