<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    On 6/23/2020 10:58 AM, Luciano Notarfrancesco via Cuis-dev wrote:
    <blockquote
cite="mid:CAL5GDypX5LBqjWK-U=FgGaDz+PaDs_Sz0JGikzuDot4o0ruWeg@mail.gmail.com"
      type="cite">
      <div>
        <div dir="auto">Sorry, should be whileTrue there...</div>
      </div>
      <div><br>
        <div class="gmail_quote">
          <div dir="ltr" class="gmail_attr">On Tue, 23 Jun 2020 at 8:57
            PM, Luciano Notarfrancesco <<a moz-do-not-send="true"
              href="mailto:luchiano@gmail.com">luchiano@gmail.com</a>>
            wrote:<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="auto">Try this in a workspace:</div>
            <div dir="auto"><br>
            </div>
            <div dir="auto">[a _ (1 << 60) atRandom.</div>
            <div dir="auto">b _ (a bitReverse: 64) bitReverse: 64.</div>
            <div dir="auto">a = b] whileFalse</div>
            <div dir="auto"><br>
            </div>
            <div dir="auto">I tested it in the latest image with a
              recent cog spur x64 VM. The loop stops with a ‘b’ that is
              a LargePositiveInteger but it actually fits in a
              SmallInteger and it is equal to ‘a’. I don’t have time to
              debug it until the weekend but I thought someone might
              find it amusing.</div>
          </blockquote>
        </div>
      </div>
    </blockquote>
    <br>
    Well, this was fun!<br>
    <br>
    When you find the problem (the primitive in #bitShiftMagnitude:
    answers the receiver if the argument is zero, without reducing it to
    SmallInteger as appropriate), and you try to fix it, then, when you
    want to write a test that fails without the fix, you can not make it
    fail!<br>
    <br>
    The problem only happens when #bitReverse: gets jitted by the Cog
    VM, and that requires a few runs to happen. Hence, the test loops a
    few times, doing exactly the same.<br>
    <br>
    Please take a look.<br>
    <br>
    Cheers,<br>
    <pre class="moz-signature" cols="72">-- 
Juan Vuletich
<a class="moz-txt-link-abbreviated" href="http://www.cuis-smalltalk.org">www.cuis-smalltalk.org</a>
<a class="moz-txt-link-freetext" href="https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev">https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev</a>
<a class="moz-txt-link-freetext" href="https://github.com/jvuletich">https://github.com/jvuletich</a>
<a class="moz-txt-link-freetext" href="https://www.linkedin.com/in/juan-vuletich-75611b3">https://www.linkedin.com/in/juan-vuletich-75611b3</a>
@JuanVuletich</pre>
  </body>
</html>