From 0f0311df0a31fce8ceab3ef9dffead0c67629dbe Mon Sep 17 00:00:00 2001 From: normal Date: Wed, 16 May 2018 21:54:42 +0000 Subject: thread: reduce GET_THREAD calls This allows native_sleep to use less stack (80 -> 64 bytes on x86-64) for GVL_UNLOCK_BEGIN/END. For future APIs, we will pass `ec` or `th` around anyways, so the BLOCKING_REGION change should be beneficial in the future. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63448 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- thread_win32.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'thread_win32.c') diff --git a/thread_win32.c b/thread_win32.c index ab308905cb..3c6d0e7369 100644 --- a/thread_win32.c +++ b/thread_win32.c @@ -210,8 +210,9 @@ int rb_w32_wait_events(HANDLE *events, int num, DWORD timeout) { int ret; + rb_thread_t *th = GET_THREAD(); - BLOCKING_REGION(ret = rb_w32_wait_events_blocking(events, num, timeout), + BLOCKING_REGION(th, ret = rb_w32_wait_events_blocking(events, num, timeout), ubf_handle, ruby_thread_from_native(), FALSE); return ret; } @@ -264,8 +265,9 @@ int WINAPI rb_w32_Sleep(unsigned long msec) { int ret; + rb_thread_t *th = GET_THREAD(); - BLOCKING_REGION(ret = rb_w32_sleep(msec), + BLOCKING_REGION(th, ret = rb_w32_sleep(msec), ubf_handle, ruby_thread_from_native(), FALSE); return ret; } @@ -276,7 +278,7 @@ native_sleep(rb_thread_t *th, struct timespec *ts) const volatile DWORD msec = (ts) ? (DWORD)(ts->tv_sec * 1000 + ts->tv_nsec / 1000000) : INFINITE; - GVL_UNLOCK_BEGIN(); + GVL_UNLOCK_BEGIN(th); { DWORD ret; @@ -299,7 +301,7 @@ native_sleep(rb_thread_t *th, struct timespec *ts) th->unblock.arg = 0; rb_native_mutex_unlock(&th->interrupt_lock); } - GVL_UNLOCK_END(); + GVL_UNLOCK_END(th); } void -- cgit v1.2.3