From 1e8a8bffb4c35e3af93e2631ed52e12cdb3b76f1 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Wed, 1 Feb 2017 07:42:14 -0500 Subject: [PATCH] =?utf8?q?[runtime]=20Fix=20parse=5Foptimizations=20()=20s?= =?utf8?q?o=20the=20optimization=20names=20don't=20=E2=80=A6=20(#4300)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * [runtime] Fix parse_optimizations () so the optimization names don't need to be in a particular order. * [jit] Avoid unused bits in optflags. --- mono/mini/driver.c | 36 ++++++++++++------------------------ mono/mini/optflags-def.h | 6 ++---- 2 files changed, 14 insertions(+), 28 deletions(-) diff --git a/mono/mini/driver.c b/mono/mini/driver.c index 018657b181a..357c1cd5057 100644 --- a/mono/mini/driver.c +++ b/mono/mini/driver.c @@ -120,11 +120,6 @@ opt_names [] = { #endif -static const OptFunc -opt_funcs [sizeof (int) * 8] = { - NULL -}; - #ifdef __native_client__ extern char *nacl_mono_path; #endif @@ -154,7 +149,8 @@ parse_optimizations (guint32 opt, const char* p, gboolean cpu_opts) { guint32 exclude = 0; const char *n; - int i, invert, len; + int i, invert; + char **parts, **ptr; /* Initialize the hwcap module if necessary. */ mono_hwcap_init (); @@ -167,7 +163,11 @@ parse_optimizations (guint32 opt, const char* p, gboolean cpu_opts) if (!p) return opt; - while (*p) { + parts = g_strsplit (p, ",", -1); + for (ptr = parts; ptr && *ptr; ptr ++) { + char *arg = *ptr; + char *p = arg; + if (*p == '-') { p++; invert = TRUE; @@ -176,24 +176,11 @@ parse_optimizations (guint32 opt, const char* p, gboolean cpu_opts) } for (i = 0; i < G_N_ELEMENTS (opt_names) && optflag_get_name (i); ++i) { n = optflag_get_name (i); - len = strlen (n); - if (strncmp (p, n, len) == 0) { + if (!strcmp (p, n)) { if (invert) opt &= ~ (1 << i); else opt |= 1 << i; - p += len; - if (*p == ',') { - p++; - break; - } else if (*p == '=') { - p++; - if (opt_funcs [i]) - opt_funcs [i] (p); - while (*p && *p++ != ','); - break; - } - /* error out */ break; } } @@ -203,15 +190,16 @@ parse_optimizations (guint32 opt, const char* p, gboolean cpu_opts) opt = 0; else opt = ~(EXCLUDED_FROM_ALL | exclude); - p += 3; - if (*p == ',') - p++; } else { fprintf (stderr, "Invalid optimization name `%s'\n", p); exit (1); } } + + g_free (arg); } + g_free (parts); + return opt; } diff --git a/mono/mini/optflags-def.h b/mono/mini/optflags-def.h index b72ab7a227d..c9eb600d46c 100644 --- a/mono/mini/optflags-def.h +++ b/mono/mini/optflags-def.h @@ -20,12 +20,10 @@ OPTFLAG(ABCREM ,18, "abcrem", "Array bound checks removal") OPTFLAG(SSAPRE ,19, "ssapre", "SSA based Partial Redundancy Elimination (obsolete)") OPTFLAG(EXCEPTION,20, "exception", "Optimize exception catch blocks") OPTFLAG(SSA ,21, "ssa", "Use plain SSA form") +OPTFLAG(FLOAT32 ,22, "float32", "Use 32 bit float arithmetic if possible") OPTFLAG(SSE2 ,23, "sse2", "SSE2 instructions on x86") -/* The id has to be smaller than gshared's, the parser code depends on this */ OPTFLAG(GSHAREDVT,24, "gsharedvt", "Generic sharing for valuetypes") -OPTFLAG (GSHARED, 25, "gshared", "Generic Sharing") +OPTFLAG (GSHARED, 25, "gshared", "Generic Sharing") OPTFLAG(SIMD ,26, "simd", "Simd intrinsics") OPTFLAG(UNSAFE ,27, "unsafe", "Remove bound checks and perform other dangerous changes") OPTFLAG(ALIAS_ANALYSIS ,28, "alias-analysis", "Alias analysis of locals") -OPTFLAG(FLOAT32 ,29, "float32", "Use 32 bit float arithmetic if possible") - -- 2.25.1