[Vm-dev] VM Maker: VMMaker.oscog-EstebanLorenzano.1714.mcz

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Tue Mar 8 20:09:37 UTC 2016


2016-03-08 18:17 GMT+01:00 <commits at source.squeak.org>:

>
> Esteban Lorenzano uploaded a new version of VMMaker to project VM Maker:
> http://source.squeak.org/VMMaker/VMMaker.oscog-EstebanLorenzano.1714.mcz
>
> ==================== Summary ====================
>
> Name: VMMaker.oscog-EstebanLorenzano.1714
> Author: EstebanLorenzano
> Time: 8 March 2016, 6:16:11.06581 pm
> UUID: e83d2c5f-76cd-47fc-ac29-6c4a25fa5deb
> Ancestors: VMMaker.oscog-nice.1713
>
> Remove wrong coertion. If coertion is present, this assertion fails:
>
> ref := ByteArray new: 4.
> ref integerAt: 1 put: -10 size: 4 signed: true.
> self assert: (ref integerAt: 1 size: 4 signed: true) = -10
>
>
> =============== Diff against VMMaker.oscog-nice.1713 ===============
>
> Item was changed:
>   ----- Method: ThreadedFFIPlugin>>primitiveFFIIntegerAt (in category
> 'primitives') -----
>   primitiveFFIIntegerAt
>         "Answer a (signed or unsigned) n byte integer from the given byte
> offset
>          in the receiver, using the platform's endianness."
>         | isSigned byteSize byteOffset rcvr addr value mask valueOop |
>         <var: 'value' type: #usqLong>
>         <var: 'mask' type: #usqLong>
>         <export: true>
>         <inline: false>
>         isSigned := interpreterProxy booleanValueOf: (interpreterProxy
> stackValue: 0).
>         byteSize := interpreterProxy stackIntegerValue: 1.
>         byteOffset := interpreterProxy stackIntegerValue: 2.
>         rcvr := interpreterProxy stackObjectValue: 3.
>         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].
>         byteSize <= 2
>                 ifTrue:
>                         [byteSize = 1
>                                 ifTrue: [value := self cCoerceSimple:
> (interpreterProxy byteAt: addr) to: #'unsigned char']
>                                 ifFalse: [value := self cCoerceSimple:
> (interpreterProxy shortAt: addr) to: #'unsigned short']]
>                 ifFalse:
>                         [byteSize = 4
> +                               ifTrue: [value := interpreterProxy
> long32At: addr]
> -                               ifTrue: [value := self cCoerceSimple:
> (interpreterProxy long32At: addr) to: #'unsigned int']
>


This will fix 32bits spur, but what will happen with 64bits?
It will happen that you'll break 32bits unsigned access...

0xFFFFFFFF will be interpreted as -1 (long32At:) then promoted to
0xFFFFFFFFFFFFFFFFULL then I don't know what integerObjectOf: will do of
it... Probably not the right thing :(



>                                 ifFalse: [value := interpreterProxy
> long64At: addr]].
>         byteSize < BytesPerWord
>                 ifTrue:
>                         [isSigned ifTrue: "sign extend value"
>                                 [mask := 1 << (byteSize * 8 - 1).
>                                 value := (value bitAnd: mask-1) - (value
> bitAnd: mask)].
>                          "note: byte/short (&long if BytesPerWord=8) never
> exceed SmallInteger range"
>                          valueOop := interpreterProxy integerObjectOf:
> value]
>                 ifFalse: "general 64 bit integer; note these never fail"
>                         [valueOop := isSigned
>
> ifTrue:[interpreterProxy signed64BitIntegerFor: value]
>
> ifFalse:[interpreterProxy positive64BitIntegerFor: value]].
>         ^interpreterProxy pop: 4 thenPush: valueOop!
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20160308/b16ca30b/attachment-0001.htm


More information about the Vm-dev mailing list