summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2015-10-16 12:21:25 +0100
committerTom Hacohen <tom@stosb.com>2015-10-16 16:38:44 +0100
commit3ee44dcef0ed30c0095eb3d690db6bca8d2dd64f (patch)
tree29f077744e56d068f92105bfaace952423ab851b /src
parentb61556aa87ad134fe04fbdc8f953bd98d941a18e (diff)
Eo do: optimise getting the thread call stack for the main loop thread.
This may look like an insignificant change, but it doubles the speed of this function, and since this function is called so often, it actually improves my benchmarks by around 8%.
Diffstat (limited to 'src')
-rw-r--r--src/lib/eo/eo.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index 5f56dfa..7868d2a 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -375,12 +375,16 @@ _eo_call_stack_free(void *ptr)
375 free(stack); 375 free(stack);
376} 376}
377 377
378static Eo_Call_Stack *main_loop_stack = NULL;
379
380#define _EO_CALL_STACK_GET(is_main_loop) ((EINA_LIKELY(is_main_loop)) ? main_loop_stack : _eo_call_stack_get_thread())
381
378static inline Eo_Call_Stack * 382static inline Eo_Call_Stack *
379_eo_call_stack_get(Eina_Bool is_main_loop) 383_eo_call_stack_get_thread(void)
380{ 384{
381 static Eo_Call_Stack *main_loop_stack = NULL; 385 Eo_Call_Stack *stack;
382 Eo_Call_Stack *stack = is_main_loop ? 386
383 main_loop_stack : eina_tls_get(_eo_call_stack_key); 387 stack = eina_tls_get(_eo_call_stack_key);
384 388
385 if (stack) return stack; 389 if (stack) return stack;
386 390
@@ -391,11 +395,7 @@ _eo_call_stack_get(Eina_Bool is_main_loop)
391 return NULL; 395 return NULL;
392 } 396 }
393 397
394 if (is_main_loop) 398 if (!eina_tls_set(_eo_call_stack_key, stack))
395 {
396 main_loop_stack = stack;
397 }
398 else if (!eina_tls_set(_eo_call_stack_key, stack))
399 { 399 {
400 EINA_LOG_ERR("Could not set eo call stack in TLS key."); 400 EINA_LOG_ERR("Could not set eo call stack in TLS key.");
401 _eo_call_stack_free(stack); 401 _eo_call_stack_free(stack);
@@ -493,7 +493,7 @@ _eo_do_start(const Eo *eo_id, const Eo_Class *cur_klass_id, Eina_Bool is_super,
493{ 493{
494 Eina_Bool ret = EINA_TRUE; 494 Eina_Bool ret = EINA_TRUE;
495 Eo_Stack_Frame *fptr, *pfptr; 495 Eo_Stack_Frame *fptr, *pfptr;
496 Eo_Call_Stack *stack = _eo_call_stack_get(eina_main_loop_is()); 496 Eo_Call_Stack *stack = _EO_CALL_STACK_GET(eina_main_loop_is());
497 497
498 if (stack->frame_ptr == stack->last_frame) 498 if (stack->frame_ptr == stack->last_frame)
499 _eo_call_stack_resize(stack, EINA_TRUE); 499 _eo_call_stack_resize(stack, EINA_TRUE);
@@ -520,7 +520,7 @@ EAPI void
520_eo_do_end(void) 520_eo_do_end(void)
521{ 521{
522 Eo_Stack_Frame *fptr; 522 Eo_Stack_Frame *fptr;
523 Eo_Call_Stack *stack = _eo_call_stack_get(eina_main_loop_is()); // Is it possible to extract information from the scope ? 523 Eo_Call_Stack *stack = _EO_CALL_STACK_GET(eina_main_loop_is()); // Is it possible to extract information from the scope ?
524 524
525 fptr = stack->frame_ptr; 525 fptr = stack->frame_ptr;
526 526
@@ -549,7 +549,7 @@ _eo_call_resolve(const char *func_name, const Eo_Op op, Eo_Op_Call_Data *call, c
549 const op_type_funcs *func; 549 const op_type_funcs *func;
550 Eina_Bool is_obj; 550 Eina_Bool is_obj;
551 551
552 fptr = _eo_call_stack_get(eina_main_loop_is())->frame_ptr; 552 fptr = _EO_CALL_STACK_GET(eina_main_loop_is())->frame_ptr;
553 553
554 if (EINA_UNLIKELY(!fptr->o.obj)) 554 if (EINA_UNLIKELY(!fptr->o.obj))
555 return EINA_FALSE; 555 return EINA_FALSE;
@@ -898,7 +898,7 @@ static Eo *
898_eo_add_internal_end(Eo *eo_id) 898_eo_add_internal_end(Eo *eo_id)
899{ 899{
900 Eo_Stack_Frame *fptr; 900 Eo_Stack_Frame *fptr;
901 Eo_Call_Stack *stack = _eo_call_stack_get(eina_main_loop_is()); 901 Eo_Call_Stack *stack = _EO_CALL_STACK_GET(eina_main_loop_is());
902 902
903 fptr = stack->frame_ptr; 903 fptr = stack->frame_ptr;
904 904
@@ -1813,6 +1813,13 @@ eo_init(void)
1813 } 1813 }
1814 } 1814 }
1815 1815
1816 main_loop_stack = _eo_call_stack_create();
1817 if (!main_loop_stack)
1818 {
1819 EINA_LOG_ERR("Could not alloc eo call stack.");
1820 return EINA_FALSE;
1821 }
1822
1816 return EINA_TRUE; 1823 return EINA_TRUE;
1817} 1824}
1818 1825