yarv-diff:110
From: ko1 atdot.net
Date: 29 Sep 2005 14:01:53 -0000
Subject: [yarv-diff:110] r266 - trunk
Author: ko1
Date: 2005-09-29 23:01:52 +0900 (Thu, 29 Sep 2005)
New Revision: 266
Modified:
trunk/ChangeLog
trunk/eval_intern.h
trunk/eval_thread.c
trunk/test.rb
trunk/yarvcore.c
trunk/yarvcore.h
Log:
* eval_intern.h, eval_thread.c : move thread_status to eval_intern.h
* yarvcore.c : fix thread/vm value
* yarvcore.h : add some parameter to yarv_thread_t
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2005-09-28 16:55:22 UTC (rev 265)
+++ trunk/ChangeLog 2005-09-29 14:01:52 UTC (rev 266)
@@ -4,6 +4,15 @@
# from Mon, 03 May 2004 01:24:19 +0900
#
+2005-09-29(Thu) 22:43:08 +0900 Koichi Sasada <ko1 atdot.net>
+
+ * eval_intern.h, eval_thread.c : move thread_status to eval_intern.h
+
+ * yarvcore.c : fix thread/vm value
+
+ * yarvcore.h : add some parameter to yarv_thread_t
+
+
2005-09-29(Thu) 01:52:33 +0900 Koichi Sasada <ko1 atdot.net>
* compile.c, yarvcore.h : add line number on last end instruction
Modified: trunk/eval_intern.h
===================================================================
--- trunk/eval_intern.h 2005-09-28 16:55:22 UTC (rev 265)
+++ trunk/eval_intern.h 2005-09-29 14:01:52 UTC (rev 266)
@@ -260,6 +260,13 @@
#define SCOPE_SET(f) (scope_vmode=(f))
#define SCOPE_TEST(f) (scope_vmode&(f))
+enum thread_status {
+ THREAD_TO_KILL,
+ THREAD_RUNNABLE,
+ THREAD_STOPPED,
+ THREAD_KILLED,
+};
+
struct ruby_env {
struct ruby_env *prev;
struct FRAME *frame;
Modified: trunk/eval_thread.c
===================================================================
--- trunk/eval_thread.c 2005-09-28 16:55:22 UTC (rev 265)
+++ trunk/eval_thread.c 2005-09-29 14:01:52 UTC (rev 266)
@@ -94,13 +94,6 @@
extern VALUE rb_last_status;
-enum thread_status {
- THREAD_TO_KILL,
- THREAD_RUNNABLE,
- THREAD_STOPPED,
- THREAD_KILLED,
-};
-
#define WAIT_FD (1<<0)
#define WAIT_SELECT (1<<1)
#define WAIT_TIME (1<<2)
Modified: trunk/test.rb
===================================================================
--- trunk/test.rb 2005-09-28 16:55:22 UTC (rev 265)
+++ trunk/test.rb 2005-09-29 14:01:52 UTC (rev 266)
@@ -1,10 +1,9 @@
-def m
-end
-while true
- m
-end
+p YARVCore::VM::Thread.new{
+
+}
+
__END__
require 'test_req'
Modified: trunk/yarvcore.c
===================================================================
--- trunk/yarvcore.c 2005-09-28 16:55:22 UTC (rev 265)
+++ trunk/yarvcore.c 2005-09-29 14:01:52 UTC (rev 266)
@@ -81,14 +81,14 @@
void yarv_setup(void *p1, void *p2, void *p3, void *p4,
void *p5, void *p6, void *p7, void *p8);
-
static yarv_thread_t *yarvCurrentRunningThread = 0;
-static VALUE yarvVM = Qnil;
+static yarv_vm_t *theYarvVM = 0;
+static VALUE yarvVMArray = Qnil;
VALUE
yarv_get_current_running_vm_value()
{
- return yarvCurrentRunningThread->vm_value;
+ return theYarvVM->self;
}
VALUE
@@ -100,7 +100,7 @@
yarv_vm_t *
yarv_get_current_running_vm()
{
- return yarvCurrentRunningThread->vm;
+ return theYarvVM;
}
yarv_thread_t *
@@ -273,13 +273,10 @@
static VALUE
yarvcore_eval_iseq(VALUE iseq)
{
- volatile VALUE vm;
+ VALUE vm;
VALUE ret;
vm = yarv_get_current_running_vm_value();
-
- SET_YARV_START();
ret = vm_eval(vm, iseq);
- SET_YARV_STOP();
return ret;
}
@@ -550,13 +547,9 @@
static VALUE vm_init(VALUE self, VALUE node){
/* allocate vm stack */
- yarv_vm_t *vmobj;
- VALUE argv[1];
- GetVMVal(self, vmobj);
-
- argv[0] = self;
- vmobj->main_thread = rb_class_new_instance(1, argv, cYarvThread);
- vmobj->self = self;
+ yarv_vm_t *vm;
+ GetVMVal(self, vm);
+ vm->self = self;
return self;
}
@@ -644,20 +637,20 @@
}
static VALUE
-thread_init(VALUE self, VALUE vmval)
+thread_init(VALUE self)
{
yarv_thread_t *th;
yarv_vm_t *vm;
-
+ VALUE vmval = yarv_get_current_running_vm_value();
+
GetThreadVal(self, th);
GetVMVal(vmval, vm);
-
+
th_init(th);
th->self = self;
-
+
th->vm_value = vmval;
th->vm = vm;
-
return self;
}
@@ -787,8 +780,6 @@
return Qnil;
}
-VALUE constant_pool_pool;
-
VALUE yarv_Array_each();
VALUE yarv_Integer_times();
// VALUE yarv_Hash_each();
@@ -850,7 +841,6 @@
rb_define_const(mYarvCore, "USAGE_ANALISYS_REGS", rb_hash_new());
rb_define_const(mYarvCore, "USAGE_ANALISYS_INSN_BIGRAM", rb_hash_new());
-
/* YARVCore::InsnNameArray */
rb_define_const(mYarvCore, "InsnNameArray", insns_name_array());
@@ -858,7 +848,6 @@
rb_define_singleton_method(mYarvCore, "parse", yarvcore_parse, 3);
rb_define_singleton_method(mYarvCore, "eval_iseq", yarvcore_eval_iseq, 1);
-
/* declare YARVCore::InstructionSequence */
cYarvISeq = rb_define_class_under(mYarvCore, "InstructionSequence", rb_cObject);
rb_define_alloc_func(cYarvISeq, iseq_alloc);
@@ -877,9 +866,11 @@
/* declare YARVCore::VM::Thread */
cYarvThread = rb_define_class_under(cYarvVM, "Thread", rb_cObject);
rb_define_alloc_func(cYarvThread, thread_alloc);
- rb_define_method(cYarvThread, "initialize", thread_init, 1);
+ rb_define_method(cYarvThread, "initialize", thread_init, 0);
rb_define_method(cYarvThread, "eval", thread_eval, 1);
-
+
+ // rb_define_singleton_method(cYarvThread, "new", rb_thread_s_new, -2);
+
/* declare YARVCore::VM::Env */
cYarvEnv = rb_define_class_under(cYarvVM, "Env", rb_cObject);
rb_define_alloc_func(cYarvEnv, env_alloc);
@@ -939,27 +930,34 @@
idThrowBackDFP = rb_intern("#__ThrowBackDFP__");
idThrowObject = rb_intern("#__ThrowObject__");
- constant_pool_pool = rb_ary_new();
- rb_global_variable(&constant_pool_pool);
-
#if TEST_AOT_COMPILE
Init_compiled();
#endif
// make vm
{
+ /* create vm object */
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);
+ theYarvVM = vm;
+
+ yarvVMArray = rb_ary_new();
+ rb_global_variable(&yarvVMArray);
+ rb_ary_push(yarvVMArray, vm->self);
+
+ /* create main thread */
+ vm->main_thread = rb_class_new_instance(0, 0, cYarvThread);
GetThreadVal(vm->main_thread, th);
thread_free(GET_THREAD());
yarv_set_current_running_thread(th);
+
+ /*
+ * set toplevel binding
+ */
+
}
}
Modified: trunk/yarvcore.h
===================================================================
--- trunk/yarvcore.h 2005-09-28 16:55:22 UTC (rev 265)
+++ trunk/yarvcore.h 2005-09-29 14:01:52 UTC (rev 266)
@@ -9,6 +9,15 @@
#include "debug.h"
#include "vm_opts.h"
+#ifdef HAVE_PTHREAD_H
+#include <pthread.h>
+typedef pthread_t yarv_thread_id_t;
+typedef pthread_mutex_t yarv_thread_lock_t;
+#else
+typedef int yarv_thread_id_t;
+typedef
+#endif /* _SAFE_THREAD */
+
/*****************/
/* configuration */
/*****************/
@@ -313,6 +322,13 @@
ID *base_local_tbl;
int base_local_size;
yarv_block_t *base_block;
+
+ /* thread control */
+ yarv_thread_id_t *thread_id;
+ VALUE value;
+ int status;
+ yarv_thread_lock_t global_interpreter_lock;
+
} yarv_thread_t;
/** node -> yarv instruction sequence object */
--
ML: yarv-diff quickml.atdot.net
Info: http://www.atdot.net/~ko1/quickml