<div dir="ltr">Hi Nicolas,<div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 8, 2016 at 2:07 PM, Nicolas Cellier <span dir="ltr">&lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> <br><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2016-04-07 3:16 GMT+02:00  <span dir="ltr">&lt;<a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a>&gt;</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>
Eliot Miranda uploaded a new version of VMMaker to project VM Maker:<br>
<a href="http://source.squeak.org/VMMaker/VMMaker.oscog-eem.1776.mcz" rel="noreferrer" target="_blank">http://source.squeak.org/VMMaker/VMMaker.oscog-eem.1776.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: VMMaker.oscog-eem.1776<br>
Author: eem<br>
Time: 6 April 2016, 6:15:12.993129 pm<br>
UUID: ffb1c333-7c42-4f80-a951-74db178aab65<br>
Ancestors: VMMaker.oscog-eem.1775<br>
<br>
Simulator:<br>
Several fixes for coercion given Nicolas&#39; new 32-bit LargeInteger plugin code.<br>
The LargeIntegersPlugin needs to coerce the arguments to cDigitOf:at:[put:] correctly during simulation.<br>
Coercion needs to support #&#39;unsigned int *&#39;.<br>
Hack read &amp; write in the FilePluginSimulator which should declare the pointer args byteArrayIndex correctly and access them via at: but for historical reasons treated them as integers.<br>
<br>
=============== Diff against VMMaker.oscog-eem.1775 ===============<br>
<br>
Item was added:<br>
+ ----- Method: CArray&gt;&gt;asCArrayAccessorUnitSize: (in category &#39;converting&#39;) -----<br>
+ asCArrayAccessorUnitSize: requiredUnitSize<br>
+       self assert: ptrOffset = 0.<br>
+       ^CArrayAccessor on: (requiredUnitSize = unitSize<br>
+                                                               ifTrue: [self]<br>
+                                                               ifFalse: [self shallowCopy unitSize: requiredUnitSize])!<br>
<br></blockquote><div><br></div><div>Hi Eliot,<br></div><div>I wonder why there is an offset correction in asCArrayAccessor<br><br>    ^ (CArrayAccessor on: self)<br>            += -1   &quot;Defeat the +1 offset in the accessor&quot;<br><br></div><div>while there it is none here.<br></div><div>Are you sure it works?<br><br></div><div>Should we assert some alignment props too?<br></div></div></div></div></blockquote><div><br></div><div>All I know is that the simulator sort-of works.  I know it doesn&#39;t work perfectly (large fonts in the Squeak 5.0 workspace are not rendered correctly), but LargeInteger operations work correctly.  I think we need to write some tests.  The CArray stuff is not at all specified or commented.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></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">
Item was added:<br>
+ ----- Method: CArray&gt;&gt;cPtrAsOop (in category &#39;accessing&#39;) -----<br>
+ cPtrAsOop<br>
+       ^arrayBaseAddress + ptrOffset!<br>
<br>
Item was changed:<br>
  ----- Method: CArray&gt;&gt;coerceTo:sim: (in category &#39;converting&#39;) -----<br>
  coerceTo: cTypeString sim: interpreterSimulator<br>
<br>
        ^cTypeString caseOf: {<br>
                [&#39;int&#39;]                         -&gt; [self ptrAddress].<br>
+               [&#39;float *&#39;]                     -&gt; [(self asCArrayAccessorUnitSize: 4) asFloatAccessor].<br>
+               [&#39;unsigned int *&#39;]      -&gt; [(self asCArrayAccessorUnitSize: 4) asUnsignedIntAccessor].<br>
+               [&#39;int *&#39;]                               -&gt; [(self asCArrayAccessorUnitSize: 4) asIntAccessor].<br>
-               [&#39;float *&#39;]                     -&gt; [self asCArrayAccessor asFloatAccessor].<br>
-               [&#39;int *&#39;]                               -&gt; [self asCArrayAccessor asIntAccessor].<br>
                [&#39;char *&#39;]                      -&gt; [self shallowCopy unitSize: 1; yourself].<br>
                [&#39;unsigned char *&#39;]     -&gt; [self shallowCopy unitSize: 1; yourself].<br>
                [&#39;unsigned&#39;]                    -&gt; [self ptrAddress].<br>
                [&#39;sqInt&#39;]                               -&gt; [self ptrAddress].<br>
                [&#39;usqInt&#39;]                      -&gt; [self ptrAddress] }!<br>
<br>
Item was added:<br>
+ ----- Method: CArray&gt;&gt;unsignedIntAt: (in category &#39;accessing&#39;) -----<br>
+ unsignedIntAt: index<br>
+       ^self at: index!<br>
<br>
Item was added:<br>
+ ----- Method: CArray&gt;&gt;unsignedIntAt:put: (in category &#39;accessing&#39;) -----<br>
+ unsignedIntAt: index put: unsignedInt<br>
+       ^ self at: index put: unsignedInt!<br>
<br>
Item was added:<br>
+ ----- Method: CObjectAccessor&gt;&gt;asUnsignedIntAccessor (in category &#39;converting&#39;) -----<br>
+ asUnsignedIntAccessor<br>
+<br>
+       ^ self asPluggableAccessor<br>
+               atBlock: [:obj :index | obj unsignedIntAt: index]<br>
+               atPutBlock: [:obj :index :value | obj unsignedIntAt: index put: value]!<br>
<br>
Item was changed:<br>
  ----- Method: FilePluginSimulator&gt;&gt;sqFile:Read:Into:At: (in category &#39;simulation&#39;) -----<br>
+ sqFile: file Read: count Into: byteArrayIndexArg At: startIndex<br>
+       | interpreter byteArrayIndex |<br>
- sqFile: file Read: count Into: byteArrayIndex At: startIndex<br>
-       | interpreter |<br>
        interpreter := interpreterProxy interpreter.<br>
+       byteArrayIndex := byteArrayIndexArg isInteger ifTrue: [byteArrayIndexArg] ifFalse: [byteArrayIndexArg cPtrAsOop].<br>
        [[startIndex to: startIndex + count - 1 do:<br>
                [ :i |<br>
                file atEnd ifTrue:<br>
                        [(file isKindOf: FakeStdinStream) ifTrue: [file atEnd: false].<br>
                         ^i - startIndex].<br>
                interpreter<br>
                        byteAt: byteArrayIndex + i<br>
                        put: file next asInteger]]<br>
                        on: Error<br>
                        do: [:ex|<br>
                                (file isKindOf: TranscriptStream) ifFalse: [ex pass].<br>
                                ^0]]<br>
                ensure: [self recordStateOf: file].<br>
        ^count!<br>
<br>
Item was changed:<br>
  ----- Method: FilePluginSimulator&gt;&gt;sqFile:Write:From:At: (in category &#39;simulation&#39;) -----<br>
+ sqFile: file Write: count From: byteArrayIndexArg At: startIndex<br>
+       | interpreter byteArrayIndex |<br>
- sqFile: file Write: count From: byteArrayIndex At: startIndex<br>
-       | interpreter |<br>
        interpreter := interpreterProxy interpreter.<br>
+       byteArrayIndex := byteArrayIndexArg isInteger ifTrue: [byteArrayIndexArg] ifFalse: [byteArrayIndexArg cPtrAsOop].<br>
        file isBinary<br>
                ifTrue:<br>
                        [startIndex to: startIndex + count - 1 do:<br>
                                [ :i | file nextPut: (interpreter byteAt: byteArrayIndex + i)]]<br>
                ifFalse:<br>
                        [startIndex to: startIndex + count - 1 do:<br>
                                [ :i | | byte |<br>
                                byte := interpreter byteAt: byteArrayIndex + i.<br>
                                file nextPut: (Character value: (byte == 12 &quot;lf&quot; ifTrue: [15&quot;cr&quot;] ifFalse: [byte]))]].<br>
        self recordStateOf: file.<br>
        ^count!<br>
<br>
Item was changed:<br>
  ----- Method: Integer&gt;&gt;coerceTo:sim: (in category &#39;*VMMaker-interpreter simulator&#39;) -----<br>
  coerceTo: cTypeString sim: interpreter<br>
<br>
        | unitSize |<br>
+       cTypeString last = $* ifTrue:  &quot;C pointer&quot;<br>
+               [unitSize := cTypeString caseOf: {<br>
-       cTypeString last = $* ifTrue: [  &quot;C pointer&quot;<br>
-               unitSize := cTypeString caseOf: {<br>
                [&#39;char *&#39;] -&gt; [1].<br>
                [&#39;short *&#39;] -&gt; [2].<br>
                [&#39;int *&#39;] -&gt; [4].<br>
                [&#39;long *&#39;] -&gt; [interpreter wordSize].<br>
                [&#39;float *&#39;] -&gt; [4].<br>
                [&#39;double *&#39;] -&gt; [8].<br>
                [&#39;unsigned *&#39;] -&gt; [4].<br>
+               [&#39;unsigned int *&#39;] -&gt; [4].<br>
+               [&#39;unsigned char *&#39;] -&gt; [4].<br>
+               [&#39;unsigned short *&#39;] -&gt; [4].<br>
                [&#39;oop *&#39;] -&gt; [interpreter bytesPerOop].<br>
                }<br>
                otherwise: [ (cTypeString beginsWith: &#39;char&#39;) ifTrue: [1] ifFalse: [interpreter wordSize] ].<br>
+               ^CArray basicNew<br>
-               ^(CArray basicNew)<br>
                        interpreter: interpreter address: self unitSize: unitSize;<br>
+                       yourself].<br>
-                       yourself.<br>
-       ].<br>
        ^ self  &quot;C number (int, char, float, etc)&quot;!<br>
<br>
Item was changed:<br>
  ----- Method: LargeIntegersPlugin&gt;&gt;cDigitOf:at: (in category &#39;C core util&#39;) -----<br>
  cDigitOf: cPointer at: zeroBasedDigitIndex<br>
        &lt;inline: true&gt;<br>
        &lt;returnTypeC: #&#39;unsigned int&#39;&gt;<br>
        &lt;var: &#39;cPointer&#39; type: #&#39;unsigned int *&#39;&gt;<br>
+       ^self byteSwapped32IfBigEndian: ((self cCode: [cPointer] inSmalltalk: [interpreterProxy cCoerce: cPointer to: #&#39;unsigned int *&#39;]) at: zeroBasedDigitIndex)!<br>
-       ^self byteSwapped32IfBigEndian: (cPointer at: zeroBasedDigitIndex)!<br>
<br>
Item was changed:<br>
  ----- Method: LargeIntegersPlugin&gt;&gt;cDigitOf:at:put: (in category &#39;C core util&#39;) -----<br>
  cDigitOf: cPointer at: zeroBasedDigitIndex put: aValue<br>
        &lt;inline: true&gt;<br>
        &lt;returnTypeC: #&#39;unsigned int&#39;&gt;<br>
        &lt;var: &#39;cPointer&#39; type: #&#39;unsigned int *&#39;&gt;<br>
        &lt;var: &#39;aValue&#39; type: #&#39;unsigned int&#39;&gt;<br>
+       ^(self cCode: [cPointer] inSmalltalk: [interpreterProxy cCoerce: cPointer to: #&#39;unsigned int *&#39;])<br>
+               at: zeroBasedDigitIndex<br>
+               put: (self byteSwapped32IfBigEndian: aValue)!<br>
-       ^cPointer at: zeroBasedDigitIndex put: (self byteSwapped32IfBigEndian: aValue)!<br>
<br>
</blockquote></div><br></div></div>
<br></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>