summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2015-10-12 17:58:44 +0100
committerTom Hacohen <tom@stosb.com>2015-11-09 11:43:04 +0000
commit680388472e188a33fe12e12c54c32059aec6283d (patch)
tree083c34f2586137911e9c783426d54566ab56a67c
parentadbc534703347631ef7ba4027f80246224325f60 (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.
-rw-r--r--src/lib/eo/eo.c43
1 files changed, 16 insertions, 27 deletions
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index 2d9b760ed4..a3c9b74ce2 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
249 249
250typedef struct _Eo_Stack_Frame 250typedef struct _Eo_Stack_Frame
251{ 251{
252 const Eo *eo_id;
253 union { 252 union {
254 _Eo_Object *obj; 253 _Eo_Object *obj;
255 const _Eo_Class *kls; 254 const _Eo_Class *kls;
256 } o; 255 } o;
257 const _Eo_Class *cur_klass; 256 const _Eo_Class *cur_klass;
257 Eina_Bool is_obj : 1;
258} Eo_Stack_Frame; 258} Eo_Stack_Frame;
259 259
260#define EO_CALL_STACK_SIZE (EO_CALL_STACK_DEPTH_MIN * sizeof(Eo_Stack_Frame)) 260#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)
428 428
429static inline Eina_Bool 429static inline Eina_Bool
430_eo_do_internal(const Eo *eo_id, const Eo_Class *cur_klass_id, 430_eo_do_internal(const Eo *eo_id, const Eo_Class *cur_klass_id,
431 Eina_Bool is_super, Eo_Stack_Frame *fptr, Eo_Stack_Frame *pfptr) 431 Eina_Bool is_super, Eo_Stack_Frame *fptr)
432{ 432{
433 Eina_Bool is_klass = _eo_is_a_class(eo_id); 433 fptr->is_obj = !_eo_is_a_class(eo_id);
434 434
435 /* If we are already in the same object context, we inherit info from it. */ 435 /* If we are already in the same object context, we inherit info from it. */
436 if (pfptr) 436 if (!fptr->is_obj)
437 { 437 {
438 memcpy(fptr, pfptr, sizeof(Eo_Stack_Frame)); 438 EO_CLASS_POINTER_RETURN_VAL(eo_id, _klass, EINA_FALSE);
439 if (!is_klass) 439 fptr->o.kls = _klass;
440 _eo_ref(fptr->o.obj);
441 } 440 }
442 else 441 else
443 { 442 {
444 fptr->eo_id = eo_id; 443 EO_OBJ_POINTER_RETURN_VAL(eo_id, _obj, EINA_FALSE);
445 if (is_klass) 444 fptr->o.obj = _obj;
446 { 445 _eo_ref(_obj);
447 EO_CLASS_POINTER_RETURN_VAL(eo_id, _klass, EINA_FALSE);
448 fptr->o.kls = _klass;
449 }
450 else
451 {
452 EO_OBJ_POINTER_RETURN_VAL(eo_id, _obj, EINA_FALSE);
453 fptr->o.obj = _obj;
454 _eo_ref(_obj);
455 }
456 } 446 }
457 447
458 if (is_super) 448 if (is_super)
@@ -472,7 +462,7 @@ EAPI Eina_Bool
472_eo_do_start(const Eo *eo_id, const Eo_Class *cur_klass_id, Eina_Bool is_super, void *eo_stack) 462_eo_do_start(const Eo *eo_id, const Eo_Class *cur_klass_id, Eina_Bool is_super, void *eo_stack)
473{ 463{
474 Eina_Bool ret = EINA_TRUE; 464 Eina_Bool ret = EINA_TRUE;
475 Eo_Stack_Frame *fptr, *pfptr; 465 Eo_Stack_Frame *fptr;
476 Eo_Call_Stack *stack = eo_stack; 466 Eo_Call_Stack *stack = eo_stack;
477 467
478 if (stack->frame_ptr == stack->last_frame) 468 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,
480 470
481 fptr = stack->frame_ptr; 471 fptr = stack->frame_ptr;
482 472
483 pfptr = ((eo_id) && (fptr->eo_id == eo_id) ? fptr : NULL);
484 fptr++; 473 fptr++;
485 474
486 if (!_eo_do_internal(eo_id, cur_klass_id, is_super, fptr, pfptr)) 475 if (!_eo_do_internal(eo_id, cur_klass_id, is_super, fptr))
487 { 476 {
488 fptr->o.obj = NULL; 477 fptr->o.obj = NULL;
489 fptr->cur_klass = NULL; 478 fptr->cur_klass = NULL;
@@ -504,7 +493,7 @@ _eo_do_end(void *eo_stack)
504 493
505 fptr = stack->frame_ptr; 494 fptr = stack->frame_ptr;
506 495
507 if (!_eo_is_a_class(fptr->eo_id) && fptr->o.obj) 496 if (fptr->is_obj && fptr->o.obj)
508 _eo_unref(fptr->o.obj); 497 _eo_unref(fptr->o.obj);
509 498
510 stack->frame_ptr--; 499 stack->frame_ptr--;
@@ -526,7 +515,7 @@ _eo_call_resolve(const char *func_name, Eo_Op_Call_Data *call, Eo_Call_Cache *ca
526 if (EINA_UNLIKELY(!fptr->o.obj)) 515 if (EINA_UNLIKELY(!fptr->o.obj))
527 return EINA_FALSE; 516 return EINA_FALSE;
528 517
529 is_obj = !_eo_is_a_class(fptr->eo_id); 518 is_obj = fptr->is_obj;
530 519
531 inputklass = klass = (is_obj) ? fptr->o.obj->klass : fptr->o.kls; 520 inputklass = klass = (is_obj) ? fptr->o.obj->klass : fptr->o.kls;
532 521
@@ -566,7 +555,7 @@ _eo_call_resolve(const char *func_name, Eo_Op_Call_Data *call, Eo_Call_Cache *ca
566 call->func = func->func; 555 call->func = func->func;
567 if (is_obj) 556 if (is_obj)
568 { 557 {
569 call->obj = (Eo *)fptr->eo_id; 558 call->obj = (Eo *) fptr->o.obj->header.id;
570 call->data = (char *)fptr->o.obj + cache->off[i].off; 559 call->data = (char *)fptr->o.obj + cache->off[i].off;
571 } 560 }
572 else 561 else
@@ -591,7 +580,7 @@ _eo_call_resolve(const char *func_name, Eo_Op_Call_Data *call, Eo_Call_Cache *ca
591 580
592 if (is_obj) 581 if (is_obj)
593 { 582 {
594 call->obj = (Eo *)fptr->eo_id; 583 call->obj = (Eo *) fptr->o.obj->header.id;
595 call->data = _eo_data_scope_get(fptr->o.obj, func->src); 584 call->data = _eo_data_scope_get(fptr->o.obj, func->src);
596 } 585 }
597 else 586 else
@@ -908,7 +897,7 @@ _eo_add_internal_end(Eo *eo_id, Eo_Call_Stack *stack)
908 897
909 fptr = stack->frame_ptr; 898 fptr = stack->frame_ptr;
910 899
911 if ((fptr == NULL) || (eo_id && (fptr->eo_id != eo_id))) 900 if (fptr == NULL)
912 { 901 {
913 ERR("Something very wrong happend to the call stack."); 902 ERR("Something very wrong happend to the call stack.");
914 return NULL; 903 return NULL;