[Vm-dev] VM Maker: VMMaker.oscog-eem.1977.mcz

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Fri Nov 4 19:41:05 UTC 2016


Hi Eliot, there's the same code in primitiveFFIIntegerAt

2016-11-04 20:15 GMT+01:00 Esteban Lorenzano <estebanlm at gmail.com>:

>
> will this fix the problem I reported a couple of hours ago? (It looks
> like, but I’m in a train and I cannot test it right now)
>
> Esteban
>
> > On 4 Nov 2016, at 20:11, commits at source.squeak.org wrote:
> >
> >
> > Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
> > http://source.squeak.org/VMMaker/VMMaker.oscog-eem.1977.mcz
> >
> > ==================== Summary ====================
> >
> > Name: VMMaker.oscog-eem.1977
> > Author: eem
> > Time: 4 November 2016, 12:11:15.657943 pm
> > UUID: e12daf50-ab4d-4d62-9c65-18cd20e5c0fe
> > Ancestors: VMMaker.oscog-eem.1976
> >
> > Fix bounds check for unsigned store in primitiveFFIIntegerAtPut.  Must
> use an unsigned long long comparison.
> >
> > =============== Diff against VMMaker.oscog-eem.1976 ===============
> >
> > Item was changed:
> >  ----- Method: ThreadedFFIPlugin>>primitiveFFIIntegerAtPut (in category
> 'primitives') -----
> >  primitiveFFIIntegerAtPut
> >       "Store a (signed or unsigned) n byte integer at the given byte
> offset
> >        in the receiver, using the platform's endianness."
> >       | isSigned byteSize byteOffset rcvr addr value max valueOop |
> >       <var: 'value' type: #sqLong>
> >       <var: 'max' type: #sqLong>
> >       <export: true>
> >       <inline: false>
> >       isSigned := interpreterProxy booleanValueOf: (interpreterProxy
> stackValue: 0).
> >       byteSize := interpreterProxy stackIntegerValue: 1.
> >       valueOop := interpreterProxy stackValue: 2.
> >       byteOffset := interpreterProxy stackIntegerValue: 3.
> >       rcvr := interpreterProxy stackObjectValue: 4.
> >       interpreterProxy failed ifTrue:[^0].
> >       (byteOffset > 0
> >        and: [(byteSize between: 1 and: 8)
> >        and: [(byteSize bitAnd: byteSize - 1) = 0 "a.k.a.
> isPowerOfTwo"]]) ifFalse:
> >               [^interpreterProxy primitiveFail].
> >       addr := self ffiAddressOf: rcvr startingAt: byteOffset size:
> byteSize.
> >       interpreterProxy failed ifTrue:[^0].
> >       isSigned
> >               ifTrue:[value := interpreterProxy
> signedMachineIntegerValueOf: valueOop]
> >               ifFalse:[value := interpreterProxy
> positiveMachineIntegerValueOf: valueOop].
> >       interpreterProxy failed ifTrue:[^0].
> >       byteSize < BytesPerWord ifTrue:
> >               [isSigned
> >                       ifTrue:
> > +                             [max := 1 asUnsignedLongLong << (8 *
> byteSize - 1).
> > -                             [max := 1 << (8 * byteSize - 1).
> >                               (value >= (0 - max) and: [value < max])
> ifFalse: [^interpreterProxy primitiveFail]]
> >                       ifFalse:
> > +                             [value asUnsignedLongLong < (1
> asUnsignedLongLong << (8 * byteSize)) ifFalse: [^interpreterProxy
> primitiveFail]]].
> > -                             [value asUnsignedLongLong < (1 <<
> (8*byteSize)) ifFalse: [^interpreterProxy primitiveFail]]].
> >       byteSize <= 2
> >               ifTrue:
> >                       [byteSize = 1
> >                               ifTrue: [interpreterProxy byteAt: addr
> put: value]
> >                               ifFalse: [interpreterProxy shortAt: addr
> put: value]]
> >               ifFalse:
> >                       [byteSize = 4
> >                               ifTrue: [interpreterProxy long32At: addr
> put: value]
> >                               ifFalse: [interpreterProxy long64At: addr
> put: value]].
> >       ^interpreterProxy pop: 5 thenPush: valueOop!
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20161104/11bc426e/attachment-0001.html>


More information about the Vm-dev mailing list