2 * Utilities for handling interpreter VM instructions
5 * Bernie Solomon (bernard@ugsolutions.com)
12 #define OPDEF(a,b,c,d) \
14 const char *mono_interp_opname[] = {
15 #include "mintops.def"
20 #define OPDEF(a,b,c,d) \
22 unsigned char mono_interp_oplen[] = {
23 #include "mintops.def"
29 #define OPDEF(a,b,c,d) \
31 MintOpArgType mono_interp_opargtype[] = {
32 #include "mintops.def"
38 mono_interp_dis_mintop(const guint16 *base, const guint16 *ip)
40 int len = mono_interp_oplen [*ip];
43 if (len < 0 || len > 10) {
44 g_print ("op %d len %d\n", *ip, len);
45 g_assert_not_reached ();
46 } else if (len == 0) { /* SWITCH */
47 int n = READ32 (ip + 1);
51 g_print ("IL_%04x: %-10s", ip - base, mono_interp_opname [*ip]);
52 switch (mono_interp_opargtype [*ip]) {
56 g_print (" %u", * (guint16 *)(ip + 1));
59 g_print (" %u,%u", * (guint16 *)(ip + 1), * (guint16 *)(ip + 2));
61 case MintOpShortAndInt:
62 g_print (" %u,%u", * (guint16 *)(ip + 1), (guint32)READ32(ip + 2));
65 g_print (" %d", * (short *)(ip + 1));
67 case MintOpClassToken:
68 case MintOpMethodToken:
69 case MintOpFieldToken:
70 token = * (guint16 *)(ip + 1);
71 g_print (" %u", token);
74 g_print (" %d", (gint32)READ32 (ip + 1));
77 g_print (" %lld", (gint64)READ64 (ip + 1));
80 gint32 tmp = READ32 (ip + 1);
81 g_print (" %g", * (float *)&tmp);
85 gint64 tmp = READ64 (ip + 1);
86 g_print (" %g", * (double *)&tmp);
89 case MintOpShortBranch:
90 target = ip + * (short *)(ip + 1) - base;
91 g_print (" IL_%04x", target);
94 target = ip + (gint32)READ32 (ip + 1) - base;
95 g_print (" IL_%04x", target);
98 const guint16 *p = ip + 1;
99 int sval = (gint32)READ32 (p);
103 for (i = 0; i < sval; ++i) {
107 offset = (gint32)READ32 (p);
108 g_print ("IL_%04x", ip - base + 3 + 2 * sval + offset);
115 g_print("unknown arg type\n");