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.
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? — |
I'd be surprised if a number is mandatory, but I'm not sure this should be part of some plugin (e.g.
Primitives 541-559 are used for SmallFloats and there's still some unused numbers after them (560 569). But I don't know how primitive numbers were reserved in the past. We might want to inform the Squeak/Pharo boards? — |
In reply to this post by David T Lewis
I came up with a first implementation in InterpreterPrimitives
It works, gives a speed-up of 1.5x to 3x in Spur64, and I expect much more from JIT version. For JIT, I will have to test cpu capabilities via CPUID and switch to LZCNT or BSR(RBIT) instructions on INTEL (or just BSR as demonstrated in the MSVC branch above). For the primitive, it's better to abandon the monolithic-omniscient style for a more distributed-object-oriented one, or there's no point in writing the VM in Smalltalk... Specifically, I would like to delegate the object-representation-dependent code to specialized classes... I don't well see which class (ObjectMemory, SpurMemoryManager, ...) nor which selector would fit the current VM-style... There will be some duplication of C-Compiler-dependent-builtin-logic, because we do not reify the C-compiler and cannot double dispatch... If there's a way to avoid, I'm all ears (JIT is somehow easier!!!). Any thought appreciated. — |
In reply to this post by David T Lewis
I have published VMMaker.oscog-nice.2542 / 2543 in https://source.squeak.org/VMMakerInbox https://source.squeak.org/VMMakerInbox/VMMaker.oscog-nice.2542.diff It's not ready for inclusion but somehow works on X64 (beware, I tested first then refactored...) — |
In reply to this post by David T Lewis
Closed #418. — |
Free forum by Nabble | Edit this page |