ruby-changes:49486
From: mame <ko1@a...>
Date: Fri, 5 Jan 2018 09:49:47 +0900 (JST)
Subject: [ruby-changes:49486] mame:r61601 (trunk): Refactor ISEQ_TYPE_DEFINED_GUARD out
mame 2018-01-05 09:49:41 +0900 (Fri, 05 Jan 2018) New Revision: 61601 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61601 Log: Refactor ISEQ_TYPE_DEFINED_GUARD out This commit removes ISEQ_TYPE_DEFINED_GUARD because it is no longer needed. And this introduces ISEQ_TYPE_PLAIN which means that the iseq does nothing special but just wrap an expression. Currently, this is used for once execution: `/foo#{ bar }baz/o`. Modified files: trunk/compile.c trunk/iseq.c trunk/vm_core.h Index: iseq.c =================================================================== --- iseq.c (revision 61600) +++ iseq.c (revision 61601) @@ -575,7 +575,7 @@ iseq_type_from_sym(VALUE type) https://github.com/ruby/ruby/blob/trunk/iseq.c#L575 const ID id_ensure = rb_intern("ensure"); const ID id_eval = rb_intern("eval"); const ID id_main = rb_intern("main"); - const ID id_defined_guard = rb_intern("defined_guard"); + const ID id_plain = rb_intern("plain"); /* ensure all symbols are static or pinned down before * conversion */ const ID typeid = rb_check_id(&type); @@ -587,7 +587,7 @@ iseq_type_from_sym(VALUE type) https://github.com/ruby/ruby/blob/trunk/iseq.c#L587 if (typeid == id_ensure) return ISEQ_TYPE_ENSURE; if (typeid == id_eval) return ISEQ_TYPE_EVAL; if (typeid == id_main) return ISEQ_TYPE_MAIN; - if (typeid == id_defined_guard) return ISEQ_TYPE_DEFINED_GUARD; + if (typeid == id_plain) return ISEQ_TYPE_PLAIN; return (enum iseq_type)-1; } @@ -1240,7 +1240,7 @@ static VALUE iseq_data_to_ary(const rb_i https://github.com/ruby/ruby/blob/trunk/iseq.c#L1240 * The type of the instruction sequence. * * Valid values are +:top+, +:method+, +:block+, +:class+, +:rescue+, - * +:ensure+, +:eval+, +:main+, and +:defined_guard+. + * +:ensure+, +:eval+, +:main+, and +plain+. * * [locals] * An array containing the names of all arguments and local variables as @@ -2145,7 +2145,7 @@ iseq_data_to_ary(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/iseq.c#L2145 DECL_SYMBOL(ensure); DECL_SYMBOL(eval); DECL_SYMBOL(main); - DECL_SYMBOL(defined_guard); + DECL_SYMBOL(plain); if (sym_top == 0) { int i; @@ -2160,7 +2160,7 @@ iseq_data_to_ary(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/iseq.c#L2160 INIT_SYMBOL(ensure); INIT_SYMBOL(eval); INIT_SYMBOL(main); - INIT_SYMBOL(defined_guard); + INIT_SYMBOL(plain); } /* type */ @@ -2173,7 +2173,7 @@ iseq_data_to_ary(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/iseq.c#L2173 case ISEQ_TYPE_ENSURE: type = sym_ensure; break; case ISEQ_TYPE_EVAL: type = sym_eval; break; case ISEQ_TYPE_MAIN: type = sym_main; break; - case ISEQ_TYPE_DEFINED_GUARD: type = sym_defined_guard; break; + case ISEQ_TYPE_PLAIN: type = sym_plain; break; default: rb_bug("unsupported iseq type"); }; Index: vm_core.h =================================================================== --- vm_core.h (revision 61600) +++ vm_core.h (revision 61601) @@ -299,7 +299,7 @@ struct rb_iseq_constant_body { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L299 ISEQ_TYPE_ENSURE, ISEQ_TYPE_EVAL, ISEQ_TYPE_MAIN, - ISEQ_TYPE_DEFINED_GUARD + ISEQ_TYPE_PLAIN } type; /* instruction sequence type */ unsigned int iseq_size; Index: compile.c =================================================================== --- compile.c (revision 61600) +++ compile.c (revision 61601) @@ -29,8 +29,6 @@ https://github.com/ruby/ruby/blob/trunk/compile.c#L29 #undef RUBY_UNTYPED_DATA_WARNING #define RUBY_UNTYPED_DATA_WARNING 0 -#define ISEQ_TYPE_ONCE_GUARD ISEQ_TYPE_DEFINED_GUARD - #define FIXNUM_INC(n, i) ((n)+(INT2FIX(i)&~FIXNUM_FLAG)) #define FIXNUM_OR(n, i) ((n)|INT2FIX(i)) @@ -706,9 +704,8 @@ rb_iseq_compile_node(rb_iseq_t *iseq, co https://github.com/ruby/ruby/blob/trunk/compile.c#L704 iseq_set_exception_local_table(iseq); CHECK(COMPILE_POPPED(ret, "ensure", node)); break; - case ISEQ_TYPE_DEFINED_GUARD: - iseq_set_exception_local_table(iseq); - CHECK(COMPILE(ret, "defined guard", node)); + case ISEQ_TYPE_PLAIN: + CHECK(COMPILE(ret, "ensure", node)); break; default: COMPILE_ERROR(ERROR_ARGS "unknown scope: %d", iseq->body->type); @@ -6626,10 +6623,8 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK https://github.com/ruby/ruby/blob/trunk/compile.c#L6623 } case NODE_ONCE:{ int ic_index = iseq->body->is_size++; - NODE tmp_node; const rb_iseq_t *block_iseq; - rb_node_init(&tmp_node, NODE_SCOPE, 0, (VALUE)node->nd_body, 0); - block_iseq = NEW_CHILD_ISEQ(&tmp_node, make_name_for_block(iseq), ISEQ_TYPE_ONCE_GUARD, line); + block_iseq = NEW_CHILD_ISEQ(node->nd_body, make_name_for_block(iseq), ISEQ_TYPE_PLAIN, line); ADD_INSN2(ret, line, once, block_iseq, INT2FIX(ic_index)); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/