[Pharo-project] Putting source code in method trailer [WAS] Re: Speeding up Finder string search

Igor Stasenko siguctua at gmail.com
Wed Jan 18 10:22:02 CET 2012

On 17 January 2012 19:22, Mariano Martinez Peck <marianopeck at gmail.com> wrote:
> On Tue, Jan 17, 2012 at 6:31 PM, Mariano Martinez Peck
> <marianopeck at 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.
you doing it a little bit wrong

 CompiledMethod allInstances do: [:aMethod |
     source := aMethod getSource.
     trailer := CompiledMethodTrailer new sourceCode: source.
     dict at: aMethod put:  (aMethod copyWithTrailerBytes: trailer).

As for what we should encode in method trailer and what we shouldn't, i think
we should put an id there, and then have a source code manager
which will work as key-value storage to retrieve stuff at given key.
And stuff can be not just a source code, but more compound object
which will also carry things like, author, timestamp, link to previous
version etc etc etc.
Now, if we could have such abstraction at first place, then it is no
longer relevant where the actual data is stored, in files, in image,
or in networked database,
because you can have any of them.

I would really like to invest some time to that, or find someone who
could do that, so i can help with it :)

Best regards,
Igor Stasenko.

More information about the Pharo-project mailing list