I want to introduce the patching rule by mrbgems to mruby core.
First, I want to make mruby-JIT mrbgems.
| diff --git a/cont.c b/cont.c | |
| index 58b2d30..b73931b 100644 | |
| --- a/cont.c | |
| +++ b/cont.c | |
| @@ -282,6 +282,19 @@ fiber_mark(void *ptr) | |
| RUBY_MARK_LEAVE("cont"); | |
| } | |
| +void | |
| +rb_fibers_mark(VALUE fibval) { |
| diff --git a/compile.c b/compile.c | |
| index 5d028c9..25e96e7 100644 | |
| --- a/compile.c | |
| +++ b/compile.c | |
| @@ -3859,7 +3859,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) | |
| ADD_INSN(ret, nd_line(node), dup); | |
| } | |
| - if (node->nd_vid) { | |
| + if (!node->nd_else) { |
| diff --git a/proc.c b/proc.c | |
| index 6ccb888..3872e81 100644 | |
| --- a/proc.c | |
| +++ b/proc.c | |
| @@ -316,6 +316,10 @@ rb_binding_new(void) | |
| rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->cfp); | |
| VALUE bindval = binding_alloc(rb_cBinding); | |
| rb_binding_t *bind; | |
| + rb_block_t *block; | |
| + VALUE blockval, *ptr; |
| diff --git a/vm.c b/vm.c | |
| index 6302153..76bfee4 100644 | |
| --- a/vm.c | |
| +++ b/vm.c | |
| @@ -412,6 +412,16 @@ vm_make_env_each(rb_thread_t * const th, rb_control_frame_t * const cfp, | |
| nenvptr = &env->env[i - 1]; | |
| nenvptr[1] = envval; /* frame self */ | |
| + if (envptr == endptr) { | |
| + rb_block_t *block = GC_GUARDED_PTR_REF(*nenvptr); |
| sym = mrb_sym_value(mrb, args[i]); | |
| name = mrb_sym2name(mrb, sym); | |
| len = snprintf(dummy, 1, "Proc.new { @%s }", name) + 1; | |
| scr = malloc(len); | |
| snprintf(scr, len, "Proc.new { @%s }", name); | |
| proc = mrb_load_string(mrb, scr); | |
| free(scr); | |
| mrb_define_method_vm(mrb, mrb_class_ptr(mod), sym, proc); |
| diff --git a/include/mruby/irep.h b/include/mruby/irep.h | |
| index af3346c..3dec0fd 100644 | |
| --- a/include/mruby/irep.h | |
| +++ b/include/mruby/irep.h | |
| @@ -29,6 +29,7 @@ typedef struct mrb_irep { | |
| #define MRB_ISEQ_NOFREE 1 | |
| void mrb_add_irep(mrb_state *mrb, int n); | |
| +mrb_irep *mrb_irep_new(mrb_state *mrb, int ilen, mrb_code *iseq, int plen, mrb_value *pool, int slen, mrb_sym *syms); | |
| diff --git a/method.h b/method.h | |
| index 57a409f..2996775 100644 | |
| --- a/method.h | |
| +++ b/method.h | |
| @@ -22,7 +22,8 @@ typedef enum { | |
| NOEX_MODFUNC = 0x12, | |
| NOEX_SUPER = 0x20, | |
| NOEX_VCALL = 0x40, | |
| - NOEX_RESPONDS = 0x80 | |
| + NOEX_RESPONDS = 0x80, |
| Index: compile.c | |
| =================================================================== | |
| --- compile.c (revision 38278) | |
| +++ compile.c (working copy) | |
| @@ -4981,8 +4981,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) | |
| RSTRING_PTR(iseq->location.label), (void *)iseq, | |
| iseq->compile_data->flip_cnt++); | |
| - hide_obj(key); | |
| - iseq_add_mark_object_compile_time(iseq, key); |
| module Foo | |
| C1 = 1 | |
| class << self | |
| C2 = 2 | |
| ::IFoo = self | |
| end | |
| end | |
| module Bar | |
| C3 = 3 | |
| class << Foo |