librelist archives

« back to archive

Reentrant deep_twin

Reentrant deep_twin

From:
Paolo Redaelli
Date:
2011-11-11 @ 01:29
Cyril can you please give me some hints on how to add a new built-in?
Please see these commits:
https://github.com/tybor/Liberty/commit/6441ad1125fc271937f00ff77c037897c057e35c
https://github.com/tybor/Liberty/commit/4423d1f8e6f02e32261b4c45386d32e177d5f3b6
I plan to make deep_twin (and then is_deep_equal) reentrant and
hopefully thread safe not having a static se_hash_table but passing it
around during deep twinning.
This require either to change deep_twin into a plain feature invoking
"Result := reentrant_deep_twin(default_pointer)"
When invoked with NULL reentrant_deep_twin will allocate a new hash
table and pass it to sub-calls to other reentrand_deep_twin implementations.
I located the C implementation of the body in
src/smarteiffel/generation/c/c_native_function_mapper.e

<https://github.com/tybor/Liberty/commit/4423d1f8e6f02e32261b4c45386d32e177d5f3b6#diff-1>
but I cannot (easily?) find the place where the signature is defined,
since it changes with compilation flags (anything not boost adds a
se_dump_stack* as first argument).
Ideally I would implement it from the start being friendly to multiple
backends.... perhaps a POINTER is not a good choice...
Happy hacking
    Paolo

Re: [libertyeiffel] Reentrant deep_twin

From:
Cyril Adrian
Date:
2012-01-02 @ 15:19
Hi Paolo, all,

First of all, happy new year to all our Liberty Eiffelists :-)

2011/11/11 Paolo Redaelli <paolo.redaelli@gmail.com>

> **
> Cyril can you please give me some hints on how to add a new built-in?
>

A built-in is a multipart beast. You need to know:
 - how to define the function
 - how to call the function

for each supported back-end (currently, C, maybe Java, and the interpreter).

Let's talk C only: in src/smarteiffel/generation/c

In SmartEiffel parlance, a function call is the "mapping" of the function.
The class C_MAPPER takes care of that by either generating a function call
or inlining the code. For some builtins, the "call" is replaced by some
inline code. That's *not* the case for *deep_twin*.

For *deep_twin*, we need a "wrapper" (a helper function): see
C_NATIVE_NEED_WRAPPER.visit_native_built_in
Therefore, the mapping is the standard one (i.e. generation of a C function
call to a C function that will also be generated).

The content of the wrapper itself is defined in
C_LIVE_TYPE_COMPILER.visit_run_feature_8 which prepares the signature and
calls cpp.native_function_mapper.compile(visited)

The latter contains the code generation you spotted :-)

Cheers,

*Cyril ADRIAN*
*http://www.cadrian.net/cyril*
[image: Facebook] <https://www.facebook.com/cyril.adrian> [image:
Twitter]<https://twitter.com/cadbart> [image:
LinkedIn] <http://fr.linkedin.com/in/cadrian> [image: Google
Plus]<https://plus.google.com/100388810006463519079/posts> [image:
Google 
Calendar]<https://www.google.com/calendar/embed?src=1t93vvvrdc26ee0f83p0cunj60%40group.calendar.google.com&ctz=Europe/Paris>
Contact me: [image: Google Talk] cyril.adrian@gmail.com
 [image: Twitter] <http://twitter.com/cadbart> Latest tweet: [Liberty]
http://t.co/Vauhqtfj Cyril Adrian - working on pointers
Follow @cadbart <http://twitter.com/cadbart> Reply

<http://twitter.com/?status=@cadbart%20&in_reply_to_status_id=153502349699190800&in_reply_to=cadbart>
Retweet

<http://twitter.com/?status=RT%20%40cadbart%3A%20%5BLiberty%5D%20http%3A%2F%2Ft.co%2FVauhqtfj%20Cyril%20Adrian%20-%20working%20on%20pointers>
 16:46 Jan-01<http://twitter.com/cadbart/statuses/153502349699190787>
  Get this email app!

<http://www.wisestamp.com/apps/twitter?utm_source=extension&utm_medium=email&utm_term=twitter&utm_campaign=apps>

 [image: Google Plus] <http://plus.google.com/100388810006463519079> My
latest G+: LinkedIn est décidément de plus en plus
intrusif....<http://plus.google.com/100388810006463519079/posts/fB4C49eLbr1/>
My G+ <http://plus.google.com/100388810006463519079> -
Posts<http://plus.google.com/100388810006463519079/posts/>- Add
to Circles <http://plus.google.com/100388810006463519079/about/> - 09:50
Dec-21 <http://plus.google.com/100388810006463519079>
  Get this email app!

<http://www.wisestamp.com/apps/plus?utm_source=extension&utm_medium=email&utm_term=plus&utm_campaign=apps>

[image: My QR VCard]
  Get a signature like this.

<http://r1.wisestamp.com/r/landing?promo=17&dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_17>
CLICK

HERE.<http://r1.wisestamp.com/r/landing?promo=17&dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_17>

Re: [libertyeiffel] Reentrant deep_twin

From:
Paolo Redaelli
Date:
2012-01-03 @ 17:05
Il 02/01/2012 16:19, Cyril ADRIAN ha scritto:
> Hi Paolo, all,
>
> First of all, happy new year to all our Liberty Eiffelists :-)
>
> 2011/11/11 Paolo Redaelli <paolo.redaelli@gmail.com
> <mailto:paolo.redaelli@gmail.com>>
>
>     Cyril can you please give me some hints on how to add a new built-in?
>
>
> A built-in is a multipart beast. You need to know:
>  - how to define the function
>  - how to call the function
>
> for each supported back-end (currently, C, maybe Java, and the
> interpreter).
>
> Let's talk C only: in src/smarteiffel/generation/c
>
> In SmartEiffel parlance, a function call is the "mapping" of the
> function. The class C_MAPPER takes care of that by either generating a
> function call or inlining the code. For some builtins, the "call" is
> replaced by some inline code. That's *_not_* the case for /deep_twin/.
>
> For /deep_twin/, we need a "wrapper" (a helper function): see
> C_NATIVE_NEED_WRAPPER.visit_native_built_in
> Therefore, the mapping is the standard one (i.e. generation of a C
> function call to a C function that will also be generated).
>
> The content of the wrapper itself is defined in
> C_LIVE_TYPE_COMPILER.visit_run_feature_8 which prepares the signature
> and calls cpp.native_function_mapper.compile(visited)
>
> The latter contains the code generation you spotted :-)
>
Thank you very much! The informations you gave here are (almost) exactly
what I need; in fact I may leave reentrant_deep_twin under the wood of
the (C) runtime but it may be useful to expose it at Eiffel level to
allow for implementation with other backends....

Re: [libertyeiffel] Reentrant deep_twin

From:
Date:
2012-01-03 @ 07:28
Hi all,

Happy near year to all and long life to Liberty.

--
Christophe
----------

----- Mail original -----
De: "Cyril ADRIAN" <cyril.adrian@gmail.com>
À: libertyeiffel@librelist.com
Envoyé: Lundi 2 Janvier 2012 16:19:11
Objet: Re: [libertyeiffel] Reentrant deep_twin

Hi Paolo, all, 


First of all, happy new year to all our Liberty Eiffelists :-) 


Cheers, 


Cyril A DRIAN