diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-08-20 17:41:13 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-08-20 17:41:13 +0000 |
commit | 30b1947df2da2192f7fcc812ac88dc1884715322 (patch) | |
tree | f5f2969d24420e851e1b580f6a0696e0c944617c /vm.c | |
parent | a8fbb064a7beb29bf34e532ba49c1bdf59cf0f99 (diff) | |
download | ruby-30b1947df2da2192f7fcc812ac88dc1884715322.tar.gz |
* insns.def: fix regexp's once option behavior.
fix [ruby-trunk - Bug #6701]
* insns.def: remove `onceinlinecache' and introduce `once' instruction.
`once' doesn't use `setinlinecache' insn any more.
* vm_core.h: `union iseq_inline_storage_entry' to store once data.
* compile.c: catch up above changes.
* iseq.c: ditto.
* vm.c, vm_insnhelper.c: ditto. fix `m_core_set_postexe()' which
is depend on `onceinlinecache' insn.
* test/ruby/test_regexp.rb: add tests.
* iseq.c: ISEQ_MINOR_VERSION to 1 (should increment major?)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm.c')
-rw-r--r-- | vm.c | 31 |
1 files changed, 12 insertions, 19 deletions
@@ -2128,27 +2128,20 @@ m_core_undef_method(VALUE self, VALUE cbase, VALUE sym) } static VALUE -m_core_set_postexe(VALUE self, VALUE iseqval) +m_core_set_postexe(VALUE self, VALUE block_iseqval, VALUE is_index_val) { - REWIND_CFP({ - rb_iseq_t *blockiseq; - rb_block_t *blockptr; - rb_thread_t *th = GET_THREAD(); - rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->cfp); - VALUE proc; + int is_index = FIX2INT(is_index_val); + rb_thread_t *th = GET_THREAD(); + rb_iseq_t *iseq = rb_vm_get_ruby_level_next_cfp(th, th->cfp)->iseq; + union iseq_inline_storage_entry *is = &iseq->is_entries[is_index]; - if (cfp == 0) { - rb_bug("m_core_set_postexe: unreachable"); + REWIND_CFP({ + if (is->once.done != Qtrue) { + rb_iseq_t *block_iseq; + GetISeqPtr(block_iseqval, block_iseq); + rb_set_end_proc(rb_call_end_proc, vm_make_proc_with_iseq(block_iseq)); + is->once.done = Qtrue; } - - GetISeqPtr(iseqval, blockiseq); - - blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(cfp); - blockptr->iseq = blockiseq; - blockptr->proc = 0; - - proc = rb_vm_make_proc(th, blockptr, rb_cProc); - rb_set_end_proc(rb_call_end_proc, proc); }); return Qnil; } @@ -2291,7 +2284,7 @@ Init_VM(void) rb_define_method_id(klass, id_core_undef_method, m_core_undef_method, 2); rb_define_method_id(klass, id_core_define_method, m_core_define_method, 3); rb_define_method_id(klass, id_core_define_singleton_method, m_core_define_singleton_method, 3); - rb_define_method_id(klass, id_core_set_postexe, m_core_set_postexe, 1); + rb_define_method_id(klass, id_core_set_postexe, m_core_set_postexe, 2); rb_define_method_id(klass, id_core_hash_from_ary, m_core_hash_from_ary, 1); rb_define_method_id(klass, id_core_hash_merge_ary, m_core_hash_merge_ary, 2); rb_define_method_id(klass, id_core_hash_merge_ptr, m_core_hash_merge_ptr, -1); |