Commit Graph

166 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
Carsten Haitzler ddfa2ef41c Revert "eo_test_general.c: Make eo_signals tests pass on Windows"
This reverts commit fc949660f7.
2020-11-05 12:17:42 +00:00
Wander Lairson Costa fc949660f7 eo_test_general.c: Make eo_signals tests pass on Windows
Summary:
EFL_CALLBACKS_ARRAY_DEFINE reorders the callbacks according to
efl_callbacks_cmp. efl_callbacks_cmp compares the address of the desc
field, which depends on the memory layout generated by the linker.

To make the test run deterministically, we define the array of callbacks
manually.

Reviewers: vtorri, felipealmeida, raster

Reviewed By: raster

Subscribers: cedric, #reviewers, #committers, jptiz, felipealmeida

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D12043
2020-11-04 18:56:37 +00: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 3bd16a46f1 eo: rework vtable allocation scheme
Summary:
with this commit a new way of allocating vtables arrived.
The old mechnism was to allocate a table big enough to carry *all*
functions at once, in order to not allocate that much memory for
functions that are not implemented on a specific klass, dichchains have
been used, which can be seens as a 2D matrix, where columns are only
allocated if min 1 entry needs to be written, this may have been a good
way to allocate back in the day when all this with eo started, however,
it showed to not pay off.

With this new way, we allocate a array of arrays. the first lvl array is
carrying enough slots, that *all* up to the time defined
interfaces/classes/abstracts/mixins can be implemented. The second lvl
array then has exactly the size of the defined APIs. The second lvl
array is obviously only allocated if needed.

When comparing the two methods, i messured two things, the usage based
on memory allocation for vtable-way-1 and vtable-way-2. Additionally, i
checked the overall memory usage of elementary_test using pmap. The
first messurement is a little bit more exact. The second messurement is
more biased, but captures the whole picture.

Memory allocation tracking:
   vtable-way-1 - vtable-way-2 = 74680 Byte

Pmap memory tracking:
   vtable-way1 - vtable-way-2 = 217088 Byte

The second messurement shows a bigger impact, likely because this is
also showing off all the sideeffects that we are taking place due to
fewer allocations.

Depends on D11524

Reviewers: zmike, tasn, stefan_schmidt, woohyun, cedric, raster

Subscribers: #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D11535
2020-03-21 00:01:29 +00: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 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
Marcel Hollerbach 5284ac36ca eo: add API for querying the class type
a class can be a interface mixin abstract or regular.
This adds a API for getting this information
2019-02-21 08:56:13 +01:00
Marcel Hollerbach 46885653bc eo: remove class functions from eo
As in the previous commit explained, we want to get rid of class
functions in eo, and make them just c functions right away.

This commit removes the class parameter from the eo_class_function_set
call, and adjusts the tests to not depend on class functions anymore.
Class functions are now not tested anymore, tests that used them as a
way to test *things* are adjusted to test them now with object
functions, tests that just tested the working of class functions are
dropped.

This fixes T7675.

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D7902
2019-02-13 16:59:59 +01:00
Marcel Hollerbach 0221ff480d eo: the object size changes for the eo_debug profile
Differential Revision: https://phab.enlightenment.org/D7909
2019-02-12 11:20:21 +01:00
Marcel Hollerbach 0709bdea6f eo: change API call of efl_class_functions_set
The next commit will bring support for something like reflection. This
commit prepares the whole tree for getting another argument in
efl_class_functions_set.

ref T7681

Differential Revision: https://phab.enlightenment.org/D7882
2019-02-07 14:43:25 +01:00
Mike Blumenkrantz c946b1477d eo: implement class overriding (+unit tests)
this enables an app or a platform to add an override for a given class,
then return a different object when that class is created. the benefit is
that a class can be internally customized by the app without needing to
modify upstream versions of that class

@feature
fix T7516

Reviewed-by: Marcel Hollerbach <marcel-hollerbach@t-online.de>
Differential Revision: https://phab.enlightenment.org/D7702
2019-02-04 19:31:17 +01:00
Cedric BAIL 549bf6e269 eo: improve efl_isa to be able to know if a class is part of the hierarchy of another class.
Reviewed-by: SangHyeon Jade Lee <sh10233.lee@samsung.com>
Differential Revision: https://phab.enlightenment.org/D7703
2019-01-24 16:29:25 -08:00
Cedric BAIL 6a144f5008 eo: add a test to enforce the upper limit of our base object size.
Differential Revision: https://phab.enlightenment.org/D7523
2019-01-09 11:02:07 -08:00
Mike Blumenkrantz 0f2a9e15cd tests/eo: add explicit test case for setting an object as its own parent
Summary: Depends on D6489

Reviewers: bu5hm4n, devilhorns

Reviewed By: bu5hm4n

Subscribers: cedric, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D6490
2018-07-05 15:11:55 -04:00
Mike Blumenkrantz a62d254306 tests/eo: add explicit ref check when setting an invalid parent
Summary: ref f4a55e9266

Reviewers: bu5hm4n, devilhorns, Hermet

Reviewed By: Hermet

Subscribers: cedric, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D6473
2018-06-29 10:21:02 +09:00
Mike Blumenkrantz f4a55e9266 tests: add coverage for efl_parent_set with invalidated parent object
this hits a codepath which was otherwise never triggered by unit tests
2018-06-25 15:14:30 -04:00
Mike Blumenkrantz d2a703e7b8 tests: add some more failure cases for efl_parent_set in eo tests
ref T6837

Differential Revision: https://phab.enlightenment.org/D6358
2018-06-25 17:17:13 +02:00
Mike Blumenkrantz b2e3c483a8 tests: ensure class constructor is called in eo_domain test
failing to call this prior to the thread invocation would result in a CRI
from class initialization in a thread

ref T7003

Differential Revision: https://phab.enlightenment.org/D6333
2018-06-25 17:03:05 +02:00
Marcel Hollerbach 6e46950169 eo: get rid of eo_id
Summary:
build with this disabled is just not working as the thread model of eo
falls apart. The threadmodel is required to have eo_id, as it decoded
the thread information in the eo_id, which is not working without eo_id.

This also fixes the testcases that have never been executed due to the
fact of the missing HAVE_EO_ID

fix T6610

Depends on D6327

Reviewers: devilhorns, zmike

Reviewed By: zmike

Subscribers: cedric, #committers, zmike

Tags: #efl

Maniphest Tasks: T6610

Differential Revision: https://phab.enlightenment.org/D6328
2018-06-19 13:35:53 -04:00
Mike Blumenkrantz dfe703b9bc tests: wrap critical errors to disable aborting in eo tests
ref T7002

Differential Revision: https://phab.enlightenment.org/D6271
2018-06-18 12:11:27 +02:00
Mike Blumenkrantz e5d4f9f63c tests: disable eo test timeouts when not forked
this makes debugging much easier

Differential Revision: https://phab.enlightenment.org/D6270
2018-06-18 12:11:27 +02:00
Cedric BAIL 3489708052 eo: we are actually testing internal function too here. 2018-05-24 16:02:20 -07:00
Mike Blumenkrantz 5490db74a0 tests: remove sleep() calls from eo tests
Summary: fix T6854

Reviewers: stefan_schmidt

Reviewed By: stefan_schmidt

Subscribers: cedric

Maniphest Tasks: T6854

Differential Revision: https://phab.enlightenment.org/D5910
2018-04-13 13:53:39 +02:00
Mike Blumenkrantz 624925fe6e tests: move to using checked fixtures for all test suites
individual tests should not need to explicitly call init/shutdown functions
in most cases, and many did not properly do this anyway

see followup commit which resolves some issues with eina tests

ref T6813
ref T6811

Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>
2018-04-05 11:10:26 +02:00
Mike Blumenkrantz adc601aca2 tests: add instrumentation to existing tests to find slow tests
efl_check.h must be included and the EFL_START/END_TEST macros must be
used in place of normal START/END_TEST macros

timing is enabled when TIMING_ENABLED is set
https://phab.enlightenment.org/w/improve_tests/

Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>
2018-04-05 11:10:25 +02:00
Cedric BAIL bc18b7e7ad efl: replace efl_del with efl_unref for cases where no parent exists
Signed-off-by: Mike Blumenkrantz <zmike@osg.samsung.com>
2018-03-20 17:20:57 -07:00
Cedric BAIL 4c4177ac20 efl: use efl_add_ref to create objects which have no parent
Signed-off-by: Mike Blumenkrantz <zmike@osg.samsung.com>
2018-03-20 17:20:56 -07:00
Cedric Bail fae4ad5fbb eo: fix warning. 2018-03-07 11:01:25 -08:00
Cedric Bail 21c80b027e eo: adjust test suite to take invalidate state into account. 2018-03-07 11:00:06 -08:00
Carsten Haitzler 4a97c7d387 tests - eo - found eo_signals test is wrong... amazing it passed before
so it was listening for cb adds and dels... and or del of any cb
except the cb add/del catcher was done.. it would fail...

but ... the test actually added other cbs than this ... like:

   efl_event_callback_array_priority_add(obj, _eo_signals_callbacks(),
-100, (void *) 1);

a while array of cb's:

{ EV_A_CHANGED, _eo_signals_a_changed_cb },
{ EV_A_CHANGED, _eo_signals_a_changed_cb2 },
{ EV_A_CHANGED, _eo_signals_a_changed_never },
{ EFL_EVENT_DEL, _eo_signals_efl_del_cb });

none of which were _eo_signals_cb_added_deled. i am amazed it passed
before...

now switch its checks to check for itself and then check for anything
BUT itself...
2018-03-03 13:40:33 +09: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-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
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
Andy Williams d5dbcdabd1 eo: Rename efl_ref_get to efl_ref_count 2017-11-08 09:30:42 +00: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
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 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 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
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
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
Tom Hacohen 047d88caa0 Eo: Add test for refcount in efl_add_ref
This commits adds a regression test to the previous commit.
2016-10-21 15:29:39 +01:00
Tom Hacohen 25242e6af9 Eo: Fix references of objects 2016-10-21 15:29:39 +01:00
Tom Hacohen 6c8489c3b7 Eo test: Fix cleanup of objects. 2016-10-21 15:29:39 +01:00
Tom Hacohen d952b35098 Eo: Add a regression test for ref leak in function resolve
This adds a regression test for the last commit.
2016-10-19 16:32:16 +01:00
Tom Hacohen f4eb94a7d8 Eo: Remove no longer relevant tests. 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 7db67aaea8 eo: Test deadlock after finalize (shared objects)
This is a test case for 258cfbbe80
Unfortunately there are many other functions that we should
be testing, not just efl_finalized_get().
2016-10-06 16:12:01 +09:00