Commit Graph

269 Commits

Author SHA1 Message Date
Felipe Magno de Almeida 138e9e5294 eo: Rename EAPI macro to EO_API in Eo library
Summary:
Patch from a series of patches to rename EAPI symbols to specific
library DSOs.

=  The Rationale =

This patch is from a series of patches to rename EAPI symbols to
specific library DSOs.

EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.

MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.

For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.

With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).

Example 1:
dll1:
```
EAPI void foo(void);

EAPI void bar()
{
  foo();
}
```
dll2:
```
EAPI void foo()
{
  printf ("foo\n");
}
```

This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.

However, the following:
Example 2:

dll1:

```
EAPI extern int foo;
EAPI void foobar(void);

EAPI void bar()
{
  foo = 5;
  foobar();
}
```

dll2:

```
EAPI int foo = 0;
EAPI void foobar()
{
  printf ("foo %d\n", foo);
}
```

This will work on mingw but will not work for MSVC. And that's why
LIBAPI is the only solution that works for MSVC.

Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>

Reviewers: jptiz, lucas, vtorri, woohyun

Reviewed By: jptiz, lucas, vtorri

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D12203
2020-12-09 13:52:25 -03:00
Marcel Hollerbach 812e9f9f09 eo: set idx on exit to 1 not to 0
if this is set to 0 the next iteration in the upper frame event would
decrement the 0 again leading to a overflow making the iteration and
callback array overflow.

Long story short: set ifx to 1 to prevent overflow, test added.

fixes T8787

Differential Revision: https://phab.enlightenment.org/D12101
2020-08-12 11:18:10 +02:00
Marcel Hollerbach 67cd017aac eo: evalulate special counts earlier
we have these special counts which are > 0 when there is a callback
subscribed. THey are currently evalulated in _callback_call. However,
we can also skip the entire call from inside eo_base_class as we are
having the fields there as well.

This way we are skipping the obj pointer lookup and vtable lookup.

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D12079
2020-08-06 10:34:33 +02:00
Marcel Hollerbach 3d547a0b06 eo: event callback call optimization
a little overfiew to how eos event emission is working:
- In eo there are 2 types of events restart events and normal events.
  Normals are *always* emitted from callback_max to 0
  Restarts are emitted from the previous emissions current idx to 0. The
  previous emission will stop then
- To keep track of the previous event emissions for restarts there was
  an eina inlist.
- To keep track of other things in eo, there was an additional eo event
  stack frame (newly inserted events etc. etc.)

This commit now uses this event stack frame for implementing the details
about the restart events. This has the advatage that every
efl_object_data contains one byte less, and the up to date keeping of
the id's in the restart infrastructure is not needed anymore, making the
whole event emission code less instructions and faster.

How this now works:
- Every emission has a event emission frame, when the emission starts,
  the frame is added, next points to the next older event emission. In
  this event stack frame we are storing the current idx, the description
  and a few other things that are not really relevant at this point.
- when a restart event is started, this event stack is searched from the
  current frame up to the next one featuring the same event description.
  The event frame stack is then remembered, if the event emission is
  done, the current idx (normally 0 or something higher when callback
  was stopped) is then copyied back to the earlier frame.
- Based on the nature of the event frame stacks, the idx is updated
  every iteration. And for the restart events, we only need to know the
  next, which removes the need of permanently updating the idx in the
  current stack.
- The event frame stack is not allocated on the heap, hence more things
  in there does not matter at all.

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D12097
2020-08-06 10:34:31 +02:00
Subhransu Mohanty 5797129334 eo: Fix memory leak in efl_key_wref_set() api.
Testcase:
   elementary_test -to snapshot

Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de>
Differential Revision: https://phab.enlightenment.org/D11888
2020-06-02 08:07:42 +02:00
Marcel Hollerbach 9f5ab4dea9 Revert "Revert eo vtale rework..."
This reverts commit efb15f510c.

The error that was causing this was in ector, and is fixed with the
previous commit.
2020-03-23 11:35:06 +01:00
Carsten Haitzler efb15f510c Revert eo vtale rework...
Revert "eo: redo vtable mro creation"
This reverts commit b05110609b.
Revert "eo: add a generic memory allocation tracking method"
This reverts commit 44071e3102.
Revert "eo: rework vtable allocation scheme"
This reverts commit 3bd16a46f1.
Revert "eo: do not allocate extension if deleting"
This reverts commit 64f7edc7fc.

This seems to breal vector rendering in lottie:

From: Hermet Park <hermetpark@gmail.com>
To: Enlightenment developer list <enlightenment-devel@lists.sourceforge.net>
Subject: Re: [E-devel] [EGIT] [core/efl] master 02/05: eo: rework
vtable allocation scheme

This patch occurs memory corruption, vector crashes :(
Here is a sample if you'd like to see it.
https://phab.enlightenment.org/F3858944
2020-03-23 09:07:08 +00:00
Marcel Hollerbach 64f7edc7fc eo: do not allocate extension if deleting
Summary:
->ext is getting freed during invalidate. If we unregister during
destruction (which is something that might happen) we should not
allocate the extension again.

Reviewers: woohyun, zmike, eagleeye

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D11524
2020-03-21 00:01:29 +00:00
Jérémy Zurcher bcdfe21e9e eo : fix 8e6e1860c3, _efl_object_event_future_scheduler_get(…) returns a pointer 2020-02-12 09:08:59 +01:00
Wonki Kim 8e6e1860c3 eo: remove potentional NULL dereferencing
Summary: this patch removes a potentional NULL dereferencing

Reviewers: jsuya, Hermet

Reviewed By: Hermet

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D11325
2020-02-12 16:47:33 +09:00
Cedric BAIL 115a9a22b1 eo: only forward event if someone is listening.
This limit long chain of useless event forwarding when nobody is listening
at the end of the pipe.

Differential Revision: https://phab.enlightenment.org/D10813
2019-12-11 10:36:02 +01:00
Marcel Hollerbach 14b6f23cb3 eo: there is no need to count callbacks here
we are going to add this description anyways, no need to count here
again. I think this is not really making anything really faster, its
more keeping things consistance.

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D10689
2019-11-20 10:15:21 +01:00
Cedric BAIL 75301b3a1a eo: do not over compute the hash when propagating events.
This should slightly improve speed in theory. In practice, I have not seen
a benchmark which would budge by 5%, so I am not sure it improve speed that
much.

Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de>
Differential Revision: https://phab.enlightenment.org/D10660
2019-11-17 12:12:28 +01:00
Cedric BAIL 6d20f32cef eo: no need to oversize type.
Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de>
Differential Revision: https://phab.enlightenment.org/D10659
2019-11-17 12:12:26 +01:00
Cedric BAIL c355616043 eo: refactor shortcut for EFL_EVENT_DESTRUCT event.
Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de>
Differential Revision: https://phab.enlightenment.org/D10658
2019-11-17 12:12:23 +01:00
Daniel Kolesa 9ca573f40f eo: fix UB in the eo event code (edje_cc hangs etc.)
Today I started experiencing mysterious hanging of edje_cc
during build. "The French are at it again" I thought, and
after spending a while bisecting, I found the culprit.
It's 7f53d91583.

So, what is happening in here?

The idea here was fundamentally sound; compute a special
hash value for event descriptors, taking range between 0
and 63 (on 64-bit systems) and 0 and 31 (on 32-bit systems),
then use a mask sized 32-bit or 64-bit (depending on your
system) and check early if to bail out from callback_call,
saving some resources. So far so good.

The problem is in the way the mask is handled. We're applying
the hash as the shift value like, `x |= (1 << hash)`. On 32-bit
systems this is okay, but on 64-bit systems, C's dumb silent
coercion rules kick in, since the left side of the expression
is 1, a literal with type signed int; that means our shifting
range is limited to 31 and what we get is... undefined behavior.

This is obviously not what we want, so take a 1ULL value as a
base. The previous thing seemingly worked on x86_64 (nobody
reported any issues) and interestingly it worked for me too
for a while (on ppc64le), but undefined behavior can be
unpredictable, so...

This shouldn't need a commit message as long as this, but I'm
making it proportional to the amount of time I wasted on this.
2019-11-14 04:18:46 +01:00
Cedric BAIL 620dd43db2 eo: make sure to return the right value for efl_event_callback_call.
EINA_FALSE is to be returned only if one of the callback did call
efl_event_callback_stop not if their was no callback called.

Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de>
Differential Revision: https://phab.enlightenment.org/D10620
2019-11-07 22:24:07 +01:00
Marcel Hollerbach 1a621c9109 eo_base_class: move shift init to the first call
Summary:
this cannot be evalulated in compile time, so this must be evalulated in
runtime, at the first call.

This should fix OSX build.

Co-authored-by: Cedric Bail <cedric.bail@free.fr>

Reviewers: zmike, cedric, raster

Reviewed By: zmike

Subscribers: #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D10582
2019-10-31 12:48:27 -04:00
Cedric Bail ff14c84fcb eo: add debug ability to detect long chain of event handler.
Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de>
Differential Revision: https://phab.enlightenment.org/D10484
2019-10-31 14:52:56 +01:00
Cedric Bail db93501e66 eo: reduce memory use to track event registration and callback call.
Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de>
Differential Revision: https://phab.enlightenment.org/D10482
2019-10-31 14:52:52 +01:00
Cedric Bail 474b1b2c2d eo: add infrastructure to attach an Eina_Future_Scheduler to any source of event.
Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de>
Differential Revision: https://phab.enlightenment.org/D10480
2019-10-31 14:52:46 +01:00
Cedric Bail 2401dae848 ecore: remove unecessary field in data structure.
Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de>
Differential Revision: https://phab.enlightenment.org/D10476
2019-10-31 14:52:35 +01:00
Cedric Bail 7f53d91583 eo: prevent unecessary callback call walk.
This patch introduce a small hash (64 or 32bits) that cache all existing
Efl_Event_Description callback handler registered on an object. It slightly
reduce the time needed to do an unecessary call and cost just a few bytes
per object.

Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de>
Differential Revision: https://phab.enlightenment.org/D10475
2019-10-31 14:52:31 +01:00
Mike Blumenkrantz 8218fb0e20 eo: block "invalidate" event emission when there are no subscribers
Summary:
this should be handled like the rest of eo internal events

ref T8321
Depends on D10353

Reviewers: bu5hm4n, cedric

Reviewed By: bu5hm4n, cedric

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T8321

Differential Revision: https://phab.enlightenment.org/D10354
2019-10-14 09:29:30 -04:00
Marcel Hollerbach 21fe2bdc41 eo: custom created legacy events should be unfreezable
a while back we have moved event submission from custom lists to eo
events. We also merged together the freeze and thaw functions, however,
this brought up one bug. smart_callbacks and the likes (those that used
custom lists before) are not effected by the legacy freeze and thaw
functions. This means, we should declare these legacy wrapper objects
unfreezable in order to obtain this behaviour.

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Reviewed-by: SangHyeon Jade Lee <sh10233.lee@samsung.com>
Differential Revision: https://phab.enlightenment.org/D10016
2019-09-19 14:37:21 -07:00
Cedric BAIL 9e6d3b44e6 eo: add ability to register provider on the Eo object directly.
This should reduce the need for custom implementation of efl_object_provider_bind.
It also enable the ability to register provider from user code on any Efl_Object.

Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de>
Differential Revision: https://phab.enlightenment.org/D9292
2019-07-17 21:57:53 +02:00
Vitor Sousa a86a0931f1 eo: add events to track the ownership status of an Eo object
Some user code may want to track an object ownership in regard to whether it is
kept by just one owner or shared between many owners.

This is specially true for code provided by bindings to other programming
languages, where different kinds of resource management may take place.

The event `ownership,unique` is triggered whenever the object refcount goes
from two to one, as a signal that it has just one owner from now on.

The event `ownership,shared` is triggered whenever the object refcount goes
from one to two, as a signal that it has multiple owners from now on.
It will not trigger when further increasing the refcount to any value beyond
two.

We also add benchmarks for sharing (i.e. increasing the refcount) and them
unsharing objects, in order to evaluate the performance impact of this patch.

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D8678
2019-05-29 15:53:23 -07:00
Cedric BAIL 89280385b4 eo: improve error message by giving an idea where the error come from.
Reviewed-by: Vitor Sousa da Silva <vitorsousa@expertisesolutions.com.br>
Differential Revision: https://phab.enlightenment.org/D8090
2019-03-01 17:10:41 -08:00
Marcel Hollerbach 37d2d378ec eolian: drop class function overriding
Until this commit eo did class functions as part of the vtable, which
enabled those functions to be overwritten in classes inheriting another
class. However in task T7675 we decided that this is not really good for
bindings, as most OOP languages do not support this sort of feature.

After this commit eolian realizes class function completly outside of
the vtable, the c-symbol that is the class funciton is now just directly
redirecting to a implementation, without the involvement of the vtable.

This also means a change to the syntax created by eo:

Calling before:
  class_function(CLASS_A);
Calling after:
   class_function();

Implementation before:
   class_function(const Eo *obj, void *pd) { ... }
Implementation after:
   class_function(void) { ... }

This fixes T7675.

Co-authored-by: lauromauro <lauromoura@expertisesolutions.com.br>

Reviewed-by: Daniel Kolesa <daniel@octaforge.org>
Differential Revision: https://phab.enlightenment.org/D7901
2019-02-13 16:59:58 +01:00
Cedric BAIL 745fb1cf3c eo: propagate knowledge of EFL_EVENT_NOREF callback registration to the event call generation.
This reduce the amount of time efl_event_callback_call(EFL_EVENT_NOREF) is triggered by a factor of 10.

Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Differential Revision: https://phab.enlightenment.org/D7744
2019-01-24 12:22:43 -08:00
Cedric BAIL 27b06dd4ad eo: remove EFL_EVENT_SPECIAL_SKIP.
EFL_EVENT_SPECIAL_SKIP has been defined to 1 for a long time and there
wasn't a way to disable it at all. There is no reason to not use it at
all, so here we go. This was default, now it is without useless code.

Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Xavi Artigas <xavierartigas@yahoo.es>
Differential Revision: https://phab.enlightenment.org/D7743
2019-01-24 11:54:22 -08:00
Cedric BAIL 4a25abccd6 eo: remove function efl_noref that duplicate EFL_EVENT_NOREF.
efl_noref is unused, but will still trigger the full eo call for nothing.
This was the most expensive NOOP. EFL_EVENT_NOREF does the same thing and
we can even filter generating that call as we know when someone is listening.
So removing the function.

Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Xavi Artigas <xavierartigas@yahoo.es>
Differential Revision: https://phab.enlightenment.org/D7742
2019-01-24 11:54:19 -08:00
Cedric BAIL dfd09ec7e4 eo: enable priority with event forwarder.
Note: Their isn't any ability to do something like a static array of
events at the moment. It might lead to large memory being used when it
wouldn't be necessary. If that was the case, we could fix it, but it
would require a lot of dynamic hash operation I think.

Reviewed-by: Marcel Hollerbach <marcel-hollerbach@t-online.de>
Differential Revision: https://phab.enlightenment.org/D7482
2019-01-02 13:39:14 -08:00
Cedric BAIL b351390b04 eo: correctly allow for triggering the same event while the previous one was cancelled.
If you are to trigger an event and just cancelled the one being processed, it would just
not propagate any event while it should. The code looks like more like it was forgotten line
or something.

Reviewed-by: Marcel Hollerbach <marcel-hollerbach@t-online.de>
Differential Revision: https://phab.enlightenment.org/D7481
2019-01-02 13:39:10 -08:00
Cedric BAIL 33c00de365 eo: make efl_future_then have a data pointer in addition of the object pointer.
Summary:
In the case when you have multiple future in flight related to one object, you
couldn't use the previous version of efl_future_then. Now all function calls
take a void* pointer that allow multiple future to have their private data
request data accessible in all the callback.

This should not break released API as Eo.h is not released yet and so
was efl_future_Eina_FutureXXX_then.

Depends on D7332

Reviewers: felipealmeida, segfaultxavi, vitor.sousa, SanghyeonLee, bu5hm4n

Reviewed By: segfaultxavi

Subscribers: #reviewers, #committers

Tags: #efl

Maniphest Tasks: T7472

Differential Revision: https://phab.enlightenment.org/D7379
2018-12-07 12:23:11 +01:00
junsu choi 9d197f38bb eo: Add null check
Summary:
This commit add null check on _efl_object_invalidate
In EO_OBJ_POINTER, if obj_id is null, obj can also be null.

Test Plan: N/A

Reviewers: cedric, zmike

Subscribers: #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D7068
2018-09-21 16:54:52 +09:00
Marcel Hollerbach 365c0334ff efl_object: add call for getting invalidating
Summary:
there is now invalidated & invalidating.

invalidated returns true when all children are invalidated, and the
object is / was requested to be invalidated.

invalidating return true when the object is called to be invalidated but
not all children are invalidated yet. However, the object is garanteed
to be invalidated in near future.

Reviewers: zmike

Reviewed By: zmike

Subscribers: cedric

Tags: #efl, #do_not_merge

Differential Revision: https://phab.enlightenment.org/D6722
2018-08-20 13:15:57 -04:00
Mike Blumenkrantz cba95178d5 eo/base_class: explicitly refuse to set an object as its own parent
somehow this has been possible until now. no.

@fix

Differential Revision: https://phab.enlightenment.org/D6489
2018-07-05 15:11:55 -04:00
Mike Blumenkrantz 51d0faec67 eo: remove some erroneous mutex unlocks during base class parent_set errors
recent changes added unlocks for these mutexes in some other places, so only
do the unlocks where necessary

fix T7020
2018-06-25 15:14:30 -04:00
Mike Blumenkrantz 02c62d3135 eo: remove some erroneous mutex unlocks during base class parent_set errors
recent changes added unlocks for these mutexes in some other places, so only
do the unlocks where necessary

fix T7020
Depends on D6356

Differential Revision: https://phab.enlightenment.org/D6357
2018-06-25 17:17:13 +02:00
Marcel Hollerbach e2d143d19e eo: make noref also a special count
Summary:
this brings down the first frame time from 2.0 sec. to something at 0.7
sec.

ref T6983

Reviewers: zmike

Reviewed By: zmike

Subscribers: YOhoho, cedric, #committers, zmike

Tags: #efl

Maniphest Tasks: T6983

Differential Revision: https://phab.enlightenment.org/D6244
2018-06-05 10:56:09 -04:00
Marcel Hollerbach 608575f5bd eo: do not return efl_invalidated true when its not true
Summary:
the object is invalidated AFTER the parent is lost, (thats what the doc
says). Returning invalidated as true when the parent is still present is
thus not correctly.

Depends on D6222

Reviewers: cedric, zmike, JackDanielZ

Subscribers: cedric, #committers, zmike

Tags: #efl

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

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
2018-05-28 21:50:17 -07:00
Cedric BAIL 38d8b615c8 eo: an object is invalidated if it is invalidated or if any parent is invalidated. 2018-05-24 16:02:21 -07:00
Cedric BAIL b1954ce1e7 eo: move wref set to NULL to append after last event.
Making wref disapear before the last event require additional work to use
them during the FREE event. As I think we should introduce a wref that
disapear after the invalidate state, it makes sense to move that to a later
stage. Especially because their is no specific event related to them
being set to NULL.
2018-05-24 16:02:20 -07:00
Cedric Bail fa795b17d3 eo: allow efl_part during object invalidate. 2018-05-24 16:02:20 -07:00
Cedric BAIL a90b5fa930 eo: remove parent_sink as this hack should not be necessary anymore. 2018-05-24 16:02:20 -07:00
Cedric BAIL 0cc07f4e6b eo: try to make efl_add and efl_add_ref refcounting sane in all case. 2018-05-24 16:02:20 -07:00
Cedric Bail e1d41eef3a eo: actually enforcing the efl_parent_set code path is necessary to enforce the predictability of the code path. 2018-05-24 16:02:19 -07:00
Cedric Bail 23e2c0bdb8 eo: as efl_del is not an Eo API call anymore, manually protect call with refcount. 2018-05-24 16:02:19 -07:00
Cedric Bail d052f001be eo: move destruction of the link with children to be always after invalidate. 2018-05-24 16:02:19 -07:00