On Aug 12, 2009, at 3:59 PM, Richard Newman wrote: >> Is there some reason that the Java JIT is not doing this, with the >> original code using defn, as fast as it works when using defmacro? > > The macro expands into bytecode within the same Java method, rather > than a method invocation. Some method blocks are too big to inline, > and perhaps the JIT doesn't have enough information (or motivation) to > do so.
To emphasize: since many common clojure forms are macros themselves, the fns you're writing are likely much larger than you think they are. Simple things like doseq (nevermind more complicated stuff like for) expand into sizable chunks of clojure, which are themselves doing way more work per LOC than typical Java methods. Thus, I'll bet typical clojure fns exceed whatever code-size windows the JIT has in mind for inlining far more often than Java methods. ...even 'and' results in more code than you'd likely expect intuitively: user=> (use 'clojure.contrib.walk) nil user=> (macroexpand-all '(and a b c)) (let* [and__3314__auto__ a] (if and__3314__auto__ (let* [and__3314__auto__ b] (if and__3314__auto__ c and__3314__auto__)) and__3314__auto__)) - Chas --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---