[Pharo-dev] [Vm-dev] Re: Nuking VM ImageSegment support (was Re:
[squeak-dev] Daily Commit Log; System-bf.916)
maxleske at gmail.com
Mon Sep 26 19:43:36 UTC 2016
No, we use ImageSegment directly (we’ve subclassed ImageSegment). Here’s the short version:
1. we copy the roots:
copyFromRoots: (Array with: anObject)
sizeHint: self fileSize // 2
2. we write the segment onto a MutliByteFileStream (which we’ve subclassed):
do: [ :stream | stream writeObject: self ].
where #writeObject: is implemented as:
(SmartRefStream on: self) nextPutObjOnly: anObject
We load the segment back by:
1. opening a MultiByteFileStream and sending the installation message:
readOnlyFileNamed: (aDirectory fullNameFor: filename)
do: [ :stream |
andDo: aBlock ]
2. #installSegmentFrom:andDo: basically sends #readObject to the file stream:
"This is a hack to allow for the old segments (mixed code and objects)
to be loaded without the #inform: in #nextAndClose opening a UI element."
^ self binary peek = ReferenceStream versionCode
ifTrue: [ (SmartRefStream on: self) nextAndClose ]
| object |
object := SmartRefStream scannedObject.
SmartRefStream scannedObject: nil.
3. and once we have the segment we send #install to it
We’ve made some modifications here and there (e.g. to suppress UI elements) but the above is the gist of it. I can give you the full source if you need it.
It’s possible that this is all overkill or parallels functionality found in other places. I’ve inherited the code and haven’t spent the time exploring improvements in that area.
> On 26 Sep 2016, at 19:39, squeak-dev-request at lists.squeakfoundation.org wrote:
> Hi Max,
> I'd be interested to learn how you are using ImageSegments. Is it
> using CodeLoader?
> - Bert -
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Squeak-dev