summaryrefslogtreecommitdiff
path: root/src
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 /src
parentb1e424d34eea2c2c06917841ae9d22686642c41c (diff)
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.
Diffstat (limited to 'src')
-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 0d9f269..5f93561 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;
252 252
253typedef struct _Eo_Stack_Frame 253typedef struct _Eo_Stack_Frame
254{ 254{
255 const Eo *eo_id;
256 union { 255 union {
257 _Eo_Object *obj; 256 _Eo_Object *obj;
258 const _Eo_Class *kls; 257 const _Eo_Class *kls;
259 } o; 258 } o;
260 const _Eo_Class *cur_klass; 259 const _Eo_Class *cur_klass;
260 Eina_Bool is_obj : 1;
261} Eo_Stack_Frame; 261} Eo_Stack_Frame;
262 262
263#define EO_CALL_STACK_SIZE (EO_CALL_STACK_DEPTH_MIN * sizeof(Eo_Stack_Frame)) 263#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)
431 431
432static inline Eina_Bool 432static inline Eina_Bool
433_eo_do_internal(const Eo *eo_id, const Eo_Class *cur_klass_id, 433_eo_do_internal(const Eo *eo_id, const Eo_Class *cur_klass_id,
434 Eina_Bool is_super, Eo_Stack_Frame *fptr, Eo_Stack_Frame *pfptr) 434 Eina_Bool is_super, Eo_Stack_Frame *fptr)
435{ 435{
436 Eina_Bool is_klass = _eo_is_a_class(eo_id); 436 fptr->is_obj = !_eo_is_a_class(eo_id);
437 437
438 /* If we are already in the same object context, we inherit info from it. */ 438 /* If we are already in the same object context, we inherit info from it. */
439 if (pfptr) 439 if (!fptr->is_obj)
440 { 440 {
441 memcpy(fptr, pfptr, sizeof(Eo_Stack_Frame)); 441 EO_CLASS_POINTER_RETURN_VAL(eo_id, _klass, EINA_FALSE);
442 if (!is_klass) 442 fptr->o.kls = _klass;
443 _eo_ref(fptr->o.obj);
444 } 443 }
445 else 444 else
446 { 445 {
447 fptr->eo_id = eo_id; 446 EO_OBJ_POINTER_RETURN_VAL(eo_id, _obj, EINA_FALSE);
448 if (is_klass) 447 fptr->o.obj = _obj;
449 { 448 _eo_ref(_obj);
450 EO_CLASS_POINTER_RETURN_VAL(eo_id, _klass, EINA_FALSE);
451 fptr->o.kls = _klass;
452 }
453 else
454 {
455 EO_OBJ_POINTER_RETURN_VAL(eo_id, _obj, EINA_FALSE);
456 fptr->o.obj = _obj;
457 _eo_ref(_obj);
458 }
459 } 449 }
460 450
461 if (is_super) 451 if (is_super)
@@ -475,7 +465,7 @@ EAPI Eina_Bool
475_eo_do_start(const Eo *eo_id, const Eo_Class *cur_klass_id, Eina_Bool is_super, void *eo_stack) 465_eo_do_start(const Eo *eo_id, const Eo_Class *cur_klass_id, Eina_Bool is_super, void *eo_stack)
476{ 466{
477 Eina_Bool ret = EINA_TRUE; 467 Eina_Bool ret = EINA_TRUE;
478 Eo_Stack_Frame *fptr, *pfptr; 468 Eo_Stack_Frame *fptr;
479 Eo_Call_Stack *stack = eo_stack; 469 Eo_Call_Stack *stack = eo_stack;
480 470
481 if (stack->frame_ptr == stack->last_frame) 471 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,
483 473
484 fptr = stack->frame_ptr; 474 fptr = stack->frame_ptr;
485 475
486 pfptr = ((eo_id) && (fptr->eo_id == eo_id) ? fptr : NULL);
487 fptr++; 476 fptr++;
488 477
489 if (!_eo_do_internal(eo_id, cur_klass_id, is_super, fptr, pfptr)) 478 if (!_eo_do_internal(eo_id, cur_klass_id, is_super, fptr))
490 { 479 {
491 fptr->o.obj = NULL; 480 fptr->o.obj = NULL;
492 fptr->cur_klass = NULL; 481 fptr->cur_klass = NULL;
@@ -507,7 +496,7 @@ _eo_do_end(void *eo_stack)
507 496
508 fptr = stack->frame_ptr; 497 fptr = stack->frame_ptr;
509 498
510 if (!_eo_is_a_class(fptr->eo_id) && fptr->o.obj) 499 if (fptr->is_obj && fptr->o.obj)
511 _eo_unref(fptr->o.obj); 500 _eo_unref(fptr->o.obj);
512 501
513 stack->frame_ptr--; 502 stack->frame_ptr--;
@@ -529,7 +518,7 @@ _eo_call_resolve(const char *func_name, const Eo_Op op, Eo_Op_Call_Data *call, c
529 if (EINA_UNLIKELY(!fptr->o.obj)) 518 if (EINA_UNLIKELY(!fptr->o.obj))
530 return EINA_FALSE; 519 return EINA_FALSE;
531 520
532 is_obj = !_eo_is_a_class(fptr->eo_id); 521 is_obj = fptr->is_obj;
533 522
534 klass = (is_obj) ? fptr->o.obj->klass : fptr->o.kls; 523 klass = (is_obj) ? fptr->o.obj->klass : fptr->o.kls;
535 524
@@ -567,7 +556,7 @@ _eo_call_resolve(const char *func_name, const Eo_Op op, Eo_Op_Call_Data *call, c
567 556
568 if (is_obj) 557 if (is_obj)
569 { 558 {
570 call->obj = (Eo *)fptr->eo_id; 559 call->obj = (Eo *) fptr->o.obj->header.id;
571 call->data = _eo_data_scope_get(fptr->o.obj, func->src); 560 call->data = _eo_data_scope_get(fptr->o.obj, func->src);
572 } 561 }
573 else 562 else
@@ -868,7 +857,7 @@ _eo_add_internal_end(Eo *eo_id, Eo_Call_Stack *stack)
868 857
869 fptr = stack->frame_ptr; 858 fptr = stack->frame_ptr;
870 859
871 if ((fptr == NULL) || (eo_id && (fptr->eo_id != eo_id))) 860 if (fptr == NULL)
872 { 861 {
873 ERR("Something very wrong happend to the call stack."); 862 ERR("Something very wrong happend to the call stack.");
874 return NULL; 863 return NULL;