summaryrefslogtreecommitdiff
path: root/vm.c
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.c
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.c')
-rw-r--r--vm.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/vm.c b/vm.c
index 77a0659dd1..879814a14b 100644
--- a/vm.c
+++ b/vm.c
@@ -379,7 +379,26 @@ VALUE rb_block_param_proxy;
#define ruby_vm_redefined_flag GET_VM()->redefined_flag
VALUE ruby_vm_const_missing_count = 0;
rb_vm_t *ruby_current_vm_ptr = NULL;
+
+#ifdef RB_THREAD_LOCAL_SPECIFIER
+RB_THREAD_LOCAL_SPECIFIER rb_execution_context_t *ruby_current_ec;
+
+#ifdef __APPLE__
+ rb_execution_context_t *
+ rb_current_ec(void)
+ {
+ return ruby_current_ec;
+ }
+ void
+ rb_current_ec_set(rb_execution_context_t *ec)
+ {
+ ruby_current_ec = ec;
+ }
+#endif
+
+#else
native_tls_key_t ruby_current_ec_key;
+#endif
rb_event_flag_t ruby_vm_event_flags;
rb_event_flag_t ruby_vm_event_enabled_global_flags;