summaryrefslogtreecommitdiff
path: root/src/lib/eo/eo_base_class.c (follow)
AgeCommit message (Collapse)Author
2018-03-03ecore - a different take on efl.app class as a super class to efl.loopCarsten Haitzler (Rasterman)
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-02-25eo: avoid useless computationsJean Guyomarc'h
Better exploit class constructor and destructor to initialize data once and for all. This allows not make initialization checks at runtime.
2018-01-10eo: Add "destruct" eventJean-Philippe Andre
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-04eo: make efl_provider_find a @const function.Cedric BAIL
2017-12-08eo: Remove trailing newline in ERR messageJean-Philippe Andre
2017-12-05eo: Move hacky API auto_unref to C onlyJean-Philippe Andre
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-10-18eo: Add beta API for auto_unref after a callJean-Philippe Andre
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-13eo: Simplify debug_name_overrideJean-Philippe Andre
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 999dbd9764426890c0e11841358f9219082b89b2 And c4769ff8989bab2b745017b843f073e5737e91e0
2017-09-28eo: Add API to allow deletion by unrefJean-Philippe Andre
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-04Efl_Object: Add integration with Eina_Future.Guilherme Iscaro
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-08-23eo: Mark name_find as constJean-Philippe Andre
The search should not require a mutable object. See the previous commit on elm_widget.
2017-08-04eo debug name: Use strbuf instead of slstrJean-Philippe Andre
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-04eo: Add debug_name read-only property to ease debuggingJean-Philippe Andre
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-05-04eo: fix missing event emissionMarcel Hollerbach
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 605fec91ee7. @fix
2017-04-26eo: move all the key_ properties to CDaniel Kolesa
2017-04-26eo: move wref_add/wref_del to CDaniel Kolesa
2017-04-26eo: move future_link to CDaniel Kolesa
2017-04-21eo: hide dbg_info from eo filesDaniel Kolesa
Continues b780cf2af299ce17be260486bb7ab64badddbaec.
2017-04-20eo: move unbindable event APIs to CDaniel Kolesa
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-18eo: Use COW to save 8~16 bytes per objectJean-Philippe Andre
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-02-16eo: ensure the generation is correctly clampedMarcel Hollerbach
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-11efl base class - fix warning about comparing differing sizesCarsten Haitzler (Rasterman)
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.
2016-12-02eo event callback frame make them single linked to save a bit of overheadCarsten Haitzler (Rasterman)
this makes the callback event frame single linked with a little less inlist overhead asa result.
2016-12-02eo: adjust generation countMarcel Hollerbach
raster suggested a few optimizations
2016-12-02eo: optimize generation increaseMarcel Hollerbach
doing it by hand here saves a function call which showed up pretty happy on perf.
2016-12-02eo: use the event stack to define behaviourMarcel Hollerbach
subscriptions are only executed if they were already subscriped at the start of the event emission.
2016-12-02eo: fix event emission for subscription while emissionMarcel Hollerbach
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-11-28eo: safety in string comparisonAndy Williams
Avoid potential for Eo to crash if app manages to unset key @fix
2016-11-26eo base class - clean up some formatting around callback add/del codeCarsten Haitzler (Rasterman)
just formatting changes really.
2016-11-23eo: make it possible to disable batch allocation for callbacks.Cedric Bail
2016-11-23eo: when there is no more callbacks, let's clean up.Cedric Bail
2016-11-23eo: inc the special countMarcel Hollerbach
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-21eo: refactor callback delayed cleaning code.Cedric Bail
2016-11-17efl object events - track del, cb add and cb del callback countsCarsten Haitzler (Rasterman)
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-17eo src formatting - line up struct memberCarsten Haitzler (Rasterman)
2016-11-17event callback call - move 0 check early before any var initCarsten Haitzler (Rasterman)
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-17eo - fix ever growing callback list by actually flagging waiting delsCarsten Haitzler (Rasterman)
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-06eo - use free queue for at least some eo core memory and pointersCarsten Haitzler (Rasterman)
this should help improve robusteness by keeping memory around for a bit until the free queue flushes or is full @feature
2016-10-28Eo: Add a method to mark objects for reuse.Tom Hacohen
This informas eo an object is going to get reused/cached, so eo can reset the object appropriately. @feature.
2016-10-25eo: do not track NULL future.Cedric Bail
2016-10-21Eo: Fix references of objectsTom Hacohen
2016-10-06eo: Fix deadlocks with composite objectsJean-Philippe Andre
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-06eo: Fix deadlock in efl_parent_setJean-Philippe Andre
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-06eo: Fix deadlock with shared objectsJean-Philippe Andre
The object pointer was passed to EO_OBJ_DONE, rather than its eo id.
2016-09-29eo - goto-ify a chunk iof code moving debug printfs out of hot pathsCarsten Haitzler (Rasterman)
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-28eo id and shared domain objects - do locking properly and betterCarsten Haitzler (Rasterman)
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-08efl: add a possibility to link death of Eo object with a future.Cedric BAIL
2016-09-07eo - make eo id table TLS private data for thread safety and speedCarsten Haitzler (Rasterman)
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-06eo base - fix free of all callbacks to set callbacks to NULLCarsten Haitzler (Rasterman)
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-05Efl object: rename shadowing variable.Tom Hacohen