<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">&lt;<a href="mailto:lewis@mail.msen.com" target="_blank">lewis@mail.msen.com</a>&gt;</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>
&gt;<br>
&gt; Eliot Miranda uploaded a new version of VMMaker to project VM Maker:<br>
&gt; <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>
&gt;<br>
&gt; ==================== Summary ====================<br>
&gt;<br>
&gt; Name: VMMaker.oscog-eem.1426<br>
&gt; Author: eem<br>
&gt; Time: 18 July 2015, 1:54:29.051 pm<br>
&gt; UUID: 94ab92ba-c5c4-4953-8566-a4cd9c38df1f<br>
&gt; Ancestors: VMMaker.oscog-eem.1425<br>
&gt;<br>
&gt; 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>
&gt;<br>
<br>
</span>I can&#39;t test now to verify, but I wonder if this change is fixing the<br>
right problem.<br></blockquote><div><br></div><div>I&#39;m pretty sure it is.  It only bites in a 64-bit implementation with &gt; 31-bit integers.  In the &quot;standard&quot; 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&#39;s a much more pervasive change than only generating the cast in integerObjectOf when on 64-bits.  So I&#39;m happy with the change that I&#39;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&gt;&gt;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&gt;&gt;generateIntegerObjectOf: msgNode on: aStream indent: level<br>
<span class="">        &quot;Generate the C code for this message onto the given stream.&quot;<br>
<br>
</span>        aStream nextPutAll: &#39;((&#39;.<br>
<span class="">        self emitCExpression: msgNode args first on: aStream.<br>
</span>        aStream nextPutAll: &#39; &lt;&lt; 1) | 1)&#39;.<br>
<br>
Dave<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
&gt; =============== Diff against VMMaker.oscog-eem.1425 ===============<br>
&gt;<br>
&gt; Item was changed:<br>
&gt;   ----- Method: CCodeGenerator&gt;&gt;generateIntegerObjectOf:on:indent: (in category &#39;C translation&#39;) -----<br>
&gt;   generateIntegerObjectOf: msgNode on: aStream indent: level<br>
&gt;       &quot;Generate the C code for this message onto the given stream.&quot;<br>
&gt; +     | expr castToSqint |<br>
&gt; +     expr := msgNode args first.<br>
&gt; +     aStream nextPutAll: &#39;((&#39;.<br>
&gt; +     &quot;Note that the default type of an integer constant in C is int.  Hence we /must/<br>
&gt; +      cast constants to long if in the 64-bit world, since e.g. in 64-bits<br>
&gt; +             (int)(16r1FFFFF &lt;&lt; 3) = (int)16rFFFFFFF8 = -8<br>
&gt; +      whereas<br>
&gt; +             (long)(16r1FFFFF &lt;&lt; 3) = (long) 16rFFFFFFF8 = 4294967288.&quot;<br>
&gt; +     castToSqint := expr isConstant and: [vmClass isNil or: [vmClass objectMemoryClass wordSize = 8]].<br>
&gt; +     castToSqint ifTrue:<br>
&gt; +             [aStream nextPutAll: &#39;(sqInt)&#39;].<br>
&gt; +     self emitCExpression: expr on: aStream.<br>
&gt; -<br>
&gt;       aStream<br>
&gt; -             nextPutAll: &#39;((&#39;.<br>
&gt; -     self emitCExpression: msgNode args first on: aStream.<br>
&gt; -     aStream<br>
&gt;               nextPutAll: &#39; &lt;&lt; &#39;;<br>
&gt;               print: vmClass objectMemoryClass numSmallIntegerTagBits;<br>
&gt;               nextPutAll: &#39;) | 1)&#39;!<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>