Re: [Pharo-users] how to load compiled code in the image and to change methods already on the stack?

2018-02-27 Thread Andrew P . Black

> On 26 Feb 2018, at 22:59 , Steven Costiou  > wrote:
> 
> Hi Pablo,
> 
> thanks :) I will try Hermes.
> 
> Basic scenario is adding/removing metalinks to a lot of a methods in an iot 
> app:
> 
> 1- If the add/remove occurs a lot of time, then there is a slowdown due to 
> recompilation of methods. As this is a remote app, i want to try recompiling 
> all methods locally then upload them. I will also try with Hermes.
> 
>  
> 2- If metalinks are put inside a loop that is running, for now i understand i 
> cannot update the method unless i replace it on the stack. Experimenting that 
> is somewhere in my todolist, but i'm taking any advice ;) Maybe that is not 
> really possible.
> 
>  
> Steven.

My suggestion would be not to try updating methods that are on the stack, but 
to update the methods that are executed in response to messages sent by what is 
on the stack.  So, for example, instead of

longRunningLoopThatHandlesEvents
[ terminationCondition ] whileFalse: [
big loop body inline here
]

write:

longRunningLoopThatHandlesEvents
[ terminationCondition ] whileFalse: [
self doOneIteration
]

doOneIteration
big loop body here

Then you can upload a new version of doOneIteration, and next time around the 
even loop, that’s what will be executed.  This is much cleaner; you don’t have 
to worry about changing code in the midst of its execution and somehow 
preserving the values of temporaries while you do so.

You can see the same thing in Pharo if you are examining an execution in the 
debugger, and edit and recompile one of the executing methods.  The method on 
the stack won’t change, but after the execution context has popped off the 
stack, you will see the new version execute in response to subsequent message 
sends.

Andrew




Re: [Pharo-users] how to load compiled code in the image and to change methods already on the stack?

2018-02-26 Thread Steven Costiou
Hi Pablo, 

thanks :) I will try Hermes. 

Basic scenario is adding/removing metalinks to a lot of a methods in an
iot app: 

1- If the add/remove occurs a lot of time, then there is a slowdown due
to recompilation of methods. As this is a remote app, i want to try
recompiling all methods locally then upload them. I will also try with
Hermes. 

2- If metalinks are put inside a loop that is running, for now i
understand i cannot update the method unless i replace it on the stack.
Experimenting that is somewhere in my todolist, but i'm taking any
advice ;) Maybe that is not really possible. 

Steven. 

Le 2018-02-26 10:36, teso...@gmail.com a écrit :

> Hi Steven,  
> 
> 1. You can use Hermes through a socket or a file. The only pre-requisite is 
> that both images run similar compatible compilers (usually you can use it 
> from and to Pharo 6.1 and 7) 
> 2. You can change the method, but if there is an activation context in the 
> stack everything can be wrong. If you change a method you should update the 
> program counter of the stack, and also any other thing can change (for 
> example, temporaries or literals).  
> Can you describe more the scenario where you want to change the method? 
> 
> Cheers,  
> 
> On Sat, Feb 24, 2018 at 11:23 AM, Steven Costiou  
> wrote:
> 
>> Hi, 
>> 
>> is this possible somehow to: 
>> 
>> - load compiled code in the image? like loading a compiled method instead of 
>> loading source then compiling it? 
>> 
>> - dynamically change a method that is on the stack? 
>> 
>> If so, how? :) 
>> 
>> Steven.
> 
> -- 
> Pablo Tesone.
> teso...@gmail.com

  

Re: [Pharo-users] how to load compiled code in the image and to change methods already on the stack?

2018-02-26 Thread teso...@gmail.com
Hi Steven,

1. You can use Hermes through a socket or a file. The only pre-requisite is
that both images run similar compatible compilers (usually you can use it
from and to Pharo 6.1 and 7)
2. You can change the method, but if there is an activation context in the
stack everything can be wrong. If you change a method you should update the
program counter of the stack, and also any other thing can change (for
example, temporaries or literals).
Can you describe more the scenario where you want to change the method?

Cheers,

On Sat, Feb 24, 2018 at 11:23 AM, Steven Costiou 
wrote:

> Hi,
>
> is this possible somehow to:
>
> - load compiled code in the image? like loading a compiled method instead
> of loading source then compiling it?
>
> - dynamically change a method that is on the stack?
>
>
>
> If so, how? :)
>
> Steven.
>



-- 
Pablo Tesone.
teso...@gmail.com


Re: [Pharo-users] how to load compiled code in the image and to change methods already on the stack?

2018-02-26 Thread Guillermo Polito
On Sun, Feb 25, 2018 at 12:59 PM, Steven Costiou 
wrote:

> Le 2018-02-25 08:37, Stephane Ducasse a écrit :
>
> On Sat, Feb 24, 2018 at 11:23 AM, Steven Costiou
>  wrote:
>
> Hi,
>
> is this possible somehow to:
>
> - load compiled code in the image? like loading a compiled method instead
> of
> loading source then compiling it?
>
>
> why is this a problem?
> you could try to serialise a method with fuel and load it.
>
>
>
> That is not necessarily a problem, I want to add new or modified methods
> in remote iot applications, while Pharo is running. I'm experimenting
> different ways to find which one suits me best. It works with TelePharo for
> example, but the method has to be recompiled on the iot application side. I
> was just wondering if Pharo provided a way to upload an already compiled
> method.
>

> I will try fuel. But is fuel part of "standard" Pharo distribution?
>

I'm really tempted to tell you to download Pharo and check it for yourself
^^


>
>
>
>
> - dynamically change a method that is on the stack?
>
>
> have a look at on:fork: to see how igor cut some stack elements
>
>
>
>

Also, send an email to Pablo, he's the DSU expert :)


> Thanks.
>
> Steven.
>
>
>
>
>
>



-- 



Guille Polito

Research Engineer

Centre de Recherche en Informatique, Signal et Automatique de Lille

CRIStAL - UMR 9189

French National Center for Scientific Research - *http://www.cnrs.fr
*


*Web:* *http://guillep.github.io* 

*Phone: *+33 06 52 70 66 13


Re: [Pharo-users] how to load compiled code in the image and to change methods already on the stack?

2018-02-25 Thread Steven Costiou
Le 2018-02-25 08:37, Stephane Ducasse a écrit :

> On Sat, Feb 24, 2018 at 11:23 AM, Steven Costiou
>  wrote: 
> 
>> Hi,
>> 
>> is this possible somehow to:
>> 
>> - load compiled code in the image? like loading a compiled method instead of
>> loading source then compiling it?
> 
> why is this a problem?
> you could try to serialise a method with fuel and load it.

That is not necessarily a problem, I want to add new or modified methods
in remote iot applications, while Pharo is running. I'm experimenting
different ways to find which one suits me best. It works with TelePharo
for example, but the method has to be recompiled on the iot application
side. I was just wondering if Pharo provided a way to upload an already
compiled method. 

I will try fuel. But is fuel part of "standard" Pharo distribution? 

>> - dynamically change a method that is on the stack?
> 
> have a look at on:fork: to see how igor cut some stack elements

Thanks. 

Steven. 

  

Re: [Pharo-users] how to load compiled code in the image and to change methods already on the stack?

2018-02-24 Thread Stephane Ducasse
On Sat, Feb 24, 2018 at 11:23 AM, Steven Costiou
 wrote:
> Hi,
>
> is this possible somehow to:
>
> - load compiled code in the image? like loading a compiled method instead of
> loading source then compiling it?

why is this a problem?
you could try to serialise a method with fuel and load it.


> - dynamically change a method that is on the stack?

have a look at on:fork: to see how igor cut some stack elements
>
>
>
> If so, how? :)
>
> Steven.



[Pharo-users] how to load compiled code in the image and to change methods already on the stack?

2018-02-24 Thread Steven Costiou
Hi, 

is this possible somehow to: 

- load compiled code in the image? like loading a compiled method
instead of loading source then compiling it? 

- dynamically change a method that is on the stack? 

If so, how? :) 

Steven.