From f4db8aedc87d0ff901206e4c59478554b7b952a6 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 20 Dec 2010 21:10:24 +0000 Subject: [PATCH] * compile.c (setup_args), vm.c (invoke_block_from_c), vm_insnhelper.c (caller_setup_args): reverted r30241 and r30243 except for the test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30283 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ compile.c | 23 ++++++++--------------- test/ruby/test_lambda.rb | 3 --- vm.c | 5 +---- vm_core.h | 1 - vm_insnhelper.c | 2 +- 6 files changed, 16 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 30b5cbbda4..315452e82c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue Dec 21 06:10:18 2010 Nobuyoshi Nakada + + * compile.c (setup_args), vm.c (invoke_block_from_c), + vm_insnhelper.c (caller_setup_args): reverted r30241 and r30243 + except for the test. + Tue Dec 21 01:41:42 2010 Masaya Tarui * io.c : add an extra byte to buffer for the specification of read diff --git a/compile.c b/compile.c index fb524011d5..99487d8e44 100644 --- a/compile.c +++ b/compile.c @@ -2886,7 +2886,7 @@ add_ensure_iseq(LINK_ANCHOR *ret, rb_iseq_t *iseq, int is_return) } static VALUE -setup_args(rb_iseq_t *iseq, LINK_ANCHOR *args, NODE *argn, VALUE *flag, VALUE *block) +setup_args(rb_iseq_t *iseq, LINK_ANCHOR *args, NODE *argn, VALUE *flag) { VALUE argc = INT2FIX(0); int nsplat = 0; @@ -2896,15 +2896,8 @@ setup_args(rb_iseq_t *iseq, LINK_ANCHOR *args, NODE *argn, VALUE *flag, VALUE *b INIT_ANCHOR(arg_block); INIT_ANCHOR(args_splat); if (argn && nd_type(argn) == NODE_BLOCK_PASS) { - if (block && nd_type(argn->nd_body) == NODE_LAMBDA) { - NODE *lambda = argn->nd_body; - *block = NEW_CHILD_ISEQVAL(lambda->nd_body, make_name_for_block(iseq), ISEQ_TYPE_BLOCK, nd_line(lambda)); - *flag |= VM_CALL_BLOCK_LAMBDA_BIT; - } - else { - COMPILE(arg_block, "block", argn->nd_body); - *flag |= VM_CALL_ARGS_BLOCKARG_BIT; - } + COMPILE(arg_block, "block", argn->nd_body); + *flag |= VM_CALL_ARGS_BLOCKARG_BIT; argn = argn->nd_head; } @@ -3816,7 +3809,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) boff = 1; default: INIT_ANCHOR(args); - argc = setup_args(iseq, args, node->nd_args->nd_head, &flag, NULL); + argc = setup_args(iseq, args, node->nd_args->nd_head, &flag); ADD_SEQ(ret, args); } ADD_INSN1(ret, nd_line(node), dupn, FIXNUM_INC(argc, 1 + boff)); @@ -4132,7 +4125,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) /* args */ if (nd_type(node) != NODE_VCALL) { - argc = setup_args(iseq, args, node->nd_args, &flag, &parent_block); + argc = setup_args(iseq, args, node->nd_args, &flag); } else { argc = INT2FIX(0); @@ -4170,7 +4163,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) INIT_ANCHOR(args); iseq->compile_data->current_block = Qfalse; if (nd_type(node) == NODE_SUPER) { - argc = setup_args(iseq, args, node->nd_args, &flag, &parent_block); + argc = setup_args(iseq, args, node->nd_args, &flag); } else { /* NODE_ZSUPER */ @@ -4343,7 +4336,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) } if (node->nd_head) { - argc = setup_args(iseq, args, node->nd_head, &flag, NULL); + argc = setup_args(iseq, args, node->nd_head, &flag); } else { argc = INT2FIX(0); @@ -4955,7 +4948,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) INIT_ANCHOR(recv); INIT_ANCHOR(args); - argc = setup_args(iseq, args, node->nd_args, &flag, NULL); + argc = setup_args(iseq, args, node->nd_args, &flag); if (node->nd_recv == (NODE *) 1) { flag |= VM_CALL_FCALL_BIT; diff --git a/test/ruby/test_lambda.rb b/test/ruby/test_lambda.rb index 6cbdd64385..02bb26939d 100644 --- a/test/ruby/test_lambda.rb +++ b/test/ruby/test_lambda.rb @@ -22,9 +22,6 @@ class TestLambdaParameters < Test::Unit::TestCase assert_raise(ArgumentError) { ->(a,b){ }.call(1,2,3) } end -end - -__END__ def test_lambda_as_iterator a = 0 2.times(&->(_){ a += 1 }) diff --git a/vm.c b/vm.c index 098842e2bf..015456bd93 100644 --- a/vm.c +++ b/vm.c @@ -531,10 +531,7 @@ invoke_block_from_c(rb_thread_t *th, const rb_block_t *block, const rb_control_frame_t *cfp; rb_control_frame_t *ncfp; int i, opt_pc, arg_size = iseq->arg_size; - int type = - block->proc == Qtrue ? VM_FRAME_MAGIC_LAMBDA : - block->proc == Qfalse ? VM_FRAME_MAGIC_BLOCK : - block_proc_is_lambda(block->proc) ? + int type = block_proc_is_lambda(block->proc) ? VM_FRAME_MAGIC_LAMBDA : VM_FRAME_MAGIC_BLOCK; rb_vm_set_finish_env(th); diff --git a/vm_core.h b/vm_core.h index bfd00089f2..c1886a56d4 100644 --- a/vm_core.h +++ b/vm_core.h @@ -550,7 +550,6 @@ typedef struct { #define VM_CALL_TAILRECURSION_BIT (0x01 << 6) #define VM_CALL_SUPER_BIT (0x01 << 7) #define VM_CALL_OPT_SEND_BIT (0x01 << 8) -#define VM_CALL_BLOCK_LAMBDA_BIT (0x01 << 9) enum vm_special_object_type { VM_SPECIAL_OBJECT_VMCORE = 1, diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 5405d2a857..46449df7b1 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -265,7 +265,7 @@ caller_setup_args(const rb_thread_t *th, rb_control_frame_t *cfp, VALUE flag, else if (blockiseq) { blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(cfp); blockptr->iseq = blockiseq; - blockptr->proc = (flag & VM_CALL_BLOCK_LAMBDA_BIT) ? Qtrue : Qfalse; + blockptr->proc = 0; *block = blockptr; } }