use compiled binary for gem_prelude.rb.

`gem_prelude.rb` is not compiled yet. This patch compile it to
compiled binary.
This commit is contained in:
Koichi Sasada 2019-12-10 16:19:13 +09:00
Родитель 943f3e5fd4
Коммит 2c5c60754c
6 изменённых файлов: 29 добавлений и 12 удалений

Просмотреть файл

@ -39,5 +39,11 @@ rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin
void
Init_builtin(void)
{
//
// nothing
}
void
Init_builtin_features(void)
{
rb_load_with_builtin_functions("gem_prelude", NULL);
}

Просмотреть файл

@ -164,7 +164,7 @@ GOLFOBJS = goruby.$(OBJEXT) golf_prelude.$(OBJEXT)
DEFAULT_PRELUDES = $(GEM_PRELUDE)
PRELUDE_SCRIPTS = $(DEFAULT_PRELUDES)
GEM_PRELUDE = $(srcdir)/gem_prelude.rb
GEM_PRELUDE =
PRELUDES = {$(srcdir)}prelude.c {$(srcdir)}miniprelude.c
GOLFPRELUDES = {$(srcdir)}golf_prelude.c
@ -1003,6 +1003,7 @@ BUILTIN_RB_SRCS = \
$(srcdir)/pack.rb \
$(srcdir)/trace_point.rb \
$(srcdir)/prelude.rb \
$(srcdir)/gem_prelude.rb \
$(empty)
BUILTIN_RB_INCS = $(BUILTIN_RB_SRCS:.rb=.rbinc)

Просмотреть файл

@ -2395,9 +2395,6 @@ RUBY_FUNC_NONNULL(1, bool rb_method_basic_definition_p_with_cc(struct rb_call_da
})
#endif
/* miniprelude.c, prelude.c */
void Init_prelude(void);
/* vm_backtrace.c */
void Init_vm_backtrace(void);
VALUE rb_vm_thread_backtrace(int argc, const VALUE *argv, VALUE thval);

Просмотреть файл

@ -6,11 +6,10 @@
// included from miniinit.c
static struct st_table *loaded_builtin_table;
rb_ast_t *rb_builtin_ast(const char *feature_name, VALUE *name_str);
void
rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin_function *table)
static const rb_iseq_t *
builtin_iseq_load(const char *feature_name, const struct rb_builtin_function *table)
{
VALUE name_str = 0;
rb_ast_t *ast = rb_builtin_ast(feature_name, &name_str);
@ -26,11 +25,16 @@ rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin
rb_io_write(rb_stdout, rb_iseq_disasm((const rb_iseq_t *)iseq));
}
// register (loaded iseq will not be freed)
st_insert(loaded_builtin_table, (st_data_t)feature_name, (st_data_t)iseq);
rb_gc_register_mark_object((VALUE)iseq);
// eval
return iseq;
}
void
rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin_function *table)
{
const rb_iseq_t *iseq = builtin_iseq_load(feature_name, table);
rb_iseq_eval(iseq);
}
@ -58,3 +62,10 @@ Init_builtin(void)
rb_define_singleton_method(rb_cRubyVM, "each_builtin", each_builtin, 0);
loaded_builtin_table = st_init_strtable();
}
void
Init_builtin_features(void)
{
// register for ruby
builtin_iseq_load("gem_prelude", NULL);
}

4
ruby.c
Просмотреть файл

@ -1408,10 +1408,12 @@ proc_options(long argc, char **argv, ruby_cmdline_options_t *opt, int envopt)
return argc0 - argc;
}
void Init_builtin_features(void);
static void
ruby_init_prelude(void)
{
Init_prelude();
Init_builtin_features();
rb_const_remove(rb_cObject, rb_intern_const("TMP_RUBY_PREFIX"));
}

Просмотреть файл

@ -38,7 +38,7 @@ class Prelude
@builtin_count = 0
@preludes = {}
@mains = preludes.map do |filename|
if prelude = filename.end_with?("_prelude.rb")
if prelude = filename.end_with?("golf_prelude.rb")
@prelude_count += 1
else
@builtin_count += 1