dumping ground for random patches and texts
 help / color / mirror / Atom feed
* [PATCH 1/2] avoid redundant GET_THREAD() calls
@ 2015-07-16 20:23 Eric Wong
  2015-07-16 20:23 ` [PATCH 2/2] remove enumerator requires Eric Wong
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Wong @ 2015-07-16 20:23 UTC (permalink / raw)
  To: spew

This reduces binary size slightly but can do even more we enable
OPT_CALL_CFUNC_WITHOUT_FRAME
---
 iseq.c    |  2 +-
 process.c |  3 ++-
 thread.c  | 12 +++++++-----
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/iseq.c b/iseq.c
index a42eae8..b9eb034 100644
--- a/iseq.c
+++ b/iseq.c
@@ -568,7 +568,7 @@ rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE absolute_path, VALUE li
 	    node = rb_parser_compile_string_path(parser, file, src, ln);
 
 	    if (!node) {
-		rb_exc_raise(GET_THREAD()->errinfo);	/* TODO: check err */
+		rb_exc_raise(th->errinfo);	/* TODO: check err */
 	    }
 	}
 
diff --git a/process.c b/process.c
index ac72463..8b583f4 100644
--- a/process.c
+++ b/process.c
@@ -876,7 +876,8 @@ rb_waitpid(rb_pid_t pid, int *st, int flags)
 							 RUBY_UBF_PROCESS, 0);
     if (result < 0) {
 	if (errno == EINTR) {
-            RUBY_VM_CHECK_INTS(GET_THREAD());
+            rb_thread_t *th = GET_THREAD();
+            RUBY_VM_CHECK_INTS(th);
             goto retry;
         }
 	return (rb_pid_t)-1;
diff --git a/thread.c b/thread.c
index 95b022f..1e16eb1 100644
--- a/thread.c
+++ b/thread.c
@@ -670,7 +670,7 @@ thread_create_core(VALUE thval, VALUE args, VALUE (*fn)(ANYARGS))
     rb_thread_t *th, *current_th = GET_THREAD();
     int err;
 
-    if (OBJ_FROZEN(GET_THREAD()->thgroup)) {
+    if (OBJ_FROZEN(current_th->thgroup)) {
 	rb_raise(rb_eThreadError,
 		 "can't start a new thread (frozen ThreadGroup)");
     }
@@ -1173,7 +1173,8 @@ rb_thread_wait_for(struct timeval time)
 void
 rb_thread_check_ints(void)
 {
-    RUBY_VM_CHECK_INTS_BLOCKING(GET_THREAD());
+    rb_thread_t *th = GET_THREAD();
+    RUBY_VM_CHECK_INTS_BLOCKING(th);
 }
 
 /*
@@ -4258,10 +4259,11 @@ rb_mutex_trylock(VALUE self)
 
     native_mutex_lock(&mutex->lock);
     if (mutex->th == 0) {
-	mutex->th = GET_THREAD();
+	rb_thread_t *th = GET_THREAD();
+	mutex->th = th;
 	locked = Qtrue;
 
-	mutex_locked(GET_THREAD(), self);
+	mutex_locked(th, self);
     }
     native_mutex_unlock(&mutex->lock);
 
@@ -4345,7 +4347,7 @@ rb_mutex_lock(VALUE self)
     }
 
     if (rb_mutex_trylock(self) == Qfalse) {
-	if (mutex->th == GET_THREAD()) {
+	if (mutex->th == th) {
 	    rb_raise(rb_eThreadError, "deadlock; recursive locking");
 	}
 
-- 
EW


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] remove enumerator requires
  2015-07-16 20:23 [PATCH 1/2] avoid redundant GET_THREAD() calls Eric Wong
@ 2015-07-16 20:23 ` Eric Wong
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Wong @ 2015-07-16 20:23 UTC (permalink / raw)
  To: spew

---
 lib/rinda/tuplespace.rb        | 1 -
 test/pathname/test_pathname.rb | 1 -
 2 files changed, 2 deletions(-)

diff --git a/lib/rinda/tuplespace.rb b/lib/rinda/tuplespace.rb
index 11532fd..14cae9e 100644
--- a/lib/rinda/tuplespace.rb
+++ b/lib/rinda/tuplespace.rb
@@ -2,7 +2,6 @@ require 'monitor'
 require 'thread'
 require 'drb/drb'
 require 'rinda/rinda'
-require 'enumerator'
 require 'forwardable'
 
 module Rinda
diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb
index b012633..94f0e36 100644
--- a/test/pathname/test_pathname.rb
+++ b/test/pathname/test_pathname.rb
@@ -3,7 +3,6 @@ require 'pathname'
 
 require 'fileutils'
 require 'tmpdir'
-require 'enumerator'
 
 
 class TestPathname < Test::Unit::TestCase
-- 
EW


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-07-16 20:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-16 20:23 [PATCH 1/2] avoid redundant GET_THREAD() calls Eric Wong
2015-07-16 20:23 ` [PATCH 2/2] remove enumerator requires Eric Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).