Commit Graph

1088 Commits

Author SHA1 Message Date
Cedric BAIL 79e4947f3e eo: add an automatic fallback at the moment when efl_unref instead of efl_del is called.
Differential Revision: https://phab.enlightenment.org/D6095
2018-05-24 16:02:18 -07:00
Cedric BAIL 93a49da161 eo: optimize efl object reuse by limiting the amount of call to pointer translation.
Differential Revision: https://phab.enlightenment.org/D6088
2018-05-24 16:02:18 -07:00
Cedric BAIL ef6cac1476 eo: prevent parenting to an already invalidated parent.
Differential Revision: https://phab.enlightenment.org/D6086
2018-05-24 16:02:18 -07:00
Cedric BAIL 546a4c79e0 eo: only call efl_parent_set(NULL) at the end of invalidate if the object is not invalidating.
Add also a comment to justify why we do force parent to NULL during invalidate.

Differential Revision: https://phab.enlightenment.org/D6085
2018-05-24 16:02:18 -07:00
Cedric BAIL 56fb2cf377 eo: improve error message by pointing to the class that is creating trouble.
Differential Revision: https://phab.enlightenment.org/D6079
2018-05-24 16:02:18 -07:00
Cedric BAIL bb66aa37ca eo: preventing infinite loop by safely iterating over children during destructor.
Differential Revision: https://phab.enlightenment.org/D6078
2018-05-24 16:02:18 -07:00
Cedric BAIL 2160fe0d4d eo: invalidate at the end of efl_invalidate only and prevent infinite recursion with an invalidating phase.
Differential Revision: https://phab.enlightenment.org/D6075
2018-05-24 16:02:18 -07:00
Cedric Bail 36f8a70041 eo: to avoid mistake in timing, efl_invalidate should always be triggered before any destructor code.
Differential Revision: https://phab.enlightenment.org/D6061
2018-05-24 16:02:17 -07:00
Xavi Artigas 029f0769a5 efl: rename Efl.Event.Description -> Efl.Event_Description 2018-05-23 17:33:47 +02:00
Xavi Artigas 35bbedc96f efl: Add missing event types
Summary:
All events must have a type now, otherwise bindings don't know how to handle
the event_info field.
Most of the missing event types were actually "void" (no event_info present).
Some struct definitions had to be moved to eo instead of h files, so they
are available to bindings. Some have not, and are marked with FIXME.
Some namespaces have been fixed (like Efl_Event_Cb -> Efl.Event_Cb).

In general, there are hundreds of changed files, but mostly to add a type which
was not present before, so there's no harm done.
Also, A lot of FIXMEs have been added which should be, like, fixed.
For example, some events can send different types of event_info, which is
very inconvenient (and error prone).

Test Plan: make with c# bindings works, make check and make examples work too.

Reviewers: cedric, q66, lauromoura

Subscribers: zmike

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D6169
2018-05-19 01:42:26 +02:00
Xavi Artigas 5d1898dd9e eo: do not expose callback,add and del events in bindings
These events have been removed from efl_object.eo. Bindings can
still use the EFL_EVENT_CALLBACK_ADD and EFL_EVENT_CALLBACK_DEL
events from C, but they won't be available to the bound language.
The rationale is that bound languages probably will have their
own way to handle callbacks and C function pointers will mean
very little to them. For example, the binding code could route
the native callback through a dispatcher so the received
function ptr would always be that of the dispatcher method.

Closes D6179.
2018-05-18 16:45:11 +02:00
Xavi Artigas 048adae83d Eo: introduce convenience macro efl_new()
Summary:
This is just a wrapper around efl_add_ref() with a NULL parent.
It only simplifies a bit object creation when no parent is desired, but it
simplifies a lot the explanation of the refcounting concepts (and tutorials).

Reviewers: cedric, bu5hm4n

Reviewed By: cedric, bu5hm4n

Subscribers: bu5hm4n, zmike

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D6024
2018-05-15 09:53:24 -04:00
Daniel Kolesa f58bdbf23a eolian: switch Eina.Future instances to future<T> 2018-05-03 17:14:39 +02:00
Xavi Artigas 5d1e1bf3ae Update docs for efl_add() and efl_add_ref()
Reviewers: cedric

Reviewed By: cedric

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D6023

Reviewed-by: Cedric Bail <cedric@osg.samsung.com>
2018-05-02 10:46:34 -07:00
Cedric BAIL cdbbaede7e efl: remove old Efl_Future, Efl_Promise. 2018-05-01 10:39:01 -07:00
Cedric Bail e7d5d34158 eo: invalidate before setting the parent to NULL. 2018-05-01 10:39:01 -07:00
Cedric BAIL b30587f5b0 eo: linking a future lifecycle with an object lifecycle doesn't change the object. 2018-05-01 10:39:01 -07:00
Cedric BAIL 67d9c0c11e eo: implement a copy function.
we do not rely on copying the object, but on refcounting it. This seems
to match the usage we have with object.
2018-05-01 10:39:01 -07:00
Cedric BAIL 79afb51626 eo: if the pointer is incorrect, goto to the error handler. 2018-05-01 10:39:01 -07:00
Cedric Bail 356e37564a eo: handle NULL nicely in efl_replace. 2018-05-01 10:39:01 -07:00
Xavi Artigas eaa4a3b10d Efl.Object_Override (from Efl.Object.Override)
Ref https://phab.enlightenment.org/T6847

Reviewed-by: Cedric Bail <cedric@osg.samsung.com>
2018-04-24 09:03:47 -07:00
Daniel Kolesa fcae7cab27 eolian gen: enable constness generation on property getter impls
This changes a lot of things all across the EFL. Previously,
methods tagged @const had both their external prototype and
internal impl generated with const on object, while property
getters only had const on the external API. This is now changed
and it all has const everywhere.

Ref T6859.
2018-04-17 20:31:55 +02:00
junsu choi ad6ef48053 eo : Add null check
Summary:
This commit add null check on __efl_auto_unref_set.
In EO_OBJ_POINTER, if obj_id is null, obj can also be null.

Test Plan: N/A

Reviewers: woohyun, kimcinoo, cedric

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D5869

Reviewed-by: Cedric BAIL <cedric@osg.samsung.com>
2018-04-16 11:24:29 -07:00
Cedric Bail 224049fa18 eo: trigger invalidate and noref event before any modification is commited on the object tree. 2018-04-02 17:18:46 -07:00
Cedric BAIL 9072c9a37a eo: add events when object get invalidated and loose all its reference matching other lifecycle events. 2018-03-30 09:53:59 -07:00
Cedric BAIL d7da460dd2 eo: use EINA_SAFETY_ON_TRUE_GOTO to error message out in case of mistake. 2018-03-29 14:07:54 -07:00
Cedric BAIL 168849e8a0 eo: use unref instead of del when constructor fails without parent
Signed-off-by: Mike Blumenkrantz <zmike@osg.samsung.com>
2018-03-20 17:20:57 -07:00
Cedric Bail a1bf513920 eo: start reporting abuse of efl_del 2018-03-20 17:20:56 -07:00
Cedric Bail 2a14a283e8 eo: slight improvement of invalidate code as parent_set(NULL) will be valid on an invalidated object. 2018-03-19 16:47:28 -07:00
Cedric Bail 21164b5a56 eo: automatically cancel a future that is attached to an invalidated object. 2018-03-19 16:38:07 -07:00
Cedric BAIL a5bb8bf3df eo: check return in efl_add before performing more operations
this fixes a crash on objects which fail to be created using efl_add_ref

Signed-off-by: Mike Blumenkrantz <zmike@osg.samsung.com>
2018-03-19 13:04:45 -07:00
Cedric BAIL e1a53fe125 eo: start printing warning when instanciating object with efl_add and no parent. 2018-03-19 13:04:45 -07:00
Lauro Moura 47ac8689f1 eo: Orphan an object that is being invalidated.
Summary:
This will avoid infinite loops and errors when the parent tries
to orphan an invalidated child.

Fixes T6780

Test Plan: Run `make check`

Reviewers: cedric

Maniphest Tasks: T6780

Differential Revision: https://phab.enlightenment.org/D5839

Reviewed-by: Cedric BAIL <cedric@osg.samsung.com>
2018-03-15 22:10:27 -07:00
Cedric BAIL 425a447379 eo: fix invalidate to always happen. 2018-03-13 15:29:21 -07:00
Cedric BAIL bae1b25b8d eo: cleanup future on invalidate. 2018-03-12 12:00:27 -07:00
Cedric Bail 626539e6e5 eo: add an helper to get an object from an Eina_Value. 2018-03-12 12:00:13 -07:00
Cedric BAIL a57eca7f02 eo: allow setting value eo Eina_Value from an Eo pointer directly. 2018-03-12 11:59:59 -07:00
Cedric BAIL 34673ab983 eo: ERR some warning when illegally using invalidated object. 2018-03-08 15:46:45 -08:00
Cedric BAIL f1aa23805a eo: when an object is reused, reset the invalidate flag. 2018-03-08 15:07:09 -08:00
Cedric Bail 83251edae7 eo: introduce invalidate and noref state.
This is just a first step. All user of destructor should be updated to
move the code that rely on their efl_parent and on efl_provider_find to
invalidate. Then we will be able to change the way efl_add and efl_del
work to properly refcount things. efl_noref won't be triggered at the
moment until both efl_parent_set(obj, NULL) and the last user ref are
set to NULL. This is not what we want, but due to how user refcount is
accounting parent at the moment, until all the code is move to rely
on invalidate we can not fix this.
2018-03-07 10:56:53 -08:00
Carsten Haitzler 1bdd9e4dd1 ecore - a different take on efl.app class as a super class to efl.loop
so the MAIN loop is actually an efl.app object. which inherits from
efl.loop. the idea is that other loops in threads will not be efl.app
objects. thread on the creator side return an efl.thread object.
inside the thread, like the mainloop, there is now an efl.appthread
object that is for all non-main-loop threads.

every thread (main loop or child) when it spawns a thread is the
parent. there are i/o pipes from parnet to child and back. so parents
are generally expected to, if they want to talk to child thread, so
use the efl.io interfaces on efl.thread, and the main loop's elf.app
class allows you to talk to stdio back to the parent process like the
efl.appthread does the same using the efl.io interfaces to talk to its
parent app or appthread. it's symmetrical

no tests here - sure. i have been holding off on tests until things
settle. that's why i haven't done them yet. those will come back in a
subsequent commit

for really quick examples on using this see:

https://phab.enlightenment.org/F2983118
https://phab.enlightenment.org/F2983142

they are just my test code for this.

Please see this design document:

https://phab.enlightenment.org/w/efl-loops-threads/
2018-03-03 13:40:33 +09:00
Jean Guyomarc'h 91966f1d16 eo: avoid useless computations
Better exploit class constructor and destructor to initialize data once
and for all. This allows not make initialization checks at runtime.
2018-02-25 14:06:52 +01:00
Jean Guyomarc'h 088f9b862f eo: mark more unlikely labels as cold
This is one more hint the compiler can take to spatially isolate
unlikely branches and possibly improving the hot paths.
2018-02-25 14:06:52 +01:00
Cedric BAIL 1eb4d1311e eo: only call costly function _eo_op_desc_name_get when in debug mode. 2018-01-24 15:36:39 -08:00
Vincent Torri f5b01ac5ce all: Simplify definition of EAPI
This will help in the transition from Autotools to Meson. This has been
tested on Windows for which EFL_XXX_BUILD were first introduced.
2018-01-18 18:04:03 +09:00
Jean-Philippe Andre dd2f450ea7 eo: Fix make check
The cache had a generation count, removing this check breaks eo suite.
EO is designed to tolerate init/shutdown cycles (as long as
dlopen/dlclose isn't involved).

Note: the ugly goto are useless as GCC -O2 understands EINA_(UN)LIKELY
and deals with it as expected (just look at the asm produced).

See 34d9f20706
2018-01-16 19:50:52 +09:00
Jean-Philippe Andre 8b4abdcd0e eo: Remove unused goto label 2018-01-16 19:35:54 +09:00
Jean-Philippe Andre f2b5b00ca2 eo: Warn on calls to NULL object
This makes eo print a WRN message in case a function is called on NULL.
efl_del is an exception to this rule (implemented in a hackish way, I
admit). I don't know any language or object model where using a null
object doesn't result in an exception or crash, except EO. In any case,
calls to null are invalid.

The next commits will resolve most warnings for EFL.

Ref T6326
2018-01-16 18:37:05 +09:00
Jean Guyomarc'h 34d9f20706 eina: remove usless newline
Summary:
ecore_evas: remove debug

eina: unregister log level when done with

Fixes a constant memory leak.

eina: introduce EINA_HOT and EINA_COLD

These attributes respectivelly expand to __attribute__ ((hot)) and
__attribute__ ((cold)) when available. They allow to mark functions are
being hot/cold (frequently used or not) as well as to qualify labels
within a function (likely/unlikely branches).

eo: speed-up generated calls by removing call cache

The call cache needed to by thread-local, to avoid concurrency issues.
Problem with TLS is that is adds an extra overhead, which appears to be
greater than the optimization the cache provides.

Op is naturally atomic, because it is an unsigned integer. As such, it
cannot be tempered with while another thread is reading it. When
entering the generated function, the first operation done is reading
'op'. If we have concurrency, we will have access sequences returning
either EFL_NOOP or a VALID op, because 'op' is not set until the very
end of the function, when everything has been computed. As such, we now
use the 'op' atomic integer to instore a lock-free/wait-free mechanism,
which allows to drop the TLS nature of the cache, speeding up the access
to the cache, and therefore making functions execute faster.

We don't test anymore the generation count. This can be put as a
limitation. If means that if you call efl_object_shutdown() and
re-initialize it later with different data, opcodes will be invalid.
I am not sure there is any usecase for this to ever happen.
We could move all the caches in a dedicated section, that can be
overwritten after a call to efl_object_shutdown(), but I am not sure it
will be very portable.

Benchmark: mean over 3 executions of
   ELM_TEST_AUTOBOUNCE=100 time elementary_test -to genlist

```
                     BEFORE               AFTER
------------------------------------------------------------
time (ns)            11114111647.0        9147676220.0
frames               2872.3333333333335   2904.6666666666665
time per frame (ns)  3869364.6666666665   3149535.3333333335
user time (s)        11.096666666666666   9.22
cpu (%)              22.666666666666668   18.333333333333332
```

Ref T6580

Reviewers: raster, cedric

Subscribers: cedric, jpeg

Maniphest Tasks: T6580

Differential Revision: https://phab.enlightenment.org/D5738
2018-01-16 17:50:46 +09:00
Carsten Haitzler f32f0d89f4 mmap memory allocation - do not used when under valgrind
we can't sensibly use things like massif to track memory if we bypass
itr with mmaping -1 fd anonymous memory... so if built with valgrind
support and running under valgrind, use malloc/calloc and free so
these tools actually do something useful for these bits of memory.
2018-01-12 03:02:43 +09:00
Jean-Philippe Andre f285fd5925 eo: Add "destruct" event
Triggered after (almost) complete destruction of the object.

Not called "deleted" because the other event is already "del".
I don't like "destruct" much but this follows the terminology of
"constructor" / "destructor".

@feature
2018-01-10 16:31:06 +09:00
Cedric BAIL 526415d903 eo: make efl_provider_find a @const function. 2018-01-04 11:45:10 -08:00
Cedric BAIL c19ef91020 Revert "efl_loop: move scheduler_get to eo API"
This reverts commit f910ba248e.

The scheduler is meant to be used only in C, not by bindings so there isn't really
a use for it in the loop class. Now this patch was triggered due to complexity in
using future/promise, so will do a follow up patch to improve that.
2018-01-03 11:21:34 -08:00
Andy Williams d280ab7410 docs: Fix eo_add -> efl_add 2018-01-03 14:44:39 +00:00
Andy Williams f910ba248e efl_loop: move scheduler_get to eo API 2018-01-03 12:46:06 +00:00
Andy Williams 5162d66c51 eo: Update grammar and readability 2017-12-20 09:52:31 +00:00
Cedric BAIL 90f30ea418 eina: make __eina_promise_cancel_all an internal only function. 2017-12-18 16:17:04 -08:00
Jean-Philippe Andre 5dbfb7961f eo/eina: Add HACK to avoid calls to EO after shutdown
Efl.Future is an EO object which means even cancelling Efl.Future
objects requires EO. So this should be done before shutting down EO,
otherwise everything fails badly.

I believe Efl.Future is going to disappear soon, but the problem will
remain: if any promise/future uses EO or anything else outside of Eina
(so, basically anything) then it needs to be canceled before shutting
down the above layers. This is the same situation as with ecore events,
for which we've introduced ecore_event_type_flush.

Ping @cedric
2017-12-18 19:54:31 +09:00
Jean-Philippe Andre 69c595b5fd eo: Fix crash with invalid objects
Not a legacy fix as auto-unref is new in 1.21.
2017-12-15 16:17:42 +09:00
Carsten Haitzler 3a703dbf4a eo - set opts hash to NULL after free 2017-12-15 14:16:53 +09:00
Carsten Haitzler c4e96e4e83 eo - fi missed error condition if eoid passed in is NULL
in some cases construction can fail badly and this causes a crash...
eoid is NULL going in and this causes a cascade of failure. survive
and be more robust.
2017-12-15 14:16:53 +09:00
Jean-Philippe Andre 3e9825cb96 eo: Remove trailing newline in ERR message 2017-12-08 16:02:23 +09:00
Jean-Philippe Andre ec8fe2a8f3 eo: Fix warning when Eo.h is used from C++ 2017-12-07 12:48:00 +09:00
Jean-Philippe Andre 3c68a8afc9 eo: Remove unnecessary defines from the EO file
Those promise/future APIs are not required in the EO files.
2017-12-07 11:25:40 +09:00
Jean-Philippe Andre e4797e75f7 eo: Move unnecessary eina type out of the EO file 2017-12-07 11:22:11 +09:00
Marcel Hollerbach f533ab94d8 eo: add definition of function back 2017-12-05 20:53:12 +00:00
Andy Williams b6b0fac978 eo: Update header for readability
Author: Nate Drake
Reviewer: Andy Williams
2017-12-05 17:04:19 +00:00
Jean-Philippe Andre 207a0cf3e3 eo: Move hacky API auto_unref to C only
This API is meant to be used by parts only, and by bindings dealing with
part objects. This patch fixes make check which got broken in the after
the previous one (cxx).
2017-12-05 15:06:34 +09:00
Carsten Haitzler 74327ddbc8 eo - by default on 64bit only use 47 bits because of luajit
luajit wants to check the upper 17 bits of pointers and assume they
are all 0 if on a 64bit architecture. it will panic and barf if they
are used. we have been using them in our eoid's for a long time.

my take on this is that this is unportable. assuming how many bits are
or are not valid in an opaque pointer (void *) that is simply passed
to you and you cannot dereference or use (no size information even for
what amount of data it points to etc.), is just wrong. it's not
portable and it's trying to be too smart and creating such issues. my
take is that luajit needs a fix for this in the longer term. but for
now let's have a 47 bit mode and go with that. it does mean i have to
drop our generation counter to 10 bits on 64bit (from 27 bits) which
increases likelihood of eoid re-use being falsely detected as valid
(before on 64bit it was 1 in 130 million or so chance, with this 47
bit change it's 1 in 1000. but to be fair on 32bit it's 7 bits for gen
count so 1 in 127 ... so still more than 10x "safer" than on 32bit...
but still...). the relevant check in luajit is:

  (((uint64_t)(p) >> 47) ? (lj_err_msg(L, LJ_ERR_BADLU), NULL) : (p))

it ONLY does this on 64bit. on 32bit pointers are not checked for
validity at all.

as an aside, armv8.2 seemingly will bring 52bit addresses so luajit is
going to fall over flat on a newer rev of armv8. it may be x86 also
uses more bits. last i knew it was 48bits so the 47 bit check luajit
does i think is even wrong for x86-64. to be detailed i read:

amd64 arch == 48 bits (so luajit is wrong). even better In addition,
the AMD specification requires that the most significant 16 bits of
any virtual address, bits 48 through 63, must be copies of bit 47 (in
a manner akin to sign extension). so if the upper bit of 48 is set
THEN all the 16 upper bits must be 1... breaking luajit, even if it
were 47bit and this rule applied. I read the architecture allows for
up to 52bits of actual addresses so architecture-wise this is even
wrong...

So I smell a core bug here in luajit. Certainly in the number of bits
it insists must be 0 (the upper 17 bits where on amd64/x86-64 it
should be the upper 16 bits... and even then these may NOT be 0 if bit
47 (the upper bit of the lower 48 is 1).... so the whole check is
invalid... :(

at least the above is at a theoretical level. i believe that the
addresses divide the 48 bits into 2 chunks (thus 47)... but at the
PHYSICAL level with no mmu and virtual memory. arm64 has this:

https://www.kernel.org/doc/Documentation/arm64/memory.txt

note in all cases the 2nd chunk of memory has at leats some upper bits
of physical addresses beign 1 ... which makes luajit invalid tyo use
without virtual memory remapping these away from high bits.

@fix
2017-11-24 18:29:23 +09:00
Jean-Philippe Andre 7e785d936d eo: Make sure auto_unref only applies after finalize
It would be pretty stupid to create an object that dies before it even
gets created. Auto-unref is for parts and should probably not be used
anywhere else :)
2017-11-24 16:15:44 +09:00
Marcel Hollerbach 2ba64efe62 Eo: be a bit more detailed in the docs
this is completly not obvious. But now its documented.
2017-11-17 16:08:14 +01:00
Andy Williams d5dbcdabd1 eo: Rename efl_ref_get to efl_ref_count 2017-11-08 09:30:42 +00:00
Carsten Haitzler eb67a08c8d eo - fix freeq usage to not use freeq for a vtable cleaning
the freeq can't allow things to access the content of the pointer
because the content canbe written over by canary handling qhen
submitted to the freeq. clear it inline then just submit the final
pointer to the freeq.

@fix
2017-11-07 17:36:57 +09:00
Cedric Bail 769a970be0 eo: fix typo.
Thanks Gustavo.
2017-11-04 13:26:21 -07:00
Cedric Bail b7066e3352 eo: add helper to manipulate Eo object as Eina_Value. 2017-11-03 15:31:31 -07:00
Cedric Bail a1e9497461 eo: refactor use of efl_replace. 2017-11-03 15:31:31 -07:00
Daniel Kolesa 4f5b72a3ed eo files: convert various to use @cref 2017-11-02 16:41:01 +01:00
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
Lauro Moura b7ab2ac1ed eo: Use any_value in eina_types.eot
Reviewers: q66, jpeg

Subscribers: jenkins, cedric

Differential Revision: https://phab.enlightenment.org/D5328
2017-10-17 17:31:38 +09:00
Jean-Philippe Andre ccee1c0944 eo: Simplify debug_name_override
Simply pass in the strbuf and don't expect the callee to own it. This
makes things simpler and safer (it'll crash only if the callee frees
said strbuf, and shouldn't leak). efl_ebug_name is new in the upcoming
release, EFL 1.21.

Realised this after talking with Amitesh. Thanks.

See 999dbd9764
And c4769ff898
2017-10-13 10:57:00 +09:00
Marcel Hollerbach 8e4d0d70e9 eo: introduce function definitions with fallback
there can be cases where the call to such a function is never going to
be directed to the actual implementation. In those cases the FallackCall
will be called.
2017-09-29 11:00:37 +02:00
Jean-Philippe Andre d3436af616 eo: Add API to allow deletion by unref
This allows deleting an object by simply calling efl_unref() on it, even
if there is a parent. Normally the parent is in charge, and you can
request deletion by calling efl_del() or efl_parent_set(NULL).

But in some rare cases, you want to give ownership of an object (@owned)
and still give a parent to that object. efl_unref() should be used (and
would be used by bindings when going out of scope or on garbage
collection), which would then print an error message. This API allows
the specific behaviour.

@feature
2017-09-28 16:42:04 +09:00
Jean-Philippe Andre 662a172139 eo_debug: Allow disabling of backtraces
export EO_LIFECYCLE_BACKTRACE=0

This means that the lifecycle can be tracked but we don't care about the
backtraces. Related to some recent eo_debug patches.
2017-09-28 16:15:07 +09:00
Jean-Philippe Andre 008ec97d84 eo: Allow efl_reuse to be called with a parent
If an object still has a parent inside the del intercept, we shouldn't
reset the "parent_sunk" flag. This would indeed break logic as
parent_sunk == false implies that a parent was never set, which means
the parent must be null. Right now this case isn't used but it can be
imagined with caches of evas objects (they should remain parented to
their evas).

@fix
2017-09-28 16:10:53 +09:00
Jean-Philippe Andre 902938f626 eo: Fix unnecessary ERR logs with eo_debug
efl_data_scope_safe_get() is often used to assert that an object is of a
certain type, but assuming it may be NULL or not of the required type.
This means that encountering an invalid type is an error handled by the
caller (we return NULL), and shouldn't print out extra ERR() logs.

This fixes issues with E run under eo_debug. E's code was safe as it's
using evas_object_smart_data_get() and verifies whether the returned
value is NULL (which is expected for a rectangle, for instance).

@fix
2017-09-28 12:30:36 +09:00
Jean-Philippe Andre 3dc140abfb eo_debug: Also print out the current backtrace
We can't use EINA_LOG_BACKTRACE=1 for that as eo_lifecycle itself prints
out ERR messages for its backtrace dump.
2017-09-28 12:30:36 +09:00
Jean-Philippe Andre 213821240b eo_debug: Enable logging of all ref/unref
This is done via the syntax (not documented yet):

  EO_LIFECYCLE_DEBUG=N:<class names>

Where N is:
 1. new/free
 2. new/free/ref/unref
 3. new/free/ref/unref/reuse

@feature
2017-09-28 12:30:36 +09:00
Jean-Philippe Andre 0ae529ac19 eo: Fix crashes with call cache after init cycle
It's not enough to check the init generation count, if the cache data is
not reset properly.

This patch adds safety in two ways:
 1. Actually reset the op call cache when we detect a new generation
 2. Verify that we don't return NULL function pointer

The 1st point is absolutely necessary, 2nd is optional (extra cost of
one if()).

@fix
2017-09-26 17:58:07 +09:00
Daniel Kolesa fdd27cadf8 eo: make more freefuncs implicit 2017-09-22 16:17:19 +02:00
Vincent Torri 0cdd501246 EFL For WIN32: Replace HAVE_EVIL define with _WIN32 2017-09-22 05:06:10 -05:00
Jean-Philippe Andre 986e5e8827 efl: Add precise_position for input events
The previous commit removed useless delta
2017-09-19 10:51:48 +09:00
Jean-Philippe Andre f3eff6eb3e efl: Introduce Eina.Rect and switch EO APIs to it
It's a complex struct but defined in EO as a simple struct. ABI-wise
it's equivalent to Eina_Rectangle. Some macros that use Eina_Rectangle
also work on Eina_Rect out of the box, most of the code dealing with
x,y,w,h will require no modifications either.

But Eina_Rect provides direct access to a size or position 2d component,
as well as the usual x,y,w,h. The field "rect" is provided as a
convenience for code dealing with both Eina_Rectangle and Eina_Rect. We
may or may not require it.

Note: Size2D could use unsigned values but I have spotted a few places
in the code that actually use -1 to indicate invalid size (as opposed to
0x0).

@feature
2017-09-18 13:22:52 +09:00
Jean Guyomarc'h 76144128ce eo: fix doxygen typo 2017-09-16 14:28:39 +02:00
Daniel Kolesa a8b8b7efde eo files: first batch of @owned conversions 2017-09-15 16:44:26 +02:00
Jean-Philippe Andre 76bc13530a eo: Add class name to error log (unref) 2017-09-13 09:57:05 +09:00
Gustavo Sverzut Barbieri 8e80d3d2dc export efl_future_then() for Eina_Future syntax sugar.
This is actually written as efl_future_Eina_FutureXXX_then() as the
old API clashes, after removing the old code we'll "sed" to fix those.
2017-09-04 10:24:00 -03:00
Guilherme Iscaro d12c652a96 Efl_Object: Add integration with Eina_Future.
This commit adds the EO support for the new future infra.
From now on there's no need to efl_future_link()/efl_future_unlink()
object and futures since the new API already handles that internally.
2017-09-04 10:24:00 -03:00
Guilherme Iscaro 5bd8c9a78d Eina: Add Eina_Promise/Eina_Future.
This commit adds a new promise/future API which aims to replace
efl_future.
2017-09-04 10:24:00 -03:00
Jean-Philippe Andre c071fd453b eo: Mark name_find as const
The search should not require a mutable object.
See the previous commit on elm_widget.
2017-08-23 20:53:20 +09:00
Jean-Philippe Andre e8826062eb eo: Define Efl.Event in EO
This can be used in the widgets propagation mechanism later. I don't see
any really good reason to not define this struct in EO anyway.

Ref T5363
2017-08-23 11:16:45 +09:00
Cedric Bail 87acc90fc7 eo: only return NULL when the object is destructed.
There is a problem with the previous version. The object can still be
alive due to the use of manual_free in evas. So you wouldn't be able
for example to remove a callback from an object that hasn't been
destroyed yet. If that callback is triggered by the destruction
of the object, you would end up with an unexpected and impossible to
prevent effect of access after free on a callback that you had removed.

Not sure if that still solve the original problem that the code was
trying to prevent in Ecore_Evas.
2017-08-13 13:18:04 -07:00
Jean-Philippe Andre e2f8ba7ad9 eo: Check refs in efl_data_scope_safe_get
This makes sure the object is actually still alive and kicking before
returning any data. Otherwise the "safe" word is a bit of an abuse...

Ref T5869

@fix
2017-08-11 11:22:11 +09:00
Jean-Philippe Andre 8b3c1eb069 eo: Add a space in documentation
This separates the brief and the content.
2017-08-09 12:21:42 +09:00
Jean-Philippe Andre d5ad85abae eo: Fix memory leak with overrides
See 0834511067
And b7840d9177

Ref T5580
2017-08-08 11:28:59 +09:00
Cedric BAIL b7840d9177 eo: temporary prevent segfault.
In some case, detected during eo test suite, the vtable does fail to
be fully assigned, but it is still being assigned as the new vtable.
Of course when later destroying it, it has already been freed. Leading
to a double free.
2017-08-07 10:42:45 -07:00
Jean-Philippe Andre 999dbd9764 eo debug name: Use strbuf instead of slstr
This should be a little bit more efficient, even if more "risky"
in terms of leaks. The final API still looks exactly the same.
2017-08-04 10:24:03 +09:00
Jean-Philippe Andre c4769ff898 eo: Add debug_name read-only property to ease debugging
This will include the following information, by default:
 - class name
 - whether the class is an override
 - eo id (pointer)
 - refcount
 - name if one was set (Efl.Object property)

This also supports classes, which is why it's an EAPI in eo.c
and not only a method of Efl.Object

This can be overriden by subclasses using the empty method
Efl.Object.debug_name_override.get

If the function is overriden, then the returned string is used
as is and so it is left to the subclass to include all the
necessary information (as above). This can easily be achieved
by calling efl_debug_name_get(efl_super()) and then concatenating
the strings.

Think of this function as something like Java's toString(), but
only for debugging (i.e. a string class should not just return
its string value).

@feature
2017-08-04 10:24:03 +09:00
Jean-Philippe Andre 0834511067 Eo: Allow multiple functions overrides
This allows two things:
 - adding new override functions on an object that already has
   overrides
 - resetting a specific function (or list of functions) to the
   parent class implementation by passing NULL as implementation

Fixes T5580

@feature
2017-08-04 10:24:03 +09:00
Jean-Philippe Andre 7231a3295b eo: Fix deadlock due to the shared mutex
Explicit lock / unlock of the shared mutex mixed with implicit
lock / unlock when accessing the internal Eo_Object data lead
to uncaught issues such as these.

This was found by trying to run E with gfx filters under eo_debug.
2017-07-19 15:44:49 +09:00
Marcel Hollerbach 68eba4817a eo: clarify what extensions are. 2017-07-18 17:51:38 +02:00
Jean-Philippe Andre 40029ce70a eo: Don't resolve function calls for NULL objects
eo_function(NULL) always leads to a no-operation. A this
point it is basically considered the normal operation
with EO to just silently ignore NULL errors.

If the API function "eo_function" belongs to a class that
has not been loaded yet (eg. no object of this type has
been created yet), then the op associated to the API func
may not be defined yet.

Fixes T5715
2017-07-12 11:20:59 +09:00
Jean-Philippe Andre 5a98f78ce8 eo: Improve invalid EO ID error message
This focus on the domain and ID bits is very confusing. Let's
keep it at the end of the message, and also try to guess whether
the object may have been deleted or simply doesn't belong to the
current thread.
2017-06-22 13:19:23 +09:00
Jean-Philippe Andre b96722cfb8 eo: Add API efl_data_scope_safe_get
This is a safe version of efl_data_scope_get, meaning that it will
return NULL if the object is not of the required type, or if there
is no data for that class, or if the given class was used as an
interface (and isn't a mixin).

@feature
2017-06-14 16:54:11 +09:00
Daniel Zaoui 3107e0d3eb Eo: add APIs to walk over classes and objects
These APIs are needed by Clouseau to get a list of classes and objects.
2017-06-05 08:55:38 +03:00
Jean-Philippe Andre ac3abd1f5b eo: Make efl_cast() return NULL if invalid cast
This makes it work like C++ dynamic_cast<> operator, so that
the return value will be NULL if the object is not an instance
of the given class.

In case of efl_super() we don't do it as efl_super is used A LOT
inside EFL itself (all constructors & destructors, for a start)
and efl_isa is in fact a bit expensive. efl_cast isn't really used
and is intended to be something like dynamic_cast.

For @cedric :)
2017-05-29 13:29:03 +09:00
Carsten Haitzler 1d0b37a9e6 eo - eoid - finally rtemove option to not have eoid. it doesn't work
we use too many bits for metadata now so eoid is broken... remove it
as an option so people dont break out the foot guns
2017-05-17 15:04:01 +09:00
Marcel Hollerbach 5b8421c550 eo: fix missing event emission
There have been cases where the logic of _event_callback_call break'ed
too early in the event submission.
Reason for that was the line ((const unsigned char *) desc -
(const unsigned char *) it->desc) producing a overflow.

This means the if statement

if (!legacy_compare &&
   ((const unsigned char *) desc - (const unsigned char *) it->desc) < 0)

was true while the pointer desc was smaller than it->desc, which means
the event subscription got aborted, even if it should not.

This turned out on two 32 bit maschines. And led to not rendering apps
anymore.

It was introduced by commit in 605fec91ee.

@fix
2017-05-04 20:44:42 +02:00
Daniel Kolesa 6af8527117 eo: move all the key_ properties to C 2017-04-26 16:19:06 +02:00
Daniel Kolesa 20d1cf94c3 eo: move wref_add/wref_del to C 2017-04-26 16:19:06 +02:00
Daniel Kolesa 67c7eb3134 eo: move future_link to C 2017-04-26 16:19:06 +02:00
Daniel Kolesa 3fb4bc336e eo: hide dbg_info from eo files
Continues b780cf2af2.
2017-04-21 17:59:32 +02:00
Daniel Kolesa da43c63ce1 eo: move event related structures and callback to C
We don't need to keep this in eo files anymore because the APIs
using them are now fully in C. This also allows removal of the
event callback builtin from Eolian.
2017-04-21 15:48:31 +02:00
Daniel Kolesa b780cf2af2 eo: move unbindable event APIs to C
In a few classes, this requires some manual expansion. This should
not break anything but it's also fairly ugly; a better solution
would be appreciated, for now we do this.

Similar changes will be done to a few other Efl.Object APIs as
well at later point.
2017-04-20 18:24:38 +02:00
Daniel Kolesa da982535f6 eo: move Efl_Event definition back to C
It's not used anywhere in eo files and has a void pointer.
2017-04-20 16:15:22 +02:00
Jean-Philippe Andre ec71288548 eo: Micro-optimize function calls
This is related to the previous changes to efl_super.
2017-04-19 14:44:14 +09:00
Jean-Philippe Andre 9a81165830 eo: Remove super bit from eo id
It is not required anymore as the super class and super bit can
be stored inside the object data. See the previous patches.
2017-04-19 11:41:15 +09:00
Jean-Philippe Andre 28d785ccb8 eo: Add docs for efl_super and efl_cast (doxygen) 2017-04-19 11:35:48 +09:00
Jean-Philippe Andre 19b9234f23 eo: Add new API efl_cast
This is similar to efl_super but the specified class is the one
we want to call the function on. This is similar to dynamic_cast<>
in C++.

Note: both efl_super() and efl_cast() need documentation!

This is an experimental feature.

Fixes T5311

@feature

Maniphest Tasks: T5311

Differential Revision: https://phab.enlightenment.org/D4797
2017-04-19 11:15:30 +09:00
Jean-Philippe Andre 85636658e0 eo: Remove lock from efl_super
I've always really disliked this lock. If someone calls a non-eo
function by accident with efl_super() then you'll most likely end
up in a deadlock.

This adds the cur_klass pointer to the object itself, exploiting
the fact that we have 8 bytes of padding (on 64 bits, at least).

Also, this opens the door to efl_cast() which would be similar to
efl_super() except that only a dynamic cast is done, not a call
to the parent function.

make benchmark shows a performance improvement, surprisingly.

This is a bit experimental. See also the following commit (efl_cast)
2017-04-19 11:04:12 +09:00
Jean-Philippe Andre 86d1f2b6cd eo: Use COW to save 8~16 bytes per object
Summary:
This uses Eina_Cow to implement support for rarely used features
in EO objects. This covers:
- composite objects (eg. UI widgets: combobox, text, video, win)
- vtable for efl_object_override
- del_intercept

All of these features are quite tricky to get right and while
very useful, should still be used with great care. With this patch,
the size of an _Eo_Object struct comes down from 80 bytes (rounded
up from 72b) to 64 bytes (rounded up from 56b) on 64 bits.

Also I haven't measured precisely but I don't expect any performance
impact since the COW data is more likely to remain in L1/L2 cache,
as the default one will be used most often. Unfortunately, the
results of "make benchmark" have been quite inconsistent over
multiple runs.

This saves ~64kb in elementary_test (>4k objects) at the cost of
~100 calls to COW write (del intercept on some events).

@optimization

Reviewers: raster, cedric

Differential Revision: https://phab.enlightenment.org/D4796
2017-04-18 18:52:27 +09:00
Jean-Philippe Andre d6d4c3c25b eo: Fix crash in case of API misuse
If efl_object_override() is called with a function that does
not exist in the original class, it may lead to a crash on
indexing an non-existing array in the vtable.

This is really just a safety check, as the usage was wrong:
 * You are only allowed to override functions that are defined in the
 * class or any of its interfaces (that is, efl_isa returning true).
2017-04-18 15:34:29 +09:00
Jean-Philippe Andre 9dc0a15499 eo: Make _eo_obj_pointer_done an inline function
@optimization
2017-02-21 10:52:39 +09:00
Marcel Hollerbach ae80040331 eo: ensure the generation is correctly clamped
Summary:
when a few recursive event emissions are happening, and in some deep
recursive level a subscription to the same object is happening, the
subscription would just be executed when the complete recursion is done.
that is wrong. The subscription needs to be executed when the event is
called after the subscription is added, undepended from any recursive
level. That fixes that and adds a regression test for it.

This was discovered in e, since e gives a lot of error messages about a eo object
that is already freed. It turned out this object is returned from evas, and exactly
the above happened to the EFL_EVENT_DEL subscription of that object.

Test Plan: make check

Reviewers: tasn, cedric, stefan_schmidt

Subscribers: stefan_schmidt, netstar, zmike, raster, jpeg

Differential Revision: https://phab.enlightenment.org/D4656

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2017-02-16 13:37:19 -08:00
Jean-Philippe Andre 8947caf120 eo: Fix shadow variable warning 2017-02-15 20:11:22 +09:00
Jean-Philippe Andre 63eb9a28b3 eo_debug: Remove some abusive goto where not needed
goto was used for micro-optimization. There is absolutely no
need for those if we're using the slow path with eo_debug.

Simplify the code.
2017-02-15 15:35:38 +09:00
Jean-Philippe Andre a11836b5a1 eo_debug: Some more log improvements
Nothing fancy here...
2017-02-15 15:35:38 +09:00
Jean-Philippe Andre 2e96b5074d eo_debug: Improve dangling xref debug logs even more
In case of manual free, as is heavily used by Evas, we can't really
print an ERR if there are still references before free has been
called.

This may not be ideal from a pure EO point of view but considering
how Evas uses manual free this is the best solution to avoid
polluting debug logs.
2017-02-15 14:50:50 +09:00
Jean-Philippe Andre a5535464bf eo_debug: Improve one log
This changes the following message when the object is referencing
its own data. Also lowers from ERR to WRN and adds the class
name for the referenced data.

ERR<17450>:eo /home/jpeg/e/core/efl/src/lib/eo/eo_private.h:337
  _efl_unref_internal() in /home/jpeg/e/core/efl/src/lib/eo/eo.c:620:
  func '_efl_object_call_end' Data of object 0x400000021008db58 is
  still referenced by object 0x400000021008db58

Note that evas and elm have a few calls to efl_data_ref(obj, NULL)
which are imho quite ugly: not using the return value and not
specifying the data class. I'm keeping them as-is for now.
2017-02-15 14:01:06 +09:00
Stefan Schmidt 337e8f1ab4 eo: add missing since tags for functions added during 1.19 cycle 2017-02-14 21:47:15 +01:00
Carsten Haitzler 6d4b85f820 eo base - fix warnings for debug logs to get format string types happy
gcc is very unhappy with these log prints - specifically on arm 32bit.
this fixes it so we can focus on real warnings/issues.
2017-02-12 00:32:16 +09:00
Carsten Haitzler eb3f6f06f1 efl base class - fix warning about comparing differing sizes
yes - we compare a difference between 2 ptrs and an index which is a
uint. the safe thing here is to promote the unit to the ptrdiff_t
type. reality is we cant have more than 2^32 cb's on an object
anyway... so this should be ok.
2017-02-11 23:13:00 +09:00
Marcel Hollerbach 15b0d0dd12 efl_object: document when callbacks are called 2017-02-10 18:50:41 +01:00
Stefan Schmidt 09352f0a6d docs: eina: add doc for new eina value type 2017-02-09 14:47:22 +01:00
Larry Jr 093c592188 efl: add efl_model and efl_ui_view classes
Efl.Model.Container and Efl.Model.Item to efl/interfaces are used
to create Efl.Model objects with predefined property values.
This is useful to any situation where we want an Efl.Model with
explicit defined property values.

Efl.Ui.View and Efl.Ui.Factory are used to connect Efl.Models with
Widgets, Elm.Layout and Efl.Ui.Image has changed to use news interfaces

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2017-02-06 15:26:21 -08:00
Gustavo Sverzut Barbieri 3813044ef6 cmake/eo: add description (fills eo.pc file) 2017-01-23 19:34:39 -02:00
Marcel Hollerbach 27504d7db0 cmake: add eo 2017-01-23 20:02:06 +01:00
Carsten Haitzler ccc68f0719 eo - remove the spare eo domain for now for future expansion 2017-01-12 13:08:57 +09:00
Gustavo Sverzut Barbieri 3680ae0bab eo_debug: print tracebacks for more errors.
If eo_debug (libeo_dbg/EO_DEBUG), then print tracebacks if lifecycle
is being tracked.
2016-12-20 10:18:31 -02:00
Tom Hacohen 78bbd29720 Eo: remove unreachable code in isa.
This condition can never be true. It can't be NULL here. A NULL here
would have caused a crash earlier, though it can only be NULL if an
allocation fails, which is something that we don't really handle
for smallish allocations.

CID1366823
2016-12-15 11:36:51 +00:00
Gustavo Sverzut Barbieri 47ddca0f42 Efl_Future: class name (string) using "." for namespace.
Following recent eolian change, the string must have "." to split
namespace, not "_".
2016-12-12 02:30:33 -02:00
Gustavo Sverzut Barbieri 87bed5622e eo_lifecycle: on log level info (3), show leaked objects.
Since we keep a log of created and deleted objects, we can walk the
log and see which were leaked. As this is expensive, do only if log
level is greater than 3 (INFO, DEBUG...), with backtrace of object
creation being displayed as backtrace if running as level 4 (DEBUG).
2016-12-08 16:00:01 -02:00
Tom Hacohen 5424cdbd81 Eo: Fix efl_isa() sometimes returning wrong results with extensions
This fixes an issue where efl_isa() wouldn't work for extensions or
ancestors of extensions of a class.

Example:
Class A implements interface F2
F2 inherits from interface F1
obj is of class A

Before this patch efl_isa(obj, F1) would return false, now it returns
true as expected.

This is just one example, there is a whole array of variations to this
issue that are now fixed.

Thanks to Gustavo for reminding me of this.

@fix
2016-12-07 13:55:13 +00:00
Gustavo Sverzut Barbieri 261b0faa54 eo: guard lifecycle obj log inside spinlock.
since the array can be pushed or looked up from multiple threads we
must have a lock in place.
2016-12-06 14:38:34 -02:00
Gustavo Sverzut Barbieri 79d44f212e eo: guard all efl_super() checks under EO_DEBUG.
Tom is worried about performance hit (god, checking a bit in a pointer
we'll fetch to memory anyway, since we return it masked), so guard
under EO_DEBUG.
2016-12-06 14:27:10 -02:00
Stefan Schmidt e90622ec41 all: use void if we really want to make sure we do not accept parameters
In C we need this to make clear that we really do not accept parameters.
Found by the smatch source code matcher. I had run and fixed this before
but it seems to creep in again over time.
2016-12-06 17:16:24 +01:00
Gustavo Sverzut Barbieri 0593216995 eo: efl_super() can receive a class as first parameter.
This fixes the src/tests/eo/test_function_overrides
2016-12-06 12:40:33 -02:00
Jean-Philippe Andre 552831386a eo: Fix potential inifinite loop
I saw a little oopsie in patch fc48161910. This
amends it to avoid a potential infinite loop.
2016-12-05 18:40:46 +09:00
Jean-Philippe Andre c6dcf3dda4 eo: Make error message less nebulous
When writing this ERR log I thought about "thread" (it's really
the keyword here) but eventually reworded to "context". Let's be
clearer about the possible issue here.
2016-12-05 09:46:55 +09:00
Gustavo Sverzut Barbieri 9eba6bf2e7 eo: do not use eina_trash when running on valgrind.
This allows valgrind to show when the object was created and deleted.
2016-12-03 10:35:27 -02:00
Gustavo Sverzut Barbieri 2e0fcbe5b4 eo: fix compilation without HAVE_BACKTRACE.
time_get() function was used even in that case to log when objects
were created or deleted.

thanks @vtorri.
2016-12-03 09:44:44 -02:00
Gustavo Sverzut Barbieri 7a1e5923f9 eo: fix missing Evil.h include 2016-12-03 09:41:09 -02:00
Jean Guyomarc'h deda8ac8e7 eo: fix build on macOS
Commit 227463bd introduces macOS-specific code, but without including the
header that provides the used declarations.
2016-12-03 12:10:04 +01:00
Gustavo Sverzut Barbieri 6e8280a540 eo: more information when we cannot resolve method.
_efl_object_api_op_id_get() will query a hash for the given pointer,
however if it wasn't populated, it will return "NOOP" and we're
hopeless while debugging on what happened.

Common case is to use the incorrect method, like:

        obj = efl_add(CLS1, ...);
        cls2_method(obj);

Since we did not create CLS2, it won't populate its methods on the
hash, thus the lookup will return NOOP.

With this change the function now gets the target object and function
name so reports an insightful message such as:

        ERR:eo file.c:123 cls2_method() Unable to resolve op for api func 0x7ff492ddea00 for obj=0x400000007e8ee1df (CLS1)
2016-12-02 21:44:23 -02:00
Gustavo Sverzut Barbieri 227463bdde eo: allow valgrind-like tracking of object lifecycle.
Eo pointer indirection is super nice as it avoids you to access
invalid memory, but this extra checks inhibits valgrind's own tracking
of memory lifecycle, usually it would report when the object was
created and when the object is deleted, both as stack traces.

This commits introduces logging of object creation and destruction
under its own eina_log_domain and controlled by EO_LIFECYCLE_DEBUG and
EO_LIFECYCLE_NO_DEBUG envvars. These will only be available if
compiled with EO_DEBUG, thus shouldn't cause any performance hits on
production code.

Running a bogus app with invalid efl_class_name_get() and double
efl_del() will report as below:

```sh
$ export EO_LIFECYCLE_NO_DEBUG=Efl_Loop_Timer,Efl_Promise,Efl_Future
$ export EO_LIFECYCLE_DEBUG=1
$ export EINA_LOG_LEVELS=eo_lifecycle:4
$ /tmp/bogus_app
DBG:eo_lifecycle lib/eo/eo.c:2712 _eo_log_obj_init() will log all object allocation and free
DBG:eo_lifecycle lib/eo/eo.c:2788 _eo_log_obj_init() will NOT log class 'Efl_Future'
DBG:eo_lifecycle lib/eo/eo.c:2788 _eo_log_obj_init() will NOT log class 'Efl_Promise'
DBG:eo_lifecycle lib/eo/eo.c:2788 _eo_log_obj_init() will NOT log class 'Efl_Loop_Timer'
DBG:eo_lifecycle lib/eo/eo.c:2665 _eo_log_obj_new() new obj=0x563fa35a1aa0 obj_id=0x4000000002cf38ef class=0x563fa35a1450 (Efl_Vpath_Core) [0.0004]
DBG:eo_lifecycle lib/eo/eo.c:2665 _eo_log_obj_new() new obj=0x563fa35af8d0 obj_id=0x4000000006cf38f0 class=0x563fa35aecf0 (Efl_Loop) [0.0005]
DBG:eo_lifecycle lib/eo/eo.c:2665 _eo_log_obj_new() new obj=0x563fa35d61a0 obj_id=0x400000007ecf390e class=0x563fa35d48f0 (Efl_Net_Dialer_Simple) [0.0054]
DBG:eo_lifecycle lib/eo/eo.c:2665 _eo_log_obj_new() new obj=0x563fa35d6470 obj_id=0x4000000082cf390f class=0x563fa35d0d60 (Efl_Net_Dialer_Tcp) [0.0055]
DBG:eo_lifecycle lib/eo/eo.c:2665 _eo_log_obj_new() new obj=0x563fa35d75b0 obj_id=0x4000000086cf3910 class=0x563fa35d66b0 (Efl_Io_Queue) [0.0056]
DBG:eo_lifecycle lib/eo/eo.c:2665 _eo_log_obj_new() new obj=0x563fa35d8f70 obj_id=0x400000008acf3911 class=0x563fa35d7860 (Efl_Io_Copier) [0.0057]
DBG:eo_lifecycle lib/eo/eo.c:2665 _eo_log_obj_new() new obj=0x563fa35df980 obj_id=0x40000000a6cf3918 class=0x563fa35d66b0 (Efl_Io_Queue) [0.0058]
DBG:eo_lifecycle lib/eo/eo.c:2665 _eo_log_obj_new() new obj=0x563fa35dfc30 obj_id=0x40000000aacf3919 class=0x563fa35d7860 (Efl_Io_Copier) [0.0058]

will efl_class_name_get() with invalid handle:

ERR:eo lib/eo/eo.c:1013 efl_class_name_get() Class (0x2000000000000029) is an invalid ref.
ERR:eo_lifecycle lib/eo/eo.c:1013 efl_class_name_get() obj_id=0x2000000000000029 was neither created or deleted (EO_LIFECYCLE_NO_DEBUG='Efl_Loop_Timer,Efl_Promise,Efl_Future').
DBG:eo_lifecycle lib/eo/eo.c:2688 _eo_log_obj_free() free obj=0x563fa35df980 obj_id=0x40000000a6cf3918 class=0x563fa35d66b0 (Efl_Io_Queue) [0.0061]
DBG:eo_lifecycle lib/eo/eo.c:2688 _eo_log_obj_free() free obj=0x563fa35dfc30 obj_id=0x40000000aacf3919 class=0x563fa35d7860 (Efl_Io_Copier) [0.0061]
DBG:eo_lifecycle lib/eo/eo.c:2688 _eo_log_obj_free() free obj=0x563fa35d75b0 obj_id=0x4000000086cf3910 class=0x563fa35d66b0 (Efl_Io_Queue) [0.0061]
DBG:eo_lifecycle lib/eo/eo.c:2688 _eo_log_obj_free() free obj=0x563fa35d8f70 obj_id=0x400000008acf3911 class=0x563fa35d7860 (Efl_Io_Copier) [0.0061]
DBG:eo_lifecycle lib/eo/eo.c:2688 _eo_log_obj_free() free obj=0x563fa35d6470 obj_id=0x4000000082cf390f class=0x563fa35d0d60 (Efl_Net_Dialer_Tcp) [0.0063]
DBG:eo_lifecycle lib/eo/eo.c:2688 _eo_log_obj_free() free obj=0x563fa35d61a0 obj_id=0x400000007ecf390e class=0x563fa35d48f0 (Efl_Net_Dialer_Simple) [0.0063]

will double free:

ERR:eo ../src/lib/eo/efl_object.eo.c:78 efl_del() EOID 0x400000007ecf390e is not a valid object. EOID domain=0, current_domain=0, local_domain=0. EOID generation=2cf390e, id=1f, ref=1, super=0. Thread self=main. Available domains [0 1    ]. Maybe it has been deleted or does not belong to your thread?
ERR:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() obj_id=0x400000007ecf390e created obj=0x563fa35d61a0, class=0x563fa35d48f0 (Efl_Net_Dialer_Simple) [0.0054s, 0.0009 ago]:
ERR:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del()    0x007f2c0bc6d0ea: libeo_dbg.so+0x90ea (in src/lib/eo/.libs/libeo_dbg.so 0x7f2c0bc64000)
ERR:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del()    0x007f2c0bc6ca62: _efl_add_internal_start+0x1c2 (in src/lib/eo/.libs/libeo_dbg.so 0x7f2c0bc64000)
ERR:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del()    0x00563fa15dc95f: bogus_app+0x295f (in /tmp/bogus_app 0x563fa15da000)
ERR:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del()    0x007f2c0ace7291: __libc_start_main+0xf1 (in /usr/lib/libc.so.6 0x7f2c0acc7000)
ERR:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del()    0x00563fa15dc48a: _start+0x2a (in /tmp/bogus_app 0x563fa15da000)
ERR:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() obj_id=0x400000007ecf390e deleted obj=0x563fa35d61a0, class=0x563fa35d48f0 (Efl_Net_Dialer_Simple) [0.0063s, 0.0000 ago]:
ERR:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del()    0x007f2c0bc6d8ba: libeo_dbg.so+0x98ba (in src/lib/eo/.libs/libeo_dbg.so 0x7f2c0bc64000)
ERR:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del()    0x007f2c0bc6d711: libeo_dbg.so+0x9711 (in src/lib/eo/.libs/libeo_dbg.so 0x7f2c0bc64000)
ERR:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del()    0x007f2c0bc6beb8: libeo_dbg.so+0x7eb8 (in src/lib/eo/.libs/libeo_dbg.so 0x7f2c0bc64000)
ERR:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del()    0x007f2c0bc6c06e: _efl_object_call_end+0x4e (in src/lib/eo/.libs/libeo_dbg.so 0x7f2c0bc64000)
ERR:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del()    0x007f2c0bc75725: efl_del+0x105 (in src/lib/eo/.libs/libeo_dbg.so 0x7f2c0bc64000)
ERR:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del()    0x00563fa15dcd54: lt-efl_net_dialer_simple_example+0x2d54 (in /tmp/bogus_app 0x563fa15da000)
ERR:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del()    0x007f2c0ace7291: __libc_start_main+0xf1 (in /usr/lib/libc.so.6 0x7f2c0acc7000)
ERR:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del()    0x00563fa15dc48a: _start+0x2a (in /tmp/bogus_app 0x563fa15da000)
ERR:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() obj_id=0x400000007ecf390e was already deleted 0.0000 seconds ago!
```
2016-12-02 21:15:17 -02:00
Gustavo Sverzut Barbieri fc48161910 eo: check for empty vtable and failed extensions.
if for some reason we fail to validate a class, then we should skip
that extension. This may result in an empty vtable, then check for
that and avoid a crash.

This is very unlike to happen in practice, but I've forced some
validation errors and could get to that.
2016-12-02 21:15:17 -02:00
Gustavo Sverzut Barbieri dfe3a4ad40 eo: improve logs by always showing event source, minor refactor.
Instead of 2 sets of macro, one for HAVE_EO_ID and another without,
use a single set of macros and have the implementation of
_eo_class_pointer_get() and _eo_obj_pointer_get() to do the actual

These functions now take the source information so the logs reflect
that and not always the same function.
2016-12-02 21:15:17 -02:00
Bruno Dilly 5d54c24a4e eo: fix oops on efl_replace() documentation 2016-12-02 15:41:48 -02:00
Guilherme Iscaro 81782414df Eo: Add efl_replace() function.
This new function adds a new way to safely replace Eo pointer values.
2016-12-02 15:12:56 -02:00
Gustavo Sverzut Barbieri 04450c4ee0 eo: if EO_DEBUG, check if efl_super() object 'isa' the given class.
A common error is to copy & paste efl_super() calls and forget to fix
the class. If usin EO_DEBUG, then use efl_isa() to error.
2016-12-02 14:51:18 -02:00
Gustavo Sverzut Barbieri 216e6e51e4 eo: better error reporting, always provide caller/source when available.
_eo_pointer_error() was kinda a bitch to debug as it provided a nice
breakpoint location, but did not provide a good output since the file,
line and function were always the same.

Change that to be a thin wrapper on top of eina_log_vprint(), then we
keep the breakpoint location yet provide useful information.

In that sense, change other error messages so they carry as much
information as possible.
2016-12-02 14:50:45 -02:00
Gustavo Sverzut Barbieri cf5aeb9804 eo: use log domain as soon as it's available. 2016-12-02 14:50:45 -02:00
Carsten Haitzler a817d2f632 eo event callback frame make them single linked to save a bit of overhead
this makes the callback event frame single linked with a little less
inlist overhead asa result.
2016-12-02 21:28:15 +09:00
Marcel Hollerbach 2ce2a65148 eo: adjust generation count
raster suggested a few optimizations
2016-12-02 12:27:37 +01:00
Marcel Hollerbach a2e90e522b eo: optimize generation increase
doing it by hand here saves a function call which showed up pretty happy
on perf.
2016-12-02 12:27:37 +01:00
Marcel Hollerbach 0f72c8a031 eo: use the event stack to define behaviour
subscriptions are only executed if they were already subscriped at the
start of the event emission.
2016-12-02 12:27:37 +01:00
Marcel Hollerbach a035bc1292 eo: fix event emission for subscription while emission
This fixes T4907

The problem was that in efl_event_callback_add the internal array was
changed. If this was happening while a efl_event_callback_call was
happening the for loop got confused and skipped one event subscription.
Which led to a bug in e where the idler ufnction was not executed
probebly and so the canvas stayed frozen.
2016-12-02 12:27:37 +01:00
Jean-Philippe Andre b6fae524ff eo: Improve debug for efl_isa errors from threads 2016-12-02 17:21:47 +09:00
Andy Williams c5181470c1 eo: safety in string comparison
Avoid potential for Eo to crash if app manages to unset key
@fix
2016-11-28 00:10:30 +00:00
Carsten Haitzler ad985e73f3 eo base class - clean up some formatting around callback add/del code
just formatting changes really.
2016-11-26 18:33:56 +09:00
Cedric Bail 6b165089a6 eo: make it possible to disable batch allocation for callbacks. 2016-11-23 18:50:19 -08:00
Cedric Bail f4527c7283 eo: when there is no more callbacks, let's clean up. 2016-11-23 18:50:19 -08:00
Jean-Philippe Andre 3ad4e0bdfc eo: Fix leak during shutdown() 2016-11-23 23:48:53 +09:00
Marcel Hollerbach 70b24abff7 eo: inc the special count
if there is a event the callback counter should be incremented not
decremented. This should fix a few crashes i found in edje, since edje
did not knew that a element was deletion.
2016-11-23 13:42:27 +01:00
Cedric Bail f511c64269 eo: refactor callback delayed cleaning code. 2016-11-21 16:03:27 -08:00
Tom Hacohen 79d76fb25e Eo gdb: add a way to resolve Eo ids from GDB without a running process
Normally when debugging Eo with gdb you can just use any of the internal
eo functions to resolve the id to its internal pointer. However, when
loading a coredump you can't execute any code, not even the id resolve
code.

This change adds a gdb function that resolves the id to its pointer form
without executing any code in the process space. This plugin is
essentially the id resolve code written in python as a gdb function.

Usage:
 Print the pointer:
 (gdb) print $eo_resolve(obj)
 $1 = (_Eo_Object *) 0x5555559bbe70

 Use it directly (e.g. to print the class name):
 (gdb) $eo_resolve(obj)->klass->desc.name

This plugin requires that the coredump would be loaded with the exact
same libeo.so binary (or at least one that hasn't changed eo internals),
and that the debug symbols for libeo.so would be available for gdb to
use.

Note:
This feature is incomplete and only resolves IDs that are owned by the
main thread and in the main domain. This is not a big issue at the
moment, because almost all of our IDs are like that.

@feature
2016-11-18 11:48:07 +00:00
Carsten Haitzler ce8e085d6d efl object events - track del, cb add and cb del callback counts
so hunting another callback issue i noticed some of THE most popular
callbacks are:

     1411  tick
     1961  move
     4157  pointer,move
     7524  dirty
     8090  damage
    13052  render,flush,post
    13052  render,flush,pre
    13205  render,post
    13205  render,pre
    21706  recalc
    21875  idle
    27224  resize
    27779  del
    31011  idle,enter
    31011  idle,exit
    60461  callback,del
   104546  callback,add
   126400  animator,tick

as you can see callback del, add and the general obj del cb's are
right up there... so it is very likely a good idea to CHECK to see if
anyone is listening before calling the callback for these very very
very common calls.

this is ifdef'd and turned on for now. it can be turned off. it
shouldnt use more memory due to the way memory alignment works (likely
all allocations will be multiples of 8 bytes anyway) so we're using
spare unused space. the only q is - is management of the counts AND
checking them worth it in general? it's really hard to tell given we
dont have a lot of benchmarks that cover a lot of use cases... it
doesnt seem to slow or speed anything up much in the genlist bounce
test... so i think i need something more specific.

@optimize
2016-11-17 18:41:32 +09:00
Carsten Haitzler 200490a850 eo src formatting - line up struct member 2016-11-17 18:41:32 +09:00
Carsten Haitzler 036cfc32e4 event callback call - move 0 check early before any var init
a LOT of callback calls call on objects with no cb's at all so the
earlier we check for 0 the better before we do ANYTHING.

@optimize
2016-11-17 18:41:32 +09:00
Carsten Haitzler 1ac86bb878 eo - fix ever growing callback list by actually flagging waiting dels
i found a massive slowdown that over time ended up with 10000's of
cb's in objects like the ecore loop object. this fixes that by
ACTUALLY flagging event deletions waiting to be true rather than false.
2016-11-17 18:41:32 +09:00
Stefan Schmidt 8e88ff7487 docs: eo: finish up docs for eo
Add some mising docs, fix some typos and align with other docs.
2016-11-10 15:14:42 +01:00
Carsten Haitzler 45771d47ab eo - use free queue for at least some eo core memory and pointers
this should help improve robusteness by keeping memory around for a
bit until the free queue flushes or is full

@feature
2016-11-06 13:13:10 +09:00
Stefan Schmidt 4a66bd14b7 docs: document all missing type defines in our eo files
With this commit we reach 100% alias doc coverage for our eo files.
2016-11-03 11:57:40 +01:00
Daniel Kolesa c4f64a3390 eolian: rename ref to ptr to avoid confusion with eo refs 2016-11-02 13:06:38 +01:00
Tom Hacohen f736946d10 Eo: Add a method to mark objects for reuse.
This informas eo an object is going to get reused/cached, so eo can
reset the object appropriately.

@feature.
2016-10-28 13:19:10 +01:00
Stefan Schmidt a41fe1bea6 docs: eo: document last missing structs
With this commits we reach 100% eo docs coverage for structs.
2016-10-27 18:22:42 +02:00
Cedric Bail ab18b01e1c eo: do not track NULL future. 2016-10-25 18:51:12 -07:00
Felipe Magno de Almeida 6dc0a07a85 eo: Fix compilation of macro in C++ because of goto
Moved variable cross-definition to the top, so no more
cross-definition between goto would happen.
2016-10-25 12:23:34 -02:00
Stefan Schmidt ea7c0ca516 docs: eo: make consistent use of $true in docs
Make use of the $true keyword instead of going with Ein_True or just true. We
need to change this tree-wide in the docs.
2016-10-24 16:52:48 +02:00
Tom Hacohen 25242e6af9 Eo: Fix references of objects 2016-10-21 15:29:39 +01:00
Stefan Schmidt d29bb3bbec docs: eina_types: add descriptions for some structs for these eina beta api's 2016-10-20 17:45:33 +02:00
Tom Hacohen 5a659fafd2 Eo: Fix reference leak when failing to resolve function.
When resolving a function for an object the object would get reference,
and then in some failure cases won't be freed.

I suspect this is a regression following the reshuffling that was done
in that function recently.

Thanks to zmike for investigating and reporting this.

Fixes T4740

@fix
2016-10-19 16:32:16 +01:00
Jean-Philippe Andre 9c95eda748 eo: Fix deadlocks with composite objects
This happens with shared objects.

The situation seems to be:
1. object has composited object a of class A in thread 1
2. call something on object a from thread 2, deadlock
In fact, do anything from thread 2 on a shared object and you deadlock.
2016-10-06 17:57:45 +09:00
Jean-Philippe Andre 6ce60a0de5 eo: Fix deadlock in efl_parent_set
If the object is shared and the given parent is invalid (eg. deleted)
then we will deadlock later. This also adds a test case with it.
2016-10-06 16:19:12 +09:00
Jean-Philippe Andre 258cfbbe80 eo: Fix deadlock with shared objects
The object pointer was passed to EO_OBJ_DONE, rather than its
eo id.
2016-10-06 12:24:59 +09:00
Carsten Haitzler 7b3e7ecc1f eo - eo ptr lookup - do some prefetches to get some micro-speedups
prefetching a bit helps.. a bit like 0.2% or so... but it does help. :)
2016-10-01 23:37:34 +09:00
Carsten Haitzler 6a5ae00ffa eo - goto-ify a chunk iof code moving debug printfs out of hot paths
this moves a lot of error case handling into goto's so the code gets
out of the hot path and this should help expecially since variou
smacros do things like:

   do { char buf[256]; sprintf(buf, fmt, ptr); _eo_pointer_error(buf); } while (0)

   _Efl_Class *klass; \
   do { \
      klass = _eo_class_pointer_get(klass_id); \
      if (!klass) { \
         _EO_POINTER_ERR("Class (%p) is an invalid ref.", klass_id); \
      return ret; \
   } \
} while (0)

so putting quite a chunk of code inside a rare "if this errors"
handler that will cause l1 cache misses and this we don't want, thus
moving stuff in eo core out of hot paths to cut down on overhead. yes
it might not be pretty but it's kind of the right thing at such a core
level of efl. this also does the same to the eo base class as this is
also going to be relatively hot given it's the core of every other
object.
2016-09-29 17:45:47 +09:00
Carsten Haitzler f387818a55 eo - fix error case lock not unlocking with shared objects from coverity
this fixes CID 1363294
2016-09-29 17:45:47 +09:00
Carsten Haitzler edf6507b9f eo - remove pointless if found by coverity
fix CID 1363295
2016-09-29 17:45:47 +09:00
Carsten Haitzler c43308efb4 eo - silence coverit "leak" on eo init if eoid table tls alloc fails
creating a new tls for the eoid table should just never fail so this
is moot anyway, but it silences CID 1362735
2016-09-29 17:45:47 +09:00
Carsten Haitzler 0f929f5546 eo id and shared domain objects - do locking properly and better
so there were a few issues. one we had a spinlokc on the eoid table
for shared objects AND then had a mutex for accessing those objects
(released on return from any eo function). BUT this missed some funcs
like eo_ref, eo_unref and so on in eo.c ... oops. so fixed. but then i
realized there was a race condition. we locked the eoid table then
unlocked with our pointer THEN locked the sharted object mutex ...
then unlocked it. that was a race condtion gap. so we should share the
same lock anyway - if it's a shared object, grab the shared object
mutex then do a lookup and if the lookup does not fail, KEEP the lock
until it is released by the return from eo function or by some special
macro/funcs that released a matching lock. since its a recursive lock
this is all fine. as its also a universal single lock for all objects
we just need the eoid to know if it's shared and needs locking based
on the domain bits. so now do this locking properly with just a single
mutex, not both a spinlock and mutex and keep the lock around until
totally done with the object. this plugs the race condition holes and
goes from 1 spinlock lock and unlock then a mutex lock and unlokc to
just a single mutex lock and unlock. this means shared objects are
actually truly safe across threads and only have the overhead of a
single recursive mutex to lock and unlock in every api call.
2016-09-28 13:38:46 +09:00
Carsten Haitzler ccbf537191 eo ptr indir - handle unlock on error with shared eoids correctly
this fixes the error handling for shared objects which would fail to
unlock on lookup error.
2016-09-26 09:16:21 +09:00
Carsten Haitzler fd1a07e2e4 eo op resolv - do micro optimization to move init to goto blob
as per other recent benchmarking, moving rearely run code (in this
case code to init the op etc.) out of the l1 cacheline prefetch inot a
blob of code at the end of the function where we goto and goto back
again should provide decent-ish speedups for the resolv cache in
avoding this code. yes it makes the code less pretty to read but at
this really low level hot path ... evil things must happen to get the
speed we want/need.
2016-09-24 15:12:09 +09:00
Marcel Hollerbach f63cd63e54 eo: fix headr to header
if you enable EO_DEBUG you cannot build eo, since the field is called
header not headr
2016-09-19 13:25:23 +02:00
Marcel Hollerbach 5a3cf323ef eo: fix reference to constants
they are renamed from the prefix EO_ to EFL_
2016-09-19 13:25:23 +02:00
Marcel Hollerbach 907bbbf965 eo: fix callback cmp
Summary:
as told in _eina_stringshared_key_cmp in eina_hash.c:

originally we want to do this:
   return key1 - key2;
but since they are ptrs and an int can't store the different of 2 ptrs in
either 32 or 64bit (signed hasn't got enough range for the diff of 2
32bit values regardless of their type... we'd need 33bits or 65bits)

So changing this to the same logic.

Reviewers: tasn, raster

Subscribers: cedric, jpeg

Differential Revision: https://phab.enlightenment.org/D4298
2016-09-19 13:25:23 +02:00
Carsten Haitzler 50d508866e eo invalid err - make the thread self more useful like main. 2016-09-17 05:49:32 +09:00
Carsten Haitzler 60f84b733a eo - id lookup failure expansive error print for ebbter debug
whenan eoid lookup fails, now print a lot of information on the issue
like the actual id, generation of the id, if its a class or object
(the class bit), if its ref or super bit is set, the actual id (which
includes the table heirachy), which thread id it is, what domain the
object id is and the current and local domains as well as what domains
are mapped in.
2016-09-16 18:51:22 +09:00
Tom Hacohen cfcdacc5f7 Eo: Remove the EO_DEBUG env check. We have DBG for that. 2016-09-09 11:38:07 +01:00
Tom Hacohen 284b6a5a3e Update the EFL according to new Eo API changes.
I didn't expect it (my bad), but why the hell is this done manually
instead of using Eolian?! People, use Eolian.
2016-09-09 11:25:12 +01:00
Tom Hacohen 7ebf9d879d Eo: Change the way functions are registered to classes
This change lets us remove a field from the structure that leads to
around 20KiB more of saving in private dirty pages in elementary.

This also looks a bit better and feels a bit cleaner.

Breaks API and ABI.
2016-09-09 11:14:35 +01:00
Tom Hacohen 5ad71f1486 Eo: don't allow object override to introduce previously undefined functions. 2016-09-09 11:14:05 +01:00
Carsten Haitzler 8b159aab68 eo - move eoid lookup to ptr indir file and clean up some code
this improves the readability of some of the new domain related and
ptr indir code..
2016-09-09 18:53:20 +09:00
Carsten Haitzler ab0cb7a62d eo - we actually steal the 3rd highest bit for classes - fix
we now just lost another bit from generation count. down to 6 in 32bit
and 26 in 64 bit. this sucks but is necessary. now we are using the
bits just below ref and super bits the code was just maskign off the
next bit as a class marker. this was so so so so wrong. it was the ide
table space. we just never used numbers high enough to start using it.
since i added domain there now those bits can be used easily with
thread domain or other domain. argh! existing eo bug found and fixed.
annoying! :) i added another #define there just to be clear we use
that bit for classes.
2016-09-09 18:53:20 +09:00
Carsten Haitzler 54c39aa564 eo class add - dont always call getenv as this is epxensive. get once
so class creation is possibly a little slower thanks to always calling
getenv. get once then store rsult from there on out.
2016-09-09 18:53:20 +09:00
Jean Guyomarc'h a336e761d2 eo: avoid redefinition of type Efl_Promise
clang complained about type redefinition being a C11 feature, throwing a
warning for each compiling unit including Eo.h.
2016-09-09 08:44:46 +02:00
Cedric BAIL bd362b13d6 efl: add documentation and last cleanup of the API. 2016-09-08 15:16:43 -07:00
Cedric Bail 52c63190d5 eio: rework efl_io_manager to use efl_future. 2016-09-08 15:16:23 -07:00
Cedric Bail f17f389b66 eo: add Eina.Binbuf native type. 2016-09-08 14:58:06 -07:00
Cedric BAIL 6f2cad6439 efl: add a possibility to link death of Eo object with a future. 2016-09-08 14:58:05 -07:00
Cedric BAIL 9a2ada6d87 eo: add abstract efl.future. 2016-09-08 14:58:05 -07:00
Tom Hacohen bd3801247e Eo: Make function overrides implicit.
Before this commit, function overrides were explicit. That is, you'd
have to explicitly state you were overriding a function instead of
creating a new one. This made the code a tad more complex, and was also
a bit more annoying to use. This commit removes this extra piece of
information.

This means we now store much less information per function, that will
let us further optimise out structures in the future.
2016-09-08 13:59:04 +01:00
Tom Hacohen 6b60560773 Eo class creation: Simplify code using recursive locks.
Now that we have recursive locks, the class creation code can be much simpler.
All the code there was essentially our own implementation of recursive locks,
or rather a special case of those.

This is no longer needed.
2016-09-08 11:14:32 +01:00
Carsten Haitzler 3ce5d1ebc7 eo_compatible - improve usability of err/warnings by duplication impl 2016-09-08 00:09:32 +09:00
Carsten Haitzler fc6759ef4d eodomain related docs - update as per some of gustavo's comments 2016-09-08 00:09:32 +09:00
Carsten Haitzler 9d2786896b eo - fix indenting in a file that was nuts and non-standard 2016-09-08 00:09:31 +09:00
Carsten Haitzler f695762d06 eo - add single global mutex for all shared eo objects to they are th-safe
this adds a signle mutex (recursive) mutex for all eo objects that is
auto-called by _efl_object_call_resolve() and _efl_object_call_end()
that wrap all eo method calls and since its recursive it can be
blindly called for sub-calls. this will lock all shared objects during
any call to any shared object so only the thread calling now has
access until it releases. not fine-grained but good enough and the
best we can do "simplistically".
2016-09-08 00:09:31 +09:00
Carsten Haitzler 4478654be1 eo resolv call cache - make TLS with __thread, linker+compiler do it
this will now fix the call cache to be a tls data member and thus
threadsafe. this is the sanest way.
2016-09-07 20:58:39 +09:00
Carsten Haitzler 09f19c3c73 eo - make eo id table TLS private data for thread safety and speed
This moved all the eoid tables, eoid lookup caches, generation count
information ad eo_isa cache into a TLS segment of memory that is
thread private. There is also a shared domain for EO objects that all
threads can access, but it has an added cost of a lock. This means
objects accessed outside the thread they were created in cannot be
accessed by another thread unless they are adopted in temporarily, or
create4d with the shared domain active at the time of creation. child
objects will use their parent object domain if created with a parent
object passed in. If you were accessing EO (EFL) objects across threads
before then this will actually now cause your code to fail as it was
invalid before to do this as no actual objects were threadsafe in EFL,
so this will force things to "fail early".
ecore_thread_main_loop_begin() and end() still work as this uses the
eo domain adoption features to temporarily adopt a domain during this
section and then return it when done.

This returns speed back to eo brining the overhead in my tests of
lookup for the elm genlist autobounce test in elementary from about
5-7% down to 2.5-2.6%. A steep drop.

This does not mean everything is perfect. Still to do are:

1. Tests in the test suite
2. Some API's to help for sending objects from thread to thread
3. Make the eo call cache TLS data to make it also safe
4. Look at other locks in eo and probably move them to TLS data
5. Make eo resolve and call wrappers that call the real method func do
   recursive mutex wrapping of the given object IF it is a shared object
   to provide threadsafety transparently for shared objects (but adding
   some overhead as a result)
6. Test test est, and that is why this commit is going in now for wider
   testing
7. Decide how to make this work with sending IPC (between threads)
8. Deciding what makes an object sendable (a sendable property in base?)
9. Deciding what makes an object shareable (a sharable property in base?)
2016-09-07 18:17:10 +09:00
Carsten Haitzler e14a11d9fa eo base - fix free of all callbacks to set callbacks to NULL
we set count to 0 but not ptr to NULL. this we must do after free so
when other destructors run dont go relying on this ptr to be valid!
2016-09-06 22:12:23 +09:00
Stefan Schmidt 689ba2ff6d eo: update documentation after EFL_CLASS_DESCRIPTION_OPS removal
Remove the references to this removed macro.
2016-09-06 14:54:42 +02:00
Tom Hacohen 829f298589 Eo array callback: Fix compilation on windows.
I knew Windows doesn't allow statically initialising pointers in the
global namespace, I had no idea it also applies to functions. That's
quite annoying.

Thanks to Cedric for reporting.
2016-09-05 17:51:09 +01:00
Tom Hacohen 9c779dca90 Rename efl_self to efl_added
It has been discussed on the ML (thread: "[RFC] rename efl_self") and
IRC, and has been decided we should rename it to this in order to avoid
confusion with the already established meaning of self which is very
similar to what we were using it for, but didn't have complete overlap.

Kudos to Marcel Hollerbach for initiating the discussion and
fighting for it until he convinced a significant mass. :)

This commit breaks API, and depending on compiler potentially ABI.

@feature
2016-09-05 16:59:56 +01:00
Tom Hacohen 5eedad98fe Efl object: Fix outdated docs. 2016-09-05 16:45:37 +01:00
Tom Hacohen b9c5ef4eea Eo array callback: simplify code and fix reliance on gcc extensions.
As far as I remember, declaring structures and arrays in a cast is a GCC
extension. I'm not 100% sure I'm right, but I remember it was the case.

Regardless of whether it's an extension or not, this commit removes that
pattern and makes everything cleaner (and faster?).
2016-09-05 16:25:36 +01:00
Tom Hacohen f13bb9d9f5 Efl object: rename shadowing variable. 2016-09-05 16:22:33 +01:00
Tom Hacohen 4aae224ef5 Efl object: change the way we set class's functions.
This is another follow up to the investigations of T4227. As stated
there, in any PIE (a shared library is one), structures, even const ones
end up being written to because of dynamic relocation. This means that
using static const structures has actually lead to no savings, only
waste. Since we never really needed them, using them made things even
worse than just having a different API that doesn't save them.

Thus, this commit changes the way we set the functions. Instead of
passing a pre-populated struct, we now just have an initialiser function
where you set the functions. This on its own doesn't significantly reduce
the amount of dirty memory pages for a reason I have yet to uncover,
though I believe it's done as a misguided compiler optimisation.
However, this design is flexible enough so we can change to another one
that is quite ugly, but I have already tested and proven that does that.
This patch series doesn't include the better improvement (passing
        everything on the stack as va_args) because the API was too ugly
for me to bear, and I would rather first make sure there is no way to
force the compiler to do the right thing here.

Unfortunately this commit gives up on useless stricter validation.
Before this commit we would make sure that we are only overriding
functions correctly defined in our hierarchy. With this one, we don't
anymore. This is not a big problem though because this is a check that
is also enforced by Eolian. So as long as you are using Eolian, you
should be fine.

Breaks API and ABI!

@feature
2016-09-05 16:03:17 +01:00
Tom Hacohen c8c0bbcfcf Efl object: rename EFL_OBJECT_OVERRIDE_OPS_DEFINE.
It is now called EFL_OPS_DEFINE as it's used for general purpose ops
definition.
2016-09-05 16:03:16 +01:00
Cedric Bail 05f05dde5c eo: protect efl_isa from thread race condition. 2016-09-02 10:19:45 -07:00
Cedric BAIL 3ab60a1564 eo: store registered callbacks in an array instead of a single chained list. 2016-09-02 10:19:45 -07:00
Cedric BAIL 605fec91ee eo: improve speed of walking callback array by sorting them during creation.
This improve speed of processing events in genlist scrolling benchmark by 30%
inside the efl_object_event_callback_call code. Not a really big deal as it
goes from 0.9% to 0.6% of the total time spend. Welcome to micro optimization.
2016-09-02 10:19:45 -07:00