[squeak-dev] Re: [Vm-dev] Bug in writing compressed stream when
saving an mcz (was: New Cog VMs available...)
Levente Uzonyi
leves at elte.hu
Sat Jul 19 18:42:02 UTC 2014
This is a good workaround for the problem, but I think the main issue is
that the VM has assumptions about the layout of an object.
I would simply pass all the parameters to the primitive. There's only 14
of them, so this could work. But this plugin also writes back the state to
the object, so that would create another problem.
I think the best would be to create new variants of #primitiveZipSendBlock
and #primitiveDeflateBlock which accept an array, and use that to
load and store the paramters of the compression algorithm. This way
objects with different layout would be able to use the plugin, and we
could get rid of these compression streams in the long term (or change
their layout without breaking them).
Another solution would be to use an external library(libraries) for
compression, but that's a lot more work.
Levente
P.S.: instead of finding the number of slots of WriteStream, it would have
been possible to index the slots from the end of the passed object. E.g.
loadDeflateStreamFrom: rcvr
| slotSize oop |
<inline: false>
(interpreterProxy isPointers: rcvr) ifFalse: [ ^false ].
slotSize := interpreterProxy slotSizeOf: rcvr.
slotSize < 15 ifTrue: [ ^false ].
...
zipCollection := interpreterProxy firstIndexableField: oop.
zipCollectionSize := interpreterProxy byteSizeOf: oop.
zipPosition := interpreterProxy fetchInteger: 1 ofObject: rcvr.
zipReadLimit := interpreterProxy fetchInteger: 2 ofObject: rcvr.
...
oop := interpreterProxy fetchPointer: slotSize - 14 ofObject: rcvr.
((interpreterProxy isWords: oop)
and: [(interpreterProxy slotSizeOf: oop) = DeflateHashTableSize]) ifFalse:
[^false].
zipHashHead := interpreterProxy firstIndexableField: oop.
oop := interpreterProxy fetchPointer: slotSize - 13 ofObject: rcvr.
((interpreterProxy isWords: oop)
and: [(interpreterProxy slotSizeOf: oop) = DeflateWindowSize]) ifFalse:
[^false].
zipHashTail := interpreterProxy firstIndexableField: oop.
zipHashValue := interpreterProxy fetchInteger: slotSize - 12 ofObject: rcvr.
zipBlockPos := interpreterProxy fetchInteger: slotSize - 11 ofObject: rcvr.
...
Of course this would have its own cons.
On Sat, 19 Jul 2014, David T. Lewis wrote:
>
> On Fri, Jul 18, 2014 at 05:26:52PM -0700, Eliot Miranda wrote:
>>
>> Hi All,
>>
>> find the fix attached. I hope we can fold this into the standard VM
>> soon.
>>
>
> Thanks Eliot, I'll update it this weekend in VMM trunk also.
>
> Dave
>
>
More information about the Vm-dev
mailing list