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

ruby-changes:58792

From: Koichi <ko1@a...>
Date: Fri, 15 Nov 2019 03:57:00 +0900 (JST)
Subject: [ruby-changes:58792] 9c1abe2a6c (master): load prelude.rb by builtin features.

https://git.ruby-lang.org/ruby.git/commit/?id=9c1abe2a6c

From 9c1abe2a6c5e6288ed208000fbf811d145af9355 Mon Sep 17 00:00:00 2001
From: Koichi Sasada <ko1@a...>
Date: Fri, 15 Nov 2019 03:51:06 +0900
Subject: load prelude.rb by builtin features.

The script in prelude.rb was embed in MRI to load it (eval this
script at everyboot).
This commit change the loading process of prelude.rb. MRI doesn't
eval a script, but load from compiled binary with builtin feature.

So that Init_prelude() does not load `prelude.rb` now.

diff --git a/common.mk b/common.mk
index e382b22..b117008 100644
--- a/common.mk
+++ b/common.mk
@@ -163,7 +163,7 @@ ALLOBJS       = $(NORMALMAINOBJ) $(MINIOBJS) $(COMMONOBJS) $(INITOBJS) https://github.com/ruby/ruby/blob/trunk/common.mk#L163
 GOLFOBJS      = goruby.$(OBJEXT) golf_prelude.$(OBJEXT)
 
 DEFAULT_PRELUDES = $(GEM_PRELUDE)
-PRELUDE_SCRIPTS = $(srcdir)/prelude.rb $(DEFAULT_PRELUDES)
+PRELUDE_SCRIPTS = $(DEFAULT_PRELUDES)
 GEM_PRELUDE   = $(srcdir)/gem_prelude.rb
 PRELUDES      = {$(srcdir)}prelude.c {$(srcdir)}miniprelude.c
 GOLFPRELUDES  = {$(srcdir)}golf_prelude.c
@@ -1000,6 +1000,7 @@ BUILTIN_RB_SRCS = \ https://github.com/ruby/ruby/blob/trunk/common.mk#L1000
 		$(srcdir)/io.rb \
 		$(srcdir)/pack.rb \
 		$(srcdir)/trace_point.rb \
+		$(srcdir)/prelude.rb \
 		$(empty)
 BUILTIN_RB_INCS = $(BUILTIN_RB_SRCS:.rb=.rbinc)
 
@@ -2231,6 +2232,8 @@ inits.$(OBJEXT): {$(VPATH)}onigmo.h https://github.com/ruby/ruby/blob/trunk/common.mk#L2232
 inits.$(OBJEXT): {$(VPATH)}oniguruma.h
 inits.$(OBJEXT): {$(VPATH)}st.h
 inits.$(OBJEXT): {$(VPATH)}subst.h
+inits.$(OBJEXT): {$(VPATH)}builtin.h
+inits.$(OBJEXT): {$(VPATH)}prelude.rbinc
 io.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
 io.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
 io.$(OBJEXT): $(CCAN_DIR)/list/list.h
@@ -2689,7 +2692,6 @@ prelude.$(OBJEXT): {$(VPATH)}node.h https://github.com/ruby/ruby/blob/trunk/common.mk#L2692
 prelude.$(OBJEXT): {$(VPATH)}onigmo.h
 prelude.$(OBJEXT): {$(VPATH)}oniguruma.h
 prelude.$(OBJEXT): {$(VPATH)}prelude.c
-prelude.$(OBJEXT): {$(VPATH)}prelude.rb
 prelude.$(OBJEXT): {$(VPATH)}ruby_assert.h
 prelude.$(OBJEXT): {$(VPATH)}ruby_atomic.h
 prelude.$(OBJEXT): {$(VPATH)}st.h
diff --git a/inits.c b/inits.c
index 9ced248..490506e 100644
--- a/inits.c
+++ b/inits.c
@@ -10,6 +10,8 @@ https://github.com/ruby/ruby/blob/trunk/inits.c#L10
 **********************************************************************/
 
 #include "internal.h"
+#include "builtin.h"
+#include "prelude.rbinc"
 
 #define CALL(n) {void Init_##n(void); Init_##n();}
 
@@ -66,6 +68,7 @@ rb_call_inits(void) https://github.com/ruby/ruby/blob/trunk/inits.c#L68
     CALL(vm_stack_canary);
     CALL(gc_stress);
 
+    // enable builtin loading
     CALL(builtin);
 
     CALL(GC);
@@ -73,5 +76,6 @@ rb_call_inits(void) https://github.com/ruby/ruby/blob/trunk/inits.c#L76
     CALL(ast);
     CALL(vm_trace);
     CALL(pack);
+    load_prelude();
 }
 #undef CALL
diff --git a/template/prelude.c.tmpl b/template/prelude.c.tmpl
index 33f6a68..e3cbbaa 100644
--- a/template/prelude.c.tmpl
+++ b/template/prelude.c.tmpl
@@ -38,7 +38,7 @@ class Prelude https://github.com/ruby/ruby/blob/trunk/template/prelude.c.tmpl#L38
     @builtin_count = 0
     @preludes = {}
     @mains = preludes.map do |filename|
-      if prelude = filename.end_with?("prelude.rb")
+      if prelude = filename.end_with?("_prelude.rb")
         @prelude_count += 1
       else
         @builtin_count += 1
-- 
cgit v0.10.2


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

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