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

yarv-diff:182

From: ko1 atdot.net
Date: 29 Dec 2005 02:24:33 -0000
Subject: [yarv-diff:182] r340 - in trunk: . test/ruby

Author: ko1
Date: 2005-12-29 11:24:32 +0900 (Thu, 29 Dec 2005)
New Revision: 340

Modified:
   trunk/ChangeLog
   trunk/common.mk
   trunk/eval.c
   trunk/gc.c
   trunk/test.rb
   trunk/test/ruby/test_iterator.rb
   trunk/test/ruby/test_lambda.rb
   trunk/test/ruby/test_proc.rb
   trunk/vm.c
   trunk/vm_dump.c
   trunk/vm_macro.def
   trunk/yarvcore.c
Log:
	* common.mk : add dependency to test-all rule

	* eval.c (rb_sourceline), vm.c (th_get_sourceline) :
	fix to skip process if iseq is ifunc

	* test/ruby/test_lambda.rb : assert(fail, ...) instead of assert_fail

	* test/ruby/test_proc.rb : ditto

	* vm_dump.c : fix stack dump (iseq name)

	* vm_macro.def : store proc (block proc) to cfp#proc for GC mark

	* yarvcore.c : mark above on thread_mark

	* eval.c (exec_under) : replace block#self ([yarv-dev:751])



Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2005-12-28 16:59:04 UTC (rev 339)
+++ trunk/ChangeLog	2005-12-29 02:24:32 UTC (rev 340)
@@ -4,6 +4,26 @@
 #  from Mon, 03 May 2004 01:24:19 +0900
 #
 
+2005-12-29(Thu) 11:17:58 +0900  Koichi Sasada  <ko1 atdot.net>
+
+	* common.mk : add dependency to test-all rule
+
+	* eval.c (rb_sourceline), vm.c (th_get_sourceline) :
+	fix to skip process if iseq is ifunc
+
+	* test/ruby/test_lambda.rb : assert(fail, ...) instead of assert_fail
+
+	* test/ruby/test_proc.rb : ditto
+
+	* vm_dump.c : fix stack dump (iseq name)
+
+	* vm_macro.def : store proc (block proc) to cfp#proc for GC mark
+
+	* yarvcore.c : mark above on thread_mark
+
+	* eval.c (exec_under) : replace block#self ([yarv-dev:751])
+
+
 2005-12-29(Thu) 01:56:46 +0900  Koichi Sasada  <ko1 atdot.net>
 
 	* vm.c : fix setting of Proc cref ([yarv-dev:741])

Modified: trunk/common.mk
===================================================================
--- trunk/common.mk	2005-12-28 16:59:04 UTC (rev 339)
+++ trunk/common.mk	2005-12-29 02:24:32 UTC (rev 340)
@@ -172,7 +172,7 @@
 test: miniruby$(EXEEXT) $(RBCONFIG) $(PROGRAM) PHONY
 	@$(MINIRUBY) $(srcdir)/rubytest.rb
 
-test-all:
+test-all: miniruby$(EXEEXT) ruby
 	$(RUNRUBY) -C "$(srcdir)/test" runner.rb --runner=$(TESTUI) $(TESTS)
 
 extconf:

Modified: trunk/eval.c
===================================================================
--- trunk/eval.c	2005-12-28 16:59:04 UTC (rev 339)
+++ trunk/eval.c	2005-12-29 02:24:32 UTC (rev 340)
@@ -1701,7 +1701,9 @@
 {
   VALUE vid;
 
-  if (argc == 0) rb_raise(rb_eArgError, "no method name given");
+  if (argc == 0) {
+    rb_raise(rb_eArgError, "no method name given");
+  }
 
   vid = *argv++; argc--;
   PASS_PASSED_BLOCK();
@@ -1883,12 +1885,7 @@
 rb_sourceline(void){
   yarv_thread_t *th = GET_THREAD();
   yarv_iseq_t *iseq = th->cfp->iseq;
-  
-  if(iseq &&
-     !CMETHOD_INFO_P(iseq)){
-    return th_get_sourceline(th->cfp);
-  }
-  return 0;
+  return th_get_sourceline(th->cfp);
 }
 
 static VALUE
@@ -2014,17 +2011,25 @@
 {
   VALUE val = Qnil;		/* OK */
   yarv_thread_t *th = GET_THREAD();
-  yarv_control_frame_t *cfp = YARV_PREVIOUS_CONTROL_FRAME(th->cfp);
-  VALUE stored_self = cfp->self;
+  yarv_control_frame_t *pcfp = YARV_PREVIOUS_CONTROL_FRAME(th->cfp);
+  VALUE stored_self = pcfp->self;
+  yarv_block_t block;
+  yarv_block_t *blockptr;
   int state;
 
   /* replace environment */
-  cfp->self = self;
+  pcfp->self = self;
+  if((blockptr = GC_GUARDED_PTR_REF(*th->cfp->lfp)) != 0){
+    /* copy block info */
+    block = *blockptr;
+    block.self = self;
+    *th->cfp->lfp = GC_GUARDED_PTR(&block);
+  }
   if(cbase){
     rb_thread_push_cref(th, cbase, NOEX_PUBLIC);
-    if(!CMETHOD_INFO_P(cfp->iseq) &&
-       cfp->iseq->klass_nest_stack){
-      rb_ary_push(cfp->iseq->klass_nest_stack, cbase);
+    if(!CMETHOD_INFO_P(pcfp->iseq) &&
+       pcfp->iseq->klass_nest_stack){
+      rb_ary_push(pcfp->iseq->klass_nest_stack, cbase);
     }
   }
 
@@ -2035,19 +2040,18 @@
   POP_TAG();
 
   /* restore environment */
-  cfp->self = stored_self;
   if(cbase){
     rb_thread_pop_cref(th);
-    if(!CMETHOD_INFO_P(cfp->iseq) &&
-       cfp->iseq->klass_nest_stack){
-      rb_ary_pop(cfp->iseq->klass_nest_stack);
+    if(!CMETHOD_INFO_P(pcfp->iseq) &&
+       pcfp->iseq->klass_nest_stack){
+      rb_ary_pop(pcfp->iseq->klass_nest_stack);
     }
   }
+  pcfp->self = stored_self;
   
   if(state){
     JUMP_TAG(state);
   }
-
   return val;
 }
 

Modified: trunk/gc.c
===================================================================
--- trunk/gc.c	2005-12-28 16:59:04 UTC (rev 339)
+++ trunk/gc.c	2005-12-29 02:24:32 UTC (rev 340)
@@ -119,7 +119,7 @@
   if (size == 0) size = 1;
   malloc_increase += size;
 
-  if (malloc_increase > malloc_limit){// || gc_debug_flag) {
+  if (malloc_increase > malloc_limit || (0 && gc_debug_flag)) {
     garbage_collect();
   }
   RUBY_CRITICAL(mem = malloc(size));

Modified: trunk/test/ruby/test_iterator.rb
===================================================================
--- trunk/test/ruby/test_iterator.rb	2005-12-28 16:59:04 UTC (rev 339)
+++ trunk/test/ruby/test_iterator.rb	2005-12-29 02:24:32 UTC (rev 340)
@@ -1,4 +1,5 @@
 # TODO: tmp
+
 class Object
   Proc_orig = Proc
   remove_const :Proc

Modified: trunk/test/ruby/test_lambda.rb
===================================================================
--- trunk/test/ruby/test_lambda.rb	2005-12-28 16:59:04 UTC (rev 339)
+++ trunk/test/ruby/test_lambda.rb	2005-12-29 02:24:32 UTC (rev 340)
@@ -3,7 +3,7 @@
 class TestLambdaParameters < Test::Unit::TestCase
 
   def test_dummy
-    assert_fail "TODO: `->' syntax not supported"
+    assert(false, "Syntax '->(){}' is not supported on YARV")
   end
 =begin
   def test_call_simple

Modified: trunk/test/ruby/test_proc.rb
===================================================================
--- trunk/test/ruby/test_proc.rb	2005-12-28 16:59:04 UTC (rev 339)
+++ trunk/test/ruby/test_proc.rb	2005-12-29 02:24:32 UTC (rev 340)
@@ -88,16 +88,14 @@
   end
 
   def test_block_par
-    assert_fail "TODO: block parameter |&b| not supported"
-=begin
-    assert_equal(10, Proc.new{|&b| b.call(10)}.call {|x| x})
-    assert_equal(12, Proc.new{|a,&b| b.call(a)}.call(12) {|x| x})
-=end
+    assert false, "TODO: block parameter |&b| not supported"
+    # assert_equal(10, Proc.new{|&b| b.call(10)}.call {|x| x})
+    # assert_equal(12, Proc.new{|a,&b| b.call(a)}.call(12) {|x| x})
   end
 
   def test_safe
-    assert_fail "TODO: $SAFE setter not supported"
-=begin
+    assert false, "TODO: $SAFE setter not supported"
+if false
     safe = $SAFE
     c = Class.new
     x = c.new
@@ -126,6 +124,6 @@
     assert_equal(safe, $SAFE)
     assert_equal(safe + 1, proc {x.method(:inc).to_proc.call; $SAFE}.call)
     assert_equal(safe, $SAFE)
-=end
+end
   end
 end

Modified: trunk/test.rb
===================================================================
--- trunk/test.rb	2005-12-28 16:59:04 UTC (rev 339)
+++ trunk/test.rb	2005-12-29 02:24:32 UTC (rev 340)
@@ -1,37 +1,38 @@
-hash = Hash.new{|h, k| p [h, k]}
-p :fooooooooo
+Const = :top
+class C
+  Const = :C
+end
 
-__END__
+$nest = false
+def m
+  p Const
+  C.module_eval %{
+    p Const
+    Boo = false
+    unless $nest
+      $nest = true
+      m
+    end
+  }
+end
 
-path = Hash.new {|h, i| h[i] = dirs.push([i])[-1]}
+m
 
-a = 1
-p a
 __END__
-class BlockWrapper
-  def initialize(block)
-    @block = block
+
+$nested = false
+$pr = proc{
+  p self
+  unless $nested
+    $nested = true
+    $pr.call
   end
+}
 
-  def call
-    @block.call
+class C
+  def initialize &b
+    10.instance_eval(&b)
   end
 end
 
-def register(&block)
-  # @h[BlockWrapper.new(block)] = 1
-  @h[1] = BlockWrapper.new(block)
-end
-
-def m
-  puts 'THRU'
-end
-
-def call
-  @h[1].call
-end
-
-@h = {}
-register(&method(:m))
-GC.start
-call
+C.new(&$pr)

Modified: trunk/vm.c
===================================================================
--- trunk/vm.c	2005-12-28 16:59:04 UTC (rev 339)
+++ trunk/vm.c	2005-12-29 02:24:32 UTC (rev 340)
@@ -680,19 +680,20 @@
 int
 th_get_sourceline(yarv_control_frame_t *cfp)
 {
-  int i;
-  int pos = cfp->pc - cfp->iseq->iseq_encoded;
+  int line_no = 0;
   yarv_iseq_t *iseq = cfp->iseq;
-  int line_no;
+  if(iseq && !CMETHOD_INFO_P(iseq) && BUILTIN_TYPE(iseq) != T_NODE){
+    int i;
+    int pos = cfp->pc - cfp->iseq->iseq_encoded;
 
-  for(i=0; i<iseq->insn_info_size; i++){
-    if(iseq->insn_info_tbl[i].position == pos){
-      line_no = iseq->insn_info_tbl[i-1].line_no;
-      goto found;
+    for(i=0; i<iseq->insn_info_size; i++){
+      if(iseq->insn_info_tbl[i].position == pos){
+        line_no = iseq->insn_info_tbl[i-1].line_no;
+        goto found;
+      }
     }
+    line_no = iseq->insn_info_tbl[i-1].line_no;
   }
-  line_no = iseq->insn_info_tbl[i-1].line_no;
-
 found:
   return line_no;
 }

Modified: trunk/vm_dump.c
===================================================================
--- trunk/vm_dump.c	2005-12-28 16:59:04 UTC (rev 339)
+++ trunk/vm_dump.c	2005-12-29 02:24:32 UTC (rev 340)
@@ -47,10 +47,13 @@
   }
 
   if(cfp->iseq != 0){
-    struct yarv_cmethod_info *cmi = (void *)cfp->iseq;
     if(CMETHOD_INFO_P(cfp->iseq)){
+      struct yarv_cmethod_info *cmi = (void *)cfp->iseq;
       iseq_name = rb_id2name(cmi->id);
     }
+    else if(BUILTIN_TYPE(cfp->iseq) == T_NODE){
+      iseq_name = "<ifunc>";
+    }
     else{
       pc = cfp->pc - cfp->iseq->iseq_encoded;
       iseq_name = RSTRING(cfp->iseq->name)->ptr;

Modified: trunk/vm_macro.def
===================================================================
--- trunk/vm_macro.def	2005-12-28 16:59:04 UTC (rev 339)
+++ trunk/vm_macro.def	2005-12-29 02:24:32 UTC (rev 340)
@@ -20,6 +20,7 @@
       }
       GetProcVal(proc, po);
       blockptr = &po->block;
+      GET_BLOCK_PTR_IN_CFP(reg_cfp)->proc = proc;
     }
     INC_SP(-1);
   }

Modified: trunk/yarvcore.c
===================================================================
--- trunk/yarvcore.c	2005-12-28 16:59:04 UTC (rev 339)
+++ trunk/yarvcore.c	2005-12-29 02:24:32 UTC (rev 340)
@@ -635,15 +635,17 @@
   if(ptr){
     th = ptr;
     if(th->stack){
-      if(0){
-        rb_gc_mark_locations(th->stack, th->cfp->sp);
+      VALUE *p = th->stack;
+      VALUE *sp = th->cfp->sp;
+      yarv_control_frame_t *cfp = th->cfp;
+      yarv_control_frame_t *limit_cfp = (void *)(th->stack + th->stack_size);
+
+      while(p < sp){
+        rb_gc_mark(*p++);
       }
-      else{
-        VALUE *p = th->stack;
-        VALUE *sp = th->cfp->sp;
-        while(p < sp){
-          rb_gc_mark(*p++);
-        }
+      while(cfp != limit_cfp){
+        rb_gc_mark(cfp->proc);
+        cfp = YARV_PREVIOUS_CONTROL_FRAME(cfp);
       }
     }
 


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

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