Page MenuHomePhabricator

Experiments with EO super & cast
ClosedPublic

Authored by jpeg on Apr 18 2017, 5:13 AM.

Details

Summary

Hi~
I'm sending this for review as this can have a performance impact (but hard to measure) and so I'd like some feedback :)
This is two patches combined into one (arcanist...). The first one is not necessary but I have always hated the spinlock in efl_super.

Patch summaries:

eo: Remove lock from efl_super [EXPERIMENTAL]

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.

eo: Add new API efl_cast [EXPERIMENTAL]

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!

Fixes T5311

@feature

Diff Detail

Repository
rEFL core/efl
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
jpeg created this revision.Apr 18 2017, 5:13 AM
jpeg retitled this revision from eo: Remove lock from efl_super [EXPERIMENTAL] to Experiments with EO super & cast.Apr 18 2017, 5:19 AM
jpeg edited the summary of this revision. (Show Details)
barbieri edited edge metadata.Apr 18 2017, 7:42 AM

lgtm

src/tests/eo/suite/eo_test_general.c
1651

plz use the ck_assert_int_eq() kind of macros, they will provide better values on error (I know the rest of the code isn't, but introduce new checks using that)

jpeg marked an inline comment as done.Apr 18 2017, 7:06 PM

Since I've had two positive answers I'll merge this. Thanks for the review!

Closed by commit rEFL19b9234f23af: eo: Add new API efl_cast (authored by Jean-Philippe Andre <jp.andre@samsung.com>). · Explain WhyApr 19 2017, 1:13 AM
This revision was automatically updated to reflect the committed changes.