<div dir="ltr"><div>To answer to myself, this method is always inlined...</div><div>So it seems here for external plugins and VM simulator, is that it?</div><div>Then we must learn to ignore this specific warning... Which is not really sustainable if we really want to use the warnings (as we ought to).<br></div></div><br><div class="gmail_quote"><div dir="ltr">Le mar. 25 déc. 2018 à 22:35, Nicolas Cellier <<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@gmail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Hi again,</div><div><br></div><div>I see this horrible generated code:</div><div><br></div><div>    /* Spur64BitMemoryManager>>#integerValueOf: */<br>sqInt<br>integerValueOf(sqInt oop)<br>{<br>    return ((((usqInt) oop >> 63)) == 1<br>        ? ((((((-(numTagBits())) < 0) ? ((usqInt) oop >> -(-(numTagBits()))) : ((usqInt) oop << (-(numTagBits()))))) & 0x1FFFFFFFFFFFFFFFLL) - 0x1FFFFFFFFFFFFFFFLL) - 1<br>        : (((-(numTagBits())) < 0) ? ((usqInt) oop >> -(-(numTagBits()))) : ((usqInt) oop << (-(numTagBits())))));<br>}</div><div><br></div><div>which of course generates a (false positive) warning:</div><div><br></div><div>Avertissement    C4293    '<<' : compteur de décalage négatif ou trop important, comportement non défini    SqueakCogSpur    X:\Smalltalk\opensmalltalk-vm\spur64src\vm\cointerp.c    41564    <br></div><div><br></div><div>Slang is:</div><div><br></div><div>integerValueOf: oop<br>    "Translator produces 'oop >> 3'"<br>    ^(oop bitShift: -63) = 1 "tests top bit"<br>        ifTrue: "negative"<br>            [((oop bitShift: self numTagBits negated) bitAnd: 16r1FFFFFFFFFFFFFFF) - 16r1FFFFFFFFFFFFFFF - 1  "Faster than -16r4000000000000000 (a LgInt)"]<br>        ifFalse: "positive"<br>            [oop bitShift: self numTagBits negated]</div><div><br></div><div>We see that the constant -63 has been translated into a directed (right) shift, but the other constant (numTagBits) not so, either because constant substitution is not aggressive enough, or because negated made an expression of the constant...</div><div><br></div><div>However, the intention is ALWAYS to perform a directed shift (to the right) so the code could be expressed to make both intention AND generated code clear (and warning-free):</div><div><br></div><div>integerValueOf: oop<br>    "Translator produces 'oop >> 3'"<br>    ^(oop >> 63) = 1 "tests top bit"<br>        ifTrue: "negative"<br>            [((oop >> self numTagBits) bitAnd: 16r1FFFFFFFFFFFFFFF) - 16r1FFFFFFFFFFFFFFF - 1  "Faster than -16r4000000000000000 (a LgInt)"]<br>        ifFalse: "positive"<br>            [oop >> self numTagBits]</div><div><br></div><div>Why use bitShift: then? Is it a problem of speed for the VM simulator?</div><div><br></div></div></div></div></div></div>
</blockquote></div>