serialization and rematerialization of CompiledMethods, assistance needed!

Bob Arning arning at charm.net
Tue Feb 26 14:55:50 UTC 2002


On Mon, 25 Feb 2002 22:27:06 -0800 (PST) Chris Muller <afunkyobject at yahoo.com> wrote:
>> 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)
>> 
>
>Hi Bob, I finally got to where I could get back into this and now realize that
>I need to know how to "populate" the method after I've created it.  For
>example, can I simply replaceFrom: 1 to: m size?  Or perhaps after the position
>(m endPC - m initialPC + 1 + 4)?

Chris,

It's not quite that easy, as Tim mentioned. CompiledMethods are unusual mixtures of pointers and bytes. Code like your example is on the right track to copy the bytes part, but is not much help for the pointer part. When you are serializing the cm in the first place, you would need to step through the literals (the pointer part) and recognize these as objects that also need to be serialized. Additional care will be needed to handle references to globals (such as a class reference). In this case, the literal sotred in the cm is the Association from Smalltalk (or elsewhere) that points to the global value. Simply exporting this association would not be enough (or even right) - you really need to export something along the lines of "when I am rematerialized, replace me with a reference to String in the receiving image". Otherwise you might bring your own definition of String along and all sorts of strange things could start to happen. It is for this reason that I suggested using source code as the transfer format and simply compiling it in the receiving system.

Cheers,
Bob



More information about the Squeak-dev mailing list