From: Jay Krell Date: Fri, 30 Aug 2019 08:27:19 +0000 (-0700) Subject: [interp] Compress interpreter opcode names in usual way, offsets vs. pointers. (mono... X-Git-Tag: submit/tizen/20210909.063632~10331^2~5^2~641 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b885ff71dae77e0817eb00d914dee0e68cba5085;p=platform%2Fupstream%2Fdotnet%2Fruntime.git [interp] Compress interpreter opcode names in usual way, offsets vs. pointers. (mono/mono#16350) * [interp] Compress the interpreter opcode names in the usual way, by changing from an array of pointers to an array of 16 bit offsets into one large "string". * PR: Make mono_interp_opname a function. Commit migrated from https://github.com/mono/mono/commit/36296ce291f8a7b19de3eccb7a32c7e4ed9df8f2 --- diff --git a/src/mono/mono/mini/interp/interp.c b/src/mono/mono/mini/interp/interp.c index 438b80a..bd4fdac 100644 --- a/src/mono/mono/mini/interp/interp.c +++ b/src/mono/mono/mini/interp/interp.c @@ -6586,7 +6586,7 @@ main_loop: } MINT_IN_DEFAULT - g_error ("Unimplemented opcode: %04x %s at 0x%x\n", *ip, mono_interp_opname[*ip], ip-frame->imethod->code); + g_error ("Unimplemented opcode: %04x %s at 0x%x\n", *ip, mono_interp_opname (*ip), ip - frame->imethod->code); } } diff --git a/src/mono/mono/mini/interp/mintops.c b/src/mono/mono/mini/interp/mintops.c index af1351c..1a3f9d6 100644 --- a/src/mono/mono/mini/interp/mintops.c +++ b/src/mono/mono/mini/interp/mintops.c @@ -10,20 +10,33 @@ #include #include "mintops.h" -#define OPDEF(a,b,c,d) b, -const char * const mono_interp_opname [] = { +// This, instead of an array of pointers, to optimize away a pointer and a relocation per string. +struct MonoInterpOpnameCharacters { +#define OPDEF(a, b, c, d) char a [sizeof (b)]; #include "mintops.def" }; #undef OPDEF -#define OPDEF(a,b,c,d) c, +extern const MonoInterpOpnameCharacters mono_interp_opname_characters = { +#define OPDEF(a, b, c, d) b, +#include "mintops.def" +}; +#undef OPDEF + +extern const guint16 mono_interp_opname_offsets [] = { +#define OPDEF(a, b, c, d) offsetof (MonoInterpOpnameCharacters, a), +#include "mintops.def" +#undef OPDEF +}; + +#define OPDEF(a, b, c, d) c, unsigned char const mono_interp_oplen [] = { #include "mintops.def" }; #undef OPDEF -#define OPDEF(a,b,c,d) d, +#define OPDEF(a, b, c, d) d, MintOpArgType const mono_interp_opargtype [] = { #include "mintops.def" }; @@ -52,7 +65,7 @@ mono_interp_dis_mintop(const guint16 *base, const guint16 *ip) guint32 token; int target; - g_string_append_printf (str, "IL_%04x: %-10s", (int)(ip - base), mono_interp_opname [*ip]); + g_string_append_printf (str, "IL_%04x: %-10s", (int)(ip - base), mono_interp_opname (*ip)); switch (mono_interp_opargtype [*ip]) { case MintOpNoArgs: break; @@ -122,3 +135,8 @@ mono_interp_dis_mintop(const guint16 *base, const guint16 *ip) return g_string_free (str, FALSE); } +const char* +mono_interp_opname (int op) +{ + return ((const char*)&mono_interp_opname_characters) + mono_interp_opname_offsets [op]; +} diff --git a/src/mono/mono/mini/interp/mintops.h b/src/mono/mono/mini/interp/mintops.h index e6a1203..f5793bf 100644 --- a/src/mono/mono/mini/interp/mintops.h +++ b/src/mono/mono/mini/interp/mintops.h @@ -53,11 +53,17 @@ enum { #define MINT_SWITCH_LEN(n) (3 + (n) * 2) -extern const char * const mono_interp_opname[]; extern unsigned char const mono_interp_oplen[]; extern MintOpArgType const mono_interp_opargtype[]; extern char* mono_interp_dis_mintop(const unsigned short *base, const guint16 *ip); extern const guint16* mono_interp_dis_mintop_len (const guint16 *ip); -#endif +// This, instead of an array of pointers, to optimize away a pointer and a relocation per string. +extern const guint16 mono_interp_opname_offsets [ ]; +typedef struct MonoInterpOpnameCharacters MonoInterpOpnameCharacters; +extern const MonoInterpOpnameCharacters mono_interp_opname_characters; + +const char* +mono_interp_opname (int op); +#endif diff --git a/src/mono/mono/mini/interp/transform.c b/src/mono/mono/mini/interp/transform.c index 3e3c027..ad4910d 100644 --- a/src/mono/mono/mini/interp/transform.c +++ b/src/mono/mono/mini/interp/transform.c @@ -532,7 +532,7 @@ binary_arith_op(TransformData *td, int mint_op) if (type1 != type2) { g_warning("%s.%s: %04x arith type mismatch %s %d %d", m_class_get_name (td->method->klass), td->method->name, - td->ip - td->il_code, mono_interp_opname[mint_op], type1, type2); + td->ip - td->il_code, mono_interp_opname (mint_op), type1, type2); } op = mint_op + type1 - STACK_TYPE_I4; CHECK_STACK(td, 2);