<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"><<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@gmail.com</a>></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"><<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>
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' 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 #'unsigned int *'.<br>
Hack read & 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>>asCArrayAccessorUnitSize: (in category 'converting') -----<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 "Defeat the +1 offset in the accessor"<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'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>>cPtrAsOop (in category 'accessing') -----<br>
+ cPtrAsOop<br>
+ ^arrayBaseAddress + ptrOffset!<br>
<br>
Item was changed:<br>
----- Method: CArray>>coerceTo:sim: (in category 'converting') -----<br>
coerceTo: cTypeString sim: interpreterSimulator<br>
<br>
^cTypeString caseOf: {<br>
['int'] -> [self ptrAddress].<br>
+ ['float *'] -> [(self asCArrayAccessorUnitSize: 4) asFloatAccessor].<br>
+ ['unsigned int *'] -> [(self asCArrayAccessorUnitSize: 4) asUnsignedIntAccessor].<br>
+ ['int *'] -> [(self asCArrayAccessorUnitSize: 4) asIntAccessor].<br>
- ['float *'] -> [self asCArrayAccessor asFloatAccessor].<br>
- ['int *'] -> [self asCArrayAccessor asIntAccessor].<br>
['char *'] -> [self shallowCopy unitSize: 1; yourself].<br>
['unsigned char *'] -> [self shallowCopy unitSize: 1; yourself].<br>
['unsigned'] -> [self ptrAddress].<br>
['sqInt'] -> [self ptrAddress].<br>
['usqInt'] -> [self ptrAddress] }!<br>
<br>
Item was added:<br>
+ ----- Method: CArray>>unsignedIntAt: (in category 'accessing') -----<br>
+ unsignedIntAt: index<br>
+ ^self at: index!<br>
<br>
Item was added:<br>
+ ----- Method: CArray>>unsignedIntAt:put: (in category 'accessing') -----<br>
+ unsignedIntAt: index put: unsignedInt<br>
+ ^ self at: index put: unsignedInt!<br>
<br>
Item was added:<br>
+ ----- Method: CObjectAccessor>>asUnsignedIntAccessor (in category 'converting') -----<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>>sqFile:Read:Into:At: (in category 'simulation') -----<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>>sqFile:Write:From:At: (in category 'simulation') -----<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 "lf" ifTrue: [15"cr"] ifFalse: [byte]))]].<br>
self recordStateOf: file.<br>
^count!<br>
<br>
Item was changed:<br>
----- Method: Integer>>coerceTo:sim: (in category '*VMMaker-interpreter simulator') -----<br>
coerceTo: cTypeString sim: interpreter<br>
<br>
| unitSize |<br>
+ cTypeString last = $* ifTrue: "C pointer"<br>
+ [unitSize := cTypeString caseOf: {<br>
- cTypeString last = $* ifTrue: [ "C pointer"<br>
- unitSize := cTypeString caseOf: {<br>
['char *'] -> [1].<br>
['short *'] -> [2].<br>
['int *'] -> [4].<br>
['long *'] -> [interpreter wordSize].<br>
['float *'] -> [4].<br>
['double *'] -> [8].<br>
['unsigned *'] -> [4].<br>
+ ['unsigned int *'] -> [4].<br>
+ ['unsigned char *'] -> [4].<br>
+ ['unsigned short *'] -> [4].<br>
['oop *'] -> [interpreter bytesPerOop].<br>
}<br>
otherwise: [ (cTypeString beginsWith: 'char') 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 "C number (int, char, float, etc)"!<br>
<br>
Item was changed:<br>
----- Method: LargeIntegersPlugin>>cDigitOf:at: (in category 'C core util') -----<br>
cDigitOf: cPointer at: zeroBasedDigitIndex<br>
<inline: true><br>
<returnTypeC: #'unsigned int'><br>
<var: 'cPointer' type: #'unsigned int *'><br>
+ ^self byteSwapped32IfBigEndian: ((self cCode: [cPointer] inSmalltalk: [interpreterProxy cCoerce: cPointer to: #'unsigned int *']) at: zeroBasedDigitIndex)!<br>
- ^self byteSwapped32IfBigEndian: (cPointer at: zeroBasedDigitIndex)!<br>
<br>
Item was changed:<br>
----- Method: LargeIntegersPlugin>>cDigitOf:at:put: (in category 'C core util') -----<br>
cDigitOf: cPointer at: zeroBasedDigitIndex put: aValue<br>
<inline: true><br>
<returnTypeC: #'unsigned int'><br>
<var: 'cPointer' type: #'unsigned int *'><br>
<var: 'aValue' type: #'unsigned int'><br>
+ ^(self cCode: [cPointer] inSmalltalk: [interpreterProxy cCoerce: cPointer to: #'unsigned int *'])<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>