yarv-diff:401
From: ko1 atdot.net
Date: 18 Oct 2006 15:33:37 +0900
Subject: [yarv-diff:401] r568 - branches/parallel
Author: ko1
Date: 2006-10-18 15:33:36 +0900 (Wed, 18 Oct 2006)
New Revision: 568
Modified:
branches/parallel/ChangeLog
branches/parallel/eval_method.h
branches/parallel/gc.c
branches/parallel/re.c
branches/parallel/thread.c
branches/parallel/thread_pthread.h
Log:
* re.c : declare methods as thread safe
* eval_method.h : add lock version of method cache for evaluation
* gc.c : ditto (lock version of object allocation)
* thread_pthread.h : fix syntax error
Modified: branches/parallel/ChangeLog
===================================================================
--- branches/parallel/ChangeLog 2006-10-11 03:45:11 UTC (rev 567)
+++ branches/parallel/ChangeLog 2006-10-18 06:33:36 UTC (rev 568)
@@ -4,6 +4,17 @@
# from Mon, 03 May 2004 01:24:19 +0900
#
+2006-10-18(Wed) 15:30:58 +0900 Koichi Sasada <ko1 atdot.net>
+
+ * re.c : declare methods as thread safe
+
+ * eval_method.h : add lock version of method cache for evaluation
+
+ * gc.c : ditto (lock version of object allocation)
+
+ * thread_pthread.h : fix syntax error
+
+
2006-10-11(Wed) 12:43:52 +0900 Koichi Sasada <ko1 atdot.net>
* common.mk : fix bench-each rule
Modified: branches/parallel/eval_method.h
===================================================================
--- branches/parallel/eval_method.h 2006-10-11 03:45:11 UTC (rev 567)
+++ branches/parallel/eval_method.h 2006-10-18 06:33:36 UTC (rev 568)
@@ -268,11 +268,26 @@
NODE *
rb_method_node(VALUE klass, ID id)
{
+#if 1
NODE *ent = cache_entries[EXPR1(klass, id)];
if (ent &&
ent->nd_mid == id && ent->nd_klass == klass && ent->nd_method) {
return ent->nd_method;
}
+#else
+ /* w/lock */
+ NODE *ent = cache_entries[EXPR1(klass, id)];
+ NODE *m;
+
+ pthread_spin_lock(&mtlock);
+ if (ent &&
+ ent->nd_mid == id && ent->nd_klass == klass && ent->nd_method) {
+ m = ent->nd_method;
+ pthread_spin_unlock(&mtlock);
+ return m;
+ }
+ pthread_spin_unlock(&mtlock);
+#endif
return rb_get_method_body(klass, id, 0);
}
Modified: branches/parallel/gc.c
===================================================================
--- branches/parallel/gc.c 2006-10-11 03:45:11 UTC (rev 567)
+++ branches/parallel/gc.c 2006-10-18 06:33:36 UTC (rev 568)
@@ -527,8 +527,8 @@
VALUE
rb_newobj(void)
{
+ yarv_thread_t *th = GET_THREAD();
#if USE_VALUE_CACHE && 1
- yarv_thread_t *th = GET_THREAD();
VALUE v = *th->value_cache_ptr;
if (v) {
@@ -545,7 +545,16 @@
#endif
return v;
#else
- return rb_newobj_from_heap();
+ VALUE v;
+ int locked;
+
+ locked = rb_thread_global_lock_acquire(th);
+ v = rb_newobj_from_heap();
+ if (locked) {
+ rb_thread_global_lock_release(th);
+ }
+
+ return v;
#endif
}
Modified: branches/parallel/re.c
===================================================================
--- branches/parallel/re.c 2006-10-11 03:45:11 UTC (rev 567)
+++ branches/parallel/re.c 2006-10-18 06:33:36 UTC (rev 568)
@@ -2319,6 +2319,8 @@
#endif
#endif
+#define rb_define_method rb_define_method_ts
+
rb_define_virtual_variable("$~", match_getter, match_setter);
rb_define_virtual_variable("$&", last_match_getter, 0);
rb_define_virtual_variable("$`", prematch_getter, 0);
Modified: branches/parallel/thread.c
===================================================================
--- branches/parallel/thread.c 2006-10-11 03:45:11 UTC (rev 567)
+++ branches/parallel/thread.c 2006-10-18 06:33:36 UTC (rev 568)
@@ -1930,7 +1930,7 @@
}
#endif
-#if 0
+#if 1
#if CPU_LIMITATION_FUNCTION
{
static int prev_confilict;
@@ -1977,7 +1977,7 @@
#endif
#endif
-#if 1
+#if 0
{
static int prev_conflict;
static int cnt = 100;
Modified: branches/parallel/thread_pthread.h
===================================================================
--- branches/parallel/thread_pthread.h 2006-10-11 03:45:11 UTC (rev 567)
+++ branches/parallel/thread_pthread.h 2006-10-18 06:33:36 UTC (rev 568)
@@ -574,7 +574,9 @@
get_cpu_cnt(void)
{
int i;
- pthread_getaffinity_np(th, sizeof(cpu_set_t), &mask);
+ cpu_set_t mask;
+
+ pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &mask);
for (i=0; i<32; i++) {
if (!__CPU_ISSET(i, &mask)) {
break;
--
ML: yarv-diff quickml.atdot.net
Info: http://www.atdot.net/~ko1/quickml