<div dir="ltr">Hi David,<div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jul 18, 2015 at 3:49 PM, David T. Lewis <span dir="ltr"><<a href="mailto:lewis@mail.msen.com" target="_blank">lewis@mail.msen.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
On Sat, Jul 18, 2015 at 08:55:27PM +0000, <a href="mailto:commits@source.squeak.org">commits@source.squeak.org</a> wrote:<br>
><br>
> Eliot Miranda uploaded a new version of VMMaker to project VM Maker:<br>
> <a href="http://source.squeak.org/VMMaker/VMMaker.oscog-eem.1426.mcz" rel="noreferrer" target="_blank">http://source.squeak.org/VMMaker/VMMaker.oscog-eem.1426.mcz</a><br>
><br>
> ==================== Summary ====================<br>
><br>
> Name: VMMaker.oscog-eem.1426<br>
> Author: eem<br>
> Time: 18 July 2015, 1:54:29.051 pm<br>
> UUID: 94ab92ba-c5c4-4953-8566-a4cd9c38df1f<br>
> Ancestors: VMMaker.oscog-eem.1425<br>
><br>
> Fix at least one set of 64-bit issues caused by Slang. In particular the integerObjectOf: code resulted in (objectMemory integerObjectOf: MillisecondClockMask) evaluating to the -1 object, instead of the 16r1FFFFFFF object, which was the cause of the initially nresponsive 64-bit image on the real VM (no problem in the simulator).<br>
><br>
<br>
</span>I can't test now to verify, but I wonder if this change is fixing the<br>
right problem.<br></blockquote><div><br></div><div>I'm pretty sure it is. It only bites in a 64-bit implementation with > 31-bit integers. In the "standard" 64-bit image SmallIntegers are still only 31-bits so the issue never occurs. The issue is that the default type of an integer constant in C is int. So if one has to shift any constant such that a non-zero bit will occupy bit 31 (0 relative), it must be cast to a long type to avoid sign extension.</div><div><br></div><div>Now of course I could generate all Integer constants with the L or UL suffix, e.g.</div><div><br></div><div>#define MillisecondClockMask 0x1FFFFFFFL</div><div><br></div><div>instead of</div><div><br></div><div>#define MillisecondClockMask 0x1FFFFFFF</div><div><br></div><div>but that's a much more pervasive change than only generating the cast in integerObjectOf when on 64-bits. So I'm happy with the change that I've made. Experience can of course prove me wrong...</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
The CCodeGenerator>>generateIntegerObjectOf:on:indent: in VMM trunk has<br>
been in use long enough that it has no author initials. I have found it<br>
to work correctly on all combinations of 32/64 bit image and VM. If it<br>
does not work correctly, I would be inclined to suspect type declaration<br>
issues elsewhere.<br>
<br>
Original implementation:<br>
<br>
CCodeGenerator>>generateIntegerObjectOf: msgNode on: aStream indent: level<br>
<span class=""> "Generate the C code for this message onto the given stream."<br>
<br>
</span> aStream nextPutAll: '(('.<br>
<span class=""> self emitCExpression: msgNode args first on: aStream.<br>
</span> aStream nextPutAll: ' << 1) | 1)'.<br>
<br>
Dave<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
> =============== Diff against VMMaker.oscog-eem.1425 ===============<br>
><br>
> Item was changed:<br>
> ----- Method: CCodeGenerator>>generateIntegerObjectOf:on:indent: (in category 'C translation') -----<br>
> generateIntegerObjectOf: msgNode on: aStream indent: level<br>
> "Generate the C code for this message onto the given stream."<br>
> + | expr castToSqint |<br>
> + expr := msgNode args first.<br>
> + aStream nextPutAll: '(('.<br>
> + "Note that the default type of an integer constant in C is int. Hence we /must/<br>
> + cast constants to long if in the 64-bit world, since e.g. in 64-bits<br>
> + (int)(16r1FFFFF << 3) = (int)16rFFFFFFF8 = -8<br>
> + whereas<br>
> + (long)(16r1FFFFF << 3) = (long) 16rFFFFFFF8 = 4294967288."<br>
> + castToSqint := expr isConstant and: [vmClass isNil or: [vmClass objectMemoryClass wordSize = 8]].<br>
> + castToSqint ifTrue:<br>
> + [aStream nextPutAll: '(sqInt)'].<br>
> + self emitCExpression: expr on: aStream.<br>
> -<br>
> aStream<br>
> - nextPutAll: '(('.<br>
> - self emitCExpression: msgNode args first on: aStream.<br>
> - aStream<br>
> nextPutAll: ' << ';<br>
> print: vmClass objectMemoryClass numSmallIntegerTagBits;<br>
> nextPutAll: ') | 1)'!<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>
</div></div>