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

yarv-diff:315

From: ko1 atdot.net
Date: 27 Feb 2006 13:10:21 -0000
Subject: [yarv-diff:315] r480 - trunk

Author: ko1
Date: 2006-02-27 22:10:21 +0900 (Mon, 27 Feb 2006)
New Revision: 480

Removed:
   trunk/rdoc/
Modified:
   trunk/
   trunk/ChangeLog
   trunk/common.mk
   trunk/compile.c
   trunk/debug.c
   trunk/disasm.c
   trunk/eval_proc.c
   trunk/gc.c
   trunk/insns.def
   trunk/node.h
   trunk/ruby.h
   trunk/vm.c
   trunk/vm_dump.c
   trunk/vm_macro.def
   trunk/yarvcore.c
   trunk/yarvcore.h
Log:
 r740@lermite:  ko1 | 2006-02-27 22:07:57 +0900
 	* common.mk : fix to display command line
 
 	* compile.c : fix comparison between a pointer and 0
 
 	* debug.c : fix to output stder
 
 	* disasm.c : add debug function
 
 	* vm_dump.c : ditto
 
 	* eval_proc.c : fix to skip class definition
 
 	* ruby.h : fix T_VALUE to T_VALUES
 
 	* gc.c : ditto
 
 	* node.h : fix prototypes
 
 	* vm.c : add VM_DEBUG macro
 
 	* vm.c : fix compile error on VC++
 
 	* vm.c : fix to inherit last lfp[0] on th_set_finish_env
 
 	* vm.c : fix to add one svar location for any frame
 
 	* vm_macro.def : ditto
 
 	* yarvcore.h : add YARV_CLASS_SPECIAL_P() and YARV_BLOCK_PTR_P()
 
 	* rdoc/ : removed
 
 	* insns.def : fix to propagete throw state
 



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

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-02-27 04:55:05 UTC (rev 479)
+++ trunk/ChangeLog	2006-02-27 13:10:21 UTC (rev 480)
@@ -4,6 +4,43 @@
 #  from Mon, 03 May 2004 01:24:19 +0900
 #
 
+2006-02-27(Mon) 21:33:49 +0900  Koichi Sasada  <ko1 atdot.net>
+
+	* common.mk : fix to display command line
+
+	* compile.c : fix comparison between a pointer and 0
+
+	* debug.c : fix to output stder
+
+	* disasm.c : add debug function
+
+	* vm_dump.c : ditto
+
+	* eval_proc.c : fix to skip class definition
+
+	* ruby.h : fix T_VALUE to T_VALUES
+
+	* gc.c : ditto
+
+	* node.h : fix prototypes
+
+	* vm.c : add VM_DEBUG macro
+
+	* vm.c : fix compile error on VC++
+
+	* vm.c : fix to inherit last lfp[0] on th_set_finish_env
+
+	* vm.c : fix to add one svar location for any frame
+
+	* vm_macro.def : ditto
+
+	* yarvcore.h : add YARV_CLASS_SPECIAL_P() and YARV_BLOCK_PTR_P()
+
+	* rdoc/ : removed
+
+	* insns.def : fix to propagete throw state
+
+
 2006-02-27(Mon) 13:54:47 +0900  Minero Aoki  <aamine loveruby.net>
 
 	* ext/syslog: imported from Ruby CVS trunk HEAD.

Modified: trunk/common.mk
===================================================================
--- trunk/common.mk	2006-02-27 04:55:05 UTC (rev 479)
+++ trunk/common.mk	2006-02-27 13:10:21 UTC (rev 480)
@@ -77,7 +77,7 @@
 EXTMK_ARGS    =	$(SCRIPT_ARGS) --extout="$(EXTOUT)" --extension $(EXTS) --extstatic $(EXTSTATIC) --
 
 all: $(MKFILES) $(PREP) $(RBCONFIG) $(LIBRUBY)
-	@$(MINIRUBY) $(srcdir)/ext/extmk.rb $(EXTMK_ARGS)
+	$(MINIRUBY) $(srcdir)/ext/extmk.rb $(EXTMK_ARGS)
 
 prog: $(PROGRAM) $(WPROGRAM)
 
@@ -175,7 +175,7 @@
 	$(RUNRUBY) -C "$(EXTCONFDIR)" $(EXTCONF) $(EXTCONFARGS)
 
 $(RBCONFIG): $(srcdir)/mkconfig.rb config.status $(PREP)
-	@$(MINIRUBY) $(srcdir)/mkconfig.rb -timestamp=$@ \
+	$(MINIRUBY) $(srcdir)/mkconfig.rb -timestamp=$@ \
 		-install_name=$(RUBY_INSTALL_NAME) \
 		-so_name=$(RUBY_SO_NAME) rbconfig.rb
 

Modified: trunk/compile.c
===================================================================
--- trunk/compile.c	2006-02-27 04:55:05 UTC (rev 479)
+++ trunk/compile.c	2006-02-27 13:10:21 UTC (rev 480)
@@ -819,7 +819,7 @@
 		search_block_local_variables(narg->nd_head, local_vars);
 		narg = narg->nd_next;
 	    }
-	    if (node->nd_args && (long)node->nd_args != -1) {
+	    if (node->nd_args != 0 && (long)node->nd_args != -1) {
 		search_block_local_variables(node->nd_args, local_vars);
 		break;
 	    }
@@ -1007,7 +1007,7 @@
 	    }
 
 	    /* check rest */
-	    if ((long)massign->nd_args > 0) {
+	    if (massign->nd_args != 0 && (long)massign->nd_args != -1) {
 		iseq->argc++;
 		iseq->arg_rest = i + 1;
 

Modified: trunk/debug.c
===================================================================
--- trunk/debug.c	2006-02-27 04:55:05 UTC (rev 479)
+++ trunk/debug.c	2006-02-27 13:10:21 UTC (rev 480)
@@ -11,9 +11,9 @@
     if (level < debug_level) {
 	int i;
 	for (i = 0; i < indent_level; i++) {
-	    printf(" ");
+	    fprintf(stderr, " ");
 	}
-	fflush(stdout);
+	fflush(stderr);
     }
 }
 
@@ -23,9 +23,9 @@
     if (level < debug_level) {
 	VALUE str;
 	str = rb_inspect(obj);
-	printf("DBG> %s: %s\n", header,
+	fprintf(stderr, "DBG> %s: %s\n", header,
 	       obj == -1 ? "" : StringValueCStr(str));
-	fflush(stdout);
+	fflush(stderr);
     }
     return obj;
 }
@@ -40,8 +40,8 @@
 debug_id(int level, int debug_level, char *header, ID id)
 {
     if (level < debug_level) {
-	printf("DBG> %s: %s\n", header, rb_id2name(id));
-	fflush(stdout);
+	fprintf(stderr, "DBG> %s: %s\n", header, rb_id2name(id));
+	fflush(stderr);
     }
     return id;
 }

Modified: trunk/disasm.c
===================================================================
--- trunk/disasm.c	2006-02-27 04:55:05 UTC (rev 479)
+++ trunk/disasm.c	2006-02-27 13:10:21 UTC (rev 480)
@@ -557,3 +557,12 @@
 	return 0;
     }
 }
+
+int
+debug_node(NODE *node)
+{
+    printf("node type: %d\n", nd_type(node));
+    printf("node name: %s\n", node_name(nd_type(node)));
+    printf("node filename: %s\n", node->nd_file);
+    return 0;
+}
\ No newline at end of file

Modified: trunk/eval_proc.c
===================================================================
--- trunk/eval_proc.c	2006-02-27 04:55:05 UTC (rev 479)
+++ trunk/eval_proc.c	2006-02-27 13:10:21 UTC (rev 480)
@@ -91,16 +91,19 @@
 {
     VALUE procval = Qnil;
     yarv_thread_t *th = GET_THREAD();
-    yarv_control_frame_t *cfp;
+    yarv_control_frame_t *cfp = th->cfp;
     yarv_block_t *block;
 
-    if ((block = GC_GUARDED_PTR_REF(th->cfp->lfp[0])) != 0) {
-	cfp = th->cfp;
+    if ((GC_GUARDED_PTR_REF(cfp->lfp[0])) != 0 &&
+	!YARV_CLASS_SPECIAL_P(cfp->lfp[0])) {
 	block = GC_GUARDED_PTR_REF(cfp->lfp[0]);
     }
     else {
-	cfp = YARV_PREVIOUS_CONTROL_FRAME(th->cfp);
-	if ((block = GC_GUARDED_PTR_REF(cfp->lfp[0])) != 0) {
+	cfp = YARV_PREVIOUS_CONTROL_FRAME(cfp);
+	if ((GC_GUARDED_PTR_REF(cfp->lfp[0])) != 0 &&
+	    !YARV_CLASS_SPECIAL_P(cfp->lfp[0])) {
+	    block = GC_GUARDED_PTR_REF(cfp->lfp[0]);
+
 	    if (is_lambda) {
 		rb_warn("tried to create Proc object without a block");
 	    }

Modified: trunk/gc.c
===================================================================
--- trunk/gc.c	2006-02-27 04:55:05 UTC (rev 479)
+++ trunk/gc.c	2006-02-27 13:10:21 UTC (rev 480)
@@ -975,7 +975,7 @@
 	}
 	break;
 
-      case T_VALUE:
+      case T_VALUES:
 	{
             rb_gc_mark(RVALUES(obj)->v1);
             rb_gc_mark(RVALUES(obj)->v2);
@@ -1197,8 +1197,9 @@
 
       case T_FLOAT:
       case T_BLOCK:
-      case T_VALUE:
 	break;
+      case T_VALUES:
+	break;
 
       case T_BIGNUM:
 	if (RANY(obj)->as.bignum.digits) {

Modified: trunk/insns.def
===================================================================
--- trunk/insns.def	2006-02-27 04:55:05 UTC (rev 479)
+++ trunk/insns.def	2006-02-27 13:10:21 UTC (rev 480)
@@ -1456,6 +1456,9 @@
 	if (FIXNUM_P(err)) {
 	    th->state = FIX2INT(err);
 	}
+	else if (SYMBOL_P(err)) {
+	    th->state = TAG_THROW;
+	}
 	else if (BUILTIN_TYPE(err) == T_NODE) {
 	    th->state = GET_THROWOBJ_STATE(err);
 	}

Modified: trunk/node.h
===================================================================
--- trunk/node.h	2006-02-27 04:55:05 UTC (rev 479)
+++ trunk/node.h	2006-02-27 13:10:21 UTC (rev 480)
@@ -362,9 +362,9 @@
 VALUE rb_parser_new(void);
 VALUE rb_parser_end_seen_p(VALUE);
 
-NODE *rb_parser_compile_cstr(VALUE, const char*, const char*, int, int);
-NODE *rb_parser_compile_string(VALUE, const char*, VALUE, int);
-NODE *rb_parser_compile_file(VALUE, const char*, VALUE, int);
+NODE *rb_parser_compile_cstr(volatile VALUE, const char*, const char*, int, int);
+NODE *rb_parser_compile_string(volatile VALUE, const char*, VALUE, int);
+NODE *rb_parser_compile_file(volatile VALUE, const char*, VALUE, int);
 
 NODE *rb_compile_cstr(const char*, const char*, int, int);
 NODE *rb_compile_string(const char*, VALUE, int);

Modified: trunk/ruby.h
===================================================================
--- trunk/ruby.h	2006-02-27 04:55:05 UTC (rev 479)
+++ trunk/ruby.h	2006-02-27 13:10:21 UTC (rev 480)
@@ -220,7 +220,7 @@
 #define T_MATCH  0x13
 #define T_SYMBOL 0x14
 
-#define T_VALUE  0x1a
+#define T_VALUES 0x1a
 #define T_BLOCK  0x1b
 #define T_UNDEF  0x1c
 #define T_NODE   0x1f

Modified: trunk/vm.c
===================================================================
--- trunk/vm.c	2006-02-27 04:55:05 UTC (rev 479)
+++ trunk/vm.c	2006-02-27 13:10:21 UTC (rev 480)
@@ -10,6 +10,7 @@
 #include "eval_intern.h"
 
 #define PROCDEBUG 0
+#define VM_DEBUG  0
 
 #define BUFSIZE 0x100
 
@@ -117,7 +118,7 @@
 th_set_finish_env(yarv_thread_t *th)
 {
     push_frame(th, 0, FRAME_MAGIC_FINISH,
-	       Qnil, 0, 0, th->cfp->sp, 0, 0);
+	       Qnil, th->cfp->lfp[0], 0, th->cfp->sp, 0, 1);
     th->cfp->pc = &yarv_finish_insn_seq[0];
     return Qtrue;
 }
@@ -187,7 +188,8 @@
 	    *envptr = GC_GUARDED_PTR(pcfp->dfp);
 	}
     }
-
+//SDR2(cfp);
+//fprintf(stderr, "lfp: %p, cfp: %p, endptr: %p\n", cfp->lfp, cfp->dfp, endptr);
     /* allocate env */
     envval = rb_obj_alloc(cYarvEnv);
     GetEnvVal(envval, env);
@@ -206,6 +208,7 @@
 
     for (i = 0; i <= local_size; i++) {
 	env->env[i] = envptr[-local_size + i];
+	//dp(env->env[i]);
 	if (YARV_NORMAL_ISEQ_P(cfp->iseq)) {
 	    /* clear value stack for GC */
 	    // envptr[-local_size + i] = 0;
@@ -231,6 +234,12 @@
     env->block.dfp = cfp->dfp;
     env->block.iseq = cfp->iseq;
 
+    if (VM_DEBUG &&
+	(!(cfp->lfp[-1] == Qnil ||
+	  BUILTIN_TYPE(cfp->lfp[-1]) == T_VALUES))) {
+	rb_bug("illegal svar");
+    }
+    
     if (!YARV_NORMAL_ISEQ_P(cfp->iseq)) {
 	/* TODO */
 	env->block.iseq = 0;
@@ -311,6 +320,7 @@
 th_make_env_object(yarv_thread_t *th, yarv_control_frame_t *cfp)
 {
     VALUE envval;
+    // SDR2(cfp);
     envval = th_make_env_each(th, cfp, cfp->dfp, cfp->lfp);
     if (PROCDEBUG) {
 	check_env_value(envval);
@@ -333,8 +343,6 @@
     bcfp = GET_CFP_FROM_BLOCK_PTR(block);
     bdfp = bcfp->dfp;
     procval = th_make_proc(th, bcfp, block);
-    /* what is this? */
-    // bdfp[-1] = procval;
     return procval;
 }
 
@@ -347,16 +355,17 @@
     VALUE procval, envval, blockprocval = 0;
     yarv_proc_t *proc;
 
-    if (GC_GUARDED_PTR_REF(cfp->lfp[0]) != 0 &&
-	!(cfp->lfp[0] & 0x02) /* not class scope */ ) {
-	yarv_proc_t *p;
+    if (GC_GUARDED_PTR_REF(cfp->lfp[0])) {
+	if (!YARV_CLASS_SPECIAL_P(cfp->lfp[0])) {
+	    yarv_proc_t *p;
 
-	blockprocval =
-	    th_make_proc_from_block(th, cfp,
-				    (yarv_block_t *)GC_GUARDED_PTR_REF(*cfp->
-								       lfp));
-	GetProcVal(blockprocval, p);
-	*cfp->lfp = GC_GUARDED_PTR(&p->block);
+	    blockprocval =
+	      th_make_proc_from_block(th, cfp,
+				      (yarv_block_t *)GC_GUARDED_PTR_REF(*cfp->
+									 lfp));
+	    GetProcVal(blockprocval, p);
+	    *cfp->lfp = GC_GUARDED_PTR(&p->block);
+	}
     }
     envval = th_make_env_object(th, cfp);
 
@@ -374,6 +383,15 @@
     proc->envval = envval;
     proc->safe_level = th->safe_level;
     proc->special_cref_stack = lfp_get_special_cref(block->lfp);
+
+    if (VM_DEBUG) {
+	if (th->stack < block->dfp && block->dfp < th->stack + th->stack_size) {
+	    rb_bug("invalid ptr: block->dfp");
+	}
+	if (th->stack < block->lfp && block->lfp < th->stack + th->stack_size) {
+	    rb_bug("invalid ptr: block->lfp");
+	}
+    }
     return procval;
 }
 
@@ -403,7 +421,8 @@
     VALUE val;
     yarv_block_t *blockptr = 0;
 
-    if (0) printf("id: %s (%p), nd: %s, argc: %d, passed: %p\n", rb_id2name(id), id, node_name(nd_type(body)), argc, th->passed_block);
+    if (0) printf("id: %s (%p), nd: %s, argc: %d, passed: %p\n",
+		  rb_id2name(id), id, node_name(nd_type(body)), argc, th->passed_block);
     //SDR2(th->cfp);
 
     if (th->passed_block) {
@@ -431,7 +450,7 @@
 	  struct yarv_cmethod_info cmi = { 0, id, klass };
 
 	  push_frame(th, (yarv_iseq_t *)&cmi, FRAME_MAGIC_CFUNC,
-		     recv, (VALUE)blockptr, 0, reg_cfp->sp, 0, 0);
+		     recv, (VALUE)blockptr, 0, reg_cfp->sp, 0, 1);
 
 	  val = call_cfunc(body->nd_cfnc, recv, body->nd_argc, argc, argv);
 
@@ -533,8 +552,8 @@
 
     push_frame(th, 0, FRAME_MAGIC_IFUNC,
 	       self, (VALUE)block->dfp,
-	       0, th->cfp->sp, block->lfp, 0);
-    
+	       0, th->cfp->sp, block->lfp, 1);
+
     val = (*ifunc->nd_cfnc) (arg, ifunc->nd_tval, Qnil);
 
     th->cfp++;
@@ -660,8 +679,8 @@
     VALUE val = Qundef;
     int state;
     volatile int stored_safe = th->safe_level;
-    NODE *stored_special_cref_stack = 0;
-
+    volatile NODE *stored_special_cref_stack = 0;
+    
     TH_PUSH_TAG(th);
     if ((state = EXEC_TAG()) == 0) {
 	stored_special_cref_stack =
@@ -709,7 +728,7 @@
     TH_POP_TAG();
 
     th->safe_level = stored_safe;
-    lfp_set_special_cref(proc->block.lfp, stored_special_cref_stack);
+    lfp_set_special_cref(proc->block.lfp, (NODE*)stored_special_cref_stack);
 
     if (state) {
 	JUMP_TAG(state);
@@ -721,7 +740,7 @@
 new_value()
 {
     struct RValues *val = RVALUES(rb_newobj());
-    OBJSETUP(val, 0, T_VALUE);
+    OBJSETUP(val, 0, T_VALUES);
     val->v1 = val->v2 = val->v3 = Qnil;
     return val;
 }
@@ -895,13 +914,35 @@
     }
 }
 
+static void
+check_svar(void)
+{
+    yarv_thread_t *th = GET_THREAD();
+    yarv_control_frame_t *cfp = th->cfp;
+    while ((void *)(cfp + 1) < (void *)(th->stack + th->stack_size)) {
+//	printf("cfp: %p\n", cfp->magic);
+	if(cfp->lfp)
+	if(cfp->lfp[-1] != Qnil &&
+	   TYPE(cfp->lfp[-1]) != T_VALUES){
+//	    dp(cfp->lfp[-1]);
+	    rb_bug("!!!illegal svar!!!");
+	}
+	cfp++;
+    }
+}
+
 static NODE *
 lfp_set_special_cref(VALUE *lfp, NODE * cref)
 {
-    NODE *node = (NODE *) lfp[-1];
+    struct RValues *values = (void *) lfp[-1];
     VALUE *pv;
     NODE *old_cref;
-    if (cref == 0 && ((VALUE)node == Qnil || node->nd_file == 0)) {
+
+    if (VM_DEBUG) {
+	check_svar();
+    }
+
+    if (cref == 0 && ((VALUE)values == Qnil || values->basic.klass == 0)) {
 	old_cref = 0;
     }
     else {
@@ -954,8 +995,9 @@
 th_cref_push(yarv_thread_t *th, VALUE klass, int noex)
 {
     NODE *cref = NEW_BLOCK(klass);
+    yarv_control_frame_t *cfp = th_get_ruby_level_cfp(th, th->cfp);
+
     cref->nd_file = 0;
-    yarv_control_frame_t *cfp = th_get_ruby_level_cfp(th, th->cfp);
     cref->nd_next = get_cref(cfp->iseq, cfp->lfp);
     cref->nd_visi = noex;
     return cref;

Modified: trunk/vm_dump.c
===================================================================
--- trunk/vm_dump.c	2006-02-27 04:55:05 UTC (rev 479)
+++ trunk/vm_dump.c	2006-02-27 13:10:21 UTC (rev 480)
@@ -7,9 +7,11 @@
 static void
 control_frame_dump(yarv_thread_t *th, yarv_control_frame_t *cfp)
 {
-    int pc = -1, bp = -1;
-    int lfp = cfp->lfp - th->stack;
-    int dfp = cfp->dfp - th->stack;
+    int pc = -1, bp = -1, line = 0;
+    unsigned int lfp = cfp->lfp - th->stack;
+    unsigned int dfp = cfp->dfp - th->stack;
+    char lfp_in_heap = ' ', dfp_in_heap = ' ';
+    char posbuf[30];
 
     char *magic, *iseq_name = "-", *selfstr = "-", *biseq_name = "-";
     VALUE tmp;
@@ -18,10 +20,14 @@
 	biseq_name = "";	//RSTRING(cfp->block_iseq->name)->ptr;
     }
 
-    if (lfp < 0 || lfp > th->stack_size)
-	lfp = lfp % 1000;
-    if (dfp < 0 || dfp > th->stack_size)
-	dfp = dfp % 1000;
+    if (lfp < 0 || lfp > th->stack_size) {
+	lfp = (unsigned int)cfp->lfp;
+	lfp_in_heap = 'p';
+    }
+    if (dfp < 0 || dfp > th->stack_size) {
+	dfp = (unsigned int)cfp->dfp;
+	dfp_in_heap = 'p';
+    }
     if (cfp->bp) {
 	bp = cfp->bp - th->stack;
     }
@@ -77,6 +83,8 @@
 	if (YARV_CMETHOD_INFO_P(cfp->iseq)) {
 	    struct yarv_cmethod_info *cmi = (void *)cfp->iseq;
 	    iseq_name = rb_id2name(cmi->id);
+	    snprintf(posbuf, 23, ":%s", rb_id2name(cmi->id));
+	    line = -1;
 	}
 	else if (YARV_IFUNC_P(cfp->iseq)) {
 	    iseq_name = "<ifunc>";
@@ -84,18 +92,37 @@
 	else {
 	    pc = cfp->pc - cfp->iseq->iseq_encoded;
 	    iseq_name = RSTRING(cfp->iseq->name)->ptr;
+	    line = th_get_sourceline(cfp);
+	    if (line) {
+		char fn[23];
+		snprintf(fn, 22, "%s", RSTRING(cfp->iseq->file_name)->ptr);
+		snprintf(posbuf, 27, "%s:%d", fn, line);
+	    }
 	}
     }
 
-    printf("c:%04ld ",
-	   (yarv_control_frame_t *)(th->stack + th->stack_size) - cfp);
-    printf("p:%04d s:%04ld b:%04d ", pc, cfp->sp - th->stack, bp);
-    printf("l:%04d d:%04d ", lfp, dfp);
-    printf("%-6s ", magic);
-    printf("i:%-8s ", iseq_name);
-    printf("s:%-8s ", selfstr);
-    printf("%-2s ", biseq_name);
-    printf("\n");
+    fprintf(stderr, "c:%04ld ",
+	    (yarv_control_frame_t *)(th->stack + th->stack_size) - cfp);
+    if (pc == -1) {
+	fprintf(stderr, "p:---- ");
+    }
+    else {
+	fprintf(stderr, "p:%04d ", pc);
+    }
+    fprintf(stderr, "s:%04ld b:%04d ", cfp->sp - th->stack, bp);
+    fprintf(stderr, lfp_in_heap == ' ' ? "l:%06d " : "l:%06p ", lfp % 10000);
+    fprintf(stderr, dfp_in_heap == ' ' ? "d:%06d " : "d:%06p ", dfp % 10000);
+    fprintf(stderr, "%-6s ", magic);
+    if (line) {
+	fprintf(stderr, "%s", posbuf);
+    }
+    if (0) {
+	fprintf(stderr, "             \t");
+	fprintf(stderr, "iseq: %-24s ", iseq_name);
+	fprintf(stderr, "self: %-24s ", selfstr);
+	fprintf(stderr, "%-1s ", biseq_name);
+    }
+    fprintf(stderr, "\n");
 }
 
 void
@@ -106,48 +133,48 @@
     VALUE *dfp = cfp->dfp;
     VALUE *p, *st, *t;
 
-    printf("-- stack frame ------------\n");
+    fprintf(stderr, "-- stack frame ------------\n");
     for (p = st = th->stack; p < sp; p++) {
-	printf("%p (%04ld): %08lx", p, p - st, *p);
+	fprintf(stderr, "%04ld (%p): %08lx", p - st, p, *p);
 
 	t = (VALUE *)*p;
 	if (th->stack <= t && t < sp) {
-	    printf(" (= %ld)", (VALUE *)GC_GUARDED_PTR_REF(t) - th->stack);
+	    fprintf(stderr, " (= %ld)", (VALUE *)GC_GUARDED_PTR_REF(t) - th->stack);
 	}
 
 	if (p == lfp)
-	    printf(" <- lfp");
+	    fprintf(stderr, " <- lfp");
 	if (p == dfp)
-	    printf(" <- dfp");
+	    fprintf(stderr, " <- dfp");
 	if (p == bp)
-	    printf(" <- bp");	/* should not be */
+	    fprintf(stderr, " <- bp");	/* should not be */
 
-	printf("\n");
+	fprintf(stderr, "\n");
     }
-    printf("-- control frame ----------\n");
+    fprintf(stderr, "-- control frame ----------\n");
     while ((void *)cfp < (void *)(th->stack + th->stack_size)) {
 	control_frame_dump(th, cfp);
 	cfp++;
     }
-    printf("---------------------------\n");
+    fprintf(stderr, "---------------------------\n");
 }
 
 void
 env_dump_raw(yarv_env_t *env, VALUE *lfp, VALUE *dfp)
 {
     int i;
-    printf("-- env --------------------\n");
+    fprintf(stderr, "-- env --------------------\n");
 
     while (env) {
-	printf("--\n");
+	fprintf(stderr, "--\n");
 	for (i = 0; i < env->env_size; i++) {
-	    printf("%04d: %08lx (%p)", -env->local_size + i, env->env[i],
+	    fprintf(stderr, "%04d: %08lx (%p)", -env->local_size + i, env->env[i],
 		   &env->env[i]);
 	    if (&env->env[i] == lfp)
-		printf(" <- lfp");
+		fprintf(stderr, " <- lfp");
 	    if (&env->env[i] == dfp)
-		printf(" <- dfp");
-	    printf("\n");
+		fprintf(stderr, " <- dfp");
+	    fprintf(stderr, "\n");
 	}
 
 	if (env->prev_envval != 0) {
@@ -157,7 +184,7 @@
 	    env = 0;
 	}
     }
-    printf("---------------------------\n");
+    fprintf(stderr, "---------------------------\n");
 }
 
 void
@@ -169,8 +196,8 @@
     selfstr = StringValueCStr(val);
 
 
-    printf("-- proc -------------------\n");
-    printf("self: %s\n", selfstr);
+    fprintf(stderr, "-- proc -------------------\n");
+    fprintf(stderr, "self: %s\n", selfstr);
     GetEnvVal(proc->envval, env);
     env_dump_raw(env, proc->block.lfp, proc->block.dfp);
 }
@@ -240,12 +267,12 @@
 	}
 	for (i = 0; i < argc; i++) {
 	    rstr = rb_inspect(*ptr);
-	    printf("  arg   %2d: %8s (%p)\n", i, StringValueCStr(rstr),
+	    fprintf(stderr, "  arg   %2d: %8s (%p)\n", i, StringValueCStr(rstr),
 		   ptr++);
 	}
 	for (; i < local_size - 1; i++) {
 	    rstr = rb_inspect(*ptr);
-	    printf("  local %2d: %8s (%p)\n", i, StringValueCStr(rstr),
+	    fprintf(stderr, "  local %2d: %8s (%p)\n", i, StringValueCStr(rstr),
 		   ptr++);
 	}
 
@@ -257,7 +284,7 @@
 	    else {
 		rstr = rb_inspect(*ptr);
 	    }
-	    printf("  stack %2d: %8s (%ld)\n", i, StringValueCStr(rstr),
+	    fprintf(stderr, "  stack %2d: %8s (%ld)\n", i, StringValueCStr(rstr),
 		   ptr - th->stack);
 	}
     }
@@ -294,7 +321,7 @@
 	dfp = -1;
 
     cfpi = ((yarv_control_frame_t *)(th->stack + th->stack_size)) - cfp;
-    printf("  [PC] %04d, [SP] %04ld, [LFP] %04d, [DFP] %04d, [CFP] %04d\n",
+    fprintf(stderr, "  [PC] %04d, [SP] %04ld, [LFP] %04d, [DFP] %04d, [CFP] %04d\n",
 	   pc, cfp->sp - th->stack, lfp, dfp, cfpi);
 }
 
@@ -319,7 +346,7 @@
     }
 
 #if VMDEBUG > 3
-    printf("        (1)");
+    fprintf(stderr, "        (1)");
     debug_print_register(th);
 #endif
 }
@@ -336,7 +363,7 @@
 #endif
 
 #if VMDEBUG > 3
-    printf("        (2)");
+    fprintf(stderr, "        (2)");
     debug_print_register(th);
 #endif
     // stack_dump_raw(th, cfp);
@@ -348,9 +375,9 @@
     {
 	VALUE rstr;
 	rstr = rb_inspect(reg_a);
-	printf("  sc reg A: %s\n", StringValueCStr(rstr));
+	fprintf(stderr, "  sc reg A: %s\n", StringValueCStr(rstr));
 	rstr = rb_inspect(reg_b);
-	printf("  sc reg B: %s\n", StringValueCStr(rstr));
+	fprintf(stderr, "  sc reg B: %s\n", StringValueCStr(rstr));
     }
 #endif
     printf
@@ -499,7 +526,7 @@
 	for (i = 0; i < sizeof(regstrs) / sizeof(regstrs[0]); i++) {
 	    int j;
 	    for (j = 0; j < 2; j++) {
-		snprintf(buff, 0x10, "%d %s %-4s", i, getsetstr[j],
+		snfprintf(stderr, buff, 0x10, "%d %s %-4s", i, getsetstr[j],
 			 regstrs[i]);
 		syms[i][j] = ID2SYM(rb_intern(buff));
 	    }
@@ -528,9 +555,9 @@
     GetThreadVal(self, th);
     cfp = th->cfp;
 
-    printf("Thread state dump:\n");
-    printf("pc : %p, sp : %p\n", cfp->pc, cfp->sp);
-    printf("cfp: %p, lfp: %p, dfp: %p\n", cfp, cfp->lfp, cfp->dfp);
+    fprintf(stderr, "Thread state dump:\n");
+    fprintf(stderr, "pc : %p, sp : %p\n", cfp->pc, cfp->sp);
+    fprintf(stderr, "cfp: %p, lfp: %p, dfp: %p\n", cfp, cfp->lfp, cfp->dfp);
 
     return Qnil;
 }

Modified: trunk/vm_macro.def
===================================================================
--- trunk/vm_macro.def	2006-02-27 04:55:05 UTC (rev 479)
+++ trunk/vm_macro.def	2006-02-27 13:10:21 UTC (rev 480)
@@ -55,7 +55,7 @@
     struct yarv_cmethod_info cmi = { 0, id, klass };
 
     push_frame(th, (yarv_iseq_t *) & cmi, FRAME_MAGIC_CFUNC,
-	       recv, (VALUE) blockptr, 0, GET_SP(), 0, 0);
+	       recv, (VALUE) blockptr, 0, GET_SP(), 0, 1);
 
     reg_cfp->sp -= num + 1;
 

Modified: trunk/yarvcore.c
===================================================================
--- trunk/yarvcore.c	2006-02-27 04:55:05 UTC (rev 479)
+++ trunk/yarvcore.c	2006-02-27 13:10:21 UTC (rev 480)
@@ -623,6 +623,7 @@
 	MARK_UNLESS_NULL(th->thgroup);
 	MARK_UNLESS_NULL(th->value);
 	MARK_UNLESS_NULL(th->errinfo);
+	MARK_UNLESS_NULL(th->local_svar);
 
 	rb_mark_tbl(th->local_storage);
 

Modified: trunk/yarvcore.h
===================================================================
--- trunk/yarvcore.h	2006-02-27 04:55:05 UTC (rev 479)
+++ trunk/yarvcore.h	2006-02-27 13:10:21 UTC (rev 480)
@@ -517,6 +517,8 @@
 #define YARV_NORMAL_ISEQ_P(ptr) \
   (ptr && !YARV_CMETHOD_INFO_P(ptr) && !YARV_IFUNC_P(ptr))
 
+#define YARV_CLASS_SPECIAL_P(ptr) (((VALUE)(ptr)) & 0x02)
+#define YARV_BLOCK_PTR_P(ptr) (!YARV_CLASS_SPECIAL_P(ptr) && GC_GUARDED_PTR_REF(ptr))
 struct yarv_cmethod_info {
     VALUE sig;			/* must be null */
     ID id;


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

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