tasn pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=680388472e188a33fe12e12c54c32059aec6283d

commit 680388472e188a33fe12e12c54c32059aec6283d
Author: Tom Hacohen <t...@stosb.com>
Date:   Mon Oct 12 17:58:44 2015 +0100

    Eo: Reduce call stack memory footprint.
    
    We don't really need the eo_id most of the time, and when we do, it's
    very easy to get it. It's better if we just don't save the eo_id on the
    stack, and just save if it's an object or a class instead.
---
 src/lib/eo/eo.c | 43 ++++++++++++++++---------------------------
 1 file changed, 16 insertions(+), 27 deletions(-)

diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index 2d9b760..a3c9b74 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -249,12 +249,12 @@ _eo_kls_itr_next(const _Eo_Class *orig_kls, const 
_Eo_Class *cur_klass, Eo_Op op
 
 typedef struct _Eo_Stack_Frame
 {
-   const Eo          *eo_id;
    union {
         _Eo_Object        *obj;
         const _Eo_Class   *kls;
    } o;
    const _Eo_Class   *cur_klass;
+   Eina_Bool is_obj : 1;
 } Eo_Stack_Frame;
 
 #define EO_CALL_STACK_SIZE (EO_CALL_STACK_DEPTH_MIN * sizeof(Eo_Stack_Frame))
@@ -428,31 +428,21 @@ _eo_call_stack_resize(Eo_Call_Stack *stack, Eina_Bool 
grow)
 
 static inline Eina_Bool
 _eo_do_internal(const Eo *eo_id, const Eo_Class *cur_klass_id,
-                Eina_Bool is_super, Eo_Stack_Frame *fptr, Eo_Stack_Frame 
*pfptr)
+                Eina_Bool is_super, Eo_Stack_Frame *fptr)
 {
-   Eina_Bool is_klass = _eo_is_a_class(eo_id);
+   fptr->is_obj = !_eo_is_a_class(eo_id);
 
    /* If we are already in the same object context, we inherit info from it. */
-   if (pfptr)
+   if (!fptr->is_obj)
      {
-        memcpy(fptr, pfptr, sizeof(Eo_Stack_Frame));
-        if (!is_klass)
-          _eo_ref(fptr->o.obj);
+        EO_CLASS_POINTER_RETURN_VAL(eo_id, _klass, EINA_FALSE);
+        fptr->o.kls = _klass;
      }
    else
      {
-        fptr->eo_id = eo_id;
-        if (is_klass)
-          {
-             EO_CLASS_POINTER_RETURN_VAL(eo_id, _klass, EINA_FALSE);
-             fptr->o.kls = _klass;
-          }
-        else
-          {
-             EO_OBJ_POINTER_RETURN_VAL(eo_id, _obj, EINA_FALSE);
-             fptr->o.obj = _obj;
-             _eo_ref(_obj);
-          }
+        EO_OBJ_POINTER_RETURN_VAL(eo_id, _obj, EINA_FALSE);
+        fptr->o.obj = _obj;
+        _eo_ref(_obj);
      }
 
    if (is_super)
@@ -472,7 +462,7 @@ EAPI Eina_Bool
 _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_Stack_Frame *fptr;
    Eo_Call_Stack *stack = eo_stack;
 
    if (stack->frame_ptr == stack->last_frame)
@@ -480,10 +470,9 @@ _eo_do_start(const Eo *eo_id, const Eo_Class 
*cur_klass_id, Eina_Bool is_super,
 
    fptr = stack->frame_ptr;
 
-   pfptr = ((eo_id) && (fptr->eo_id == eo_id) ? fptr : NULL);
    fptr++;
 
-   if (!_eo_do_internal(eo_id, cur_klass_id, is_super, fptr, pfptr))
+   if (!_eo_do_internal(eo_id, cur_klass_id, is_super, fptr))
      {
         fptr->o.obj = NULL;
         fptr->cur_klass = NULL;
@@ -504,7 +493,7 @@ _eo_do_end(void *eo_stack)
 
    fptr = stack->frame_ptr;
 
-   if (!_eo_is_a_class(fptr->eo_id) && fptr->o.obj)
+   if (fptr->is_obj && fptr->o.obj)
      _eo_unref(fptr->o.obj);
 
    stack->frame_ptr--;
@@ -526,7 +515,7 @@ _eo_call_resolve(const char *func_name, Eo_Op_Call_Data 
*call, Eo_Call_Cache *ca
    if (EINA_UNLIKELY(!fptr->o.obj))
       return EINA_FALSE;
 
-   is_obj = !_eo_is_a_class(fptr->eo_id);
+   is_obj = fptr->is_obj;
 
    inputklass = klass = (is_obj) ? fptr->o.obj->klass : fptr->o.kls;
 
@@ -566,7 +555,7 @@ _eo_call_resolve(const char *func_name, Eo_Op_Call_Data 
*call, Eo_Call_Cache *ca
                   call->func = func->func;
                   if (is_obj)
                     {
-                       call->obj = (Eo *)fptr->eo_id;
+                       call->obj = (Eo *) fptr->o.obj->header.id;
                        call->data = (char *)fptr->o.obj + cache->off[i].off;
                     }
                   else
@@ -591,7 +580,7 @@ _eo_call_resolve(const char *func_name, Eo_Op_Call_Data 
*call, Eo_Call_Cache *ca
 
         if (is_obj)
           {
-             call->obj = (Eo *)fptr->eo_id;
+             call->obj = (Eo *) fptr->o.obj->header.id;
              call->data = _eo_data_scope_get(fptr->o.obj, func->src);
           }
         else
@@ -908,7 +897,7 @@ _eo_add_internal_end(Eo *eo_id, Eo_Call_Stack *stack)
 
    fptr = stack->frame_ptr;
 
-   if ((fptr == NULL) || (eo_id && (fptr->eo_id != eo_id)))
+   if (fptr == NULL)
      {
         ERR("Something very wrong happend to the call stack.");
         return NULL;

-- 


Reply via email to