<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi Nicolas,<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Sep 4, 2019 at 2:35 PM Nicolas Cellier <<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"> <div dir="ltr"><div>Hi Eliot,</div><div>thanks. Yes, for now I let responsibility to image side (Smalltalk voidCogVMState), because it sounded complex to relink to interpreter...</div><div>French say (but this might come from Sweden): do<b>n'</b><b>t cut</b><b> off </b><b>the</b><b> branch </b><b>you'</b><b>re </b><b>sitting</b><b> on</b></div></div></blockquote><div><br></div><div>:-).</div><div><br></div><div>I shall add the ability too store the setting in a bit stored in the image header then.</div><div><br></div><div>I have one favor to ask you.  Can you rewrite InterpreterPrimitives>>#primitiveHighBit in the following way?</div><div><br></div><div>a) have all the special compiler versions separate and not nested.  So</div><div><br></div><div>    ...</div><div>    self cppIf: #'__GNUC__' defined</div><div>          ifTrue:</div><div>               [...</div><div>                ^self].</div><div>    self cppIf: #'_MSC_VER' defined</div><div>          ifTrue:</div><div>               [...</div><div>                ^self].</div><div>    slow by-hand version here...</div><div><br></div><div>Why I want this is so that simulation reflects the real VM as much as possible.  The way that the primitive is written right now is that when simulated it will always fail, and that means that the simulator doesn't really do what the real VM does.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le mer. 4 sept. 2019 à 21:28, Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"> <div dir="ltr"><div dir="ltr"><div dir="ltr">Hi Nicolas,<div><br></div><div>    this looks great!  Thanks for your patience while I've reviewed this.  I do see that to implement CoInterpreter>>setPrimitiveDoMixedArithmetic: correctly we'll either have to discard JITed methods with primitives and remap context pcs.  See e.g. CoInterpreterPrimitives>>primitiveVoidVMStateForMethod.  I am happy to do this; the code needs a few changes anyway to make sure things still simulate.  But you may be doing this anyway.  If we step on each other's fingers then no worries.  You can always commit your code over mine.</div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Aug 30, 2019 at 5:04 PM <<a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"> <br>
Nicolas Cellier uploaded a new version of VMMaker to project VM Maker Inbox:<br>
<a href="http://source.squeak.org/VMMakerInbox/VMMaker.oscog-nice.2547.mcz" rel="noreferrer" target="_blank">http://source.squeak.org/VMMakerInbox/VMMaker.oscog-nice.2547.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: VMMaker.oscog-nice.2547<br>
Author: nice<br>
Time: 31 August 2019, 2:02:51.22464 am<br>
UUID: 66e4c466-c54c-4035-a7fa-6078386cbc66<br>
Ancestors: VMMaker.oscog-nice.2546<br>
<br>
Fix genPrimitiveHighBit<br>
<br>
We must not modify ReceiverResultReg when we CompletePrimitive (in case of negative receiver).<br>
<br>
Hence, like in WIN64, we must better use TempReg.<br>
<br>
=============== Diff against VMMaker.oscog-nice.2546 ===============<br>
<br>
Item was changed:<br>
  ----- Method: CogObjectRepresentation>>genPrimitiveHighBit (in category 'primitive generators') -----<br>
  genPrimitiveHighBit<br>
+       "Implementation notes: there are two reasons to use TempReg<br>
+       -1) if primitive fails, ReceiverResultReg must remain unchanged (we CompletePrimitive)<br>
+       -2) CLZ/BSR only work on 64bits for registers R0-R7 on Intel X64. But Win64 uses R9<br>
+       Normally, this should be backEnd dependent, but for now we have a single 64bits target..."<br>
+       <br>
        | jumpNegativeReceiver |<br>
        <var: #jumpNegativeReceiver type: #'AbstractInstruction *'><br>
        "remove excess tag bits from the receiver oop"<br>
+       cogit MoveR: ReceiverResultReg R: TempReg.<br>
        self numSmallIntegerTagBits > 1<br>
                ifTrue:<br>
+                       [cogit OrCq: 1 << self numSmallIntegerTagBits - 1 R: TempReg.<br>
+                       cogit ArithmeticShiftRightCq: self numSmallIntegerTagBits - 1 R: TempReg].<br>
-                       [cogit OrCq: 1 << self numSmallIntegerTagBits - 1 R: ReceiverResultReg.<br>
-                       cogit ArithmeticShiftRightCq: self numSmallIntegerTagBits - 1 R: ReceiverResultReg].<br>
        "and use the abstract cogit facility for case of single tag-bit"<br>
+       jumpNegativeReceiver := cogit genHighBitIn: TempReg ofSmallIntegerOopWithSingleTagBit: TempReg.<br>
-       jumpNegativeReceiver := cogit genHighBitIn: ReceiverResultReg ofSmallIntegerOopWithSingleTagBit: ReceiverResultReg.<br>
        "Jump is NULL if above operation is not implemented, else return the result"<br>
        jumpNegativeReceiver = 0<br>
                ifFalse:<br>
+                       [cogit MoveR: TempReg R: ReceiverResultReg.<br>
+                       cogit genConvertIntegerToSmallIntegerInReg: ReceiverResultReg.<br>
-                       [cogit genConvertIntegerToSmallIntegerInReg: ReceiverResultReg.<br>
                        cogit genPrimReturn.<br>
                        jumpNegativeReceiver jmpTarget: cogit Label].<br>
        ^CompletePrimitive!<br>
<br>
Item was removed:<br>
- ----- Method: CogObjectRepresentation>>genPrimitiveHighBitgenPrimitiveHighBit (in category 'primitive generators') -----<br>
- genPrimitiveHighBitgenPrimitiveHighBit<br>
-       | jumpNegativeReceiver |<br>
-       <var: #jumpNegativeReceiver type: #'AbstractInstruction *'><br>
-       "remove excess tag bits from the receiver oop"<br>
-       self numSmallIntegerTagBits > 1<br>
-               ifTrue:<br>
-                       [cogit OrCw: 1 << self numSmallIntegerTagBits - 1 R: ReceiverResultReg.<br>
-                       cogit ArithmeticShiftRightCq: self numSmallIntegerTagBits - 1 R: ReceiverResultReg].<br>
-       "and use the abstract cogit facility for case of single tag-bit"<br>
-       jumpNegativeReceiver := cogit genHighBitIn: ReceiverResultReg ofSmallIntegerOopWithSingleTagBit: ReceiverResultReg.<br>
-       "The jump instruction is NULL when backend does not really has a jitted implementation: fallback to normal primitive"<br>
-       jumpNegativeReceiver = 0 ifTrue: [^CompletePrimitive].<br>
-       cogit genPrimReturn.<br>
-       jumpNegativeReceiver jmpTarget: cogit Label.<br>
-       ^UnimplementedPrimitive!<br>
<br>
Item was removed:<br>
- ----- Method: CogObjectRepresentationFor64BitSpur>>genPrimitiveHighBit (in category 'primitive generators') -----<br>
- genPrimitiveHighBit<br>
-       "Implementation notes: same as super, but CLZ/BSR only work on 64bits for registers R0-R7 on Intel X64.<br>
-       Normally, this should be backEnd dependent, but for now we have a single 64bits target..."<br>
-       | jumpNegativeReceiver reg |<br>
-       <var: #jumpNegativeReceiver type: #'AbstractInstruction *'><br>
-       "remove excess tag bits from the receiver oop"<br>
-       <br>
-       ReceiverResultReg > 7<br>
-               ifTrue: [cogit MoveR: ReceiverResultReg R: (reg := TempReg)]<br>
-               ifFalse: [reg := ReceiverResultReg].<br>
-       self numSmallIntegerTagBits > 1<br>
-               ifTrue:<br>
-                       [cogit OrCw: 1 << self numSmallIntegerTagBits - 1 R: reg.<br>
-                       cogit ArithmeticShiftRightCq: self numSmallIntegerTagBits - 1 R: reg].<br>
-       "and use the abstract cogit facility for case of single tag-bit"<br>
-       jumpNegativeReceiver := cogit genHighBitIn: reg ofSmallIntegerOopWithSingleTagBit: reg.<br>
-       "Jump is NULL if above operation is not implemented, else return the result"<br>
-       jumpNegativeReceiver = 0<br>
-               ifFalse:<br>
-                       [ReceiverResultReg > 7<br>
-                               ifTrue: [cogit MoveR: reg R: ReceiverResultReg].<br>
-                       cogit genConvertIntegerToSmallIntegerInReg: ReceiverResultReg.<br>
-                       cogit genPrimReturn.<br>
-                       jumpNegativeReceiver jmpTarget: cogit Label].<br>
-       ^CompletePrimitive!<br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>
</blockquote></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" 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></div></div>