From 319afed20fba8f9b44611d16e4930260f7b56b86 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Mon, 19 Oct 2020 16:47:32 +0900 Subject: 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 --- vm.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'vm.c') 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; -- cgit v1.2.3