<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2016-10-31 22:42 GMT+01: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:0 0 0 .8ex;border-left:1px #ccc solid;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.1972.mcz" rel="noreferrer" target="_blank">http://source.squeak.org/<wbr>VMMaker/VMMaker.oscog-eem.<wbr>1972.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: VMMaker.oscog-eem.1972<br>
Author: eem<br>
Time: 31 October 2016, 2:42:12.362675 pm<br>
UUID: 0e6a54ad-d62f-4b69-9f0d-<wbr>7b66f8350984<br>
Ancestors: VMMaker.oscog-eem.1971<br>
<br>
Redo fixing extB sign extension in NewsqueakV4 &amp; SistaV1 extPushIntegerBytecode &amp; extUnconditionalJump in interpreter and Cogit using bitShift: 8 instead of &lt;&lt; 8.  Slang seems to generate the correct code with bitAShift:, but not with &lt;&lt;.<br>
<br></blockquote><div><br></div><div>Hi Eliot,<br></div><div>it would have worked if you would have used bitOr: instead of +<br>I&#39;d say bitOr: better fits the intention:<br></div><div>you want to assemble the bits, you do not really want to perform arithmetic here.<br></div><div><br></div><div>Also, the result we are after is a signed int, so consider that &lt;&lt; is doing the right thing, it gives you a signed int.<br></div><div>The expression you propose is unsigned. It works OK in this context, because we assign immediately to a signed int.<br>But for a more general usage, it could deceive the inliner (for example if variable is automatically typed or eliminated...)<br></div><div><br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
=============== Diff against VMMaker.oscog-eem.1971 ===============<br>
<br>
Item was changed:<br>
  ----- Method: SimpleStackBasedCogit&gt;&gt;<wbr>genExtPushIntegerBytecode (in category &#39;bytecode generators&#39;) -----<br>
  genExtPushIntegerBytecode<br>
        &quot;NewsqueakV4:   229             11100101        iiiiiiii        Push Integer #iiiiiiii (+ Extend B * 256, where bbbbbbbb = sddddddd, e.g. -32768 = i=0, a=0, s=1)<br>
        SistaV1:                232             11101000        iiiiiiii        Push Integer #iiiiiiii (+ Extend B * 256, where bbbbbbbb = sddddddd, e.g. -32768 = i=0, a=0, s=1)&quot;<br>
        | value |<br>
+       value := byte1 + ((extB &gt; 127 ifTrue: [extB - 256] ifFalse: [extB]) bitShift: 8).<br>
-       value := byte1 + ((extB &gt; 127 ifTrue: [extB - 256] ifFalse: [extB]) &lt;&lt; 8).<br>
        extB := 0.<br>
        ^self genPushLiteral: (objectMemory integerObjectOf: value)!<br>
<br>
Item was changed:<br>
  ----- Method: SimpleStackBasedCogit&gt;&gt;<wbr>genExtUnconditionalJump (in category &#39;bytecode generators&#39;) -----<br>
  genExtUnconditionalJump<br>
        &quot;242            11110010        i i i i i i i i Jump i i i i i i i i (+ Extend B * 256, where bbbbbbbb = sddddddd, e.g. -32768 = i=0, a=0, s=1)&quot;<br>
        | distance target |<br>
+       distance := byte1 + ((extB &gt; 127 ifTrue: [extB - 256] ifFalse: [extB]) bitShift: 8).<br>
-       distance := byte1 + ((extB &gt; 127 ifTrue: [extB - 256] ifFalse: [extB]) &lt;&lt; 8).<br>
        self assert: distance = (self v4: (self generatorAt: byte0)<br>
                                                                Long: bytecodePC<br>
                                                                Branch: (extA ~= 0 ifTrue: [1] ifFalse: [0]) + (extB ~= 0 ifTrue: [1] ifFalse: [0])<br>
                                                                Distance: methodObj).<br>
        extB := 0.<br>
        target := distance + 2 + bytecodePC.<br>
        distance &lt; 0 ifTrue:<br>
                [^self genJumpBackTo: target].<br>
        self genJumpTo: target.<br>
        &quot;The bytecode must be mapped since it can be either forward or backward, and<br>
          backwards branches must be mapped. So if forward, we need to map.&quot;<br>
        self annotateBytecode: self lastOpcode.<br>
        ^0!<br>
<br>
Item was changed:<br>
  ----- Method: SimpleStackBasedCogit&gt;&gt;v4:<wbr>Long:Branch:Distance: (in category &#39;span functions&#39;) -----<br>
  v4: descriptor Long: pc Branch: nExts Distance: aMethodObj<br>
        &quot;242            11110010        i i i i i i i i Jump i i i i i i i i (+ Extend B * 256, where bbbbbbbb = sddddddd, e.g. -32768 = i=0, a=0, s=1)&quot;<br>
        &lt;var: #descriptor type: #&#39;BytecodeDescriptor *&#39;&gt;<br>
        | extBValue |<br>
        self assert: nExts &gt;= 0.<br>
        self parseV4Exts: nExts priorTo: pc in: aMethodObj into: [:ea :eb| extBValue := eb].<br>
        ^(objectMemory fetchByte: pc + 1 ofObject: aMethodObj)<br>
+       + (extBValue bitShift: 8)!<br>
-       + (extBValue &lt;&lt; 8)!<br>
<br>
Item was changed:<br>
  ----- Method: StackInterpreter&gt;&gt;<wbr>extPushIntegerBytecode (in category &#39;stack bytecodes&#39;) -----<br>
  extPushIntegerBytecode<br>
        &quot;229            11100101        i i i i i i i i Push Integer #iiiiiiii (+ Extend B * 256, where bbbbbbbb = sddddddd, e.g. -32768 = i=0, a=0, s=1)&quot;<br>
        | value |<br>
+       value := self fetchByte + ((extB &gt; 127 ifTrue: [extB - 256] ifFalse: [extB]) bitShift: 8).<br>
-       value := self fetchByte + ((extB &gt; 127 ifTrue: [extB - 256] ifFalse: [extB]) &lt;&lt; 8).<br>
        self fetchNextBytecode.<br>
        extB := 0.<br>
        self internalPush: (objectMemory integerObjectOf: value)!<br>
<br>
Item was changed:<br>
  ----- Method: StackInterpreter&gt;&gt;<wbr>extUnconditionalJump (in category &#39;jump bytecodes&#39;) -----<br>
  extUnconditionalJump<br>
        &quot;242            11110010        i i i i i i i i Jump i i i i i i i i (+ Extend B * 256, where bbbbbbbb = sddddddd, e.g. -32768 = i=0, a=0, s=1)&quot;<br>
        | byte offset |<br>
        byte := self fetchByte.<br>
+       offset := byte + ((extB &gt; 127 ifTrue: [extB - 256] ifFalse: [extB]) bitShift: 8).<br>
-       offset := byte + ((extB &gt; 127 ifTrue: [extB - 256] ifFalse: [extB]) &lt;&lt; 8).<br>
        extB := 0.<br>
        localIP := localIP + offset.<br>
        self ifBackwardsCheckForEvents: offset.<br>
        self fetchNextBytecode!<br>
<br>
</blockquote></div><br></div></div>