[Vm-dev] [OpenSmalltalk/opensmalltalk-vm] Proposal: an (optional) primitive for SmallInteger highBit (#418)
notifications at github.com
Wed Aug 21 12:30:21 UTC 2019
I have more and more algorithms depending on highBit and the code is fast yet but not enough (appears in tally espcially in Spur64)...
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.
Something like this pseudo code:
leadingZeroCount := builtin_clz( taggedIntegerReceiver );
if (clz == 0) return primitiveFail();
highBit := WordSize * 8 "CHAR_BIT" - numTagBits - leadingZeroCount;
return makeSmallInteger( highBit );
This primitive should be jitted of course (easy, just need to add an instruction).
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).
Is a primitive number mandatory for being jitted?
If yes, how to reserve/allocate one?
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Vm-dev