<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions in tools.emitter.jvm</title>
<link>https://ask.clojure.org/index.php/questions/contrib-libs/tools-emitter-jvm</link>
<description></description>
<item>
<title>Emit unchecked locals</title>
<link>https://ask.clojure.org/index.php/7996/emit-unchecked-locals</link>
<description>&lt;p&gt;At present, TEMJVM emits checked code for hinted locals. This isn't correct according to clojure.org, which states that tags are not enforced and and are for reflection elimination rather than Java style static typing.&lt;/p&gt;
&lt;p&gt;This issue manifests itself when loading clojure.core/ns-publics, which makes use of a ^clojure.lang.Namespace hinted argument but is expected to accept the java.lang.Object domain as per the stated hinting behavior of clojure.&lt;/p&gt;
&lt;p&gt;The fix is to adopt Clojure's checkcast style, in that locals are not type hinted more precisely than Object, nor are function arguments. Only interop sites should actually emit checkcasts.&lt;/p&gt;
&lt;p&gt;This behavior is arguably silly but it prevents TEMJVM from self-hosting so there it is.&lt;/p&gt;
</description>
<category>tools.emitter.jvm</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/7996/emit-unchecked-locals</guid>
<pubDate>Tue, 28 Jul 2015 05:51:16 +0000</pubDate>
</item>
<item>
<title>Modularize -emit method</title>
<link>https://ask.clojure.org/index.php/7992/modularize-emit-method</link>
<description>&lt;p&gt;As mentioned briefly via email, a critical failure of TEMJVM in terms of extensibility is that clients are unable to leverage the existing emitter code without duplicating it wholesale or altering the loaded copy of TEMJVM in place.&lt;/p&gt;
&lt;p&gt;The feature/fragmented-emitter branch experiments with refactoring the various emit operations so that rather than using multimethods, they are represented as maps of :op keywords to simple functions taking an extra leading argument being the dispatch map or set of maps. Clients using TEMJVM then can recycle any and all code from the emitter itself simply by associng onto these mappings and using them. This may come at a performance penalty due to multimethod caching, however it should hugely reduce the verbosity of client code which doesn't have to define a mostly repetitive multimethod.&lt;/p&gt;
</description>
<category>tools.emitter.jvm</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/7992/modularize-emit-method</guid>
<pubDate>Thu, 23 Jul 2015 00:32:19 +0000</pubDate>
</item>
<item>
<title>Improve test coverage</title>
<link>https://ask.clojure.org/index.php/7993/improve-test-coverage</link>
<description>&lt;p&gt;The &quot;develop&quot; branch brings test coverage of TEMJVM up from 48% by forms to 79%. Still not covered are many of the -emit-set! operations and some details of deftype and defrecord emission.&lt;/p&gt;
&lt;p&gt;Tests broken until TEMJVM-11 is fixed.&lt;/p&gt;
&lt;p&gt;Ongoing point of work.&lt;/p&gt;
</description>
<category>tools.emitter.jvm</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/7993/improve-test-coverage</guid>
<pubDate>Wed, 22 Jul 2015 22:51:31 +0000</pubDate>
</item>
<item>
<title>Stack error in recur</title>
<link>https://ask.clojure.org/index.php/7991/stack-error-in-recur</link>
<description>&lt;br /&gt;
user&amp;gt; (loop [acc 0&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;col (range 50)]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(if-not (empty? col)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(recur (+ acc (first col)) (rest col))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;acc))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Generates exception&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
expected: (= (apply + (range 50)) (e/eval (quote (loop [acc 0 col (range 50)] (if-not (empty? col) (recur (+ acc (first col)) (rest col)) acc)))))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;actual: java.lang.VerifyError: Bad type on operand stack&lt;br /&gt;
Exception Details:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;Location:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;clojure/tools/emitter/passes/jvm/annotate_internal_name$fn__8917.invoke()Ljava/lang/Object; @4: invokestatic&lt;br /&gt;
&amp;nbsp;&amp;nbsp;Reason:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Type 'java/lang/Number' (current frame, stack[0]) is not assignable to long_2nd&lt;br /&gt;
&amp;nbsp;&amp;nbsp;Current Frame:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;bci: @4&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;flags: { }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;locals: { 'clojure/tools/emitter/passes/jvm/annotate_internal_name$fn__8917' }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;stack: { 'java/lang/Number' }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;Bytecode:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0x0000000: 2ab6 0045 b800 49b0&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;at java.lang.Class.getDeclaredConstructors0 (Class.java:-2)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;java.lang.Class.privateGetDeclaredConstructors (Class.java:2671)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;java.lang.Class.getConstructor0 (Class.java:3075)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;java.lang.Class.newInstance (Class.java:412)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;clojure.tools.emitter.jvm$eval.invoke (clojure/tools/emitter/jvm.clj:105)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;clojure.tools.emitter.jvm$eval.invoke (clojure/tools/emitter/jvm.clj:83)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;clojure.tools.emitter.jvm.core_test$fn__8193$fn__8328.invoke (core_test.clj:74)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;clojure.tools.emitter.jvm.core_test/fn (core_test.clj:73)&lt;br /&gt;
</description>
<category>tools.emitter.jvm</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/7991/stack-error-in-recur</guid>
<pubDate>Wed, 22 Jul 2015 19:10:45 +0000</pubDate>
</item>
<item>
<title>Fix line number info</title>
<link>https://ask.clojure.org/index.php/7997/fix-line-number-info</link>
<description>&lt;p&gt;Relevant tickets &lt;/p&gt;
&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;http://dev.clojure.org/jira/browse/CLJ-1561&quot;&gt;http://dev.clojure.org/jira/browse/CLJ-1561&lt;/a&gt;&lt;br&gt;
&lt;a rel=&quot;nofollow&quot; href=&quot;http://dev.clojure.org/jira/browse/CLJ-1568&quot;&gt;http://dev.clojure.org/jira/browse/CLJ-1568&lt;/a&gt;&lt;/p&gt;
</description>
<category>tools.emitter.jvm</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/7997/fix-line-number-info</guid>
<pubDate>Wed, 22 Oct 2014 17:40:07 +0000</pubDate>
</item>
<item>
<title>Change fn name munging scheme to match the one introduced with CLJ-1330</title>
<link>https://ask.clojure.org/index.php/7994/change-name-munging-scheme-match-the-one-introduced-with-1330</link>
<description></description>
<category>tools.emitter.jvm</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/7994/change-name-munging-scheme-match-the-one-introduced-with-1330</guid>
<pubDate>Mon, 13 Oct 2014 10:49:06 +0000</pubDate>
</item>
<item>
<title>Optimize constant metadata emission</title>
<link>https://ask.clojure.org/index.php/7995/optimize-constant-metadata-emission</link>
<description></description>
<category>tools.emitter.jvm</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/7995/optimize-constant-metadata-emission</guid>
<pubDate>Sun, 27 Apr 2014 23:22:50 +0000</pubDate>
</item>
</channel>
</rss>