On Tue, Jan 17, 2012 at 6:31 PM, Mariano Martinez Peck < marianopeck@gmail.com> wrote:
If you don't bother about being slow, you can also make it much easier:
|trailer source m | m := (Gofer>>#load). trailer := m trailer. source := m getSource. trailer sourceCode: source. m becomeForward: (m copyWithTrailerBytes: trailer)
and if you want to do it for the whole image you can use one bulk become and it will be fast.
I will experiment and see if it is working.
Well, with the following script it seems I am able to embed all source code in trailers: | trailer source key dict classes | dict := IdentityDictionary new. CompiledMethod allInstances do: [:aMethod | trailer := aMethod trailer. source := aMethod getSource. trailer sourceCode: source. dict at: aMethod put: (aMethod copyWithTrailerBytes: trailer). ]. dict keys asArray elementsExchangeIdentityWith: dict values asArray. Problem is that after executing the script, when a method is recompiled from the system browser, it puts back a trailer with a .changes pointer :( I will see if I find where I can change that. Cheers -- Mariano http://marianopeck.wordpress.com