Mon Aug 9 14:41:45 CEST 2004 Paolo Molaro <lupus@ximian.com>
authorPaolo Molaro <lupus@oddwiz.org>
Mon, 9 Aug 2004 11:41:12 +0000 (11:41 -0000)
committerPaolo Molaro <lupus@oddwiz.org>
Mon, 9 Aug 2004 11:41:12 +0000 (11:41 -0000)
* opcodes.c, opcodes.h: reduce runtime relocations.

svn path=/trunk/mono/; revision=32066

mono/dis/dis-cil.c
mono/interpreter/transform.c
mono/metadata/ChangeLog
mono/metadata/opcodes.c
mono/metadata/opcodes.h
mono/mini/helpers.c
mono/monograph/monograph.c

index b812da688a5da3862cd6984366478b45129457e3..26a5e4444f514fc93296a86a2716e5411c65c317 100644 (file)
@@ -129,7 +129,7 @@ dissasemble_cil (MonoImage *m, MonoMethodHeader *mh)
                 if (in_fault && entry->opval == 0xDC)
                         fprintf (output, " %s", "endfault");
                 else
-                        fprintf (output, " %s ", mono_opcode_names [i]);
+                        fprintf (output, " %s ", mono_opcode_name (i));
                ptr++;
                switch (entry->argument){
                case MonoInlineBrTarget: {
index f28203df6401c22b401d22ac66ff6bb400e43eea..4287339d105512c161f47b540879f54b86b2c609 100644 (file)
@@ -759,7 +759,7 @@ generate(MonoMethod *method, RuntimeMethod *rtm, unsigned char *is_bb_start)
                                td.is_bb_start [td.ip - td.il_code] == 3 ? "<>" :
                                td.is_bb_start [td.ip - td.il_code] == 2 ? "< " :
                                td.is_bb_start [td.ip - td.il_code] == 1 ? " >" : "  ",
-                               mono_opcode_names [*td.ip], td.new_ip - td.new_code, td.sp - td.stack, 
+                               mono_opcode_name (*td.ip), td.new_ip - td.new_code, td.sp - td.stack, 
                                td.sp > td.stack ? stack_type_string [td.sp [-1].type] : "  ",
                                (td.sp > td.stack && (td.sp [-1].type == STACK_TYPE_O || td.sp [-1].type == STACK_TYPE_VT)) ? (td.sp [-1].klass == NULL ? "?" : td.sp [-1].klass->name) : "",
                                td.vt_sp, td.max_vt_sp);
index cbe8fd9ca328733aa342f5f895909908f5344598..58c8019e985a2b51c266085f542d0f8cba82a512 100644 (file)
@@ -1,4 +1,8 @@
 
+Mon Aug 9 14:41:45 CEST 2004 Paolo Molaro <lupus@ximian.com>
+
+       * opcodes.c, opcodes.h: reduce runtime relocations.
+
 Mon Aug 9 13:30:53 CEST 2004 Paolo Molaro <lupus@ximian.com>
 
        * culture-info.h, locales.c: fixes and chages to sue the new
index 1e22212f3b9fb7751c2a487cafdfb6a87e7959d9..c7328c15c50b6babe8f4660bd9451e24829eaca4 100644 (file)
@@ -23,14 +23,29 @@ mono_opcodes [MONO_CEE_LAST + 1] = {
 
 #undef OPDEF
 
+#define MSGSTRFIELD(line) MSGSTRFIELD1(line)
+#define MSGSTRFIELD1(line) str##line
+static const struct msgstr_t {
+#define OPDEF(a,b,c,d,e,f,g,h,i,j) char MSGSTRFIELD(__LINE__) [sizeof (b)];
+#include "mono/cil/opcode.def"
+#undef OPDEF
+} opstr = {
 #define OPDEF(a,b,c,d,e,f,g,h,i,j) b,
-
-const char* const
-mono_opcode_names [MONO_CEE_LAST + 1] = {
 #include "mono/cil/opcode.def"
-       NULL
+#undef OPDEF
+};
+static const int opidx [] = {
+#define OPDEF(a,b,c,d,e,f,g,h,i,j) [MONO_ ## a] = offsetof (struct msgstr_t, MSGSTRFIELD(__LINE__)),
+#include "mono/cil/opcode.def"
+#undef OPDEF
 };
 
+const char*
+mono_opcode_name (int opcode)
+{
+       return (const char*)&opstr + opidx [opcode];
+}
+
 MonoOpcodeEnum
 mono_opcode_value (const guint8 **ip, const guint8 *end)
 {
index f83cd614450771e5f0f0b4381a88d8e283d03034..60c6a53e036d605576c64753dfb4a34da920756f 100644 (file)
@@ -61,7 +61,9 @@ typedef struct {
 } MonoOpcode;
 
 extern const MonoOpcode mono_opcodes [];
-extern const char* const mono_opcode_names [];
+
+const char*
+mono_opcode_name (int opcode);
 
 MonoOpcodeEnum
 mono_opcode_value (const guint8 **ip, const guint8 *end);
index 24daf024c27cc0dfa8510276b87308cf135c8d27..b4df1e5c3daaa6217d9a65009d87d04698f1538d 100644 (file)
@@ -12,7 +12,7 @@
 #endif
 #define MINI_OP(a,b) b,
 /* keep in sync with the enum in mini.h */
-static const char* 
+static const char* const
 opnames[] = {
 #include "mini-ops.h"
 };
@@ -23,7 +23,7 @@ mono_inst_name (int op) {
        if (op >= OP_LOAD && op <= OP_LAST)
                return opnames [op - OP_LOAD];
        if (op < OP_LOAD)
-               return mono_opcode_names [op];
+               return mono_opcode_name (op);
        g_error ("unknown opcode name for %d", op);
        return NULL;
 }
index 72103b0b9af9347499a7a0d5dbd1be260caa9494..b2649fde8ec19fbdde36b87d97bd1beccfb181fb 100644 (file)
@@ -236,10 +236,10 @@ method_stats (MonoMethod *method) {
                        n = read32 (ip + 1);
                        if (n >= -1 && n <= 8) {
                                int_waste += 4;
-                               g_print ("%s %d\n", mono_opcode_names [i], n);
+                               g_print ("%s %d\n", mono_opcode_name (i), n);
                        } else if (n < 128 && n >= -128) {
                                int_waste += 3;
-                               g_print ("%s %d\n", mono_opcode_names [i], n);
+                               g_print ("%s %d\n", mono_opcode_name (i), n);
                        }
                        ip += 5;
                        break;
@@ -280,16 +280,16 @@ method_stats (MonoMethod *method) {
                                        case MONO_CEE_LDLOC:
                                        case MONO_CEE_STLOC:
                                                var_waste += 3;
-                                               g_print ("%s %d\n", mono_opcode_names [i], n);
+                                               g_print ("%s %d\n", mono_opcode_name (i), n);
                                                break;
                                        default:
                                                var_waste += 2;
-                                               g_print ("%s %d\n", mono_opcode_names [i], n);
+                                               g_print ("%s %d\n", mono_opcode_name (i), n);
                                                break;
                                        }
                                } else {
                                        var_waste += 2;
-                                       g_print ("%s %d\n", mono_opcode_names [i], n);
+                                       g_print ("%s %d\n", mono_opcode_name (i), n);
                                }
                        }
                        ip += 3;
@@ -301,7 +301,7 @@ method_stats (MonoMethod *method) {
                                case MONO_CEE_LDLOC_S:
                                case MONO_CEE_STLOC_S:
                                        var_waste++;
-                                       g_print ("%s %d\n", mono_opcode_names [i], (signed char)ip [1]);
+                                       g_print ("%s %d\n", mono_opcode_name (i), (signed char)ip [1]);
                                        break;
                                default:
                                        break;
@@ -311,7 +311,7 @@ method_stats (MonoMethod *method) {
                        break;
                case MonoShortInlineI:
                        if ((signed char)ip [1] <= 8 && (signed char)ip [1] >= -1) {
-                               g_print ("%s %d\n", mono_opcode_names [i], (signed char)ip [1]);
+                               g_print ("%s %d\n", mono_opcode_name (i), (signed char)ip [1]);
                                int_waste ++;
                        }
                        ip += 2;