<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2016-03-08 21:09 GMT+01:00 Nicolas Cellier <span dir="ltr"><<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">2016-03-08 18:17 GMT+01:00 <span dir="ltr"><<a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Esteban Lorenzano uploaded a new version of VMMaker to project VM Maker:<br>
<a href="http://source.squeak.org/VMMaker/VMMaker.oscog-EstebanLorenzano.1714.mcz" rel="noreferrer" target="_blank">http://source.squeak.org/VMMaker/VMMaker.oscog-EstebanLorenzano.1714.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: VMMaker.oscog-EstebanLorenzano.1714<br>
Author: EstebanLorenzano<br>
Time: 8 March 2016, 6:16:11.06581 pm<br>
UUID: e83d2c5f-76cd-47fc-ac29-6c4a25fa5deb<br>
Ancestors: VMMaker.oscog-nice.1713<br>
<br>
Remove wrong coertion. If coertion is present, this assertion fails:<br>
<br>
ref := ByteArray new: 4.<br>
ref integerAt: 1 put: -10 size: 4 signed: true.<br>
self assert: (ref integerAt: 1 size: 4 signed: true) = -10<br>
<br>
<br>
=============== Diff against VMMaker.oscog-nice.1713 ===============<br>
<br>
Item was changed:<br>
----- Method: ThreadedFFIPlugin>>primitiveFFIIntegerAt (in category 'primitives') -----<br>
primitiveFFIIntegerAt<br>
"Answer a (signed or unsigned) n byte integer from the given byte offset<br>
in the receiver, using the platform's endianness."<br>
| isSigned byteSize byteOffset rcvr addr value mask valueOop |<br>
<var: 'value' type: #usqLong><br>
<var: 'mask' type: #usqLong><br>
<export: true><br>
<inline: false><br>
isSigned := interpreterProxy booleanValueOf: (interpreterProxy stackValue: 0).<br>
byteSize := interpreterProxy stackIntegerValue: 1.<br>
byteOffset := interpreterProxy stackIntegerValue: 2.<br>
rcvr := interpreterProxy stackObjectValue: 3.<br>
interpreterProxy failed ifTrue:[^0].<br>
(byteOffset > 0<br>
and: [(byteSize between: 1 and: 8)<br>
and: [(byteSize bitAnd: byteSize - 1) = 0 "a.k.a. isPowerOfTwo"]]) ifFalse:<br>
[^interpreterProxy primitiveFail].<br>
addr := self ffiAddressOf: rcvr startingAt: byteOffset size: byteSize.<br>
interpreterProxy failed ifTrue:[^0].<br>
byteSize <= 2<br>
ifTrue:<br>
[byteSize = 1<br>
ifTrue: [value := self cCoerceSimple: (interpreterProxy byteAt: addr) to: #'unsigned char']<br>
ifFalse: [value := self cCoerceSimple: (interpreterProxy shortAt: addr) to: #'unsigned short']]<br>
ifFalse:<br>
[byteSize = 4<br>
+ ifTrue: [value := interpreterProxy long32At: addr]<br>
- ifTrue: [value := self cCoerceSimple: (interpreterProxy long32At: addr) to: #'unsigned int']<br></blockquote><div><br><br></div></div></div><div>This will fix 32bits spur, but what will happen with 64bits?<br></div><div>It will happen that you'll break 32bits unsigned access...<br><br></div><div>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 :(<br><br></div><span class=""><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
ifFalse: [value := interpreterProxy long64At: addr]].<br>
byteSize < BytesPerWord<br>
ifTrue:<br>
[isSigned ifTrue: "sign extend value"<br>
[mask := 1 << (byteSize * 8 - 1).<br>
value := (value bitAnd: mask-1) - (value bitAnd: mask)].<br>
"note: byte/short (&long if BytesPerWord=8) never exceed SmallInteger range"<br>
valueOop := interpreterProxy integerObjectOf: value]<br>
ifFalse: "general 64 bit integer; note these never fail"<br>
[valueOop := isSigned<br>
ifTrue:[interpreterProxy signed64BitIntegerFor: value]<br></blockquote></span></div></div></div></blockquote><div><br></div><div>IMO the right fix would be to force coercion here:<br><span class=""><br>
ifTrue:[interpreterProxy signed64BitIntegerFor: (</span><span class="">self cCoerceSimple: value to: #sqLong)]<br><br></span></div><div><span class="">But maybe we can avoid signed64/unsigned64 and use signedMachineInteger and positiveMachineInteger when byteSize = bytePerWord...<br><br></span></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
ifFalse:[interpreterProxy positive64BitIntegerFor: value]].<br>
^interpreterProxy pop: 4 thenPush: valueOop!<br>
<br>
</blockquote></span></div><br></div></div>
</blockquote></div><br></div></div>