summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/benchmarks/eo/eo_bench.c4
-rw-r--r--src/benchmarks/eo/eo_bench_eo_do.c46
-rw-r--r--src/lib/eo/Eo.h44
-rw-r--r--src/lib/eo/eo.c882
4 files changed, 515 insertions, 461 deletions
diff --git a/src/benchmarks/eo/eo_bench.c b/src/benchmarks/eo/eo_bench.c
index 3b6584e2b1..5836c64a5b 100644
--- a/src/benchmarks/eo/eo_bench.c
+++ b/src/benchmarks/eo/eo_bench.c
@@ -20,8 +20,8 @@ struct _Eina_Benchmark_Case
static const Eina_Benchmark_Case etc[] = {
{ "eo_do", eo_bench_eo_do },
- { "eo_add", eo_bench_eo_add },
- { "eo_callbacks", eo_bench_callbacks },
+ /* { "eo_add", eo_bench_eo_add }, */
+ /* { "eo_callbacks", eo_bench_callbacks }, */
{ NULL, NULL }
};
diff --git a/src/benchmarks/eo/eo_bench_eo_do.c b/src/benchmarks/eo/eo_bench_eo_do.c
index 0c15b716b2..7045d2aeb4 100644
--- a/src/benchmarks/eo/eo_bench_eo_do.c
+++ b/src/benchmarks/eo/eo_bench_eo_do.c
@@ -20,6 +20,34 @@ bench_eo_do_simple(int request)
}
static void
+bench_eo_do_multi_simple(int request)
+{
+ int i;
+ Eo *obj = eo_add(SIMPLE_CLASS, NULL);
+ for (i = 0 ; i < request ; i++)
+ {
+ eo_do(obj, simple_a_set(i) // 1
+ ;simple_a_set(i) // 2
+ ;simple_a_set(i) // 3
+ ;simple_a_set(i) // 4
+ ;simple_a_set(i) // 5
+ /* ;simple_a_set(i) // 6 */
+ /* ;simple_a_set(i) // 7 */
+ /* ;simple_a_set(i) // 8 */
+ /* ;simple_a_set(i) // 9 */
+ /* ;simple_a_set(i) // 10 */
+ /* ;simple_a_set(i) // 11 */
+ /* ;simple_a_set(i) // 12 */
+ /* ;simple_a_set(i) // 13 */
+ /* ;simple_a_set(i) // 14 */
+ /* ;simple_a_set(i) // 15 */
+ );
+ }
+
+ eo_unref(obj);
+}
+
+static void
bench_eo_do_two_objs(int request)
{
int i;
@@ -91,12 +119,14 @@ bench_eo_do_super(int request)
void eo_bench_eo_do(Eina_Benchmark *bench)
{
- eina_benchmark_register(bench, "simple",
- EINA_BENCHMARK(bench_eo_do_simple), _EO_BENCH_TIMES(1000, 10, 500000));
- eina_benchmark_register(bench, "super",
- EINA_BENCHMARK(bench_eo_do_super), _EO_BENCH_TIMES(1000, 10, 500000));
- eina_benchmark_register(bench, "two_objs",
- EINA_BENCHMARK(bench_eo_do_two_objs), _EO_BENCH_TIMES(1000, 10, 500000));
- eina_benchmark_register(bench, "two_objs_growing_stack",
- EINA_BENCHMARK(bench_eo_do_two_objs_growing_stack), _EO_BENCH_TIMES(1000, 10, 40000));
+ /* eina_benchmark_register(bench, "simple", */
+ /* EINA_BENCHMARK(bench_eo_do_simple), _EO_BENCH_TIMES(1000, 10, 500000)); */
+ eina_benchmark_register(bench, "simple_multi",
+ EINA_BENCHMARK(bench_eo_do_multi_simple), _EO_BENCH_TIMES(1000, 10, 500000));
+ /* eina_benchmark_register(bench, "super", */
+ /* EINA_BENCHMARK(bench_eo_do_super), _EO_BENCH_TIMES(1000, 10, 500000)); */
+ /* eina_benchmark_register(bench, "two_objs", */
+ /* EINA_BENCHMARK(bench_eo_do_two_objs), _EO_BENCH_TIMES(1000, 10, 500000)); */
+ /* eina_benchmark_register(bench, "two_objs_growing_stack", */
+ /* EINA_BENCHMARK(bench_eo_do_two_objs_growing_stack), _EO_BENCH_TIMES(1000, 10, 40000)); */
}
diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
index 3ff7b8bf20..046f4e463b 100644
--- a/src/lib/eo/Eo.h
+++ b/src/lib/eo/Eo.h
@@ -489,7 +489,7 @@ typedef struct _Eo_Call_Cache
___cache.op = _eo_api_op_id_get(EO_FUNC_COMMON_OP_FUNC(_EO_##Name)); \
if (___cache.op == EO_NOOP) return DefRet; \
} \
- if (!_eo_call_resolve(#Name, &___call, &___cache, eo_stack, \
+ if (!_eo_call_resolve(#Name, &___call, &___cache, (Eo*)eo_stack, \
__FILE__, __LINE__)) return DefRet; \
_Eo_##Name##_func _func_ = (_Eo_##Name##_func) ___call.func; \
@@ -549,37 +549,37 @@ 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, Eo_Op_Call_Data *call, Eo_Call_Cache *cache, void *eo_stack, const char *file, int line);
+EAPI Eina_Bool _eo_call_resolve(const char *func_name, Eo_Op_Call_Data *call, Eo_Call_Cache *cache, Eo* eo_stack, 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);
+// // 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);
-// end of the eo_do barrier, unref the obj, move the stack pointer
-EAPI void _eo_do_end(void *eo_stack);
+// // end of the eo_do barrier, unref the obj, move the stack pointer
+// EAPI void _eo_do_end(void *eo_stack);
-// end of the eo_add. Calls finalize among others
-EAPI Eo * _eo_add_end(void *eo_stack);
+// // end of the eo_add. Calls finalize among others
+// EAPI Eo * _eo_add_end(void *eo_stack);
-// XXX: We cheat and make it const to indicate to the compiler that the value never changes
-EAPI EINA_CONST void *_eo_stack_get(void);
+// // XXX: We cheat and make it const to indicate to the compiler that the value never changes
+// EAPI EINA_CONST void *_eo_stack_get(void);
// eo object method calls batch,
#define _eo_do_common(eoid, clsid, is_super, ...) \
do { \
- void *__eo_ctx = _eo_stack_get(); \
+ Eo *__eo_ctx = eoid; \
(void)__eo_ctx; \
- _eo_do_start(eoid, clsid, is_super, _eo_stack_get()); \
+ /*_eo_do_start(eoid, clsid, is_super, _eo_stack_get());*/ \
__VA_ARGS__; \
- _eo_do_end(_eo_stack_get()); \
+ /*_eo_do_end(_eo_stack_get());*/ \
} while (0)
#define _eo_do_common_ret(eoid, clsid, is_super, ret_tmp, func) \
({ \
- void *__eo_ctx = _eo_stack_get(); \
- _eo_do_start(eoid, clsid, is_super, _eo_stack_get()), \
+ void *__eo_ctx = eoid; \
+ /*_eo_do_start(eoid, clsid, is_super, _eo_stack_get()),*/ \
ret_tmp = func, \
- _eo_do_end(_eo_stack_get()), \
+ /*_eo_do_end(_eo_stack_get()),*/ \
ret_tmp; \
})
@@ -612,11 +612,13 @@ EAPI const Eo_Class *eo_class_get(const Eo *obj);
#define _eo_add_common(klass, parent, is_ref, ...) \
({ \
- void *__eo_ctx = _eo_stack_get(); (void) __eo_ctx; \
- _eo_do_start(_eo_add_internal_start(__FILE__, __LINE__, klass, parent, is_ref), \
- klass, EINA_FALSE, _eo_stack_get()) \
- , ##__VA_ARGS__, \
- (Eo *) _eo_add_end(_eo_stack_get()); \
+ /*void *__eo_ctx = _eo_stack_get(); (void) __eo_ctx;*/ \
+ Eo* __eo_ctx = _eo_add_internal_start(__FILE__, __LINE__, klass, parent, is_ref); \
+ /*_eo_do_start(_eo_add_internal_start(__FILE__, __LINE__, klass, parent, is_ref), \
+ klass, EINA_FALSE, _eo_stack_get())*/ \
+ __VA_ARGS__; \
+ /*(Eo *) _eo_add_end(_eo_stack_get());*/ \
+ __eo_ctx; \
})
/**
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index e76f4398c7..af2b7288ca 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -246,340 +246,362 @@ _eo_kls_itr_next(const _Eo_Class *orig_kls, const _Eo_Class *cur_klass, Eo_Op op
return NULL;
}
-/************************************ EO ************************************/
+/* /\************************************ EO ************************************\/ */
+
+/* // 1024 entries == 16k or 32k (32 or 64bit) for eo call stack. that's 1023 */
+/* // imbricated/recursive calls it can handle before barfing. i'd say that's ok */
+/* #define EO_CALL_STACK_DEPTH_MIN 1024 */
+/* #define EO_CALL_STACK_SHRINK_DROP (EO_CALL_STACK_DEPTH_MIN >> 1) */
+
+/* typedef struct _Eo_Stack_Frame */
+/* { */
+/* 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)) */
+
+/* static Eina_TLS _eo_call_stack_key = 0; */
+
+/* typedef struct _Eo_Call_Stack { */
+/* Eo_Stack_Frame *frames; */
+/* Eo_Stack_Frame *frame_ptr; */
+/* Eo_Stack_Frame *last_frame; */
+/* Eo_Stack_Frame *shrink_frame; */
+/* } Eo_Call_Stack; */
+
+/* #define MEM_PAGE_SIZE 4096 */
+
+/* static void * */
+/* _eo_call_stack_mem_alloc(size_t size) */
+/* { */
+/* #ifdef HAVE_MMAP */
+/* // allocate eo call stack via mmped anon segment if on linux - more */
+/* // secure and safe. also gives page aligned memory allowing madvise */
+/* void *ptr; */
+/* size_t newsize; */
+/* newsize = MEM_PAGE_SIZE * ((size + MEM_PAGE_SIZE - 1) / */
+/* MEM_PAGE_SIZE); */
+/* ptr = mmap(NULL, newsize, PROT_READ | PROT_WRITE, */
+/* MAP_PRIVATE | MAP_ANON, -1, 0); */
+/* if (ptr == MAP_FAILED) */
+/* { */
+/* ERR("eo call stack mmap failed."); */
+/* return NULL; */
+/* } */
+/* return ptr; */
+/* #else */
+/* //in regular cases just use malloc */
+/* return calloc(1, size); */
+/* #endif */
+/* } */
+
+/* #ifdef HAVE_MMAP */
+/* static void */
+/* _eo_call_stack_mem_resize(void **ptr EINA_UNUSED, size_t newsize, size_t size) */
+/* { */
+/* if (newsize > size) */
+/* { */
+/* CRI("eo call stack overflow, abort."); */
+/* abort(); */
+/* } */
+/* return; // Do nothing, code for actual implementation in history. See commit message for details. */
+/* #else */
+/* static void */
+/* _eo_call_stack_mem_resize(void **ptr, size_t newsize, size_t size EINA_UNUSED) */
+/* { */
+/* *ptr = realloc(*ptr, newsize); */
+/* if (!*ptr) */
+/* { */
+/* CRI("eo call stack resize failed, abort."); */
+/* abort(); */
+/* } */
+/* #endif */
+/* } */
+
+/* #ifdef HAVE_MMAP */
+/* static void */
+/* _eo_call_stack_mem_free(void *ptr, size_t size) */
+/* { */
+/* // free mmaped memory */
+/* munmap(ptr, size); */
+/* #else */
+/* static void */
+/* _eo_call_stack_mem_free(void *ptr, size_t size EINA_UNUSED) */
+/* { */
+/* // free regular memory */
+/* free(ptr); */
+/* #endif */
+/* } */
+
+/* static Eo_Call_Stack * */
+/* _eo_call_stack_create() */
+/* { */
+/* Eo_Call_Stack *stack; */
+
+/* stack = calloc(1, sizeof(Eo_Call_Stack)); */
+/* if (!stack) */
+/* return NULL; */
+
+/* stack->frames = _eo_call_stack_mem_alloc(EO_CALL_STACK_SIZE); */
+/* if (!stack->frames) */
+/* { */
+/* free(stack); */
+/* return NULL; */
+/* } */
+
+/* // first frame is never used */
+/* stack->frame_ptr = stack->frames; */
+/* stack->last_frame = &stack->frames[EO_CALL_STACK_DEPTH_MIN - 1]; */
+/* stack->shrink_frame = stack->frames; */
+
+/* return stack; */
+/* } */
+
+/* static void */
+/* _eo_call_stack_free(void *ptr) */
+/* { */
+/* Eo_Call_Stack *stack = (Eo_Call_Stack *) ptr; */
+
+/* if (!stack) return; */
+
+/* if (stack->frames) */
+/* _eo_call_stack_mem_free(stack->frames, EO_CALL_STACK_SIZE); */
+
+/* free(stack); */
+/* } */
+
+/* #ifdef HAVE_THREAD_SPECIFIER */
+/* static __thread Eo_Call_Stack *_eo_thread_stack = NULL; */
+
+/* #define _EO_CALL_STACK_GET() ((_eo_thread_stack) ? _eo_thread_stack : (_eo_thread_stack = _eo_call_stack_create())) */
+
+/* #else */
+
+/* static Eo_Call_Stack *main_loop_stack = NULL; */
+
+/* #define _EO_CALL_STACK_GET() ((EINA_LIKELY(eina_main_loop_is())) ? main_loop_stack : _eo_call_stack_get_thread()) */
+
+/* static inline Eo_Call_Stack * */
+/* _eo_call_stack_get_thread(void) */
+/* { */
+/* Eo_Call_Stack *stack = eina_tls_get(_eo_call_stack_key); */
+
+/* if (stack) return stack; */
+
+/* stack = _eo_call_stack_create(); */
+/* eina_tls_set(_eo_call_stack_key, stack); */
+
+/* return stack; */
+/* } */
+/* #endif */
+
+/* EAPI EINA_CONST void * */
+/* _eo_stack_get(void) */
+/* { */
+/* return _EO_CALL_STACK_GET(); */
+/* } */
+
+/* static inline void */
+/* _eo_call_stack_resize(Eo_Call_Stack *stack, Eina_Bool grow) */
+/* { */
+/* size_t sz, next_sz; */
+/* int frame_offset; */
+
+/* sz = stack->last_frame - stack->frames + 1; */
+/* if (grow) */
+/* next_sz = sz * 2; */
+/* else */
+/* next_sz = sz / 2; */
+/* frame_offset = stack->frame_ptr - stack->frames; */
+
+/* _eo_call_stack_mem_resize((void **)&(stack->frames), */
+/* next_sz * sizeof(Eo_Stack_Frame), */
+/* sz * sizeof(Eo_Stack_Frame)); */
+
+/* stack->frame_ptr = &stack->frames[frame_offset]; */
+/* stack->last_frame = &stack->frames[next_sz - 1]; */
+
+/* if (next_sz == EO_CALL_STACK_DEPTH_MIN) */
+/* frame_offset = 0; */
+/* else */
+/* { */
+/* if (grow) */
+/* frame_offset = sz - EO_CALL_STACK_SHRINK_DROP; */
+/* else */
+/* frame_offset = (next_sz / 2) - EO_CALL_STACK_SHRINK_DROP; */
+/* } */
+/* stack->shrink_frame = &stack->frames[frame_offset]; */
+/* } */
+
+/* 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) */
+/* { */
+/* fptr->is_obj = _eo_is_a_obj(eo_id); */
+
+/* /\* If we are already in the same object context, we inherit info from it. *\/ */
+/* if (fptr->is_obj) */
+/* { */
+/* EO_OBJ_POINTER_RETURN_VAL(eo_id, _obj, EINA_FALSE); */
+/* fptr->o.obj = _obj; */
+/* _eo_ref(_obj); */
+/* } */
+/* else */
+/* { */
+/* EO_CLASS_POINTER_RETURN_VAL(eo_id, _klass, EINA_FALSE); */
+/* fptr->o.kls = _klass; */
+/* } */
+
+/* if (is_super) */
+/* { */
+/* EO_CLASS_POINTER_RETURN_VAL(cur_klass_id, cur_klass, EINA_FALSE); */
+/* fptr->cur_klass = cur_klass; */
+/* } */
+/* else */
+/* { */
+/* fptr->cur_klass = NULL; */
+/* } */
+
+/* return EINA_TRUE; */
+/* } */
+
+/* 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; *\/ */
+/* /\* Eo_Call_Stack *stack = eo_stack; *\/ */
+
+/* /\* if (stack->frame_ptr == stack->last_frame) *\/ */
+/* /\* _eo_call_stack_resize(stack, EINA_TRUE); *\/ */
+
+/* /\* fptr = stack->frame_ptr; *\/ */
+
+/* /\* fptr++; *\/ */
+
+/* /\* if (!_eo_do_internal(eo_id, cur_klass_id, is_super, fptr)) *\/ */
+/* /\* { *\/ */
+/* /\* fptr->o.obj = NULL; *\/ */
+/* /\* fptr->cur_klass = NULL; *\/ */
+
+/* /\* ret = EINA_FALSE; *\/ */
+/* /\* } *\/ */
+
+/* /\* stack->frame_ptr++; *\/ */
+
+/* return ret; */
+/* } */
+
+/* EAPI void */
+/* _eo_do_end(void *eo_stack) */
+/* { */
+/* /\* Eo_Stack_Frame *fptr; *\/ */
+/* /\* Eo_Call_Stack *stack = eo_stack; *\/ */
+
+/* /\* fptr = stack->frame_ptr; *\/ */
+
+/* /\* if (fptr->is_obj && fptr->o.obj) *\/ */
+/* /\* _eo_unref(fptr->o.obj); *\/ */
+
+/* /\* stack->frame_ptr--; *\/ */
+
+/* /\* if (fptr == stack->shrink_frame) *\/ */
+/* /\* _eo_call_stack_resize(stack, EINA_FALSE); *\/ */
+/* } */
-// 1024 entries == 16k or 32k (32 or 64bit) for eo call stack. that's 1023
-// imbricated/recursive calls it can handle before barfing. i'd say that's ok
-#define EO_CALL_STACK_DEPTH_MIN 1024
-#define EO_CALL_STACK_SHRINK_DROP (EO_CALL_STACK_DEPTH_MIN >> 1)
-
-typedef struct _Eo_Stack_Frame
-{
- 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))
-
-static Eina_TLS _eo_call_stack_key = 0;
-
-typedef struct _Eo_Call_Stack {
- Eo_Stack_Frame *frames;
- Eo_Stack_Frame *frame_ptr;
- Eo_Stack_Frame *last_frame;
- Eo_Stack_Frame *shrink_frame;
-} Eo_Call_Stack;
-
-#define MEM_PAGE_SIZE 4096
-
-static void *
-_eo_call_stack_mem_alloc(size_t size)
-{
-#ifdef HAVE_MMAP
- // allocate eo call stack via mmped anon segment if on linux - more
- // secure and safe. also gives page aligned memory allowing madvise
- void *ptr;
- size_t newsize;
- newsize = MEM_PAGE_SIZE * ((size + MEM_PAGE_SIZE - 1) /
- MEM_PAGE_SIZE);
- ptr = mmap(NULL, newsize, PROT_READ | PROT_WRITE,
- MAP_PRIVATE | MAP_ANON, -1, 0);
- if (ptr == MAP_FAILED)
- {
- ERR("eo call stack mmap failed.");
- return NULL;
- }
- return ptr;
-#else
- //in regular cases just use malloc
- return calloc(1, size);
-#endif
-}
-
-#ifdef HAVE_MMAP
-static void
-_eo_call_stack_mem_resize(void **ptr EINA_UNUSED, size_t newsize, size_t size)
-{
- if (newsize > size)
- {
- CRI("eo call stack overflow, abort.");
- abort();
- }
- return; // Do nothing, code for actual implementation in history. See commit message for details.
-#else
-static void
-_eo_call_stack_mem_resize(void **ptr, size_t newsize, size_t size EINA_UNUSED)
-{
- *ptr = realloc(*ptr, newsize);
- if (!*ptr)
- {
- CRI("eo call stack resize failed, abort.");
- abort();
- }
-#endif
-}
-
-#ifdef HAVE_MMAP
-static void
-_eo_call_stack_mem_free(void *ptr, size_t size)
-{
- // free mmaped memory
- munmap(ptr, size);
-#else
-static void
-_eo_call_stack_mem_free(void *ptr, size_t size EINA_UNUSED)
-{
- // free regular memory
- free(ptr);
-#endif
-}
-
-static Eo_Call_Stack *
-_eo_call_stack_create()
-{
- Eo_Call_Stack *stack;
-
- stack = calloc(1, sizeof(Eo_Call_Stack));
- if (!stack)
- return NULL;
-
- stack->frames = _eo_call_stack_mem_alloc(EO_CALL_STACK_SIZE);
- if (!stack->frames)
- {
- free(stack);
- return NULL;
- }
-
- // first frame is never used
- stack->frame_ptr = stack->frames;
- stack->last_frame = &stack->frames[EO_CALL_STACK_DEPTH_MIN - 1];
- stack->shrink_frame = stack->frames;
-
- return stack;
-}
-
-static void
-_eo_call_stack_free(void *ptr)
-{
- Eo_Call_Stack *stack = (Eo_Call_Stack *) ptr;
-
- if (!stack) return;
-
- if (stack->frames)
- _eo_call_stack_mem_free(stack->frames, EO_CALL_STACK_SIZE);
-
- free(stack);
-}
-
-#ifdef HAVE_THREAD_SPECIFIER
-static __thread Eo_Call_Stack *_eo_thread_stack = NULL;
-
-#define _EO_CALL_STACK_GET() ((_eo_thread_stack) ? _eo_thread_stack : (_eo_thread_stack = _eo_call_stack_create()))
-
-#else
-
-static Eo_Call_Stack *main_loop_stack = NULL;
-
-#define _EO_CALL_STACK_GET() ((EINA_LIKELY(eina_main_loop_is())) ? main_loop_stack : _eo_call_stack_get_thread())
-
-static inline Eo_Call_Stack *
-_eo_call_stack_get_thread(void)
-{
- Eo_Call_Stack *stack = eina_tls_get(_eo_call_stack_key);
-
- if (stack) return stack;
-
- stack = _eo_call_stack_create();
- eina_tls_set(_eo_call_stack_key, stack);
-
- return stack;
-}
-#endif
-
-EAPI EINA_CONST void *
-_eo_stack_get(void)
-{
- return _EO_CALL_STACK_GET();
-}
-
-static inline void
-_eo_call_stack_resize(Eo_Call_Stack *stack, Eina_Bool grow)
+EAPI Eina_Bool
+_eo_call_resolve(const char *func_name, Eo_Op_Call_Data *call, Eo_Call_Cache *cache, Eo* eo_id, const char *file, int line)
{
- size_t sz, next_sz;
- int frame_offset;
-
- sz = stack->last_frame - stack->frames + 1;
- if (grow)
- next_sz = sz * 2;
- else
- next_sz = sz / 2;
- frame_offset = stack->frame_ptr - stack->frames;
-
- _eo_call_stack_mem_resize((void **)&(stack->frames),
- next_sz * sizeof(Eo_Stack_Frame),
- sz * sizeof(Eo_Stack_Frame));
+ const _Eo_Class *klass/*, *inputklass*/;
+ const op_type_funcs *func;
+ Eina_Bool is_obj;
+ const _Eo_Object* _obj;
- stack->frame_ptr = &stack->frames[frame_offset];
- stack->last_frame = &stack->frames[next_sz - 1];
+ /* fptr = stack->frame_ptr; */
- if (next_sz == EO_CALL_STACK_DEPTH_MIN)
- frame_offset = 0;
- else
- {
- if (grow)
- frame_offset = sz - EO_CALL_STACK_SHRINK_DROP;
- else
- frame_offset = (next_sz / 2) - EO_CALL_STACK_SHRINK_DROP;
- }
- stack->shrink_frame = &stack->frames[frame_offset];
-}
+ /* if (EINA_UNLIKELY(!fptr->o.obj)) */
+ /* return EINA_FALSE; */
-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)
-{
- fptr->is_obj = _eo_is_a_obj(eo_id);
+ is_obj = _eo_is_a_obj(eo_id);
+ /* is_obj = fptr->is_obj; */
- /* If we are already in the same object context, we inherit info from it. */
- if (fptr->is_obj)
+ if (is_obj)
{
- EO_OBJ_POINTER_RETURN_VAL(eo_id, _obj, EINA_FALSE);
- fptr->o.obj = _obj;
- _eo_ref(_obj);
+ _obj = _eo_obj_pointer_get((Eo_Id)eo_id);
+ /* EO_OBJ_POINTER_RETURN_VAL(eo_id, _obj, EINA_FALSE); */
+ /* fptr->o.obj = _obj; */
+ /* _eo_ref(_obj); */
}
else
{
- EO_CLASS_POINTER_RETURN_VAL(eo_id, _klass, EINA_FALSE);
- fptr->o.kls = _klass;
- }
-
- if (is_super)
- {
- EO_CLASS_POINTER_RETURN_VAL(cur_klass_id, cur_klass, EINA_FALSE);
- fptr->cur_klass = cur_klass;
+ klass = _eo_class_pointer_get(eo_id);
+ /* EO_CLASS_POINTER_RETURN_VAL(eo_id, _klass, EINA_FALSE); */
+ /* fptr->o.kls = _klass; */
+ /* assert(!!klass); */
+ if(!klass)
+ return EINA_FALSE;
}
- else
+ if(is_obj)
{
- fptr->cur_klass = NULL;
+ /*inputklass = */klass = _obj->klass;
+ assert(!!klass);
}
- return EINA_TRUE;
-}
-
-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;
- Eo_Call_Stack *stack = eo_stack;
-
- if (stack->frame_ptr == stack->last_frame)
- _eo_call_stack_resize(stack, EINA_TRUE);
+ assert(!!klass);
- fptr = stack->frame_ptr;
+ /* if (!cache->op) */
+ /* { */
+ /* ERR("%s:%d: unable to resolve %s api func '%s' in class '%s'.", */
+ /* file, line, (!is_obj ? "class" : "regular"), */
+ /* func_name, klass->desc->name); */
- fptr++;
-
- if (!_eo_do_internal(eo_id, cur_klass_id, is_super, fptr))
- {
- fptr->o.obj = NULL;
- fptr->cur_klass = NULL;
-
- ret = EINA_FALSE;
- }
-
- stack->frame_ptr++;
-
- return ret;
-}
-
-EAPI void
-_eo_do_end(void *eo_stack)
-{
- Eo_Stack_Frame *fptr;
- Eo_Call_Stack *stack = eo_stack;
-
- fptr = stack->frame_ptr;
-
- if (fptr->is_obj && fptr->o.obj)
- _eo_unref(fptr->o.obj);
-
- stack->frame_ptr--;
-
- if (fptr == stack->shrink_frame)
- _eo_call_stack_resize(stack, EINA_FALSE);
-}
-
-EAPI Eina_Bool
-_eo_call_resolve(const char *func_name, Eo_Op_Call_Data *call, Eo_Call_Cache *cache, void *eo_stack, const char *file, int line)
-{
- Eo_Call_Stack *stack = eo_stack;
- Eo_Stack_Frame *fptr;
- const _Eo_Class *klass, *inputklass;
- const op_type_funcs *func;
- Eina_Bool is_obj;
-
- fptr = stack->frame_ptr;
-
- if (EINA_UNLIKELY(!fptr->o.obj))
- return EINA_FALSE;
-
- is_obj = fptr->is_obj;
-
- inputklass = klass = (is_obj) ? fptr->o.obj->klass : fptr->o.kls;
-
- if (!cache->op)
- {
- ERR("%s:%d: unable to resolve %s api func '%s' in class '%s'.",
- file, line, (!is_obj ? "class" : "regular"),
- func_name, klass->desc->name);
-
- return EINA_FALSE;
- }
+ /* return EINA_FALSE; */
+ /* } */
/* 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, cache->op);
-
- if (!func)
- goto end;
-
- klass = func->src;
- }
- else
- {
-# if EO_CALL_CACHE_SIZE > 0
-# if EO_CALL_CACHE_SIZE > 1
- int i;
-
- for (i = 0; i < EO_CALL_CACHE_SIZE; i++)
-# else
- const int i = 0;
-# endif
- {
- if ((const void *)inputklass == cache->index[i].klass)
- {
- func = (const op_type_funcs *)cache->entry[i].func;
- call->func = func->func;
- if (is_obj)
- {
- call->obj = (Eo *) fptr->o.obj->header.id;
- call->data = (char *)fptr->o.obj + cache->off[i].off;
- }
- else
- {
- call->obj = _eo_class_id_get(inputklass);
- call->data = NULL;
- }
- return EINA_TRUE;
- }
- }
-#endif
+ /* if (fptr->cur_klass) */
+ /* { */
+ /* func = _eo_kls_itr_next(klass, fptr->cur_klass, cache->op); */
+
+ /* if (!func) */
+ /* goto end; */
+
+ /* klass = func->src; */
+ /* } */
+ /* else */
+ {
+/* # if EO_CALL_CACHE_SIZE > 0 */
+/* # if EO_CALL_CACHE_SIZE > 1 */
+/* int i; */
+
+/* for (i = 0; i < EO_CALL_CACHE_SIZE; i++) */
+/* # else */
+/* const int i = 0; */
+/* # endif */
+/* { */
+/* if ((const void *)inputklass == cache->index[i].klass) */
+/* { */
+/* func = (const op_type_funcs *)cache->entry[i].func; */
+/* call->func = func->func; */
+/* if (is_obj) */
+/* { */
+/* call->obj = (Eo *) _obj->header.id; */
+/* call->data = (char *)_obj + cache->off[i].off; */
+/* } */
+/* else */
+/* { */
+/* call->obj = _eo_class_id_get(inputklass); */
+/* call->data = NULL; */
+/* } */
+/* return EINA_TRUE; */
+/* } */
+/* } */
+/* #endif */
func = _dich_func_get(klass, cache->op);
@@ -593,8 +615,8 @@ _eo_call_resolve(const char *func_name, Eo_Op_Call_Data *call, Eo_Call_Cache *ca
if (is_obj)
{
- call->obj = (Eo *) fptr->o.obj->header.id;
- call->data = _eo_data_scope_get(fptr->o.obj, func->src);
+ call->obj = (Eo *) _obj->header.id;
+ call->data = _eo_data_scope_get(_obj, func->src);
}
else
{
@@ -602,22 +624,22 @@ _eo_call_resolve(const char *func_name, Eo_Op_Call_Data *call, Eo_Call_Cache *ca
call->data = NULL;
}
-# if EO_CALL_CACHE_SIZE > 0
- if (!fptr->cur_klass)
- {
-# if EO_CALL_CACHE_SIZE > 1
- const int slot = cache->next_slot;
-# else
- const int slot = 0;
-# endif
- 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
- cache->next_slot = (slot + 1) % EO_CALL_CACHE_SIZE;
-# endif
- }
-#endif
+/* # if EO_CALL_CACHE_SIZE > 0 */
+/* if (!fptr->cur_klass) */
+/* { */
+/* # if EO_CALL_CACHE_SIZE > 1 */
+/* const int slot = cache->next_slot; */
+/* # else */
+/* const int slot = 0; */
+/* # endif */
+/* 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 */
+/* cache->next_slot = (slot + 1) % EO_CALL_CACHE_SIZE; */
+/* # endif */
+/* } */
+/* #endif */
return EINA_TRUE;
}
@@ -636,7 +658,7 @@ end:
{
Eina_List *itr;
Eo *emb_obj_id;
- EINA_LIST_FOREACH(((_Eo_Object *) fptr->o.obj)->composite_objects, itr, emb_obj_id)
+ EINA_LIST_FOREACH(((_Eo_Object *) _obj)->composite_objects, itr, emb_obj_id)
{
_Eo_Object *emb_obj = _eo_obj_pointer_get((Eo_Id)emb_obj_id);
@@ -660,21 +682,21 @@ end:
{
const _Eo_Class *main_klass;
- main_klass = (is_obj) ? fptr->o.obj->klass : fptr->o.kls;
+ main_klass = (is_obj) ? _obj->klass : klass;
/* If it's a do_super call. */
- 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, 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, cache->op, main_klass->desc->name);
- }
+ /* 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, 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, cache->op, main_klass->desc->name); */
+ /* } */
}
return EINA_FALSE;
}
@@ -908,65 +930,65 @@ _eo_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo
return eo_id;
}
-static Eo *
-_eo_add_internal_end(Eo *eo_id, Eo_Call_Stack *stack)
-{
- Eo_Stack_Frame *fptr;
-
- fptr = stack->frame_ptr;
-
- if (EINA_UNLIKELY(!fptr->o.obj))
- {
- ERR("Corrupt call stack, shouldn't happen, please report!");
- return NULL;
- }
-
- if (!fptr->o.obj->condtor_done)
- {
- const _Eo_Class *klass = fptr->o.obj->klass;
-
- ERR("Object of class '%s' - Not all of the object constructors have been executed.",
- klass->desc->name);
- goto cleanup;
- }
-
- if (!eo_id)
- {
- // XXX: Given EFL usage of objects, construction is a perfectly valid thing
- // to do. we shouldn't complain about it as handling a NULL obj creation is
- // the job of the caller. a perfect example here is ecore_con and ecore_ipc
- // where you create a con or ipc obj then set up type/destination/port and
- // the finalize of the constructor does the actual connect and thus this
- // fails or succeeds based on if service is there.
- //
- // until there is a better solution - don't complain here.
- //
- // ERR("Object of class '%s' - Finalizing the object failed.",
- // klass->desc->name);
- goto cleanup;
- }
-
- fptr->o.obj->finalized = EINA_TRUE;
-
- _eo_unref(fptr->o.obj);
-
- return (Eo *)eo_id;
-
-cleanup:
- _eo_unref(fptr->o.obj);
- eo_del((Eo *) fptr->o.obj->header.id);
- return NULL;
-}
-
-EAPI Eo *
-_eo_add_end(void *eo_stack)
-{
- void *__eo_ctx = _eo_stack_get();
- Eo *ret = eo_finalize();
- ret = _eo_add_internal_end(ret, eo_stack);
- _eo_do_end(eo_stack);
- return ret;
-}
+/* static Eo * */
+/* _eo_add_internal_end(Eo *eo_id, Eo_Call_Stack *stack) */
+/* { */
+/* Eo_Stack_Frame *fptr; */
+
+/* fptr = stack->frame_ptr; */
+
+/* if (EINA_UNLIKELY(!fptr->o.obj)) */
+/* { */
+/* ERR("Corrupt call stack, shouldn't happen, please report!"); */
+/* return NULL; */
+/* } */
+
+/* if (!fptr->o.obj->condtor_done) */
+/* { */
+/* const _Eo_Class *klass = fptr->o.obj->klass; */
+
+/* ERR("Object of class '%s' - Not all of the object constructors have been executed.", */
+/* klass->desc->name); */
+/* goto cleanup; */
+/* } */
+
+/* if (!eo_id) */
+/* { */
+/* // XXX: Given EFL usage of objects, construction is a perfectly valid thing */
+/* // to do. we shouldn't complain about it as handling a NULL obj creation is */
+/* // the job of the caller. a perfect example here is ecore_con and ecore_ipc */
+/* // where you create a con or ipc obj then set up type/destination/port and */
+/* // the finalize of the constructor does the actual connect and thus this */
+/* // fails or succeeds based on if service is there. */
+/* // */
+/* // until there is a better solution - don't complain here. */
+/* // */
+/* // ERR("Object of class '%s' - Finalizing the object failed.", */
+/* // klass->desc->name); */
+/* goto cleanup; */
+/* } */
+
+/* fptr->o.obj->finalized = EINA_TRUE; */
+
+/* _eo_unref(fptr->o.obj); */
+
+/* return (Eo *)eo_id; */
+
+/* cleanup: */
+/* _eo_unref(fptr->o.obj); */
+/* eo_del((Eo *) fptr->o.obj->header.id); */
+/* return NULL; */
+/* } */
+
+/* EAPI Eo * */
+/* _eo_add_end(void *eo_stack) */
+/* { */
+/* void *__eo_ctx = _eo_stack_get(); */
+/* Eo *ret = eo_finalize(); */
+/* ret = _eo_add_internal_end(ret, eo_stack); */
+/* _eo_do_end(eo_stack); */
+/* return ret; */
+/* } */
/*****************************************************************************/
@@ -1822,26 +1844,26 @@ eo_init(void)
/* bootstrap EO_CLASS_CLASS */
(void) EO_ABSTRACT_CLASS_CLASS;
- if (_eo_call_stack_key != 0)
- WRN("_eo_call_stack_key already set, this should not happen.");
- else
- {
- if (!eina_tls_cb_new(&_eo_call_stack_key, _eo_call_stack_free))
- {
- EINA_LOG_ERR("Could not create TLS key for call stack.");
- return EINA_FALSE;
-
- }
- }
-
-#ifndef HAVE_THREAD_SPECIFIER
- main_loop_stack = _eo_call_stack_create();
- if (!main_loop_stack)
- {
- EINA_LOG_ERR("Could not alloc eo call stack.");
- return EINA_FALSE;
- }
-#endif
+/* if (_eo_call_stack_key != 0) */
+/* WRN("_eo_call_stack_key already set, this should not happen."); */
+/* else */
+/* { */
+/* if (!eina_tls_cb_new(&_eo_call_stack_key, _eo_call_stack_free)) */
+/* { */
+/* EINA_LOG_ERR("Could not create TLS key for call stack."); */
+/* return EINA_FALSE; */
+
+/* } */
+/* } */
+
+/* #ifndef HAVE_THREAD_SPECIFIER */
+/* main_loop_stack = _eo_call_stack_create(); */
+/* if (!main_loop_stack) */
+/* { */
+/* EINA_LOG_ERR("Could not alloc eo call stack."); */
+/* return EINA_FALSE; */
+/* } */
+/* #endif */
return EINA_TRUE;
}
@@ -1873,10 +1895,10 @@ eo_shutdown(void)
eina_spinlock_free(&_ops_storage_lock);
eina_spinlock_free(&_eo_class_creation_lock);
- if (_eo_call_stack_key != 0)
- eina_tls_free(_eo_call_stack_key);
+ /* if (_eo_call_stack_key != 0) */
+ /* eina_tls_free(_eo_call_stack_key); */
- _eo_free_ids_tables();
+ /* _eo_free_ids_tables(); */
eina_log_domain_unregister(_eo_log_dom);
_eo_log_dom = -1;