From 807fbd69403bcae4bc38138a8f8a4bba5914dcda Mon Sep 17 00:00:00 2001 From: ko1 Date: Tue, 1 Jul 2008 12:19:00 +0000 Subject: * compile.c, vm.c, insns.def: call FrozenCore.set_postexe method instead to use "postexe" insn. * id.c, id.h: add a prepared id for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17779 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ compile.c | 10 +++++++--- id.c | 1 + id.h | 1 + insns.def | 23 ----------------------- vm.c | 23 +++++++++++++++++++++++ 6 files changed, 39 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index be28a5c784..fe5e34cd47 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Tue Jul 1 21:13:17 2008 Koichi Sasada + + * compile.c, vm.c, insns.def: call FrozenCore.set_postexe method + instead to use "postexe" insn. + + * id.c, id.h: add a prepared id for above. + Tue Jul 1 21:09:58 2008 URABE Shyouhei * lib/mkmf.rb (create_tmpsrc): we need to include COMMON_HEADERS, diff --git a/compile.c b/compile.c index ecae60d236..074c3a5fd4 100644 --- a/compile.c +++ b/compile.c @@ -4528,9 +4528,13 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) } case NODE_POSTEXE:{ VALUE block = NEW_CHILD_ISEQVAL(node->nd_body, make_name_for_block(iseq), ISEQ_TYPE_BLOCK); - ADD_INSN1(ret, nd_line(node), postexe, block); - if (!poped) { - ADD_INSN(ret, nd_line(node), putnil); + + ADD_INSN1(ret, nd_line(node), putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE)); + ADD_INSN1(ret, nd_line(node), putiseq, block); + ADD_SEND (ret, nd_line(node), ID2SYM(id_core_set_postexe), INT2FIX(1)); + + if (poped) { + ADD_INSN(ret, nd_line(node), pop); } break; } diff --git a/id.c b/id.c index 5e3072dcba..a02504d809 100644 --- a/id.c +++ b/id.c @@ -74,4 +74,5 @@ Init_id(void) id_core_undef_method = rb_intern("core_undef_method"); id_core_define_method = rb_intern("core_define_method"); id_core_define_singleton_method = rb_intern("core_define_singleton_method"); + id_core_set_postexe = rb_intern("core_set_postexe"); } diff --git a/id.h b/id.h index 75cc7b1a6c..977dcf57a3 100644 --- a/id.h +++ b/id.h @@ -58,5 +58,6 @@ extern ID id_core_set_variable_alias; extern ID id_core_undef_method; extern ID id_core_define_method; extern ID id_core_define_singleton_method; +extern ID id_core_set_postexe; #endif /* RUBY_ID_H */ diff --git a/insns.def b/insns.def index b5c5fa4314..161dc38e2e 100644 --- a/insns.def +++ b/insns.def @@ -840,29 +840,6 @@ defined } } -/** - @c setting - @e END{} - @j END{} に対応するためにブロックを登録する。 - */ -DEFINE_INSN -postexe -(ISEQ blockiseq) -() -() -{ - rb_block_t *blockptr; - VALUE proc; - extern void rb_call_end_proc(VALUE data); - - blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(GET_CFP()); - blockptr->iseq = blockiseq; - blockptr->proc = 0; - - proc = vm_make_proc(th, GET_CFP(), blockptr); - rb_set_end_proc(rb_call_end_proc, proc); -} - /** @c setting @e trace diff --git a/vm.c b/vm.c index cfa6d7556a..6039daef05 100644 --- a/vm.c +++ b/vm.c @@ -1669,6 +1669,28 @@ m_core_define_singleton_method(VALUE self, VALUE cbase, VALUE sym, VALUE iseqval return Qnil; } +static VALUE +m_core_set_postexe(VALUE self, VALUE iseqval) +{ + rb_iseq_t *blockiseq; + rb_block_t *blockptr; + rb_thread_t *th = GET_THREAD(); + rb_control_frame_t *cfp = vm_get_ruby_level_next_cfp(th, th->cfp); + VALUE proc; + extern void rb_call_end_proc(VALUE data); + + GetISeqPtr(iseqval, blockiseq); + + blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(cfp); + blockptr->iseq = blockiseq; + blockptr->proc = 0; + + proc = vm_make_proc(th, cfp, blockptr); + rb_set_end_proc(rb_call_end_proc, proc); + + return Qnil; +} + VALUE insns_name_array(void); extern VALUE *rb_gc_stack_start; extern size_t rb_gc_stack_maxsize; @@ -1725,6 +1747,7 @@ Init_VM(void) rb_define_singleton_method(rb_mRubyVMFrozenCore, "core_undef_method", m_core_undef_method, 2); rb_define_singleton_method(rb_mRubyVMFrozenCore, "core_define_method", m_core_define_method, 3); rb_define_singleton_method(rb_mRubyVMFrozenCore, "core_define_singleton_method", m_core_define_singleton_method, 3); + rb_define_singleton_method(rb_mRubyVMFrozenCore, "core_set_postexe", m_core_set_postexe, 1); rb_obj_freeze(rb_mRubyVMFrozenCore); /* ::VM::Env */ -- cgit v1.2.3