3 * Utilities for handling interpreter VM instructions
6 * Bernie Solomon (bernard@ugsolutions.com)
13 #define OPDEF(a,b,c,d) \
15 const char *mono_interp_opname[] = {
16 #include "mintops.def"
21 #define OPDEF(a,b,c,d) \
23 unsigned char mono_interp_oplen[] = {
24 #include "mintops.def"
30 #define OPDEF(a,b,c,d) \
32 MintOpArgType mono_interp_opargtype[] = {
33 #include "mintops.def"
39 mono_interp_dis_mintop(const guint16 *base, const guint16 *ip)
41 int len = mono_interp_oplen [*ip];
44 if (len < 0 || len > 10) {
45 g_print ("op %d len %d\n", *ip, len);
46 g_assert_not_reached ();
47 } else if (len == 0) { /* SWITCH */
48 int n = READ32 (ip + 1);
52 g_print ("IL_%04x: %-10s", ip - base, mono_interp_opname [*ip]);
53 switch (mono_interp_opargtype [*ip]) {
57 g_print (" %u", * (guint16 *)(ip + 1));
60 g_print (" %u,%u", * (guint16 *)(ip + 1), * (guint16 *)(ip + 2));
62 case MintOpShortAndInt:
63 g_print (" %u,%u", * (guint16 *)(ip + 1), (guint32)READ32(ip + 2));
66 g_print (" %d", * (short *)(ip + 1));
68 case MintOpClassToken:
69 case MintOpMethodToken:
70 case MintOpFieldToken:
71 token = * (guint16 *)(ip + 1);
72 g_print (" %u", token);
75 g_print (" %d", (gint32)READ32 (ip + 1));
78 g_print (" %lld", (gint64)READ64 (ip + 1));
81 gint32 tmp = READ32 (ip + 1);
82 g_print (" %g", * (float *)&tmp);
86 gint64 tmp = READ64 (ip + 1);
87 g_print (" %g", * (double *)&tmp);
90 case MintOpShortBranch:
91 target = ip + * (short *)(ip + 1) - base;
92 g_print (" IL_%04x", target);
95 target = ip + (gint32)READ32 (ip + 1) - base;
96 g_print (" IL_%04x", target);
99 const guint16 *p = ip + 1;
100 int sval = (gint32)READ32 (p);
104 for (i = 0; i < sval; ++i) {
108 offset = (gint32)READ32 (p);
109 g_print ("IL_%04x", ip - base + 3 + 2 * sval + offset);
116 g_print("unknown arg type\n");