On Wed, Aug 12, 2009 at 4:24 PM, Richard Newman<holyg...@gmail.com> wrote: > >> I may be wrong, but doesn't a typical function invocation involve >> dereferencing the Var holding the object that implements "IFn" and >> calling invoke? It seems pretty intuitive to me that this would be >> difficult to inline by the JIT, there is a little bit of >> synchronization going on every time a Var is dereferenced. > > In principle, the JIT can inline the Var lookup, and do the > appropriate analysis to eliminate much of the work -- Vars have thread- > local bindings, so the JVM should be pretty well aware of access and > scope. Of course, this will only happen if everything is small enough, > frequently used, etc. etc. > > I saw a presentation at JavaOne which illustrated to just what extent > the dynamic compiler can eliminate locks, allocations, aliases, > synchronization boundaries, do closed-world analysis of class > hierarchies, and so on. It's pretty impressive. ("Inside Out: A Modern > Virtual Machine Revealed", if you're interested.) >
I don't think Vars are thread-local. They're one of the shared mutable state primitives. They can be defacto thread local if only used by a single thread but you need a "sufficiently smart compiler" to notice that. Hotspot definitely is smart enough in some cases, but I think for Escape Analysis you currently need a black magic command line parameter. I'm playing around with: "-XX:+DoEscapeAnalysis -XX:+UseBiasedLocking" with inconsistant results. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---