summaryrefslogtreecommitdiff
path: root/vm_core.h
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2020-10-19 16:47:32 +0900
committerKoichi Sasada <ko1@atdot.net>2020-10-20 01:05:06 +0900
commit319afed20fba8f9b44611d16e4930260f7b56b86 (patch)
tree39d24da0464a39a2bfbc93f4ab5849945bc6f652 /vm_core.h
parent3f97940252a37db6e601b4bb1aa1e87204f769df (diff)
Use language TLS specifier if it is possible.
To access TLS, it is faster to use language TLS specifier instead of using pthread_get/setspecific functions. Original proposal is: Use native thread locals. #3665
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3667
Diffstat (limited to 'vm_core.h')
-rw-r--r--vm_core.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/vm_core.h b/vm_core.h
index 73b6be52f6..f644e8a6bc 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -1721,8 +1721,6 @@ RUBY_EXTERN rb_event_flag_t ruby_vm_event_flags;
RUBY_EXTERN rb_event_flag_t ruby_vm_event_enabled_global_flags;
RUBY_EXTERN unsigned int ruby_vm_event_local_num;
-RUBY_EXTERN native_tls_key_t ruby_current_ec_key;
-
RUBY_SYMBOL_EXPORT_END
#define GET_VM() rb_current_vm()
@@ -1764,7 +1762,15 @@ rb_ec_vm_ptr(const rb_execution_context_t *ec)
static inline rb_execution_context_t *
rb_current_execution_context(void)
{
+#ifdef RB_THREAD_LOCAL_SPECIFIER
+ #if __APPLE__
+ rb_execution_context_t *ec = rb_current_ec();
+ #else
+ rb_execution_context_t *ec = ruby_current_ec;
+ #endif
+#else
rb_execution_context_t *ec = native_tls_get(ruby_current_ec_key);
+#endif
VM_ASSERT(ec != NULL);
return ec;
}