ruby-changes:46891
From: ko1 <ko1@a...>
Date: Sat, 3 Jun 2017 19:07:50 +0900 (JST)
Subject: [ruby-changes:46891] ko1:r59006 (trunk): * vm_core.h: remove VM_FRAME_MAGIC_LAMBDA and introduce
ko1 2017-06-03 19:07:44 +0900 (Sat, 03 Jun 2017) New Revision: 59006 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59006 Log: * vm_core.h: remove VM_FRAME_MAGIC_LAMBDA and introduce VM_FRAME_FLAG_LAMBDA. So that lambda block frame is VM_FRAME_MAGIC_BLOCK | VM_FRAME_FLAG_LAMBDA. * vm_core.h: remvoe VM_FRAME_MAGIC_PROC because nobody uses it. Modified files: trunk/vm.c trunk/vm_core.h trunk/vm_dump.c trunk/vm_insnhelper.c Index: vm_core.h =================================================================== --- vm_core.h (revision 59005) +++ vm_core.h (revision 59006) @@ -980,12 +980,12 @@ typedef rb_control_frame_t * https://github.com/ruby/ruby/blob/trunk/vm_core.h#L980 enum { /* Frame/Environment flag bits: - * MMMM MMMM MMMM MMMM ____ ____ FFFF EEEX (LSB) + * MMMM MMMM MMMM MMMM ____ __FF FFFF EEEX (LSB) * * X : tag for GC marking (It seems as Fixnum) * EEE : 3 bits Env flags - * FFFF: 4 bits Frame flags - * MMMM: 16 bits frame magic (to check frame corruption) + * FF..: 6 bits Frame flags + * MM..: 16 bits frame magic (to check frame corruption) */ /* frame types */ @@ -994,12 +994,10 @@ enum { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L994 VM_FRAME_MAGIC_CLASS = 0x33330001, VM_FRAME_MAGIC_TOP = 0x44440001, VM_FRAME_MAGIC_CFUNC = 0x55550001, - VM_FRAME_MAGIC_PROC = 0x66660001, - VM_FRAME_MAGIC_IFUNC = 0x77770001, - VM_FRAME_MAGIC_EVAL = 0x88880001, - VM_FRAME_MAGIC_LAMBDA = 0x99990001, - VM_FRAME_MAGIC_RESCUE = 0xaaaa0001, - VM_FRAME_MAGIC_DUMMY = 0xbbbb0001, + VM_FRAME_MAGIC_IFUNC = 0x66660001, + VM_FRAME_MAGIC_EVAL = 0x77770001, + VM_FRAME_MAGIC_RESCUE = 0x88880001, + VM_FRAME_MAGIC_DUMMY = 0x99990001, VM_FRAME_MAGIC_MASK = 0xffff0001, @@ -1008,6 +1006,7 @@ enum { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L1006 VM_FRAME_FLAG_FINISH = 0x0020, VM_FRAME_FLAG_BMETHOD = 0x0040, VM_FRAME_FLAG_CFRAME = 0x0080, + VM_FRAME_FLAG_LAMBDA = 0x0100, /* env flag */ VM_ENV_FLAG_LOCAL = 0x0002, @@ -1058,9 +1057,15 @@ VM_FRAME_TYPE(const rb_control_frame_t * https://github.com/ruby/ruby/blob/trunk/vm_core.h#L1057 } static inline int +VM_FRAME_LAMBDA_P(const rb_control_frame_t *cfp) +{ + return VM_ENV_FLAGS(cfp->ep, VM_FRAME_FLAG_LAMBDA) != 0; +} + +static inline int VM_FRAME_FINISHED_P(const rb_control_frame_t *cfp) { - return VM_ENV_FLAGS(cfp->ep, VM_FRAME_FLAG_FINISH ) != 0; + return VM_ENV_FLAGS(cfp->ep, VM_FRAME_FLAG_FINISH) != 0; } static inline int Index: vm.c =================================================================== --- vm.c (revision 59005) +++ vm.c (revision 59006) @@ -1008,7 +1008,7 @@ invoke_iseq_block_from_c(rb_thread_t *th https://github.com/ruby/ruby/blob/trunk/vm.c#L1008 { const rb_iseq_t *iseq = rb_iseq_check(captured->code.iseq); int i, opt_pc; - VALUE type = is_lambda ? VM_FRAME_MAGIC_LAMBDA : VM_FRAME_MAGIC_BLOCK; + VALUE type = VM_FRAME_MAGIC_BLOCK | (is_lambda ? VM_FRAME_FLAG_LAMBDA : 0); rb_control_frame_t *cfp = th->ec.cfp; VALUE *sp = cfp->sp; const rb_callable_method_entry_t *me = th->passed_bmethod_me; @@ -1021,7 +1021,7 @@ invoke_iseq_block_from_c(rb_thread_t *th https://github.com/ruby/ruby/blob/trunk/vm.c#L1021 } opt_pc = vm_yield_setup_args(th, iseq, argc, sp, passed_block_handler, - (type == VM_FRAME_MAGIC_LAMBDA ? (splattable ? arg_setup_lambda : arg_setup_method) : arg_setup_block)); + (is_lambda ? (splattable ? arg_setup_lambda : arg_setup_method) : arg_setup_block)); cfp->sp = sp; if (me == NULL) { @@ -1605,10 +1605,8 @@ vm_frametype_name(const rb_control_frame https://github.com/ruby/ruby/blob/trunk/vm.c#L1605 case VM_FRAME_MAGIC_CLASS: return "class"; case VM_FRAME_MAGIC_TOP: return "top"; case VM_FRAME_MAGIC_CFUNC: return "cfunc"; - case VM_FRAME_MAGIC_PROC: return "proc"; case VM_FRAME_MAGIC_IFUNC: return "ifunc"; case VM_FRAME_MAGIC_EVAL: return "eval"; - case VM_FRAME_MAGIC_LAMBDA: return "lambda"; case VM_FRAME_MAGIC_RESCUE: return "rescue"; default: rb_bug("unknown frame"); @@ -1665,7 +1663,6 @@ hook_before_rewind(rb_thread_t *th, cons https://github.com/ruby/ruby/blob/trunk/vm.c#L1663 THROW_DATA_CONSUMED_SET(err); break; case VM_FRAME_MAGIC_BLOCK: - case VM_FRAME_MAGIC_LAMBDA: if (VM_FRAME_BMETHOD_P(th->ec.cfp)) { EXEC_EVENT_HOOK(th, RUBY_EVENT_B_RETURN, th->ec.cfp->self, 0, 0, 0, frame_return_value(err)); Index: vm_dump.c =================================================================== --- vm_dump.c (revision 59005) +++ vm_dump.c (revision 59006) @@ -60,12 +60,6 @@ control_frame_dump(rb_thread_t *th, rb_c https://github.com/ruby/ruby/blob/trunk/vm_dump.c#L60 case VM_FRAME_MAGIC_CFUNC: magic = "CFUNC"; break; - case VM_FRAME_MAGIC_PROC: - magic = "PROC"; - break; - case VM_FRAME_MAGIC_LAMBDA: - magic = "LAMBDA"; - break; case VM_FRAME_MAGIC_IFUNC: magic = "IFUNC"; break; @@ -258,8 +252,6 @@ vm_stack_dump_each(rb_thread_t *th, rb_c https://github.com/ruby/ruby/blob/trunk/vm_dump.c#L252 VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_TOP || VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_BLOCK || VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_CLASS || - VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_PROC || - VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_LAMBDA|| VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_CFUNC || VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_IFUNC || VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_EVAL || Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 59005) +++ vm_insnhelper.c (revision 59006) @@ -130,7 +130,7 @@ vm_check_frame_detail(VALUE type, int re https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L130 } else { /* cref or Qfalse */ if (cref_or_me != Qfalse && cref_or_me_type != imemo_cref) { - if ((magic == VM_FRAME_MAGIC_LAMBDA || magic == VM_FRAME_MAGIC_IFUNC) && (cref_or_me_type == imemo_ment)) { + if (((type & VM_FRAME_FLAG_LAMBDA) || magic == VM_FRAME_MAGIC_IFUNC) && (cref_or_me_type == imemo_ment)) { /* ignore */ } else { @@ -178,10 +178,8 @@ vm_check_frame(VALUE type, https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L178 CHECK(VM_FRAME_MAGIC_TOP, TRUE, FALSE, TRUE, FALSE); CHECK(VM_FRAME_MAGIC_CFUNC, TRUE, TRUE, FALSE, TRUE); CHECK(VM_FRAME_MAGIC_BLOCK, FALSE, FALSE, FALSE, FALSE); - CHECK(VM_FRAME_MAGIC_PROC, FALSE, FALSE, FALSE, FALSE); CHECK(VM_FRAME_MAGIC_IFUNC, FALSE, FALSE, FALSE, TRUE); CHECK(VM_FRAME_MAGIC_EVAL, FALSE, FALSE, FALSE, FALSE); - CHECK(VM_FRAME_MAGIC_LAMBDA, FALSE, FALSE, FALSE, FALSE); CHECK(VM_FRAME_MAGIC_RESCUE, FALSE, FALSE, FALSE, FALSE); CHECK(VM_FRAME_MAGIC_DUMMY, TRUE, FALSE, FALSE, FALSE); default: @@ -1073,7 +1071,7 @@ vm_throw_start(rb_thread_t *const th, rb https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1071 } } - if (VM_FRAME_TYPE(escape_cfp) == VM_FRAME_MAGIC_LAMBDA) { + if (VM_FRAME_LAMBDA_P(escape_cfp)) { /* lambda{... break ...} */ is_orphan = 0; state = TAG_RETURN; @@ -1141,7 +1139,7 @@ vm_throw_start(rb_thread_t *const th, rb https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1139 } if (lep == target_lep) { - if (VM_FRAME_TYPE(escape_cfp) == VM_FRAME_MAGIC_LAMBDA) { + if (VM_FRAME_LAMBDA_P(escape_cfp)) { if (in_class_frame) { /* lambda {class A; ... return ...; end} */ goto valid_return; @@ -2684,7 +2682,7 @@ vm_invoke_iseq_block(rb_thread_t *th, rb https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2682 SET_SP(rsp); vm_push_frame(th, iseq, - is_lambda ? VM_FRAME_MAGIC_LAMBDA : VM_FRAME_MAGIC_BLOCK, + VM_FRAME_MAGIC_BLOCK | (is_lambda ? VM_FRAME_FLAG_LAMBDA : 0), captured->self, VM_GUARDED_PREV_EP(captured->ep), 0, iseq->body->iseq_encoded + opt_pc, -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/