summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2015-10-16 16:23:48 +0100
committerTom Hacohen <tom@stosb.com>2015-10-16 16:38:46 +0100
commit07ea62419aa0d871780bf4c3f6e1b0782f9f413a (patch)
tree030e12d81b8f824fdfd6d2cf7a1c9cc67ee0a638 /src
parent3ee44dcef0ed30c0095eb3d690db6bca8d2dd64f (diff)
Eo do: Reuse stack fetching across eo functions.
This causes a significant speed up (around 10% here) and is definitely worth it. The way it's done lets the compiler cache the value across different eo_do calls, and across the parts of eo_do. Start and end. This breaks ABI.
Diffstat (limited to 'src')
-rw-r--r--src/lib/eo/Eo.h21
-rw-r--r--src/lib/eo/eo.c27
2 files changed, 28 insertions, 20 deletions
diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
index a50a327..6ddc238 100644
--- a/src/lib/eo/Eo.h
+++ b/src/lib/eo/Eo.h
@@ -540,28 +540,31 @@ EAPI Eo_Op _eo_api_op_id_get(const void *api_func);
540EAPI Eina_Bool _eo_call_resolve(const char *func_name, const Eo_Op op, Eo_Op_Call_Data *call, const char *file, int line); 540EAPI Eina_Bool _eo_call_resolve(const char *func_name, const Eo_Op op, Eo_Op_Call_Data *call, const char *file, int line);
541 541
542// start of eo_do barrier, gets the object pointer and ref it, put it on the stask 542// start of eo_do barrier, gets the object pointer and ref it, put it on the stask
543 EAPI Eina_Bool _eo_do_start(const Eo *obj, const Eo_Class *cur_klass, Eina_Bool is_super, const char *file, const char *func, int line); 543 EAPI Eina_Bool _eo_do_start(const Eo *obj, const Eo_Class *cur_klass, Eina_Bool is_super, void *eo_stack);
544 544
545// end of the eo_do barrier, unref the obj, move the stack pointer 545// end of the eo_do barrier, unref the obj, move the stack pointer
546EAPI void _eo_do_end(void); 546EAPI void _eo_do_end(void *eo_stack);
547 547
548// end of the eo_add. Calls finalize among others 548// end of the eo_add. Calls finalize among others
549EAPI Eo * _eo_add_end(void); 549EAPI Eo * _eo_add_end(void *eo_stack);
550
551// XXX: We cheat and make it const to indicate to the compiler that the value never changes
552EAPI EINA_CONST void *_eo_stack_get(void);
550 553
551// eo object method calls batch, 554// eo object method calls batch,
552 555
553#define _eo_do_common(eoid, clsid, is_super, ...) \ 556#define _eo_do_common(eoid, clsid, is_super, ...) \
554 do { \ 557 do { \
555 _eo_do_start(eoid, clsid, is_super, __FILE__, __FUNCTION__, __LINE__); \ 558 _eo_do_start(eoid, clsid, is_super, _eo_stack_get()); \
556 __VA_ARGS__; \ 559 __VA_ARGS__; \
557 _eo_do_end(); \ 560 _eo_do_end(_eo_stack_get()); \
558 } while (0) 561 } while (0)
559 562
560#define _eo_do_common_ret(eoid, clsid, is_super, ret_tmp, func) \ 563#define _eo_do_common_ret(eoid, clsid, is_super, ret_tmp, func) \
561 ( \ 564 ( \
562 _eo_do_start(eoid, clsid, is_super, __FILE__, __FUNCTION__, __LINE__), \ 565 _eo_do_start(eoid, clsid, is_super, _eo_stack_get()), \
563 ret_tmp = func, \ 566 ret_tmp = func, \
564 _eo_do_end(), \ 567 _eo_do_end(_eo_stack_get()), \
565 ret_tmp \ 568 ret_tmp \
566 ) 569 )
567 570
@@ -595,9 +598,9 @@ EAPI const Eo_Class *eo_class_get(const Eo *obj);
595#define _eo_add_common(klass, parent, is_ref, ...) \ 598#define _eo_add_common(klass, parent, is_ref, ...) \
596 ( \ 599 ( \
597 _eo_do_start(_eo_add_internal_start(__FILE__, __LINE__, klass, parent, is_ref), \ 600 _eo_do_start(_eo_add_internal_start(__FILE__, __LINE__, klass, parent, is_ref), \
598 klass, EINA_FALSE, __FILE__, __FUNCTION__, __LINE__) \ 601 klass, EINA_FALSE, _eo_stack_get()) \
599 , ##__VA_ARGS__, \ 602 , ##__VA_ARGS__, \
600 (Eo *) _eo_add_end() \ 603 (Eo *) _eo_add_end(_eo_stack_get()) \
601 ) 604 )
602 605
603/** 606/**
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index 7868d2a..27073f6 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -377,7 +377,7 @@ _eo_call_stack_free(void *ptr)
377 377
378static Eo_Call_Stack *main_loop_stack = NULL; 378static Eo_Call_Stack *main_loop_stack = NULL;
379 379
380#define _EO_CALL_STACK_GET(is_main_loop) ((EINA_LIKELY(is_main_loop)) ? main_loop_stack : _eo_call_stack_get_thread()) 380#define _EO_CALL_STACK_GET() ((EINA_LIKELY(eina_main_loop_is())) ? main_loop_stack : _eo_call_stack_get_thread())
381 381
382static inline Eo_Call_Stack * 382static inline Eo_Call_Stack *
383_eo_call_stack_get_thread(void) 383_eo_call_stack_get_thread(void)
@@ -405,6 +405,12 @@ _eo_call_stack_get_thread(void)
405 return stack; 405 return stack;
406} 406}
407 407
408EAPI EINA_CONST void *
409_eo_stack_get(void)
410{
411 return _EO_CALL_STACK_GET();
412}
413
408static inline void 414static inline void
409_eo_call_stack_resize(Eo_Call_Stack *stack, Eina_Bool grow) 415_eo_call_stack_resize(Eo_Call_Stack *stack, Eina_Bool grow)
410{ 416{
@@ -489,11 +495,11 @@ _eo_do_internal(const Eo *eo_id, const Eo_Class *cur_klass_id,
489} 495}
490 496
491EAPI Eina_Bool 497EAPI Eina_Bool
492_eo_do_start(const Eo *eo_id, const Eo_Class *cur_klass_id, Eina_Bool is_super, const char *file EINA_UNUSED, const char *func EINA_UNUSED, int line EINA_UNUSED) 498_eo_do_start(const Eo *eo_id, const Eo_Class *cur_klass_id, Eina_Bool is_super, void *eo_stack)
493{ 499{
494 Eina_Bool ret = EINA_TRUE; 500 Eina_Bool ret = EINA_TRUE;
495 Eo_Stack_Frame *fptr, *pfptr; 501 Eo_Stack_Frame *fptr, *pfptr;
496 Eo_Call_Stack *stack = _EO_CALL_STACK_GET(eina_main_loop_is()); 502 Eo_Call_Stack *stack = eo_stack;
497 503
498 if (stack->frame_ptr == stack->last_frame) 504 if (stack->frame_ptr == stack->last_frame)
499 _eo_call_stack_resize(stack, EINA_TRUE); 505 _eo_call_stack_resize(stack, EINA_TRUE);
@@ -517,10 +523,10 @@ _eo_do_start(const Eo *eo_id, const Eo_Class *cur_klass_id, Eina_Bool is_super,
517} 523}
518 524
519EAPI void 525EAPI void
520_eo_do_end(void) 526_eo_do_end(void *eo_stack)
521{ 527{
522 Eo_Stack_Frame *fptr; 528 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 ? 529 Eo_Call_Stack *stack = eo_stack;
524 530
525 fptr = stack->frame_ptr; 531 fptr = stack->frame_ptr;
526 532
@@ -549,7 +555,7 @@ _eo_call_resolve(const char *func_name, const Eo_Op op, Eo_Op_Call_Data *call, c
549 const op_type_funcs *func; 555 const op_type_funcs *func;
550 Eina_Bool is_obj; 556 Eina_Bool is_obj;
551 557
552 fptr = _EO_CALL_STACK_GET(eina_main_loop_is())->frame_ptr; 558 fptr = _EO_CALL_STACK_GET()->frame_ptr;
553 559
554 if (EINA_UNLIKELY(!fptr->o.obj)) 560 if (EINA_UNLIKELY(!fptr->o.obj))
555 return EINA_FALSE; 561 return EINA_FALSE;
@@ -895,10 +901,9 @@ _eo_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo
895} 901}
896 902
897static Eo * 903static Eo *
898_eo_add_internal_end(Eo *eo_id) 904_eo_add_internal_end(Eo *eo_id, Eo_Call_Stack *stack)
899{ 905{
900 Eo_Stack_Frame *fptr; 906 Eo_Stack_Frame *fptr;
901 Eo_Call_Stack *stack = _EO_CALL_STACK_GET(eina_main_loop_is());
902 907
903 fptr = stack->frame_ptr; 908 fptr = stack->frame_ptr;
904 909
@@ -955,11 +960,11 @@ cleanup:
955} 960}
956 961
957EAPI Eo * 962EAPI Eo *
958_eo_add_end(void) 963_eo_add_end(void *eo_stack)
959{ 964{
960 Eo *ret = eo_finalize(); 965 Eo *ret = eo_finalize();
961 ret = _eo_add_internal_end(ret); 966 ret = _eo_add_internal_end(ret, eo_stack);
962 _eo_do_end(); 967 _eo_do_end(eo_stack);
963 return ret; 968 return ret;
964} 969}
965 970