I created an issue and attached a patch http://dev.clojure.org/jira/browse/CLJ-1111
Now the 5 last lines of bytecode are: 52: goto 9 55: goto 61 58: pop 59: dload 5 61: dreturn Christophe On Tue, Nov 20, 2012 at 10:27 PM, Christophe Grand <christo...@cgrand.net>wrote: > I think CLJ-701 is about loop in non-terminal position. > > > On Tue, Nov 20, 2012 at 6:30 PM, Andy Fingerhut > <andy.finger...@gmail.com>wrote: > >> Any relationship to CLJ-701, other than similar symptoms? >> >> http://dev.clojure.org/jira/browse/CLJ-701 >> >> Andy >> >> On Nov 20, 2012, at 9:15 AM, Christophe Grand wrote: >> >> Hi, >> >> It looks like, because of the recur, the compiler fails to notice that if >> returns a primitive. >> As far as I understand in Compiler.java, RecurExpr does not implement >> MaybePrimitiveExpr and thus causes on canEmitPrimitive the surrounding >> IfExpr to return false. >> >> Someone to confirm this analysis? >> >> >> On Tue, Nov 20, 2012 at 4:34 PM, Gunnar Völkel < >> gunnar.voel...@googlemail.com> wrote: >> >>> I have written a primitive function for exponentiation with integers as >>> power using the multiply-and-square algorithm. >>> For performance reasons I used primitive type hints for the arguments >>> and the return value. >>> Profiling the whole application I noticed that there are a lot of >>> java.lang.Double/valueOf calls. >>> Looking at the bytecode I see that in Clojure 1.3 as well as in Clojure >>> 1.4 the result value gets boxed and unboxed like >>> Double.valueOf(result).doubleValue(). >>> >>> Am I doing something wrong? Is there a serious bug related to the >>> support of primitive functions? >>> >>> The source code: >>> >>> (defn first-bit? >>> {:inline (fn [n] `(== 1 (clojure.lang.Numbers/and ~n, 1)) )} >>> [^long n] >>> (== 1 (clojure.lang.Numbers/and n, 1))) >>> >>> (defn exp-int >>> ^double [^double x, ^long c] >>> (loop [result 1.0, factor x, c c] >>> (if (> c 0) >>> (recur >>> (if (first-bit? c) >>> (* result factor) >>> result), >>> (* factor factor), >>> (bit-shift-right c 1)) >>> result))) >>> >>> Last lines of the Java bytecode of `exp-int`: >>> 59 dload 5; /* result */ >>> 61 invokestatic 40; /* java.lang.Double >>> java.lang.Double.valueOf(double c) */ >>> 64 checkcast 85; /* java.lang.Number */ >>> 67 invokevirtual 89; /* double doubleValue() */ >>> 70 dreturn; >>> >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Clojure" group. >> To post to this group, send email to clojure@googlegroups.com >> Note that posts from new members are moderated - please be patient with >> your first post. >> To unsubscribe from this group, send email to >> clojure+unsubscr...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/clojure?hl=en >> > > > > -- > Professional: http://cgrand.net/ (fr) > On Clojure: http://clj-me.cgrand.net/ (en) > -- Professional: http://cgrand.net/ (fr) On Clojure: http://clj-me.cgrand.net/ (en) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en