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

ruby-changes:52056

From: nobu <ko1@a...>
Date: Fri, 10 Aug 2018 14:02:41 +0900 (JST)
Subject: [ruby-changes:52056] nobu:r64264 (trunk): version.c: separate Init_ruby_description

nobu	2018-08-10 14:02:35 +0900 (Fri, 10 Aug 2018)

  New Revision: 64264

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64264

  Log:
    version.c: separate Init_ruby_description
    
    * version.c (Init_ruby_description): separate to initialize
      RUBY_DESCRIPTION constant according to mjit.

  Modified files:
    trunk/mjit.c
    trunk/ruby.c
    trunk/version.c
Index: ruby.c
===================================================================
--- ruby.c	(revision 64263)
+++ ruby.c	(revision 64264)
@@ -54,6 +54,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby.c#L54
 
 #include "mjit.h"
 
+void Init_ruby_description(void);
+
 #ifndef HAVE_STDLIB_H
 char *getenv();
 #endif
@@ -1633,6 +1635,7 @@ process_options(int argc, char **argv, r https://github.com/ruby/ruby/blob/trunk/ruby.c#L1635
         /* Using TMP_RUBY_PREFIX created by ruby_init_loadpath_safe(). */
         mjit_init(&opt->mjit);
 
+    Init_ruby_description();
     Init_enc();
     lenc = rb_locale_encoding();
     rb_enc_associate(rb_progname, lenc);
Index: version.c
===================================================================
--- version.c	(revision 64263)
+++ version.c	(revision 64264)
@@ -33,7 +33,7 @@ const char ruby_release_date[] = RUBY_RE https://github.com/ruby/ruby/blob/trunk/version.c#L33
 const char ruby_platform[] = RUBY_PLATFORM;
 const int ruby_patchlevel = RUBY_PATCHLEVEL;
 const char ruby_description[] = RUBY_DESCRIPTION_WITH("");
-const char ruby_description_with_jit[] = RUBY_DESCRIPTION_WITH(" +JIT");
+static const char ruby_description_with_jit[] = RUBY_DESCRIPTION_WITH(" +JIT");
 const char ruby_copyright[] = RUBY_COPYRIGHT;
 const char ruby_engine[] = "ruby";
 
@@ -67,11 +67,6 @@ Init_version(void) https://github.com/ruby/ruby/blob/trunk/version.c#L67
      */
     rb_define_global_const("RUBY_REVISION", MKINT(revision));
     /*
-     * The full ruby version string, like <tt>ruby -v</tt> prints'
-     * This might be overwritten by mjit_init().
-     */
-    rb_define_global_const("RUBY_DESCRIPTION", MKSTR(description));
-    /*
      * The copyright string for ruby
      */
     rb_define_global_const("RUBY_COPYRIGHT", MKSTR(copyright));
@@ -86,6 +81,23 @@ Init_version(void) https://github.com/ruby/ruby/blob/trunk/version.c#L81
     rb_define_global_const("RUBY_ENGINE_VERSION", (1 ? version : MKSTR(version)));
 }
 
+void
+Init_ruby_description(void)
+{
+    VALUE description;
+
+    if (mjit_opts.on) {
+        description = MKSTR(description_with_jit);
+    }
+    else {
+        description = MKSTR(description);
+    }
+    /*
+     * The full ruby version string, like <tt>ruby -v</tt> prints
+     */
+    rb_define_global_const("RUBY_DESCRIPTION", description);
+}
+
 /*! Prints the version information of the CRuby interpreter to stdout. */
 void
 ruby_show_version(void)
Index: mjit.c
===================================================================
--- mjit.c	(revision 64263)
+++ mjit.c	(revision 64264)
@@ -1674,8 +1674,6 @@ system_tmpdir(void) https://github.com/ruby/ruby/blob/trunk/mjit.c#L1674
 /* Minimum value for JIT cache size.  */
 #define MIN_CACHE_SIZE 10
 
-extern const char ruby_description_with_jit[];
-
 /* Start MJIT worker. Return TRUE if worker is sucessfully started. */
 static int
 start_worker(void)
@@ -1702,8 +1700,6 @@ start_worker(void) https://github.com/ruby/ruby/blob/trunk/mjit.c#L1700
 void
 mjit_init(struct mjit_options *opts)
 {
-    VALUE rb_description;
-
     mjit_opts = *opts;
     mjit_enabled = TRUE;
     mjit_call_p = TRUE;
@@ -1755,11 +1751,6 @@ mjit_init(struct mjit_options *opts) https://github.com/ruby/ruby/blob/trunk/mjit.c#L1751
         rb_id_table_foreach(RCLASS_CONST_TBL(rb_cObject), valid_class_serials_add_i, NULL);
     }
 
-    /* Overwrites RUBY_DESCRIPTION constant */
-    rb_const_remove(rb_cObject, rb_intern("RUBY_DESCRIPTION"));
-    rb_description = rb_usascii_str_new_static(ruby_description_with_jit, strlen(ruby_description_with_jit));
-    rb_define_global_const("RUBY_DESCRIPTION", rb_obj_freeze(rb_description));
-
     /* Initialize worker thread */
     start_worker();
 }

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

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