efl/src/tests/eo
Jean-Philippe Andre df304d0155 eo: Add beta API for auto_unref after a call
Before screaming in horror (C++...) here's why we may need this:
Efl.Part.part API returns an object that is by definition valid for a
single function call only. Enforcing this in practice is actually quite
hard as all implementation functions must manually take care of the
life-cycle. This is a lot of code in many places and a lot of
opportunities to forget to properly handle that life-cycle. Also, this
means any invalid function call on a part will leak an object.

This API absolutely must remain either "internal" or "beta" and
definitely not become abused by applications. On top of that such an API
can cause great trouble for bindings like C++. As a consequence, only
specially crafted APIs like efl_part() should return an object marked as
auto_unref.

Alternatively this API could be defined in Eo.h or some other
Eo_Internal.h. I placed it in efl_object.eo because it's much more
convenient :) (read: I'm lazy)

****

Performance notes:

Tested with clang & gcc (with -O2), I had a look at the output of perf
top, in particular the asm view. I used eo_bench in a loop. My
conclusions are:

- EINA_LIKELY/UNLIKELY actually works. The jump statement varies
  according to the expectation. I highly doubt all those ugly goto in
  eo.c / Eo.h are even useful.

- The impact of auto_unref on a call_resolve is so small it doesn't even
  appear in the trace. It is significant inside call_end, though
  (obviously, that function is just a few lines long). That function
  accounts for ~1% to ~4% of all CPU time. The impact of auto_unref in
  call_end is ~4% of the function time. This means ~0.16% of all CPU
  time (worst measured case). _efl_object_op_api_id_get simply doesn't
  show up because of caching, so the extra check there is negligible.

PS: I also tested EINA_LIKELY/UNLIKELY by compiling with -O2 and looking
at the output with objdump. The flag is well respected, and the jump
instructions are what you would expect (no jump for LIKELY and jump for
UNLIKELY). Conclusion: The goto's in eo.c only make the code harder to
read...
2017-10-18 11:02:16 +09:00
..
access cmake: add eo 2017-01-23 20:02:06 +01:00
children cmake: add eo 2017-01-23 20:02:06 +01:00
composite_objects cmake: add eo 2017-01-23 20:02:06 +01:00
constructors cmake: add eo 2017-01-23 20:02:06 +01:00
function_overrides cmake: add eo 2017-01-23 20:02:06 +01:00
interface cmake: add eo 2017-01-23 20:02:06 +01:00
mixin cmake: add eo 2017-01-23 20:02:06 +01:00
signals cmake: add eo 2017-01-23 20:02:06 +01:00
suite eo: Add beta API for auto_unref after a call 2017-10-18 11:02:16 +09:00
.gitignore ignores: eo_suite_add_fallback 2016-05-18 21:57:02 +02:00
eunit_tests.h Eo tests: Fix function overrides test to not test some things when NDEBUG is used. 2013-01-18 16:13:30 +00:00