recompiling CompiledMethod?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

recompiling CompiledMethod?

"Hernán Morales"

Hello all there.
This is my first message to the list, and I just want
to know if possible, how to add (the easiest way) an
instance variable to CompiledMethod class, without
breaking the system of course.
Thanks in advance.

Hernán


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 

Reply | Threaded
Open this post in threaded view
|

Re: recompiling CompiledMethod?

Mark Pirogovsky-3
Hernán,
Would you explain Why would you want to do that ?

AS always there are so many ways to achieve your objectives without
resorting to such drastic measures...

--Mark

Hernán Morales wrote:

> Hello all there.
> This is my first message to the list, and I just want
> to know if possible, how to add (the easiest way) an
> instance variable to CompiledMethod class, without
> breaking the system of course.
> Thanks in advance.
>
> Hernán
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com 
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: recompiling CompiledMethod?

Reinout Heeck
In reply to this post by "Hernán Morales"
Hernán Morales wrote:
> Hello all there.
> This is my first message to the list,

Welcome!

> and I just want
> to know if possible, how to add (the easiest way) an
> instance variable to CompiledMethod class, without
> breaking the system of course.


Wow, you are try something not many people on this list have done ;-)

Have you tried it already? What happens if you browse to CompiledMethod and
'acccept' the class definition with your new instance variable added?

I guess it is important that you add your new ivar as the last one after the
existing ivars since the VM knows the location of the existing ivars.

Please let us know what happens, I'm curious ;-)


If this doesn't break your system you will possibly have incompatibilities
with some libraries, one that comes to mind is the parcel saving/loading
mechanism.


If you don't want to alter all the CompiledMethods in your system you could
try creating a subclass of CompiledMethod, have the normal compiler compile
your method, then copy it's contents into your extended compiledmethod and
use #become: to swap the two.
Be aware that you will need to flush the JIT cache whenever you alter
CompiledMthods in such a low level way (#flushVMCacheFor:)



Success!

Reinout
-------

Reply | Threaded
Open this post in threaded view
|

Re: recompiling CompiledMethod?

Ralf Propach
Reinout Heeck wrote:

> Hernán Morales wrote:
>>Hello all there.
>>This is my first message to the list,
>
> Welcome!
>
>>and I just want
>>to know if possible, how to add (the easiest way) an
>>instance variable to CompiledMethod class, without
>>breaking the system of course.
>
>
> Wow, you are try something not many people on this list have done ;-)
>
> Have you tried it already? What happens if you browse to CompiledMethod and
> 'acccept' the class definition with your new instance variable added?
>
> I guess it is important that you add your new ivar as the last one after the
> existing ivars since the VM knows the location of the existing ivars.

Correct.
>
> Please let us know what happens, I'm curious ;-)

No visible difference, the image reacts just as before.
But I did not do any thorough testing.
>
>
> If this doesn't break your system you will possibly have incompatibilities
> with some libraries, one that comes to mind is the parcel saving/loading
> mechanism.

And the subclasses of CompiledMethod are affected as well.
E.g. you need to perform ExternalMethod install to inform the VM before doing any
DLLCC calls.

Ralf