[前][次][番号順一覧][スレッド一覧]

ruby-changes:70815

From: Nobuyoshi <ko1@a...>
Date: Tue, 11 Jan 2022 17:27:07 +0900 (JST)
Subject: [ruby-changes:70815] 3d675c72b9 (master): Use `setup_yjit_options` only when supported

https://git.ruby-lang.org/ruby.git/commit/?id=3d675c72b9

From 3d675c72b9f23791a03bd3b2251e8a2c488b33df Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Tue, 11 Jan 2022 17:26:21 +0900
Subject: Use `setup_yjit_options` only when supported

---
 ruby.c | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/ruby.c b/ruby.c
index e26996ec90c..c06cd7bd787 100644
--- a/ruby.c
+++ b/ruby.c
@@ -1084,20 +1084,15 @@ set_option_encoding_once(const char *type, VALUE *name, const char *e, long elen https://github.com/ruby/ruby/blob/trunk/ruby.c#L1084
 #define yjit_opt_match_arg(s, l, name) \
     opt_match(s, l, name) && (*(s) && *(s+1) ? 1 : (rb_raise(rb_eRuntimeError, "--yjit-" name " needs an argument"), 0))
 
-static bool
+#if YJIT_SUPPORTED_P
+static void
 setup_yjit_options(const char *s, struct rb_yjit_options *yjit_opt)
 {
-    const char prefix[] = "yjit-";
-    if (strncmp(prefix, s, sizeof(prefix)-1) != 0) {
-        return false;
-    }
-    s += sizeof(prefix)-1;
     const size_t l = strlen(s);
     if (l == 0) {
-        return false;
+        return;
     }
-
-    if (yjit_opt_match_arg(s, l, "exec-mem-size")) {
+    else if (yjit_opt_match_arg(s, l, "exec-mem-size")) {
         yjit_opt->exec_mem_size = atoi(s + 1);
     }
     else if (yjit_opt_match_arg(s, l, "call-threshold")) {
@@ -1119,16 +1114,17 @@ setup_yjit_options(const char *s, struct rb_yjit_options *yjit_opt) https://github.com/ruby/ruby/blob/trunk/ruby.c#L1114
         rb_raise(rb_eRuntimeError,
                  "invalid yjit option `%s' (--help will show valid yjit options)", s);
     }
-    return true;
 }
+#endif
 
 #if USE_MJIT
 static void
 setup_mjit_options(const char *s, struct mjit_options *mjit_opt)
 {
-    if (*s != '-') return;
-    const size_t l = strlen(++s);
-    if (*s == 0) return;
+    const size_t l = strlen(s);
+    if (l == 0) {
+        return;
+    }
     else if (opt_match_noarg(s, l, "warnings")) {
         mjit_opt->warnings = 1;
     }
@@ -1537,17 +1533,18 @@ proc_options(long argc, char **argv, ruby_cmdline_options_t *opt, int envopt) https://github.com/ruby/ruby/blob/trunk/ruby.c#L1533
                 FEATURE_SET(opt->features, FEATURE_BIT(yjit));
 #endif
             }
-            else if (strncmp("mjit", s, 4) == 0) {
+            else if (is_option_with_optarg("mjit", '-', true, false, false)) {
 #if USE_MJIT
                 FEATURE_SET(opt->features, FEATURE_BIT(mjit));
-                setup_mjit_options(s + 4, &opt->mjit);
+                setup_mjit_options(s, &opt->mjit);
 #else
                 rb_warn("MJIT support is disabled.");
 #endif
             }
-            else if (strcmp("yjit", s) == 0 || setup_yjit_options(s, &opt->yjit)) {
+            else if (is_option_with_optarg("yjit", '-', true, false, false)) {
 #if USE_MJIT
                 FEATURE_SET(opt->features, FEATURE_BIT(yjit));
+                setup_yjit_options(s, &opt->yjit);
 #else
                 rb_warn("Ruby was built without JIT support");
 #endif
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]