[前][次][番号順一覧][スレッド一覧][生データ]

yarv-diff:273

From: ko1 atdot.net
Date: 17 Feb 2006 17:51:07 -0000
Subject: [yarv-diff:273] r437 - in trunk: . benchmark yarvtest

Author: ko1
Date: 2006-02-18 02:51:07 +0900 (Sat, 18 Feb 2006)
New Revision: 437

Added:
   trunk/benchmark/bm_app_answer.rb
Modified:
   trunk/
   trunk/ChangeLog
   trunk/eval.c
   trunk/eval_jump.h
   trunk/eval_proc.c
   trunk/insns.def
   trunk/signal.c
   trunk/test.rb
   trunk/thread.c
   trunk/vm.c
   trunk/vm_macro.def
   trunk/vm_opts.h.base
   trunk/yarv.h
   trunk/yarvcore.c
   trunk/yarvtest/test_method.rb
Log:
 r663@lermite:  ko1 | 2006-02-18 00:04:23 +0900
 	* vm.c, yarv.h : change th_invoke_proc() interface
 
 	* eval_proc.c : ditto
 
 	* signal.c : ditto
 
 	* thread.c : ditto
 
 	* yarvcore.c : ditto
 
 	* vm_macro.def : ditto and fix NODE_BMETHOD call
 
 	* vm.c : change name ("th_set_env()" to "push_frame()") and
 	change interface
 
 	* insns.def : ditto
 
 	* eval.c : remove proc_jump_error()
 
 	* benchmark/bm_app_answer.rb : added
 
 	* vm_opts.h.base : add optimize option
 



Property changes on: trunk
___________________________________________________________________
Name: svk:merge
   - 81cd9672-7512-7e48-ae48-6936450e977d:/local/yarv/trunk:660
   + 81cd9672-7512-7e48-ae48-6936450e977d:/local/yarv/trunk:663

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-02-17 04:46:38 UTC (rev 436)
+++ trunk/ChangeLog	2006-02-17 17:51:07 UTC (rev 437)
@@ -4,6 +4,32 @@
 #  from Mon, 03 May 2004 01:24:19 +0900
 #
 
+2006-02-17(Fri) 23:59:51 +0900  Koichi Sasada  <ko1 atdot.net>
+
+	* vm.c, yarv.h : change th_invoke_proc() interface
+
+	* eval_proc.c : ditto
+
+	* signal.c : ditto
+
+	* thread.c : ditto
+
+	* yarvcore.c : ditto
+
+	* vm_macro.def : ditto and fix NODE_BMETHOD call
+
+	* vm.c : change name ("th_set_env()" to "push_frame()") and
+	change interface
+
+	* insns.def : ditto
+
+	* eval.c : remove proc_jump_error()
+
+	* benchmark/bm_app_answer.rb : added
+
+	* vm_opts.h.base : add optimize option
+
+
 2006-02-17(Fri) 13:37:57 +0900  Koichi Sasada  <ko1 atdot.net>
 
 	* eval.c, ruby.h : add rb_errinfo()

Added: trunk/benchmark/bm_app_answer.rb
===================================================================
--- trunk/benchmark/bm_app_answer.rb	2006-02-17 04:46:38 UTC (rev 436)
+++ trunk/benchmark/bm_app_answer.rb	2006-02-17 17:51:07 UTC (rev 437)
@@ -0,0 +1,15 @@
+def ack(m, n)
+  if m == 0 then
+    n + 1
+  elsif n == 0 then
+    ack(m - 1, 1)
+  else
+    ack(m - 1, ack(m, n - 1))
+  end
+end
+
+def the_answer_to_life_the_universe_and_everything
+  (ack(3,7).to_s.split(//).inject(0){|s,x| s+x.to_i}.to_s + "2" ).to_i
+end
+
+answer = the_answer_to_life_the_universe_and_everything

Modified: trunk/eval.c
===================================================================
--- trunk/eval.c	2006-02-17 04:46:38 UTC (rev 436)
+++ trunk/eval.c	2006-02-17 17:51:07 UTC (rev 437)
@@ -1147,33 +1147,6 @@
 
 VALUE rb_eThreadError;
 
-NORETURN(static void proc_jump_error(int, VALUE));
-static void
-proc_jump_error(state, result)
-    int state;
-    VALUE result;
-{
-    char mesg[32];
-    char *statement;
-
-    switch (state) {
-    case TAG_BREAK:
-	statement = "break";
-	break;
-    case TAG_RETURN:
-	statement = "return";
-	break;
-    case TAG_RETRY:
-	statement = "retry";
-	break;
-    default:
-	statement = "local-jump";
-	break;			/* should not happen */
-    }
-    snprintf(mesg, sizeof mesg, "%s from proc-closure", statement);
-    th_localjump_error(mesg, result, state);
-}
-
 void
 rb_need_block()
 {
@@ -1745,15 +1718,7 @@
 }
 
 VALUE
-#ifdef HAVE_STDARG_PROTOTYPES
 rb_funcall(VALUE recv, ID mid, int n, ...)
-#else
-rb_funcall(recv, mid, n, va_alist)
-    VALUE recv;
-    ID mid;
-    int n;
-    va_dcl
-#endif
 {
     VALUE *argv;
     va_list ar;
@@ -1772,7 +1737,6 @@
     else {
 	argv = 0;
     }
-
     return rb_call(CLASS_OF(recv), recv, mid, n, argv, NOEX_NOSUPER);
 }
 

Modified: trunk/eval_jump.h
===================================================================
--- trunk/eval_jump.h	2006-02-17 04:46:38 UTC (rev 436)
+++ trunk/eval_jump.h	2006-02-17 17:51:07 UTC (rev 437)
@@ -274,8 +274,7 @@
 static void call_end_proc _((VALUE data));
 
 static void
-call_end_proc(data)
-    VALUE data;
+call_end_proc(VALUE data)
 {
     // TODO: fix me
     proc_invoke(data, rb_ary_new2(0), Qundef, 0);

Modified: trunk/eval_proc.c
===================================================================
--- trunk/eval_proc.c	2006-02-17 04:46:38 UTC (rev 436)
+++ trunk/eval_proc.c	2006-02-17 17:51:07 UTC (rev 437)
@@ -200,8 +200,8 @@
     GetProcVal(self, proc);
 
     /* ignore self and klass */
-    return th_invoke_proc(GET_THREAD(), proc, RARRAY(args)->len,
-			  RARRAY(args)->ptr);
+    return th_invoke_proc(GET_THREAD(), proc, proc->block.self,
+			  RARRAY(args)->len, RARRAY(args)->ptr);
 }
 
 /* CHECKME: are the argument checking semantics correct? */

Modified: trunk/insns.def
===================================================================
--- trunk/insns.def	2006-02-17 04:46:38 UTC (rev 436)
+++ trunk/insns.def	2006-02-17 17:51:07 UTC (rev 437)
@@ -1053,10 +1053,10 @@
     COPY_CREF(klass_iseq->cref_stack, th_cref_push(th, klass, NOEX_PUBLIC));
 
     /* enter scope */
-    th_set_env(th, klass_iseq,
+    push_frame(th, klass_iseq,
 	       FRAME_MAGIC_CLASS, klass, (VALUE) GET_DFP() | 0x02,
 	       klass_iseq->iseq_encoded, GET_SP(), 0,
-	       klass_iseq->local_size, 0, 0);
+	       klass_iseq->local_size);
     RESTORE_REGS();
 
     INC_VM_STATE_VERSION();
@@ -1084,10 +1084,10 @@
     COPY_CREF(sklass_iseq->cref_stack, th_cref_push(th, klass, NOEX_PUBLIC));
 
     /* enter scope */
-    th_set_env(th, sklass_iseq,
+    push_frame(th, sklass_iseq,
 	       FRAME_MAGIC_CLASS, klass, (VALUE) GET_DFP() | 0x02,
 	       sklass_iseq->iseq_encoded, GET_SP(), 0,
-	       sklass_iseq->local_size, 0, 0);
+	       sklass_iseq->local_size);
     RESTORE_REGS();
     
     INC_VM_STATE_VERSION();
@@ -1131,10 +1131,10 @@
     COPY_CREF(module_iseq->cref_stack, th_cref_push(th, module, NOEX_PUBLIC));
 
     /* enter scope */
-    th_set_env(th, module_iseq,
+    push_frame(th, module_iseq,
 	       FRAME_MAGIC_CLASS, module, (VALUE) GET_DFP() | 0x02,
 	       module_iseq->iseq_encoded, GET_SP(), 0,
-	       module_iseq->local_size, 0, 0);
+	       module_iseq->local_size);
     RESTORE_REGS();
 
     INC_VM_STATE_VERSION();
@@ -1315,10 +1315,10 @@
 	argc = th_yield_setup_args(iseq, argc, GET_SP());
 	INC_SP(argc);
 
-	th_set_env(th, iseq,
+	push_frame(th, iseq,
 		   FRAME_MAGIC_BLOCK, block->self, (VALUE) block->dfp,
 		   iseq->iseq_encoded, GET_SP(), block->lfp,
-		   iseq->local_size - argc, 0, 0);
+		   iseq->local_size - argc);
 
 	reg_cfp->sp -= argc;
 	RESTORE_REGS();
@@ -1326,7 +1326,8 @@
 	/* unreachable */
     }
     else {
-	val = th_invoke_yield_cfunc(th, block, num, STACK_ADDR_FROM_TOP(num));
+	val = th_invoke_yield_cfunc(th, block, block->self,
+				    num, STACK_ADDR_FROM_TOP(num));
 	POPN(num);
     }
 }

Modified: trunk/signal.c
===================================================================
--- trunk/signal.c	2006-02-17 04:46:38 UTC (rev 436)
+++ trunk/signal.c	2006-02-17 17:51:07 UTC (rev 437)
@@ -526,7 +526,7 @@
     yarv_proc_t *proc;
     VALUE signum = INT2FIX(sig);
     GetProcVal(cmd, proc);
-    th_invoke_proc(th, proc, 1, &signum);
+    th_invoke_proc(th, proc, proc->block.self, 1, &signum);
   }
 }
 

Modified: trunk/test.rb
===================================================================
--- trunk/test.rb	2006-02-17 04:46:38 UTC (rev 436)
+++ trunk/test.rb	2006-02-17 17:51:07 UTC (rev 437)
@@ -1,4 +1,58 @@
 
+__END__
+
+Object.instance_eval do
+  define_method(:hoge) do
+    p self
+    p caller(0)
+    break :ok
+  end
+end
+
+p hoge()
+__END__
+
+class A
+  def hoge
+    :hoge
+  end
+
+  def foo
+    :foo
+  end
+end
+
+class B < A
+  def memoize(name)
+    B.instance_eval do
+      define_method(name) do
+        [name, super]
+      end
+    end
+  end
+end
+
+b = B.new
+b.memoize(:hoge)
+b.memoize(:foo)
+p [b.foo, b.hoge]
+
+__END__
+
+class C
+  def m
+    self.priv_m
+  end
+  private
+  def priv_m
+  end
+end
+
+C.new.m
+__END__
+
+
+
 Const = :hoge
 
 require 'irb'

Modified: trunk/thread.c
===================================================================
--- trunk/thread.c	2006-02-17 04:46:38 UTC (rev 436)
+++ trunk/thread.c	2006-02-17 17:51:07 UTC (rev 437)
@@ -162,9 +162,8 @@
 	    th->errinfo = Qnil;
 	    th->local_lfp = proc->block.lfp;
 	    th->local_svar = Qnil;
-	    th->value =
-		th_invoke_proc(th, proc, RARRAY(args)->len,
-			       RARRAY(args)->ptr);
+	    th->value = th_invoke_proc(th, proc, proc->block.self,
+				       RARRAY(args)->len, RARRAY(args)->ptr);
 	}
 	else {
 	    th->value = Qnil;

Modified: trunk/vm.c
===================================================================
--- trunk/vm.c	2006-02-17 04:46:38 UTC (rev 436)
+++ trunk/vm.c	2006-02-17 17:51:07 UTC (rev 437)
@@ -26,8 +26,10 @@
 void vm_analysis_insn(int insn);
 
 static inline VALUE
- th_invoke_yield_cfunc(yarv_thread_t *th,
-		       yarv_block_t *block, int argc, VALUE *argv);
+ th_invoke_yield_cfunc(yarv_thread_t *th, yarv_block_t *block,
+		       VALUE self, int argc, VALUE *argv);
+VALUE th_invoke_proc(yarv_thread_t *th, yarv_proc_t *proc,
+		     VALUE self, int argc, VALUE *argv);
 
 VALUE th_eval_body(yarv_thread_t *th);
 static NODE *lfp_get_special_cref(VALUE *lfp);
@@ -73,24 +75,16 @@
  * prepare stack frame
  */
 static inline VALUE
-th_set_env(yarv_thread_t *th, yarv_iseq_t *iseq,
-	   VALUE magic, VALUE self, VALUE specval,
-	   VALUE *pc, VALUE *sp, VALUE *lfp,
-	   int local_size, int argc, const VALUE *argv)
+push_frame(yarv_thread_t *th, yarv_iseq_t *iseq, VALUE magic,
+	   VALUE self, VALUE specval, VALUE *pc,
+	   VALUE *sp, VALUE *lfp, int local_size)
 {
     VALUE *dfp;
     yarv_control_frame_t *cfp;
     int i;
 
-    /* copy args */
-    for (i = 0; i < argc; i++) {
-	*sp = *argv;
-	sp++;
-	argv++;
-    }
-
     /* nil initialize */
-    for (; i < local_size; i++) {
+    for (i=0; i < local_size; i++) {
 	*sp = Qnil;
 	sp++;
     }
@@ -121,8 +115,8 @@
 VALUE
 th_set_finish_env(yarv_thread_t *th)
 {
-    th_set_env(th, 0,
-	       FRAME_MAGIC_FINISH, Qnil, 0, 0, th->cfp->sp, 0, 0, 0, 0);
+    push_frame(th, 0, FRAME_MAGIC_FINISH,
+	       Qnil, 0, 0, th->cfp->sp, 0, 0);
     th->cfp->pc = &yarv_finish_insn_seq[0];
     return Qtrue;
 }
@@ -136,10 +130,9 @@
     /* for return */
     th_set_finish_env(th);
 
-    return th_set_env(th, iseq,
-		      FRAME_MAGIC_TOP, ruby_top_self, 0,
-		      iseq->iseq_encoded, th->cfp->sp, 0,
-		      iseq->local_size, 0, 0);
+    return push_frame(th, iseq, FRAME_MAGIC_TOP,
+		      ruby_top_self, 0, iseq->iseq_encoded, th->cfp->sp, 0,
+		      iseq->local_size);
 }
 
 VALUE
@@ -151,10 +144,9 @@
 
     /* for return */
     th_set_finish_env(th);
-    th_set_env(th, iseq,
-	       FRAME_MAGIC_EVAL, block->self, GC_GUARDED_PTR(block->dfp),
-	       iseq->iseq_encoded, th->cfp->sp, block->lfp,
-	       iseq->local_size, 0, 0);
+    push_frame(th, iseq, FRAME_MAGIC_EVAL, block->self,
+	       GC_GUARDED_PTR(block->dfp), iseq->iseq_encoded,
+	       th->cfp->sp, block->lfp, iseq->local_size);
     return 0;
 }
 
@@ -419,9 +411,8 @@
 	  yarv_control_frame_t *reg_cfp = th->cfp;
 	  struct yarv_cmethod_info cmi = { 0, id, klass };
 
-	  th_set_env(th, (yarv_iseq_t *)&cmi,
-		     FRAME_MAGIC_CFUNC, recv, (VALUE)blockptr,
-		     0, reg_cfp->sp, 0, 0, 0, 0);
+	  push_frame(th, (yarv_iseq_t *)&cmi, FRAME_MAGIC_CFUNC,
+		     recv, (VALUE)blockptr, 0, reg_cfp->sp, 0, 0);
 
 	  val = call_cfunc(body->nd_cfnc, recv, body->nd_argc, argc, argv);
 
@@ -455,9 +446,8 @@
 	  for (i = 0; i < argc; i++) {
 	      *reg_cfp->sp++ = argv[i];
 	  }
-	  macro_eval_invoke_bmethod(body->nd_cval, recv, klass, blockptr,
-				    argc);
-	  val = th_eval_body(th);
+	  macro_eval_invoke_bmethod(body->nd_cval, recv, klass,
+				    blockptr, argc);
 	  break;
       }
       default:
@@ -515,8 +505,8 @@
 }
 
 static inline VALUE
-th_invoke_yield_cfunc(yarv_thread_t *th,
-		      yarv_block_t *block, int argc, VALUE *argv)
+th_invoke_yield_cfunc(yarv_thread_t *th, yarv_block_t *block,
+		      VALUE self, int argc, VALUE *argv)
 {
     NODE *ifunc = (NODE *) block->iseq;
     VALUE val;
@@ -532,9 +522,10 @@
 	arg = rb_ary_new();
     }
 
-    th_set_env(th, 0,
-	       FRAME_MAGIC_IFUNC, block->self, (VALUE)block->dfp,
-	       0, th->cfp->sp, block->lfp, 0, 0, 0);
+    push_frame(th, 0, FRAME_MAGIC_IFUNC,
+	       self, (VALUE)block->dfp,
+	       0, th->cfp->sp, block->lfp, 0);
+    
     val = (*ifunc->nd_cfnc) (arg, ifunc->nd_tval, Qnil);
 
     th->cfp++;
@@ -634,48 +625,22 @@
 	    argc = th_yield_setup_args(iseq, argc, th->cfp->sp);
 	    th->cfp->sp += argc;
 
-	    th_set_env(th, iseq, FRAME_MAGIC_BLOCK,
+	    push_frame(th, iseq, FRAME_MAGIC_BLOCK,
 		       block->self, GC_GUARDED_PTR(block->dfp),
 		       iseq->iseq_encoded, th->cfp->sp, block->lfp,
-		       iseq->local_size - argc, 0, 0);
+		       iseq->local_size - argc);
 	    val = th_eval_body(th);
 	}
 	else {
-	    val = th_invoke_yield_cfunc(th, block, argc, argv);
+	    val = th_invoke_yield_cfunc(th, block, block->self, argc, argv);
 	}
     }
     return val;
 }
 
-static VALUE
-th_invoke_proc_under(yarv_thread_t *th, yarv_proc_t *proc,
-		     int argc, VALUE *argv, VALUE self)
-{
-    if (BUILTIN_TYPE(proc->block.iseq) == T_NODE) {
-	return th_invoke_yield_cfunc(th, &proc->block, argc, argv);
-    }
-    else {
-	yarv_iseq_t *iseq = proc->block.iseq;
-	int i;
-	th_set_finish_env(th);
-
-	/* TODO: check overflow */
-	for (i=0; i<argc; i++) {
-	    th->cfp->sp[i] = argv[i];
-	}
-	argc = th_yield_setup_args(iseq, argc, th->cfp->sp);
-	th->cfp->sp += argc;
-
-	th_set_env(th, iseq,
-		   FRAME_MAGIC_PROC, self, (VALUE)proc->block.dfp,
-		   iseq->iseq_encoded, th->cfp->sp, proc->block.lfp,
-		   iseq->local_size - argc, 0, 0);
-	return th_eval_body(th);
-    }
-}
-
 VALUE
-th_invoke_proc(yarv_thread_t *th, yarv_proc_t *proc, int argc, VALUE *argv)
+th_invoke_proc(yarv_thread_t *th, yarv_proc_t *proc,
+	       VALUE self, int argc, VALUE *argv)
 {
     VALUE val = Qundef;
     int state;
@@ -684,7 +649,6 @@
 
     TH_PUSH_TAG(th);
     if ((state = EXEC_TAG()) == 0) {
-
 	if (proc->special_cref_stack) {
 	    stored_special_cref_stack =
 	      lfp_set_special_cref(proc->block.lfp, proc->special_cref_stack);
@@ -692,10 +656,26 @@
 	th->safe_level = proc->safe_level;
 
 	if (BUILTIN_TYPE(proc->block.iseq) == T_NODE) {
-	    val = th_invoke_yield_cfunc(th, &proc->block, argc, argv);
+	    val = th_invoke_yield_cfunc(th, &proc->block,
+					proc->block.self, argc, argv);
 	}
 	else {
-	    val = th_invoke_proc_under(th, proc, argc, argv, proc->block.self);
+	    yarv_iseq_t *iseq = proc->block.iseq;
+	    int i;
+	    th_set_finish_env(th);
+
+	    /* TODO: check overflow */
+	    for (i=0; i<argc; i++) {
+		th->cfp->sp[i] = argv[i];
+	    }
+	    argc = th_yield_setup_args(iseq, argc, th->cfp->sp);
+	    th->cfp->sp += argc;
+
+	    push_frame(th, iseq, FRAME_MAGIC_PROC,
+		       self, (VALUE)proc->block.dfp, iseq->iseq_encoded,
+		       th->cfp->sp, proc->block.lfp,
+		       iseq->local_size - argc);
+	    val = th_eval_body(th);
 	}
     }
     else {
@@ -1625,11 +1605,11 @@
 	    cfp->pc = cfp->iseq->iseq_encoded + cont_pc;
 
 	    /* push block frame */
-	    th_set_env(th, catch_iseq,
-		       FRAME_MAGIC_BLOCK, cfp->self, GC_GUARDED_PTR(cfp->dfp),
-		       catch_iseq->iseq_encoded, cfp->sp, cfp->lfp,
-		       catch_iseq->local_size - 1, 1, &err);
-
+	    cfp->sp[0] = err;
+	    push_frame(th, catch_iseq, FRAME_MAGIC_BLOCK,
+		       cfp->self, (VALUE)cfp->dfp, catch_iseq->iseq_encoded,
+		       cfp->sp + 1, cfp->lfp, catch_iseq->local_size - 1);
+	    
 	    state = 0;
 	    th->errinfo = Qnil;
 	    goto vm_loop_start;

Modified: trunk/vm_macro.def
===================================================================
--- trunk/vm_macro.def	2006-02-17 04:46:38 UTC (rev 436)
+++ trunk/vm_macro.def	2006-02-17 17:51:07 UTC (rev 437)
@@ -54,9 +54,8 @@
 {
     struct yarv_cmethod_info cmi = { 0, id, klass };
 
-    th_set_env(th, (yarv_iseq_t *) & cmi,
-	       FRAME_MAGIC_CFUNC, recv, (VALUE) blockptr,
-	       0, GET_SP(), 0, 0, 0, 0);
+    push_frame(th, (yarv_iseq_t *) & cmi, FRAME_MAGIC_CFUNC,
+	       recv, (VALUE) blockptr, 0, GET_SP(), 0, 0);
 
     reg_cfp->sp -= num + 1;
 
@@ -191,9 +190,9 @@
     {
 	if (0 && (flag & VM_CALL_TAILCALL_BIT)) {
 	    th->cfp++;
-	    th_set_env(th, niseq,
-		       FRAME_MAGIC_METHOD, recv, (VALUE) blockptr,
-		       niseq->iseq_encoded + opt_pc, sp, 0, 0, 0, 0);
+	    push_frame(th, niseq, FRAME_MAGIC_METHOD,
+		       recv, (VALUE) blockptr,
+		       niseq->iseq_encoded + opt_pc, sp, 0, 0);
 	}
 	else if (0 &&
 		 (flag & VM_CALL_TAILRECURSION_BIT) && niseq == GET_ISEQ()) {
@@ -207,9 +206,9 @@
 	    SET_PC(niseq->iseq_encoded + opt_pc);
 	}
 	else {
-	    th_set_env(th, niseq,
+	    push_frame(th, niseq,
 		       FRAME_MAGIC_METHOD, recv, (VALUE) blockptr,
-		       niseq->iseq_encoded + opt_pc, sp, 0, 0, 0, 0);
+		       niseq->iseq_encoded + opt_pc, sp, 0, 0);
 	    reg_cfp->sp = rsp;
 	}
 	RESTORE_REGS();
@@ -218,27 +217,38 @@
 
 MACRO macro_eval_invoke_bmethod(procval, recv, klass, blockptr, num)
 {
-    VALUE *sp = GET_SP();
-    VALUE *rsp = sp - num - 1;
+    if (0) {
+	VALUE *sp = GET_SP();
+	VALUE *rsp = sp - num - 1;
+	yarv_proc_t *proc;
+	GetProcVal(procval, proc);
 
-    yarv_proc_t *proc;
-    GetProcVal(procval, proc);
-
-    if (BUILTIN_TYPE(proc->block.iseq) == T_NODE) {
-	val =
-	    th_invoke_yield_cfunc(th, &proc->block, num,
-				  STACK_ADDR_FROM_TOP(num));
+	if (BUILTIN_TYPE(proc->block.iseq) == T_NODE) {
+	    val =
+	      th_invoke_yield_cfunc(th, &proc->block, proc->block.self,
+				    num, STACK_ADDR_FROM_TOP(num));
+	}
+	else {
+	    if (proc->block.iseq->argc != num) {
+		rb_raise(rb_eArgError, "wrong number of arguments (%lu for %d)",
+			 (unsigned long)num, proc->block.iseq->argc);
+	    }
+	    push_frame(th, proc->block.iseq, FRAME_MAGIC_PROC,
+		       recv, (VALUE) proc->block.dfp,
+		       proc->block.iseq->iseq_encoded, th->cfp->sp,
+		       proc->block.lfp, proc->block.iseq->local_size - num);
+	    reg_cfp->sp = rsp;
+	    RESTORE_REGS();
+	}
     }
     else {
-	if (proc->block.iseq->argc != num) {
-	    rb_raise(rb_eArgError, "wrong number of arguments (%lu for %d)",
-		     (unsigned long)num, proc->block.iseq->argc);
-	}
-	th_set_env(th, proc->block.iseq,
-		   FRAME_MAGIC_PROC, recv, (VALUE) proc->block.dfp,
-		   proc->block.iseq->iseq_encoded, th->cfp->sp,
-		   proc->block.lfp, proc->block.iseq->local_size - num, 0, 0);
-	reg_cfp->sp = rsp;
+	VALUE *argv = GET_SP() - num;
+	yarv_proc_t *proc;
+	
+	GetProcVal(procval, proc);
+	val = th_invoke_proc(th, proc, recv, num, argv);
+	reg_cfp->sp = argv;
+	reg_cfp->sp[-1] = val;
 	RESTORE_REGS();
     }
 }

Modified: trunk/vm_opts.h.base
===================================================================
--- trunk/vm_opts.h.base	2006-02-17 04:46:38 UTC (rev 436)
+++ trunk/vm_opts.h.base	2006-02-17 17:51:07 UTC (rev 437)
@@ -29,5 +29,8 @@
 
 #endif /* IGNORE_OPTIMIZE */
 
+/* misc */
+#define SUPPORT_JOKE                 0
+
 #endif /* VM_OPTS_H_INCLUDED */
 

Modified: trunk/yarv.h
===================================================================
--- trunk/yarv.h	2006-02-17 04:46:38 UTC (rev 436)
+++ trunk/yarv.h	2006-02-17 17:51:07 UTC (rev 437)
@@ -86,8 +86,8 @@
 
 VALUE yarvcore_eval_parsed(VALUE node, VALUE file);
 
-VALUE th_invoke_proc(yarv_thread_t *th, yarv_proc_t *proc, int argc,
-		     VALUE *argv);
+VALUE th_invoke_proc(yarv_thread_t *th, yarv_proc_t *proc,
+		     VALUE self, int argc, VALUE *argv);
 VALUE th_make_proc(yarv_thread_t *th, yarv_control_frame_t *cfp,
 		   yarv_block_t *block);
 VALUE th_make_env_object(yarv_thread_t *th, yarv_control_frame_t *cfp);

Modified: trunk/yarvcore.c
===================================================================
--- trunk/yarvcore.c	2006-02-17 04:46:38 UTC (rev 436)
+++ trunk/yarvcore.c	2006-02-17 17:51:07 UTC (rev 437)
@@ -858,15 +858,12 @@
     return obj;
 }
 
-VALUE th_invoke_proc(yarv_thread_t *th, yarv_proc_t *proc, int argc,
-		     VALUE *argv);
-
 static VALUE
 proc_call(int argc, VALUE *argv, VALUE procval)
 {
     yarv_proc_t *proc;
     GetProcVal(procval, proc);
-    return th_invoke_proc(GET_THREAD(), proc, argc, argv);
+    return th_invoke_proc(GET_THREAD(), proc, proc->block.self, argc, argv);
 }
 
 static VALUE

Modified: trunk/yarvtest/test_method.rb
===================================================================
--- trunk/yarvtest/test_method.rb	2006-02-17 04:46:38 UTC (rev 436)
+++ trunk/yarvtest/test_method.rb	2006-02-17 17:51:07 UTC (rev 437)
@@ -513,5 +513,16 @@
       $ans
     }
   end
+
+  def test_break_from_defined_method
+    ae %q{
+      class C
+        define_method(:foo){
+          break :ok
+        }
+      end
+      C.new.foo
+    }
+  end
 end
 


-- 
ML: yarv-diff quickml.atdot.net
Info: http://www.atdot.net/~ko1/quickml

[前][次][番号順一覧][スレッド一覧][生データ]