summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2015-10-12 17:58:44 +0100
committerTom Hacohen <tom@stosb.com>2015-10-19 10:22:41 +0100
commitdffa54876b008af1e7a811b5d0b8377caecc5eaa (patch)
tree1181967b13ebe83898506a46d7266a49eeff59b1
parentb1e424d34eea2c2c06917841ae9d22686642c41c (diff)
downloadefl-dffa54876b008af1e7a811b5d0b8377caecc5eaa.tar.gz
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.
-rw-r--r--src/lib/eo/eo.c41
1 files changed, 15 insertions, 26 deletions
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index 0d9f269083..5f9356195b 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -252,12 +252,12 @@ EAPI Eo_Hook_Call eo_hook_call_post = NULL;
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))
@@ -431,31 +431,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)
@@ -475,7 +465,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)
@@ -483,10 +473,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;
@@ -507,7 +496,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--;
@@ -529,7 +518,7 @@ _eo_call_resolve(const char *func_name, const Eo_Op op, Eo_Op_Call_Data *call, c
if (EINA_UNLIKELY(!fptr->o.obj))
return EINA_FALSE;
- is_obj = !_eo_is_a_class(fptr->eo_id);
+ is_obj = fptr->is_obj;
klass = (is_obj) ? fptr->o.obj->klass : fptr->o.kls;
@@ -567,7 +556,7 @@ _eo_call_resolve(const char *func_name, const Eo_Op op, Eo_Op_Call_Data *call, c
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
@@ -868,7 +857,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;