serialization and rematerialization of CompiledMethods, assistance needed!

Bob Arning arning at charm.net
Thu Feb 21 15:08:50 UTC 2002


On Wed, 20 Feb 2002 21:20:58 -0800 (PST) Chris Muller <afunkyobject at yahoo.com> wrote:
>I need to be able to serialize a CompiledMethod to a byteArray and bring it
>back and use it.
>
>The serialization is easy since the CompiledMethod already is a ByteArray.
>
>But how do I convert that ByteArray to a usable method again?  The overridden
>basicNew: constructor urges "CompiledMethods may only be created with
>newMethod:header:".
>
>But I'm not sure where to get that first argument (labelled "numberOfBytes" in
>the method code).  I tried using the #size of the original method.  It
>functioned, but it did not report = to the original.  See my test script here:

Chris,

That number should be the number of bytecodes plus the number of trailer bytes. This should get the right sized method:

copy _ (CompiledMethod newMethod: m endPC - m initialPC + 1 + 4 header: m header)

However, I wonder why go to all that trouble. Why not export the method source and recompile it on the other end? That would avoid some of the grungier details.

Cheers,
Bob



More information about the Squeak-dev mailing list