backend: emit bitwise ops as native ops (test.check PRNG ~2.4x)
Profiling the test.check distribution/large-sample slowness (jolt-i5if): the hot path is the SplitMix PRNG, dominated by 64-bit mix arithmetic, and the bitwise ops (bit-and/or/xor/not, shifts) were NOT in the backend native-ops table — so (bit-xor a b) compiled to a var-deref through the variadic overlay (__bit-xor) instead of a direct call, the way +/-/* already emit. Map bit-and/or/xor/not to the Chez bitwise-and/ior/xor/not primitives (inlined to native code; a non-integer operand now errors like the JVM instead of being silently truncated) and the shifts to a direct helper call. bit-and-not stays on its overlay — its only Scheme impl is 2-arg, so a value-position arity-3 use would mis-emit. mix-64 arithmetic 2.7x faster, raw split+rand-long 2.4x, gen/vector ~1.4x. The remaining gap is the bignum-vs-native-long floor (~20x, substrate) plus the generator machinery (deftype/fn dispatch, separate). Corpus rows added for value position, bit-not, apply, and a full-64-bit unsigned shift.
This commit is contained in:
parent
b5ea06c5c2
commit
f17b68ccfe
4 changed files with 153 additions and 135 deletions
|
|
@ -1545,6 +1545,11 @@
|
|||
{:suite "numbers / variadic bit ops" :label "bit-and-not 3" :expected "8" :actual "(bit-and-not 12 6 3)"}
|
||||
{:suite "numbers / variadic bit ops" :label "bit-and single arg throws" :expected :throws :actual "(bit-and 5)"}
|
||||
{:suite "numbers / variadic bit ops" :label "bit-or keeps binary fast path" :expected "3" :actual "(bit-or 1 2)"}
|
||||
{:suite "numbers / variadic bit ops" :label "bit-not" :expected "-6" :actual "(bit-not 5)"}
|
||||
{:suite "numbers / variadic bit ops" :label "bit-and in value position" :expected "8" :actual "(reduce bit-and [15 9 12])"}
|
||||
{:suite "numbers / variadic bit ops" :label "bit-xor in value position" :expected "0" :actual "(reduce bit-xor 0 [1 2 3])"}
|
||||
{:suite "numbers / variadic bit ops" :label "bit-or via apply" :expected "7" :actual "(apply bit-or [1 2 4])"}
|
||||
{:suite "numbers / variadic bit ops" :label "unsigned-shift over a full 64-bit value" :expected "17179869183" :actual "(unsigned-bit-shift-right -1 30)"}
|
||||
{:suite "predicates / nil & boolean" :label "nil? true" :expected "true" :actual "(nil? nil)"}
|
||||
{:suite "predicates / nil & boolean" :label "nil? false" :expected "false" :actual "(nil? 0)"}
|
||||
{:suite "predicates / nil & boolean" :label "some? true" :expected "true" :actual "(some? 0)"}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue