<div dir="ltr">Hi All,<div><br></div><div>    just a quick sketch of an idea (and a bucket of whitewash) in the light of finding that </div><div><br></div><div>FloatArray&gt;&gt;at: index<div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>&lt;primitive: &#39;primitiveAt&#39; module: &#39;FloatArrayPlugin&#39;&gt;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>^Float fromIEEE32Bit: (self basicAt: index)</div><div><br></div><div>and at:put: are very slow.  The basic idea is to annotate selected internal plugin primitive implementation methods with a corresponding Cogit or CogObjectRepresentation generator for a machine code version of the primitive.  FloatArray&gt;&gt;at:put: is I think about 6 times slower than the native Cogit implementation of at:put:; this because invoking plugin primitives is very slow (native stack pointers must be written back to the interpreter&#39;s stack pointers, arguments must be pushed onto the stack, the primFailCode must be tested explicitly).</div><div><br></div><div>First, Roni has added some single-precision float support to the Cogit for Lowcode.  To do single-precision to double-precision we would still need something like ConvertRsRd and ConvertRdRs to do the conversion.  A related task is to implement the Lowcode instruction support for the other platforms; Roni has done x86 (IA32), which leaves ARMv6 &amp; 7, x86-64 and MIPS32.</div><div><br></div><div>Second, one could add a translation-time scheme to associate specific plugin primitives with JIT versions.  For example, let&#39;s imagine we annotate the above&#39;s corresponding primitive implementation as:</div><div><br></div><div>FloatArrayPlugin&gt;&gt;primitiveAt</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>&lt;cogitPrimitive: #genFloatArrayPluginAt&gt;<br></div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>| index rcvr floatValue floatPtr |</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>&lt;export: true&gt;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>&lt;var: #floatValue type: #double&gt;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>&lt;var: #floatPtr type: #&#39;float *&#39;&gt;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>index := interpreterProxy stackIntegerValue: 0.</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>rcvr := interpreterProxy stackValue: 1.</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>(interpreterProxy failed not</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span> and: [(interpreterProxy isWords: rcvr)</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span> and: [index &gt; 0 and: [index &lt;= (interpreterProxy slotSizeOf: rcvr)]]]) ifFalse:</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>[^interpreterProxy primitiveFail].</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>floatPtr := interpreterProxy firstIndexableField: rcvr.</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>floatValue := (floatPtr at: index-1) asFloat.</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>interpreterProxy pop: 2.</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>interpreterProxy pushFloat: floatValue</div><div><br></div><div>and then generate a string table that contains the tuple {&quot;FloatArrayPlugin&quot;, &quot;primitiveAt&quot;, genFloatArrayPluginAt } which could be consulted by the Cogit whenever a plugin primitive call in an internal plugin occurs in a jitter method.  The Cogit would then generate the call via the generator, which might or might not fall back on the plugin primitive in unusual circumstances, but would handle the common case in machine code and reap much improved performance as a result.</div><div><br></div><div>Don&#39;t have time to do this now (perhaps you do ;-) ) so documenting the idea to not forget it.</div><div><br></div><div><br></div><div>Candidates: FloatArrayPlugin at: at:put:, LargeIntegerArithmeticPlugin comparisons.</div><div class="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>
</div></div>