Sat Aug 18 12:40:32 CEST 2001 Paolo Molaro <lupus@ximian.com>
[mono.git] / mono / interpreter / hacks.h
1 /*
2  * Attempt at using the goto label construct of GNU GCC:
3  * it turns out this does give some benefit: 5-15% speedup.
4  * Don't look at these macros, it hurts...
5  */
6 #define GOTO_LABEL
7 #undef GOTO_LABEL
8 #ifdef GOTO_LABEL
9
10 #define SWITCH(a) goto *goto_map [(a)];
11 #define BREAK SWITCH(*ip)
12 #define CASE(l) l ## _LABEL:
13 #define DEFAULT \
14         CEE_ILLEGAL_LABEL:      \
15         CEE_ENDMAC_LABEL:
16 #define SUB_SWITCH \
17         CEE_PREFIX1_LABEL: \
18         CEE_ARGLIST_LABEL: \
19         CEE_CEQ_LABEL: \
20         CEE_CGT_LABEL: \
21         CEE_CGT_UN_LABEL: \
22         CEE_CLT_LABEL: \
23         CEE_CLT_UN_LABEL: \
24         CEE_LDFTN_LABEL: \
25         CEE_LDVIRTFTN_LABEL: \
26         CEE_UNUSED56_LABEL: \
27         CEE_LDARG_LABEL: \
28         CEE_LDARGA_LABEL: \
29         CEE_STARG_LABEL: \
30         CEE_LDLOC_LABEL: \
31         CEE_LDLOCA_LABEL: \
32         CEE_STLOC_LABEL: \
33         CEE_LOCALLOC_LABEL: \
34         CEE_UNUSED57_LABEL: \
35         CEE_ENDFILTER_LABEL: \
36         CEE_UNALIGNED__LABEL: \
37         CEE_VOLATILE__LABEL: \
38         CEE_TAIL__LABEL: \
39         CEE_INITOBJ_LABEL: \
40         CEE_UNUSED68_LABEL: \
41         CEE_CPBLK_LABEL: \
42         CEE_INITBLK_LABEL: \
43         CEE_UNUSED69_LABEL: \
44         CEE_RETHROW_LABEL: \
45         CEE_UNUSED_LABEL: \
46         CEE_SIZEOF_LABEL: \
47         CEE_REFANYTYPE_LABEL: \
48         CEE_UNUSED52_LABEL: \
49         CEE_UNUSED53_LABEL: \
50         CEE_UNUSED54_LABEL: \
51         CEE_UNUSED55_LABEL: \
52         CEE_UNUSED70_LABEL:
53 #define GOTO_LABEL_VARS \
54         const static void * const goto_map [] = {\
55 #define OPDEF(a,b,c,d,e,f,g,h,i,j) \    \
56         && a ## _LABEL, \
57 #include "mono/cil/opcode.def"  \
58 #undef OPDEF    \
59         &&DUMMY_LABEL   \
60         };      \
61         DUMMY_LABEL:
62
63 #else
64         
65 #define SWITCH(a) switch(a)
66 #define BREAK   break
67 #define CASE(l) case l:
68 #define DEFAULT \
69                 default:        \
70                         g_error ("Unimplemented opcode: %x at 0x%x\n", *ip, ip-header->code);
71 #define SUB_SWITCH case 0xFE:
72 #define GOTO_LABEL_VARS
73
74 #endif