mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	avoid redundant GET_THREAD() calls
This reduces binary size slightly on my 32-bit system: text data bss dec hex filename 2847705 12360 30632 2890697 2c1bc9 ruby.orig 2847641 12360 30632 2890633 2c1b89 ruby * iseq.c (rb_iseq_compile_with_option): reuse result of previous GET_THREAD() call * thread.c (thread_create_core): ditto (rb_mutex_trylock): ditto (rb_mutex_lock): ditto * process.c (rb_waitpid): avoid multiple eval from RUBY_VM_CHECK_INTS * thread.c (rb_thread_check_ints): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									5d59a808ce
								
							
						
					
					
						commit
						4fd2443580
					
				
					 4 changed files with 20 additions and 7 deletions
				
			
		
							
								
								
									
										10
									
								
								ChangeLog
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								ChangeLog
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,3 +1,13 @@
 | 
			
		|||
Fri Jul 17 05:33:58 2015  Eric Wong  <e@80x24.org>
 | 
			
		||||
 | 
			
		||||
	* iseq.c (rb_iseq_compile_with_option): reuse result of previous
 | 
			
		||||
	  GET_THREAD() call
 | 
			
		||||
	* thread.c (thread_create_core): ditto
 | 
			
		||||
	  (rb_mutex_trylock): ditto
 | 
			
		||||
	  (rb_mutex_lock): ditto
 | 
			
		||||
	* process.c (rb_waitpid): avoid multiple eval from RUBY_VM_CHECK_INTS
 | 
			
		||||
	* thread.c (rb_thread_check_ints): ditto
 | 
			
		||||
 | 
			
		||||
Thu Jul 16 19:12:30 2015  Eric Wong  <e@80x24.org>
 | 
			
		||||
 | 
			
		||||
	* thread.c (mutex_alloc): remove needless volatile
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										2
									
								
								iseq.c
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								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 */
 | 
			
		||||
	    }
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -887,7 +887,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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										12
									
								
								thread.c
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								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");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue