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

yarv-diff:74

From: ko1 atdot.net
Date: 14 Aug 2005 16:03:59 -0000
Subject: [yarv-diff:74] r230 - in trunk: . yarvext yarvtest

Author: ko1
Date: 2005-08-15 01:03:58 +0900 (Mon, 15 Aug 2005)
New Revision: 230

Added:
   trunk/yarvtest/test_test.rb
Modified:
   trunk/ChangeLog
   trunk/common.mk
   trunk/compile.c
   trunk/debug.c
   trunk/depend
   trunk/eval.c
   trunk/inits.c
   trunk/insns.def
   trunk/version.c
   trunk/vm.c
   trunk/vm_macro.def
   trunk/yarv.h
   trunk/yarv_version.h
   trunk/yarvcore.c
   trunk/yarvcore.h
   trunk/yarvext/extconf.rb
   trunk/yarvext/test.rb
   trunk/yarvsubst.c
   trunk/yarvtest/test_flow.rb
   trunk/yarvtest/yarvtest.rb
Log:
	* yarv_version.h : move configurations to yarvcore.h

	* yarvcore.c : remove VALUE yarv_get_current_running_thread() and
	add yarv_thread_t *yarv_get_current_running_thread(), ...

	* yarvcore.h : yarv_thread_t#vm -> vm_value

	* compile.c : fix "break from nested classes"

	* yarvext/extconf.rb : use have_func instead of defined?(YARV_PACHED)

	* depend : fix pass

	* eval.c : change to kick VM

	* version.c : fix to show yarv version

	* common.mk : fix dependent

	* inits.c : fix to kick Init_yarvcore


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2005-08-13 17:07:54 UTC (rev 229)
+++ trunk/ChangeLog	2005-08-14 16:03:58 UTC (rev 230)
@@ -4,6 +4,30 @@
 #  from Mon, 03 May 2004 01:24:19 +0900
 #
 
+2005-08-15(Mon) 00:53:28 +0900  Koichi Sasada  <ko1 atdot.net>
+
+	* yarv_version.h : move configurations to yarvcore.h
+
+	* yarvcore.c : remove VALUE yarv_get_current_running_thread() and
+	add yarv_thread_t *yarv_get_current_running_thread(), ...
+
+	* yarvcore.h : yarv_thread_t#vm -> vm_value
+
+	* compile.c : fix "break from nested classes"
+
+	* yarvext/extconf.rb : use have_func instead of defined?(YARV_PACHED)
+
+	* depend : fix pass
+
+	* eval.c : change to kick VM
+
+	* version.c : fix to show yarv version
+
+	* common.mk : fix dependent
+
+	* inits.c : fix to kick Init_yarvcore
+
+
 2005-08-14(Sun) 02:05:15 +0900  Koichi Sasada  <ko1 atdot.net>
 
 	* README : add description

Modified: trunk/common.mk
===================================================================
--- trunk/common.mk	2005-08-13 17:07:54 UTC (rev 229)
+++ trunk/common.mk	2005-08-14 16:03:58 UTC (rev 230)
@@ -337,12 +337,14 @@
   {$(VPATH)}env.h {$(VPATH)}node.h {$(VPATH)}st.h {$(VPATH)}util.h
 version.$(OBJEXT): {$(VPATH)}version.c {$(VPATH)}ruby.h config.h rev.inc \
   {$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
-  {$(VPATH)}version.h
+  {$(VPATH)}version.h {$(VPATH)}yarv_version.h rev.inc
 
-compile.o:   {$(VPATH)}compile.c {$(VPATH)}yarvcore.h {$(VPATH)}compile.h {$(VPATH)}yarv_version.h {$(VPATH)}debug.h insns.inc insns_info.inc optinsn.inc opt_sc.inc optunifs.inc
-disasm.o:    {$(VPATH)}disasm.c {$(VPATH)}yarvcore.h {$(VPATH)}yarv_version.h {$(VPATH)}debug.h
-vm.o:        {$(VPATH)}vm.c {$(VPATH)}vm.h {$(VPATH)}yarv_version.h {$(VPATH)}insnhelper.h {$(VPATH)}yarvcore.h {$(VPATH)}debug.h {$(VPATH)}vm_evalbody.h insns.inc vm.inc vmtc.inc vm_macro.inc
-vm_dump.o: {$(VPATH)}vm.h
+compile.o:   {$(VPATH)}compile.c {$(VPATH)}yarvcore.h {$(VPATH)}compile.h {$(VPATH)}debug.h \
+             insns.inc insns_info.inc optinsn.inc opt_sc.inc optunifs.inc
+disasm.o:    {$(VPATH)}disasm.c {$(VPATH)}yarvcore.h {$(VPATH)}debug.h
+vm.o:        {$(VPATH)}vm.c {$(VPATH)}vm.h {$(VPATH)}insnhelper.h {$(VPATH)}yarvcore.h {$(VPATH)}debug.h \
+             {$(VPATH)}vm_evalbody.h insns.inc vm.inc vmtc.inc vm_macro.inc
+vm_dump.o:   {$(VPATH)}yarvcore.h {$(VPATH)}vm.h
 yarvcore.o:  {$(VPATH)}yarvcore.c {$(VPATH)}yarvcore.h {$(VPATH)}yarv_version.h {$(VPATH)}debug.h rev.inc
 debug.o:     {$(VPATH)}debug.h
 yarvsubst.o: {$(VPATH)}yarv.h

Modified: trunk/compile.c
===================================================================
--- trunk/compile.c	2005-08-13 17:07:54 UTC (rev 229)
+++ trunk/compile.c	2005-08-14 16:03:58 UTC (rev 230)
@@ -2215,6 +2215,9 @@
       yarv_iseq_t *ip = iseqobj->parent_iseqobj;
       
       while(ip){
+        if(level > 5){
+          exit(0);
+        }
         level++;
         if(ip->type == ISEQ_TYPE_BLOCK){
           level <<= 16;
@@ -2227,7 +2230,7 @@
           }
           goto break_by_jump;
         }
-        ip = iseqobj->parent_iseqobj;
+        ip = ip->parent_iseqobj;
       }
       COMPILE_ERROR(("can't put break"));
     }
@@ -2259,7 +2262,7 @@
           }
           break;
         }
-        ip = iseqobj->parent_iseqobj;
+        ip = ip->parent_iseqobj;
       }
       if(ip != 0){
         COMPILE(ret, "next val", node->nd_stts);
@@ -2290,7 +2293,7 @@
         else if(ip->compile_data->redo_label != 0){
           break;
         }
-        ip = iseqobj->parent_iseqobj;
+        ip = ip->parent_iseqobj;
       }
       if(ip != 0){
         add_ensure_iseq(ret, iseqobj, self);

Modified: trunk/debug.c
===================================================================
--- trunk/debug.c	2005-08-13 17:07:54 UTC (rev 229)
+++ trunk/debug.c	2005-08-14 16:03:58 UTC (rev 230)
@@ -11,6 +11,7 @@
     for(i=0 ;i<indent_level; i++){
       printf(" ");
     }
+    fflush(stdout);
   }
 }
 
@@ -19,6 +20,7 @@
     VALUE str;
     str = rb_inspect(obj);
     printf("DBG> %s: %s\n",header, obj == -1 ? "" : StringValueCStr(str));
+    fflush(stdout);
   }
   return obj;
 }

Modified: trunk/depend
===================================================================
--- trunk/depend	2005-08-13 17:07:54 UTC (rev 229)
+++ trunk/depend	2005-08-14 16:03:58 UTC (rev 230)
@@ -6,7 +6,7 @@
 debug.o:     $(srcdir)/debug.h
 yarvsubst.o: $(srcdir)/yarv.h
 
-INSNS2VMOPT = $(CPPFLAGS) --srcdir=$(srcdir)/..
+INSNS2VMOPT = $(CPPFLAGS) --srcdir=$(srcdir)
 
 minsns.inc:
 	$(RUBY) $(srcdir)/rb/insns2vm.rb $(INSNS2VMOPT)
@@ -54,7 +54,7 @@
 	$(RUBY) -I$(srcdir)/yarvext -I$(srcdir) $(srcdir)/yarvtest/test_$(ITEM).rb $(OPT)
 
 run: all
-	$(RUBY) -I$(srcdir) $(srcdir)/test.rb $(RUNOPT)
+	$(RUBY) -I$(srcdir)/yarvext $(srcdir)/yarvext/test.rb $(RUNOPT)
 
 benchmark: all
 	$(RUBY) -I$(srcdir) $(srcdir)/benchmark/run.rb $(OPT) $(ITEMS)
@@ -90,4 +90,4 @@
 	echo run > run.gdb
 
 gdb: all run.gdb
-	gdb -x run.gdb --quiet --args $(RUBY) -I$(srcdir) $(srcdir)/test.rb
+	gdb -x run.gdb --quiet --args $(RUBY) -I$(srcdir)/yarvext $(srcdir)/yarvext/test.rb

Modified: trunk/eval.c
===================================================================
--- trunk/eval.c	2005-08-13 17:07:54 UTC (rev 229)
+++ trunk/eval.c	2005-08-14 16:03:58 UTC (rev 230)
@@ -969,7 +969,8 @@
     struct tag *prev;
     int blkid;
 };
-static struct tag *prot_tag;
+struct tag *ruby_prot_tag;
+#define prot_tag ruby_prot_tag
 
 #define PUSH_TAG(ptag) do {		\
     struct tag _tag;			\
@@ -1585,21 +1586,14 @@
 static int
 ruby_exec_internal()
 {
-    int state;
-
-    PUSH_THREAD_TAG();
-    PUSH_ITER(ITER_NOT);
-    /* default visibility is private at toplevel */
-    SCOPE_SET(SCOPE_PRIVATE);
-    if ((state = EXEC_TAG()) == 0) {
-	eval_node(ruby_top_self, ruby_eval_tree);
-    }
-    else if (state == TAG_THREAD) {
-	rb_thread_start_1();
-    }
-    POP_ITER();
-    POP_THREAD_TAG();
-    return state;
+  int state;
+  PUSH_TAG(0);
+  if((state = EXEC_TAG()) == 0) {
+    // VM start
+    yarvcore_eval_parsed(ruby_eval_tree, ruby_sourcefile);
+  }
+  POP_TAG();
+  return state;
 }
 
 int

Modified: trunk/inits.c
===================================================================
--- trunk/inits.c	2005-08-13 17:07:54 UTC (rev 229)
+++ trunk/inits.c	2005-08-14 16:03:58 UTC (rev 230)
@@ -46,6 +46,7 @@
 void Init_Time _((void));
 void Init_var_tables _((void));
 void Init_version _((void));
+void Init_yarvcore _((void));
 
 void
 rb_call_inits()
@@ -82,5 +83,6 @@
     Init_GC();
     Init_marshal();
     Init_Enumerator();
+    Init_yarvcore();
     Init_version();
 }

Modified: trunk/insns.def
===================================================================
--- trunk/insns.def	2005-08-13 17:07:54 UTC (rev 229)
+++ trunk/insns.def	2005-08-14 16:03:58 UTC (rev 230)
@@ -735,7 +735,8 @@
 
   /* make new node */
   newbody = NEW_NODE(YARV_METHOD_NODE, NOEX_PUBLIC, body, 0);
-  
+  // printf("define: %s: %s\n", rb_id2name(id), node_name(nd_type(newbody)));
+
   //debugp_(-1, "self", GET_SELF());
   //printf("%s\n", body_name(nd_type(newbody)));
   //fflush(stdout);
@@ -750,6 +751,13 @@
   }
   
   rb_add_method(klass, id, newbody, NOEX_PUBLIC);
+
+  if(0){
+    NODE *mn = rb_method_node(klass, id);
+    dp(klass);
+    printf("defined: %s: %s\n", rb_id2name(id), node_name(nd_type(mn)));
+  }
+  
   INC_VM_STATE_VERSION();
 }
 
@@ -1009,7 +1017,7 @@
     rb_set_class_path(module, mbase, rb_id2name(id));
     rb_const_set(mbase, id, module);
   }
-  
+
   /* enter scope */
   GetISeqVal(module_iseqval, module_iseq);
   th_set_env(th, module_iseq,
@@ -1281,7 +1289,7 @@
   ulong state = throw_state & 0xff;
   ulong flag  = throw_state & 0x8000;
   ulong level = throw_state >> 16;
-  
+
   if(state != 0){
     VALUE *pt;
     int i;

Modified: trunk/version.c
===================================================================
--- trunk/version.c	2005-08-13 17:07:54 UTC (rev 229)
+++ trunk/version.c	2005-08-14 16:03:58 UTC (rev 230)
@@ -12,6 +12,7 @@
 
 #include "ruby.h"
 #include "version.h"
+#include "yarv_version.h"
 #include <stdio.h>
 
 const char ruby_version[] = RUBY_VERSION;
@@ -37,8 +38,10 @@
 ruby_show_version()
 {
 #include "rev.inc"
-    printf("rite rev:%s  --  based on ruby %s (%s) [%s]\n", rev, RUBY_VERSION, RUBY_RELEASE_DATE, RUBY_PLATFORM);
-    fflush(stdout);
+  printf("ruby %s (%s) [%s]\n", RUBY_VERSION, RUBY_RELEASE_DATE, RUBY_PLATFORM);
+  printf("%s (rev: %s)\n", yarv_version, rev);
+  printf("YARVCore options: %s\n", yarv_options);
+  fflush(stdout);
 }
 
 void

Modified: trunk/vm.c
===================================================================
--- trunk/vm.c	2005-08-13 17:07:54 UTC (rev 229)
+++ trunk/vm.c	2005-08-14 16:03:58 UTC (rev 230)
@@ -266,6 +266,7 @@
   case NODE_CFUNC:{
     yarv_control_frame_t *reg_cfp = th->cfp;
     struct 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,
@@ -301,8 +302,6 @@
   return th_call0(th, klass, recv, id, oid, argc, argv, body, nosuper);
 }
 
-
-static
 VALUE th_call_super(yarv_thread_t *th, int argc, const VALUE *argv){
   VALUE recv  = th->cfp->self;
   VALUE klass;
@@ -517,7 +516,6 @@
   return th_svar(th, cnt);
 }
 
-
 static
 VALUE th_backtrace_each(yarv_thread_t *th, yarv_control_frame_t *cfp,
                         char *file, int line_no, VALUE ary){
@@ -564,7 +562,6 @@
   return str;
 }
 
-static
 VALUE th_backtrace(yarv_thread_t *th, int lev){
   VALUE ary;
   yarv_control_frame_t *cfp = th->cfp;
@@ -809,7 +806,12 @@
     struct tag *prev;
     int blkid;
 };
+
+#if YARVEXT
 RUBY_EXTERN struct tag *ruby_prot_tag;
+#else
+RUBY_EXTERN struct tag *ruby_prot_tag;
+#endif
 
 #define PUSH_TAG(ptag) do {            \
   _tag.prev = ruby_prot_tag;           \
@@ -1167,6 +1169,11 @@
       goto vm_loop_start;
     }
     else{
+      /* pop cref */
+      if(cfp->iseq->type == ISEQ_TYPE_CLASS){
+        rb_ary_pop(th->klass_nest_stack);
+      }
+      
       th->cfp++;
       if(th->cfp->pc != &yarv_finish_insn_seq[0]){
         goto exception_handler;

Modified: trunk/vm_macro.def
===================================================================
--- trunk/vm_macro.def	2005-08-13 17:07:54 UTC (rev 229)
+++ trunk/vm_macro.def	2005-08-14 16:03:58 UTC (rev 230)
@@ -237,6 +237,13 @@
       POP();
       break;
     }
+    case NODE_SCOPE:{
+      dpi(id);
+      SDR();
+      rb_bug("eval_invoke_method: NODE_SCOPE");
+      /* unreachable */
+      break;
+    }
     default:{
       rb_bug("eval_invoke_method: unreachable");
       /* unreachable */

Modified: trunk/yarv.h
===================================================================
--- trunk/yarv.h	2005-08-13 17:07:54 UTC (rev 229)
+++ trunk/yarv.h	2005-08-14 16:03:58 UTC (rev 230)
@@ -9,13 +9,25 @@
 VALUE yarv_yield _((VALUE val));
 
 /* original API */
+
+#if YARVEXT
 RUBY_EXTERN int yarvIsWorking;
 #define IS_YARV_WORKING() (yarvIsWorking)
 #define SET_YARV_START()  (yarvIsWorking = 1)
 #define SET_YARV_STOP()   (yarvIsWorking = 0)
+#else
+#define IS_YARV_WORKING() 1
+#define SET_YARV_START()
+#define SET_YARV_STOP() 
+#endif
 
-VALUE yarv_get_current_running_thread _(());
+VALUE yarv_get_current_running_vm_value _(());
+VALUE yarv_get_current_running_thread_value _(());
 
+yarv_vm_t *yarv_get_current_running_vm _(());
+yarv_thread_t *yarv_get_current_running_thread _(());
+
+
 struct yarv_yield_data{
   yarv_thread_t *th;
   yarv_block_t *block;

Modified: trunk/yarv_version.h
===================================================================
--- trunk/yarv_version.h	2005-08-13 17:07:54 UTC (rev 229)
+++ trunk/yarv_version.h	2005-08-14 16:03:58 UTC (rev 230)
@@ -12,56 +12,10 @@
 #define MINOR_VER   3
 #define DEVEL_VER   0
 
-/*****************/
-/* configuration */
-/*****************/
+extern char  yarv_version[];
+extern char *yarv_options;
 
-/* gcc ver. check */
-#if defined(__GNUC__) && __GNUC__ >= 2
 
-#ifdef OPT_TOKEN_THREADED_CODE
-#ifdef OPT_DIRECT_THREADED_CODE
-#undef OPT_DIRECT_THREADED_CODE
-#endif
-#endif
-
-#else
-
-/* disable threaded code options */
-#ifdef OPT_DIRECT_THREADED_CODE
-#undef OPT_DIRECT_THREADED_CODE
-#endif
-#ifdef OPT_TOKEN_THREADED_CODE
-#undef OPT_TOKEN_THREADED_CODE
-#endif
-#endif
-
-/* call threaded code */
-#ifdef OPT_CALL_THREADED_CODE
-#ifdef OPT_DIRECT_THREADED_CODE
-#undef OPT_DIRECT_THREADED_CODE
-#endif
-#ifdef OPT_STACK_CACHING
-#undef OPT_STACK_CACHING
-#endif
-#define YARV_AOT_COMPILED 1
-#endif
-
-/* likely */
-#ifdef __GCC__
-#define LIKELY(x)   (__builtin_expect(x, 1))
-#define UNLIKELY(x) (__builtin_expect(x, 0))
-#else
-#define LIKELY(x)   ((x) == 1)
-#define UNLIKELY(x) ((x) == 0)
-#endif
-
-
-#define YARVDEBUG 0
-#define CPDEBUG   0
-#define VMDEBUG   0
-#define GCDEBUG   0
-
 #endif	// _VERSION_H_INCLUDED_
 
 

Modified: trunk/yarvcore.c
===================================================================
--- trunk/yarvcore.c	2005-08-13 17:07:54 UTC (rev 229)
+++ trunk/yarvcore.c	2005-08-14 16:03:58 UTC (rev 230)
@@ -11,7 +11,9 @@
 #include <ruby.h>
 #include <node.h>
 
+#include "yarv_version.h"
 #include "yarvcore.h"
+#include "yarv.h"
 
 VALUE mYarvCore;
 VALUE cYarvISeq;
@@ -76,28 +78,36 @@
 /************/
 
 /* temporalily */
-static VALUE yarvCurrentRunningVM     = Qnil;
-static VALUE yarvCurrentRunningThread = Qnil;
-
 void yarv_setup(void *p1, void *p2, void *p3, void *p4,
                 void *p5, void *p6, void *p7, void *p8);
 
-VALUE yarv_get_current_running_vm(){
-  return yarvCurrentRunningVM;
+
+static yarv_thread_t *yarvCurrentRunningThread = 0;
+static VALUE yarvVM = Qnil;
+
+VALUE yarv_get_current_running_vm_value(){
+  return yarvCurrentRunningThread->vm_value;
 }
 
-VALUE yarv_get_current_running_thread(){
+VALUE yarv_get_current_running_thread_value(){
+  return yarvCurrentRunningThread->self;
+}
+
+yarv_vm_t *yarv_get_current_running_vm(){
+  return yarvCurrentRunningThread->vm;
+}
+
+yarv_thread_t *yarv_get_current_running_thread(){
   return yarvCurrentRunningThread;
 }
 
+void yarv_set_current_running_thread(yarv_thread_t *th){
+  yarvCurrentRunningThread = th;
+}
+
 /* rb_block_given */
 int yarv_block_given_p(){
-  VALUE th = yarv_get_current_running_thread();
-  yarv_thread_t *thobj;
-  
-  GetThreadVal(th, thobj);
-
-  if(GC_GUARDED_PTR_REF(thobj->cfp->lfp[0])){
+  if(GC_GUARDED_PTR_REF(yarv_get_current_running_thread()->cfp->lfp[0])){
     return 1;
   }
   else{
@@ -109,12 +119,8 @@
 
 /* rb_yield_values */
 VALUE yarv_yield_values(int argc, VALUE *argv){
-  VALUE thval;
-  yarv_thread_t *th;
+  yarv_thread_t *th = yarv_get_current_running_thread();
 
-  thval = yarv_get_current_running_thread();
-  GetThreadVal(thval, th);
-
   if(argc == 1 && CLASS_OF(argv[0]) == rb_cValues){
     argc = RARRAY(argv[0])->len;
     argv = RARRAY(argv[0])->ptr;
@@ -129,23 +135,20 @@
 /* rb_call0 continued for yarv function */
 VALUE yarv_call0(VALUE klass, VALUE recv, VALUE id, ID oid,
                  int argc, VALUE *argv, NODE *body, int nosuper){
-  VALUE th   = yarv_get_current_running_thread();
-  return thread_call0(th, klass, recv, id, oid, argc, argv, body, nosuper);
+  return th_call0(yarv_get_current_running_thread(), klass, recv, id, oid, argc, argv, body, nosuper);
 }
 
 
 VALUE thread_call_super(VALUE self, int argc, const VALUE *argv);
 
 VALUE yarv_call_super(int argc, const VALUE *argv){
-  VALUE th   = yarv_get_current_running_thread();
-  return thread_call_super(th, argc, argv);
+  return th_call_super(yarv_get_current_running_thread(), argc, argv);
 }
 
 VALUE thread_backtrace(VALUE th, int level);
 
 VALUE yarv_backtrace(int level){
-  VALUE th = yarv_get_current_running_thread();
-  return thread_backtrace(th, level);
+  return th_backtrace(yarv_get_current_running_thread(), level);
 }
 
 VALUE yarv_caller(VALUE self, VALUE level){
@@ -191,21 +194,19 @@
   argv[4] = ISEQ_TYPE_TOP;
   iseq = rb_class_new_instance(5, argv, cYarvISeq);
 
-  vm_eval(yarv_get_current_running_vm(), iseq);
+  vm_eval(yarv_get_current_running_vm_value(), iseq);
   return 0;
 }
 
 
-VALUE *thread_svar(VALUE self, int cnt);
+VALUE *th_svar(yarv_thread_t *self, int cnt);
+
 VALUE *yarv_svar(int cnt){
-  return thread_svar(yarv_get_current_running_thread(), cnt);
+  return th_svar(yarv_get_current_running_thread(), cnt);
 }
 
 static int yarv_iterate(NODE *node){
-  VALUE thval = yarv_get_current_running_thread();
-  yarv_thread_t *th;
-  GetThreadVal(thval, th);
-  
+  yarv_thread_t *th = yarv_get_current_running_thread();
   th->ifuncnode = node;
   return 0;
 }
@@ -222,22 +223,21 @@
   return (VALUE)node;
 }
 
-static VALUE yarvcore_eval_parsed(VALUE self, VALUE iseq){
+
+static VALUE yarvcore_eval_iseq(VALUE iseq){
   volatile VALUE vm;
   VALUE ret;
-  vm = rb_class_new_instance(0, 0, cYarvVM);
+  vm = yarv_get_current_running_vm_value();
   
-  yarvCurrentRunningVM = vm;
   SET_YARV_START();
   ret = vm_eval(vm, iseq);
   SET_YARV_STOP();
   return ret;
 }
 
-static VALUE yarvcore_eval(VALUE self, VALUE str, VALUE file, VALUE line){
-  VALUE node = compile_string(str, file, line);
+VALUE yarvcore_eval_parsed(VALUE node, VALUE file){
   VALUE argv[5];
-  volatile VALUE iseq;
+  VALUE iseq;
   
   argv[0] = node;
   argv[1] = rb_str_new2("<main>");
@@ -245,9 +245,14 @@
   argv[3] = Qfalse;
   argv[4] = ISEQ_TYPE_TOP;
   iseq = rb_class_new_instance(5, argv, cYarvISeq);
-  return yarvcore_eval_parsed(self, iseq);
+  yarvcore_eval_iseq(iseq);
 }
 
+VALUE yarvcore_eval(VALUE self, VALUE str, VALUE file, VALUE line){
+  VALUE node = compile_string(str, file, line);
+  return yarvcore_eval_parsed(node, file);
+}
+
 static VALUE yarvcore_parse(VALUE self, VALUE str, VALUE file, VALUE line){
   VALUE node = compile_string(str, file, line);
   VALUE argv[5];
@@ -326,58 +331,59 @@
 
 static VALUE iseq_alloc(VALUE klass){
   VALUE volatile obj;
-  yarv_iseq_t *iseqobj;
+  yarv_iseq_t *iseq;
 
   obj = Data_Make_Struct(klass, yarv_iseq_t,
-                         iseq_mark, iseq_free, iseqobj);
+                         iseq_mark, iseq_free, iseq);
   return obj;
 }
 
-static VALUE prepare_iseq_build(yarv_iseq_t *iseqobj,
+static VALUE prepare_iseq_build(yarv_iseq_t *iseq,
                                 VALUE name, VALUE file_name,
                                 VALUE parent, VALUE type){
   
-  iseqobj->name            = name;
-  iseqobj->file_name       = file_name;
-  iseqobj->iseq_mark_ary   = rb_ary_new();
-  iseqobj->catch_table_ary = rb_ary_new();
-  iseqobj->type            = type;
-  iseqobj->arg_rest        = -1;
-  iseqobj->arg_block       = -1;
+  iseq->name            = name;
+  iseq->file_name       = file_name;
+  iseq->iseq_mark_ary   = rb_ary_new();
+  iseq->catch_table_ary = rb_ary_new();
+  iseq->type            = type;
+  iseq->arg_rest        = -1;
+  iseq->arg_block       = -1;
 
+  /* set class nest stack */
   if(parent){
     if(type != ISEQ_TYPE_CLASS){
       yarv_iseq_t *piseq;
       GetISeqVal(parent, piseq);
-      iseqobj->klass_nest_stack = piseq->klass_nest_stack;
+      iseq->klass_nest_stack = piseq->klass_nest_stack;
     }
   }
   else if(type == ISEQ_TYPE_TOP){
-    iseqobj->klass_nest_stack = rb_ary_new();
-    rb_ary_push(iseqobj->klass_nest_stack, rb_cObject);
+    iseq->klass_nest_stack = rb_ary_new();
+    rb_ary_push(iseq->klass_nest_stack, rb_cObject);
   }
   else if(type == ISEQ_TYPE_METHOD){
-    iseqobj->klass_nest_stack = rb_ary_new();
+    iseq->klass_nest_stack = rb_ary_new();
   }
 
-  iseqobj->compile_data    = ALLOC_N(struct iseq_compile_data, 1);
-  MEMZERO(iseqobj->compile_data, struct iseq_compile_data, 1);
-  iseqobj->compile_data->mark_ary = rb_ary_new();
+  iseq->compile_data    = ALLOC_N(struct iseq_compile_data, 1);
+  MEMZERO(iseq->compile_data, struct iseq_compile_data, 1);
+  iseq->compile_data->mark_ary = rb_ary_new();
 
-  iseqobj->compile_data->storage_head = iseqobj->compile_data->storage_current =
+  iseq->compile_data->storage_head = iseq->compile_data->storage_current =
     (struct iseq_compile_data_storage *)
       ALLOC_N(char, INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE +
               sizeof(struct iseq_compile_data_storage));
 
-  iseqobj->compile_data->storage_head->pos  = 0;
-  iseqobj->compile_data->storage_head->next = 0;
-  iseqobj->compile_data->storage_head->size = INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE;
-  iseqobj->compile_data->storage_head->buff = (char *)(&iseqobj->compile_data->storage_head->buff + 1);
+  iseq->compile_data->storage_head->pos  = 0;
+  iseq->compile_data->storage_head->next = 0;
+  iseq->compile_data->storage_head->size = INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE;
+  iseq->compile_data->storage_head->buff = (char *)(&iseq->compile_data->storage_head->buff + 1);
 
   if(parent && CLASS_OF(parent) == cYarvISeq){
-    yarv_iseq_t *piseqobj;
-    GetISeqVal(parent, piseqobj);
-    iseqobj->parent_iseqobj = piseqobj;
+    yarv_iseq_t *piseq;
+    GetISeqVal(parent, piseq);
+    iseq->parent_iseqobj = piseq;
   }
   return Qtrue;
 }
@@ -449,8 +455,8 @@
 
 static VALUE vm_alloc(VALUE klass){
   VALUE volatile obj;
-  yarv_vm_t *vmobj;
-  obj = Data_Make_Struct(klass, yarv_vm_t, vm_mark, vm_free, vmobj);
+  yarv_vm_t *vm;
+  obj = Data_Make_Struct(klass, yarv_vm_t, vm_mark, vm_free, vm);
   return obj;
 }
 
@@ -512,7 +518,7 @@
     }
     
     /* mark ruby objects */
-    MARK_UNLESS_NULL(th->vm);
+    MARK_UNLESS_NULL(th->vm_value);
     MARK_UNLESS_NULL(th->stat_insn_usage);
     MARK_UNLESS_NULL(th->klass_nest_stack);
   }
@@ -530,10 +536,13 @@
 
 extern VALUE thread_set_top_stack(VALUE self, VALUE iseq);
 
-static VALUE thread_init(VALUE self, VALUE vm){
+static VALUE thread_init(VALUE self, VALUE vmval){
   yarv_thread_t *th;
+  yarv_vm_t *vm;
+  
   GetThreadVal(self, th);
-
+  GetVMVal(vmval, vm);
+  
   /* allocate thread stack */
   th->stack      = ALLOC_N(VALUE, YARV_THREAD_STACK_SIZE);
   th->stack_size = YARV_THREAD_STACK_SIZE;
@@ -551,7 +560,9 @@
   th->cfp->magic = 0;
   
   th->self = self;
-  th->vm   = vm;
+  
+  th->vm_value = vmval;
+  th->vm       = vm;
 
   return self;
 }
@@ -563,9 +574,10 @@
   yarv_thread_t *th;
   GetThreadVal(self, th);
 
-  yarvCurrentRunningThread = self;
+  // TODO
   thread_set_top_stack(self, iseq);
   val = th_eval_body(th);
+
   return val;
 }
 
@@ -639,9 +651,13 @@
   return obj;
 }
 
-static VALUE proc_call(int argc, VALUE *argv, VALUE proc){
-  VALUE th = yarv_get_current_running_thread();
-  return thread_invoke_proc_call(th, proc, argc, argv);
+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(yarv_get_current_running_thread(), proc, argc, argv);
 }
 
 
@@ -663,9 +679,8 @@
 // VALUE yarv_Hash_each();
 VALUE insns_name_array();
 
-void Init_yarvcore(){
-  char opts[] = ""
-
+char yarv_version[0x20];
+char *yarv_options = ""
 #if   OPT_DIRECT_THREADED_CODE
     "[direct threaded code] "
 #elif OPT_TOKEN_THREADED_CODE
@@ -699,19 +714,21 @@
 #endif
       ;
 
+
+void Init_yarvcore(){
+
 #include "rev.inc"
 
-  char ver[0x20];
-  snprintf(ver, 0x20, "YARVCore %d.%d.%d", MAJOR_VER, MINOR_VER, DEVEL_VER);
+  snprintf(yarv_version, 0x20, "YARVCore %d.%d.%d", MAJOR_VER, MINOR_VER, DEVEL_VER);
   
   /* declare YARVCore module */
   mYarvCore = rb_define_module("YARVCore");
-  rb_define_const(mYarvCore, "VERSION", rb_str_new2(ver));
+  rb_define_const(mYarvCore, "VERSION", rb_str_new2(yarv_version));
   rb_define_const(mYarvCore, "MAJOR"  , INT2FIX(MAJOR_VER));
   rb_define_const(mYarvCore, "MINOR"  , INT2FIX(MINOR_VER));
   rb_define_const(mYarvCore, "REV"    , rb_str_new2(rev));
   rb_define_const(mYarvCore, "DATE"   , rb_str_new2(date));
-  rb_define_const(mYarvCore, "OPTS"   , rb_str_new2(opts));
+  rb_define_const(mYarvCore, "OPTS"   , rb_str_new2(yarv_options));
 
   /* YARVCore::USAGE_ANALISYS_* */
   rb_define_const(mYarvCore, "USAGE_ANALISYS_INSN", rb_hash_new());
@@ -724,7 +741,7 @@
   
   rb_define_singleton_method(mYarvCore, "eval" , yarvcore_eval , 3);
   rb_define_singleton_method(mYarvCore, "parse", yarvcore_parse, 3);
-  rb_define_singleton_method(mYarvCore, "eval_parsed", yarvcore_eval_parsed, 1);
+  rb_define_singleton_method(mYarvCore, "eval_iseq", yarvcore_eval_iseq, 1);
   
   
   /* declare YARVCore::InstructionSequence */
@@ -774,9 +791,11 @@
   /* Hash#each */
   // rb_define_method(rb_cHash,"each", yarv_Hash_each, 0);
 
+#if YARVEXT
   yarv_setup(yarv_yield_values, yarv_call0, yarv_block_given_p, yarv_load,
              yarv_svar, yarv_iterate, yarv_call_super, yarv_backtrace);
-
+#endif
+  
   symIFUNC = ID2SYM(rb_intern("<IFUNC>"));
   symCFUNC = ID2SYM(rb_intern("<CFUNC>"));
 
@@ -812,5 +831,19 @@
   Init_compiled();
 #endif
 
+  // make vm
+  {
+    VALUE vmval = rb_class_new_instance(0, 0, cYarvVM);
+    yarv_vm_t *vm;
+    yarv_thread_t *th;
+
+    yarvVM = vmval;
+    rb_global_variable(&yarvVM);
+    
+    GetVMVal(vmval, vm);
+    GetThreadVal(vm->main_thread, th);
+
+    yarv_set_current_running_thread(th);
+  }
 }
 

Modified: trunk/yarvcore.h
===================================================================
--- trunk/yarvcore.h	2005-08-13 17:07:54 UTC (rev 229)
+++ trunk/yarvcore.h	2005-08-14 16:03:58 UTC (rev 230)
@@ -6,9 +6,60 @@
 #ifndef _YARVCORE_H_INCLUDED_
 #define _YARVCORE_H_INCLUDED_
 
-#include "yarv_version.h"
 #include "debug.h"
 
+/*****************/
+/* configuration */
+/*****************/
+
+/* gcc ver. check */
+#if defined(__GNUC__) && __GNUC__ >= 2
+
+#ifdef OPT_TOKEN_THREADED_CODE
+#ifdef OPT_DIRECT_THREADED_CODE
+#undef OPT_DIRECT_THREADED_CODE
+#endif
+#endif
+
+#else
+
+/* disable threaded code options */
+#ifdef OPT_DIRECT_THREADED_CODE
+#undef OPT_DIRECT_THREADED_CODE
+#endif
+#ifdef OPT_TOKEN_THREADED_CODE
+#undef OPT_TOKEN_THREADED_CODE
+#endif
+#endif
+
+/* call threaded code */
+#ifdef OPT_CALL_THREADED_CODE
+#ifdef OPT_DIRECT_THREADED_CODE
+#undef OPT_DIRECT_THREADED_CODE
+#endif
+#ifdef OPT_STACK_CACHING
+#undef OPT_STACK_CACHING
+#endif
+#define YARV_AOT_COMPILED 1
+#endif
+
+/* likely */
+#ifdef __GCC__
+#define LIKELY(x)   (__builtin_expect(x, 1))
+#define UNLIKELY(x) (__builtin_expect(x, 0))
+#else
+#define LIKELY(x)   ((x) == 1)
+#define UNLIKELY(x) ((x) == 0)
+#endif
+
+#define YARVDEBUG 0
+#define CPDEBUG   0
+#define VMDEBUG   0
+#define GCDEBUG   0
+
+
+
+
 /* classes and modules */
 extern VALUE mYarvCore;
 extern VALUE cYarvISeq;
@@ -231,7 +282,8 @@
 
 typedef struct{
   VALUE self;
-  VALUE vm;
+  VALUE vm_value;
+  yarv_vm_t *vm;
   
   /* execution information */
   VALUE *stack;                   /* must free, must mark*/

Modified: trunk/yarvext/extconf.rb
===================================================================
--- trunk/yarvext/extconf.rb	2005-08-13 17:07:54 UTC (rev 229)
+++ trunk/yarvext/extconf.rb	2005-08-14 16:03:58 UTC (rev 230)
@@ -36,12 +36,12 @@
   raise "YARV requires ruby 1.9.0"
 end
 
-unless defined?(::YARV_PATCHED)
+require 'mkmf.rb'
+
+unless have_func("yarv_setup")
   raise "ruby should be applied yarv patch"
 end
 
-require 'mkmf.rb'
-
 # it's for debug
 CONFIG['LDSHARED'].sub!(/-s\b/, '')
 $opt_defs = []
@@ -91,6 +91,7 @@
 $cleanfiles += %w( *.inc ) - %w(vm_evalbody.inc call_cfunc.inc)
 
 $defs.concat $opt_defs
+$defs << '-DYARVEXT'
 
 puts
 puts "YARV options:"
@@ -103,7 +104,7 @@
 )
 
 #
-create_makefile('yarvcore', '../..')
+create_makefile('yarvcore', File.join(File.dirname(__FILE__), '..'))
 
 if macro_defined?("__GNUC__", "") && try_compile(<<-EOS, '-fno-crossjumping')
   int main(){

Modified: trunk/yarvext/test.rb
===================================================================
--- trunk/yarvext/test.rb	2005-08-13 17:07:54 UTC (rev 229)
+++ trunk/yarvext/test.rb	2005-08-14 16:03:58 UTC (rev 230)
@@ -8,14 +8,46 @@
 ###########################################################
 $prog =<<'__EOP__'
 
-def m a
-  p a
+def m a, b, &c
+  c.call(a, b)
 end
-m 1
 
+m(10, 20){|x, y|
+  [x+y, x*y]
+}
+
 __END__
 
+module Enumerable
+  def all_?
+    self.each{|e|
+      unless yield(e)
+        return false
+      end
+    }
+    true
+  end
+end
+GC.start
+100000.times{|x|
+  x.to_s
+}
+GC.start
 
+xxx = 0
+[1,2].each{|bi|
+  [3,4].each{|bj|
+    [true, nil, true].all_?{|be| be}
+    break
+  }
+  xxx += 1
+}
+xxx
+__END__
+
+__END__
+
+
 def m
   /a/ =~ 'a'
 end

Modified: trunk/yarvsubst.c
===================================================================
--- trunk/yarvsubst.c	2005-08-13 17:07:54 UTC (rev 229)
+++ trunk/yarvsubst.c	2005-08-14 16:03:58 UTC (rev 230)
@@ -23,7 +23,7 @@
 
     if(IS_YARV_WORKING()){
       /* yarv specific speedup tech */
-      VALUE th = yarv_get_current_running_thread();
+      VALUE th = yarv_get_current_running_thread_value();
       VALUE val;
       struct yarv_yield_data data;
       

Modified: trunk/yarvtest/test_flow.rb
===================================================================
--- trunk/yarvtest/test_flow.rb	2005-08-13 17:07:54 UTC (rev 229)
+++ trunk/yarvtest/test_flow.rb	2005-08-14 16:03:58 UTC (rev 230)
@@ -387,18 +387,45 @@
     }
     ae_flow %q{
       3.times{
+        class A
+          class B
+            break
+          end
+        end
+      }
+    }
+    ae_flow %q{
+      3.times{
         class C
           next
         end
       }
     }
     ae_flow %q{
+      3.times{
+        class C
+          class D
+            next
+          end
+        end
+      }
+    }
+    ae_flow %q{
       while true
         class C
           break
         end
       end
     }
+    ae_flow %q{
+      while true
+        class C
+          class D
+            break
+          end
+        end
+      end
+    }
   end
   
 end

Added: trunk/yarvtest/test_test.rb
===================================================================
--- trunk/yarvtest/test_test.rb	2005-08-13 17:07:54 UTC (rev 229)
+++ trunk/yarvtest/test_test.rb	2005-08-14 16:03:58 UTC (rev 230)
@@ -0,0 +1,7 @@
+require 'yarvtest/yarvtest'
+
+# test of syntax
+class TestTest < YarvTestBase
+  def test_1
+  end
+end


Property changes on: trunk/yarvtest/test_test.rb
___________________________________________________________________
Name: svn:executable
   + *

Modified: trunk/yarvtest/yarvtest.rb
===================================================================
--- trunk/yarvtest/yarvtest.rb	2005-08-13 17:07:54 UTC (rev 229)
+++ trunk/yarvtest/yarvtest.rb	2005-08-14 16:03:58 UTC (rev 230)
@@ -21,6 +21,7 @@
 
     ruby = YARVUtil.eval_in_wrap(str)
     yield if block_given?
+
     yarv = YARVUtil.eval(str)
     yield if block_given?
 


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

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