From 30b1947df2da2192f7fcc812ac88dc1884715322 Mon Sep 17 00:00:00 2001 From: ko1 Date: Tue, 20 Aug 2013 17:41:13 +0000 Subject: * 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 --- vm_insnhelper.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'vm_insnhelper.c') diff --git a/vm_insnhelper.c b/vm_insnhelper.c index c3a243f815..bb72b88b82 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -512,7 +512,7 @@ vm_getivar(VALUE obj, ID id, IC ic, rb_call_info_t *ci, int is_attr) if (LIKELY((!is_attr && (ic->ic_class == klass && ic->ic_vmstat == GET_VM_STATE_VERSION())) || (is_attr && ci->aux.index > 0))) { - long index = !is_attr ? ic->ic_value.index : ci->aux.index - 1; + long index = !is_attr ? (long)ic->ic_value.index : ci->aux.index - 1; long len = ROBJECT_NUMIV(obj); VALUE *ptr = ROBJECT_IVPTR(obj); @@ -568,7 +568,7 @@ vm_setivar(VALUE obj, ID id, VALUE val, IC ic, rb_call_info_t *ci, int is_attr) if (LIKELY( (!is_attr && ic->ic_class == klass && ic->ic_vmstat == GET_VM_STATE_VERSION()) || (is_attr && ci->aux.index > 0))) { - long index = !is_attr ? ic->ic_value.index : ci->aux.index-1; + long index = !is_attr ? (long)ic->ic_value.index : ci->aux.index-1; long len = ROBJECT_NUMIV(obj); VALUE *ptr = ROBJECT_IVPTR(obj); @@ -2351,3 +2351,36 @@ vm_invoke_block(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_info_t *ci return val; } } + +static VALUE +vm_make_proc_with_iseq(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); + + if (cfp == 0) { + rb_bug("m_core_set_postexe: unreachable"); + } + + blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(cfp); + blockptr->iseq = blockiseq; + blockptr->proc = 0; + + return rb_vm_make_proc(th, blockptr, rb_cProc); +} + +static VALUE +vm_once_exec(rb_iseq_t *iseq) +{ + VALUE proc = vm_make_proc_with_iseq(iseq); + return rb_proc_call_with_block(proc, 0, 0, Qnil); +} + +static VALUE +vm_once_clear(VALUE data) +{ + union iseq_inline_storage_entry *is = (union iseq_inline_storage_entry *)data; + is->once.running_thread = NULL; + return Qnil; +} -- cgit v1.2.3