tasn pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=07ea62419aa0d871780bf4c3f6e1b0782f9f413a

commit 07ea62419aa0d871780bf4c3f6e1b0782f9f413a
Author: Tom Hacohen <t...@stosb.com>
Date:   Fri Oct 16 16:23:48 2015 +0100

    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.
---
 src/lib/eo/Eo.h | 21 ++++++++++++---------
 src/lib/eo/eo.c | 27 ++++++++++++++++-----------
 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);
 EAPI Eina_Bool _eo_call_resolve(const char *func_name, const Eo_Op op, 
Eo_Op_Call_Data *call, const char *file, int line);
 
 // start of eo_do barrier, gets the object pointer and ref it, put it on the 
stask
-  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);
+  EAPI Eina_Bool _eo_do_start(const Eo *obj, const Eo_Class *cur_klass, 
Eina_Bool is_super, void *eo_stack);
 
 // end of the eo_do barrier, unref the obj, move the stack pointer
-EAPI void _eo_do_end(void);
+EAPI void _eo_do_end(void *eo_stack);
 
 // end of the eo_add. Calls finalize among others
-EAPI Eo * _eo_add_end(void);
+EAPI Eo * _eo_add_end(void *eo_stack);
+
+// XXX: We cheat and make it const to indicate to the compiler that the value 
never changes
+EAPI EINA_CONST void *_eo_stack_get(void);
 
 // eo object method calls batch,
 
 #define _eo_do_common(eoid, clsid, is_super, ...)                       \
   do {                                                                  \
-       _eo_do_start(eoid, clsid, is_super, __FILE__, __FUNCTION__, __LINE__); \
+       _eo_do_start(eoid, clsid, is_super, _eo_stack_get()); \
        __VA_ARGS__;                                                     \
-       _eo_do_end();                                                    \
+       _eo_do_end(_eo_stack_get());                                            
        \
   } while (0)
 
 #define _eo_do_common_ret(eoid, clsid, is_super, ret_tmp, func)      \
   (                                                                     \
-       _eo_do_start(eoid, clsid, is_super, __FILE__, __FUNCTION__, __LINE__), \
+       _eo_do_start(eoid, clsid, is_super, _eo_stack_get()), \
        ret_tmp = func,                                                  \
-       _eo_do_end(),                                                    \
+       _eo_do_end(_eo_stack_get()),                                            
        \
        ret_tmp                                                          \
   )
 
@@ -595,9 +598,9 @@ EAPI const Eo_Class *eo_class_get(const Eo *obj);
 #define _eo_add_common(klass, parent, is_ref, ...) \
    ( \
      _eo_do_start(_eo_add_internal_start(__FILE__, __LINE__, klass, parent, 
is_ref), \
-        klass, EINA_FALSE, __FILE__, __FUNCTION__, __LINE__) \
+        klass, EINA_FALSE, _eo_stack_get()) \
      , ##__VA_ARGS__, \
-     (Eo *) _eo_add_end() \
+     (Eo *) _eo_add_end(_eo_stack_get()) \
    )
 
 /**
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)
 
 static Eo_Call_Stack *main_loop_stack = NULL;
 
-#define _EO_CALL_STACK_GET(is_main_loop) ((EINA_LIKELY(is_main_loop)) ? 
main_loop_stack : _eo_call_stack_get_thread())
+#define _EO_CALL_STACK_GET() ((EINA_LIKELY(eina_main_loop_is())) ? 
main_loop_stack : _eo_call_stack_get_thread())
 
 static inline Eo_Call_Stack *
 _eo_call_stack_get_thread(void)
@@ -405,6 +405,12 @@ _eo_call_stack_get_thread(void)
    return stack;
 }
 
+EAPI EINA_CONST void *
+_eo_stack_get(void)
+{
+   return _EO_CALL_STACK_GET();
+}
+
 static inline void
 _eo_call_stack_resize(Eo_Call_Stack *stack, Eina_Bool grow)
 {
@@ -489,11 +495,11 @@ _eo_do_internal(const Eo *eo_id, const Eo_Class 
*cur_klass_id,
 }
 
 EAPI Eina_Bool
-_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)
+_eo_do_start(const Eo *eo_id, const Eo_Class *cur_klass_id, Eina_Bool 
is_super, void *eo_stack)
 {
    Eina_Bool ret = EINA_TRUE;
    Eo_Stack_Frame *fptr, *pfptr;
-   Eo_Call_Stack *stack = _EO_CALL_STACK_GET(eina_main_loop_is());
+   Eo_Call_Stack *stack = eo_stack;
 
    if (stack->frame_ptr == stack->last_frame)
      _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,
 }
 
 EAPI void
-_eo_do_end(void)
+_eo_do_end(void *eo_stack)
 {
    Eo_Stack_Frame *fptr;
-   Eo_Call_Stack *stack = _EO_CALL_STACK_GET(eina_main_loop_is()); // Is it 
possible to extract information from the scope ?
+   Eo_Call_Stack *stack = eo_stack;
 
    fptr = stack->frame_ptr;
 
@@ -549,7 +555,7 @@ _eo_call_resolve(const char *func_name, const Eo_Op op, 
Eo_Op_Call_Data *call, c
    const op_type_funcs *func;
    Eina_Bool is_obj;
 
-   fptr = _EO_CALL_STACK_GET(eina_main_loop_is())->frame_ptr;
+   fptr = _EO_CALL_STACK_GET()->frame_ptr;
 
    if (EINA_UNLIKELY(!fptr->o.obj))
       return EINA_FALSE;
@@ -895,10 +901,9 @@ _eo_add_internal_start(const char *file, int line, const 
Eo_Class *klass_id, Eo
 }
 
 static Eo *
-_eo_add_internal_end(Eo *eo_id)
+_eo_add_internal_end(Eo *eo_id, Eo_Call_Stack *stack)
 {
    Eo_Stack_Frame *fptr;
-   Eo_Call_Stack *stack = _EO_CALL_STACK_GET(eina_main_loop_is());
 
    fptr = stack->frame_ptr;
 
@@ -955,11 +960,11 @@ cleanup:
 }
 
 EAPI Eo *
-_eo_add_end(void)
+_eo_add_end(void *eo_stack)
 {
    Eo *ret = eo_finalize();
-   ret = _eo_add_internal_end(ret);
-   _eo_do_end();
+   ret = _eo_add_internal_end(ret, eo_stack);
+   _eo_do_end(eo_stack);
    return ret;
 }
 

-- 


Reply via email to