* gc.c: added UNLIKELY to probes for optimization.

* vm.c: ditto.

* thread.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
yugui 2010-01-04 12:36:46 +00:00
Родитель 7e22f102a6
Коммит b80814c339
4 изменённых файлов: 19 добавлений и 11 удалений

Просмотреть файл

@ -1,3 +1,11 @@
Mon Jan 4 21:24:18 2010 Yuki Sonoda (Yugui) <yugui@yugui.jp>
* gc.c: added UNLIKELY to probes for optimization.
* vm.c: ditto.
* thread.c: ditto.
Mon Jan 4 09:30:54 2010 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/Makefile.sub (TRACING_MODEL): follow yugui's previous changes.

6
gc.c
Просмотреть файл

@ -1977,7 +1977,7 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
break;
}
if (TRACE_OBJECT_FREE_ENABLED()) FIRE_OBJECT_FREE(rb_obj_id(obj));
if (UNLIKELY(TRACE_OBJECT_FREE_ENABLED())) FIRE_OBJECT_FREE(rb_obj_id(obj));
if (FL_TEST(obj, FL_EXIVAR)) {
rb_free_generic_ivar((VALUE)obj);
@ -2159,7 +2159,7 @@ garbage_collect(rb_objspace_t *objspace)
during_gc++;
objspace->count++;
if (TRACE_GC_BEGIN_ENABLED()) FIRE_GC_BEGIN();
if (UNLIKELY(TRACE_GC_BEGIN_ENABLED())) FIRE_GC_BEGIN();
GC_PROF_TIMER_START;
GC_PROF_MARK_TIMER_START;
SET_STACK_END;
@ -2208,7 +2208,7 @@ garbage_collect(rb_objspace_t *objspace)
GC_PROF_SWEEP_TIMER_STOP;
GC_PROF_TIMER_STOP;
if (TRACE_GC_END_ENABLED()) FIRE_GC_END();
if (UNLIKELY(TRACE_GC_END_ENABLED())) FIRE_GC_END();
if (GC_NOTIFY) printf("end garbage_collect()\n");
return TRUE;
}

Просмотреть файл

@ -376,7 +376,7 @@ thread_cleanup_func(void *th_ptr)
{
rb_thread_t *th = th_ptr;
if (TRACE_THREAD_TERM_ENABLED()) FIRE_THREAD_TERM(th->self, rb_sourcefile(), rb_sourceline());
if (UNLIKELY(TRACE_THREAD_TERM_ENABLED())) FIRE_THREAD_TERM(th->self, rb_sourcefile(), rb_sourceline());
/* unlock all locking mutexes */
if (th->keeping_mutexes) {
@ -429,7 +429,7 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s
th->errinfo = Qnil;
th->local_lfp = proc->block.lfp;
th->local_svar = Qnil;
if (TRACE_THREAD_ENTER_ENABLED()) {
if (UNLIKELY(TRACE_THREAD_ENTER_ENABLED())) {
VALUE filename = proc->block.iseq->filename;
int lineno = proc->block.iseq->line_no;
FIRE_THREAD_ENTER(th->self, (TYPE(filename) == T_STRING ? RSTRING_PTR(filename) : 0), lineno);
@ -438,7 +438,7 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s
(int)RARRAY_LEN(args), RARRAY_PTR(args), 0);
}
else {
if (TRACE_THREAD_ENTER_ENABLED()) FIRE_THREAD_ENTER(th->self, 0, 0);
if (UNLIKELY(TRACE_THREAD_ENTER_ENABLED())) FIRE_THREAD_ENTER(th->self, 0, 0);
th->value = (*th->first_func)((void *)args);
}
});
@ -469,7 +469,7 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s
th->status = THREAD_KILLED;
thread_debug("thread end: %p\n", (void *)th);
if (TRACE_THREAD_LEAVE_ENABLED()) FIRE_THREAD_LEAVE(th->self, 0, 0);
if (UNLIKELY(TRACE_THREAD_LEAVE_ENABLED())) FIRE_THREAD_LEAVE(th->self, 0, 0);
main_th = th->vm->main_thread;
if (th != main_th) {
@ -542,7 +542,7 @@ thread_create_core(VALUE thval, VALUE args, VALUE (*fn)(ANYARGS))
native_mutex_initialize(&th->interrupt_lock);
/* kick thread */
st_insert(th->vm->living_threads, thval, (st_data_t) th->thread_id);
if (TRACE_THREAD_INIT_ENABLED()) FIRE_THREAD_INIT(th->self, rb_sourcefile(), rb_sourceline());
if (UNLIKELY(TRACE_THREAD_INIT_ENABLED())) FIRE_THREAD_INIT(th->self, rb_sourcefile(), rb_sourceline());
err = native_thread_create(th);
if (err) {
st_delete_wrap(th->vm->living_threads, th->self);
@ -992,7 +992,7 @@ rb_thread_schedule_rec(int sched_depth)
rb_thread_t *th = GET_THREAD();
thread_debug("rb_thread_schedule/switch start\n");
if (TRACE_THREAD_LEAVE_ENABLED()) FIRE_THREAD_LEAVE(th->self, rb_sourcefile(), rb_sourceline());
if (UNLIKELY(TRACE_THREAD_LEAVE_ENABLED())) FIRE_THREAD_LEAVE(th->self, rb_sourcefile(), rb_sourceline());
RB_GC_SAVE_MACHINE_CONTEXT(th);
native_mutex_unlock(&th->vm->global_vm_lock);
@ -1003,7 +1003,7 @@ rb_thread_schedule_rec(int sched_depth)
rb_thread_set_current(th);
thread_debug("rb_thread_schedule/switch done\n");
if (TRACE_THREAD_ENTER_ENABLED()) FIRE_THREAD_ENTER(th->self, rb_sourcefile(), rb_sourceline());
if (UNLIKELY(TRACE_THREAD_ENTER_ENABLED())) FIRE_THREAD_ENTER(th->self, rb_sourcefile(), rb_sourceline());
if (!sched_depth && UNLIKELY(GET_THREAD()->interrupt_flag)) {
rb_threadptr_execute_interrupts_rec(GET_THREAD(), sched_depth+1);

2
vm.c
Просмотреть файл

@ -2072,7 +2072,7 @@ Init_BareVM(void)
rb_thread_t * th = malloc(sizeof(*th));
if (!vm || !th) {
fprintf(stderr, "[FATAL] failed to allocate memory\n");
if (TRACE_RAISE_ENABLED()) FIRE_RAISE_FATAL();
if (UNLIKELY(TRACE_RAISE_ENABLED())) FIRE_RAISE_FATAL();
exit(EXIT_FAILURE);
}
MEMZERO(th, rb_thread_t, 1);