raster pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=9ef9f2deb8b09eba0c6a432072dd0bb30abe2e87

commit 9ef9f2deb8b09eba0c6a432072dd0bb30abe2e87
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
Date:   Wed Oct 21 22:23:18 2015 +0900

    eo resolv cache - remove params passed to resolv func for efficiency
    
    we pass both the callcache and the op id - both are static and filled
    in at runtime, so merge them into the same struct. this should lead to
    better alignment/padding with the offset array and the next slot and
    op fields, probably saving about 4-8 bytes of rame per method with no
    downsides. also pass in only cache ptr, not both cache ptr and opid -
    less passing of stuff around and should be better.
---
 src/lib/eo/Eo.h | 18 ++++++++++--------
 src/lib/eo/eo.c | 41 ++++++++++++++++++++---------------------
 2 files changed, 30 insertions(+), 29 deletions(-)

diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
index 6f5e4bd..38b60c2 100644
--- a/src/lib/eo/Eo.h
+++ b/src/lib/eo/Eo.h
@@ -460,12 +460,15 @@ typedef struct _Eo_Call_Cache_Off
 
 typedef struct _Eo_Call_Cache
 {
+#if EO_CALL_CACHE_SIZE > 0
    Eo_Call_Cache_Index index[EO_CALL_CACHE_SIZE];
    Eo_Call_Cache_Entry entry[EO_CALL_CACHE_SIZE];
    Eo_Call_Cache_Off   off  [EO_CALL_CACHE_SIZE];
-#if EO_CALL_CACHE_SIZE > 1
-   int next_slot;
+# if EO_CALL_CACHE_SIZE > 1
+   int                 next_slot;
+# endif
 #endif
+   Eo_Op               op;
 } Eo_Call_Cache;
 
 // to pass the internal function call to EO_FUNC_BODY (as Func parameter)
@@ -479,12 +482,11 @@ typedef struct _Eo_Call_Cache
 
 // cache OP id, get real fct and object data then do the call
 #define EO_FUNC_COMMON_OP(Name, DefRet)                                 \
-     static Eo_Call_Cache ___callcache; /* static 0 by default */       \
-     static Eo_Op ___op; /* static 0 by default */                      \
+     static Eo_Call_Cache ___cache; /* static 0 by default */           \
      Eo_Op_Call_Data ___call;                                           \
-     if (___op == EO_NOOP)                                              \
-       ___op = _eo_api_op_id_get(EO_FUNC_COMMON_OP_FUNC(Name));         \
-     if (!_eo_call_resolve(#Name, ___op, &___call, &___callcache,       \
+     if (___cache.op == EO_NOOP)                                        \
+       ___cache.op = _eo_api_op_id_get(EO_FUNC_COMMON_OP_FUNC(Name));   \
+     if (!_eo_call_resolve(#Name, &___call, &___cache,                  \
                            __FILE__, __LINE__)) return DefRet;          \
      _Eo_##Name##_func _func_ = (_Eo_##Name##_func) ___call.func;       \
 
@@ -544,7 +546,7 @@ typedef struct _Eo_Call_Cache
 EAPI Eo_Op _eo_api_op_id_get(const void *api_func);
 
 // gets the real function pointer and the object data
-EAPI Eina_Bool _eo_call_resolve(const char *func_name, const Eo_Op op, 
Eo_Op_Call_Data *call, Eo_Call_Cache *callcache, const char *file, int line);
+EAPI Eina_Bool _eo_call_resolve(const char *func_name, Eo_Op_Call_Data *call, 
Eo_Call_Cache *callcache, 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, void *eo_stack);
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index b147ba5..af4a980 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -521,10 +521,8 @@ _eo_do_end(void *eo_stack)
      _eo_call_stack_resize(stack, EINA_FALSE);
 }
 
-#define EO_CALL_RESOLVE_CACHE 1
-
 EAPI Eina_Bool
-_eo_call_resolve(const char *func_name, const Eo_Op op, Eo_Op_Call_Data *call, 
Eo_Call_Cache *callcache, const char *file, int line)
+_eo_call_resolve(const char *func_name, Eo_Op_Call_Data *call, Eo_Call_Cache 
*cache, const char *file, int line)
 {
    Eo_Stack_Frame *fptr;
    const _Eo_Class *klass, *inputklass;
@@ -540,7 +538,7 @@ _eo_call_resolve(const char *func_name, const Eo_Op op, 
Eo_Op_Call_Data *call, E
 
    inputklass = klass = (is_obj) ? fptr->o.obj->klass : fptr->o.kls;
 
-   if (op == EO_NOOP)
+   if (cache->op == EO_NOOP)
      {
         ERR("%s:%d: unable to resolve %s api func '%s' in class '%s'.",
             file, line, (!is_obj ? "class" : "regular"),
@@ -549,7 +547,7 @@ _eo_call_resolve(const char *func_name, const Eo_Op op, 
Eo_Op_Call_Data *call, E
         return EINA_FALSE;
      }
 
-#ifdef EO_CALL_RESOLVE_CACHE
+# if EO_CALL_CACHE_SIZE > 0
    if (!fptr->cur_klass)
      {
 # if EO_CALL_CACHE_SIZE > 1
@@ -560,9 +558,9 @@ _eo_call_resolve(const char *func_name, const Eo_Op op, 
Eo_Op_Call_Data *call, E
         const int i = 0;
 # endif
           {
-             if ((const void *)inputklass == callcache->index[i].klass)
+             if ((const void *)inputklass == cache->index[i].klass)
                {
-                  func = (const op_type_funcs *)callcache->entry[i].func;
+                  func = (const op_type_funcs *)cache->entry[i].func;
                   call->func = func->func;
                   if (is_obj)
                     {
@@ -570,11 +568,11 @@ _eo_call_resolve(const char *func_name, const Eo_Op op, 
Eo_Op_Call_Data *call, E
                        if (func->src == fptr->o.obj->klass)
                          {
                             if (fptr->obj_data == EO_INVALID_DATA)
-                              fptr->obj_data = (char *)fptr->o.obj + 
callcache->off[i].off;
+                              fptr->obj_data = (char *)fptr->o.obj + 
cache->off[i].off;
                             call->data = fptr->obj_data;
                          }
                        else
-                         call->data = (char *)fptr->o.obj + 
callcache->off[i].off;
+                         call->data = (char *)fptr->o.obj + cache->off[i].off;
                     }
                   else
                     {
@@ -589,7 +587,7 @@ _eo_call_resolve(const char *func_name, const Eo_Op op, 
Eo_Op_Call_Data *call, E
    /* If we have a current class, we need to itr to the next. */
    if (fptr->cur_klass)
      {
-        func = _eo_kls_itr_next(klass, fptr->cur_klass, op);
+        func = _eo_kls_itr_next(klass, fptr->cur_klass, cache->op);
 
         if (!func)
           goto end;
@@ -598,7 +596,7 @@ _eo_call_resolve(const char *func_name, const Eo_Op op, 
Eo_Op_Call_Data *call, E
      }
    else
      {
-        func = _dich_func_get(klass, op);
+        func = _dich_func_get(klass, cache->op);
 
         if (!func)
           goto end;
@@ -626,19 +624,20 @@ _eo_call_resolve(const char *func_name, const Eo_Op op, 
Eo_Op_Call_Data *call, E
              call->data = NULL;
           }
 
-#ifdef EO_CALL_RESOLVE_CACHE
+# if EO_CALL_CACHE_SIZE > 0
+        #warning "blah"
         if (!fptr->cur_klass)
           {
 # if EO_CALL_CACHE_SIZE > 1
-             const int slot = callcache->next_slot;
+             const int slot = cache->next_slot;
 # else
              const int slot = 0;
 # endif
-             callcache->index[slot].klass = (const void *)inputklass;
-             callcache->entry[slot].func = (const void *)func;
-             callcache->off[slot].off = (int)((long)((char *)call->data - 
(char *)fptr->o.obj));
+             cache->index[slot].klass = (const void *)inputklass;
+             cache->entry[slot].func = (const void *)func;
+             cache->off[slot].off = (int)((long)((char *)call->data - (char 
*)fptr->o.obj));
 # if EO_CALL_CACHE_SIZE > 1
-             callcache->next_slot = (slot + 1) % EO_CALL_CACHE_SIZE;
+             cache->next_slot = (slot + 1) % EO_CALL_CACHE_SIZE;
 # endif
           }
 #endif
@@ -649,7 +648,7 @@ _eo_call_resolve(const char *func_name, const Eo_Op op, 
Eo_Op_Call_Data *call, E
    if (func->src != NULL)
      {
         ERR("in %s:%d: you called a pure virtual func '%s' (%d) of class 
'%s'.",
-            file, line, func_name, op, klass->desc->name);
+            file, line, func_name, cache->op, klass->desc->name);
         return EINA_FALSE;
      }
 
@@ -667,7 +666,7 @@ end:
              if (!emb_obj)
                continue;
 
-             func = _dich_func_get(emb_obj->klass, op);
+             func = _dich_func_get(emb_obj->klass, cache->op);
              if (func == NULL)
                continue;
 
@@ -690,14 +689,14 @@ end:
         if (fptr->cur_klass)
           {
              ERR("in %s:%d: func '%s' (%d) could not be resolved for class 
'%s' for super of '%s'.",
-                 file, line, func_name, op, main_klass->desc->name,
+                 file, line, func_name, cache->op, main_klass->desc->name,
                  fptr->cur_klass->desc->name);
           }
         else
           {
              /* we should not be able to take this branch */
              ERR("in %s:%d: func '%s' (%d) could not be resolved for class 
'%s'.",
-                 file, line, func_name, op, main_klass->desc->name);
+                 file, line, func_name, cache->op, main_klass->desc->name);
           }
      }
    return EINA_FALSE;

-- 


Reply via email to