<p>I have more and more algorithms depending on highBit and the code is fast yet but not enough (appears in tally espcially in Spur64)...</p>
<p>The primitive could use the Count Leading Zero instructions available on most uproc via gcc builtin_clz or MSVC __lzcnt, 32 and 64 bits variants.<br>
Something like this pseudo code:</p>
<pre><code>leadingZeroCount := builtin_clz( taggedIntegerReceiver );
if (clz == 0) return primitiveFail();
else {
    highBit := WordSize * 8 "CHAR_BIT" - numTagBits - leadingZeroCount;
    return makeSmallInteger( highBit );
}
</code></pre>
<p>This primitive should be jitted of course (easy, just need to add an instruction).</p>
<p>Primitive fallback code would aggregate < 0 failure test case + code of highBitOfPositiveReceiver if primitive is absent (no need for two messages, in most case the primitive will be here and fast enough).</p>
<p>Is a primitive number mandatory for being jitted?<br>
If yes, how to reserve/allocate one?</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/418?email_source=notifications&email_token=AIJPEWYWPOUVDQD46FEVP33QFUYN3A5CNFSM4IOGIB32YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HGP7A7A">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AIJPEW4KCTIGYIVVZYSZI73QFUYN3ANCNFSM4IOGIB3Q">mute the thread</a>.<img src="https://github.com/notifications/beacon/AIJPEW3YO7ZBP6BVNWPL3YLQFUYN3A5CNFSM4IOGIB32YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HGP7A7A.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/418?email_source=notifications\u0026email_token=AIJPEWYWPOUVDQD46FEVP33QFUYN3A5CNFSM4IOGIB32YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HGP7A7A",
"url": "https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/418?email_source=notifications\u0026email_token=AIJPEWYWPOUVDQD46FEVP33QFUYN3A5CNFSM4IOGIB32YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HGP7A7A",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>