[Pharo-dev] [Vm-dev] Re: Nuking VM ImageSegment support (was Re:
[squeak-dev] Daily Commit Log; System-bf.916)
Max Leske
maxleske at gmail.com
Mon Sep 26 19:43:36 UTC 2016
Hi Bert,
No, we use ImageSegment directly (we’ve subclassed ImageSegment). Here’s the short version:
1. we copy the roots:
self
copyFromRoots: (Array with: anObject)
sizeHint: self fileSize // 2
areUnique: true.
2. we write the segment onto a MutliByteFileStream (which we’ve subclassed):
NSSegmentStream
forceNewFileNamed: fileName
do: [ :stream | stream writeObject: self ].
where #writeObject: is implemented as:
writeObject: anObject
(SmartRefStream on: self) nextPutObjOnly: anObject
We load the segment back by:
1. opening a MultiByteFileStream and sending the installation message:
NSSegmentStream
readOnlyFileNamed: (aDirectory fullNameFor: filename)
do: [ :stream |
self
installSegmentFrom: stream
andDo: aBlock ]
2. #installSegmentFrom:andDo: basically sends #readObject to the file stream:
readObject
"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 ]
ifFalse: [
| object |
self
ascii;
fileIn.
object := SmartRefStream scannedObject.
SmartRefStream scannedObject: nil.
object ]
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.
Cheers,
Max
> 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...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20160926/8da35119/attachment.htm
More information about the Squeak-dev
mailing list
|