Nicola Mometto <brobro...@gmail.com> writes: > I don't think that's what Mike was talking about. > Say we have (defn x ^long [] 1), clojure will use the IFn$L and emit an > "public long invokePrim()" method. > > When we do (defn y [] (let [a (x)] a) the compiler will call .invokePrim > instead of invoke. > > If we redefine (defn x [] "") then y won't work because the new version > of x doesn't implement IFn$L, we'd need to recompile y too.
Actually I am talking about the same problem. For virtual calls the JIT compiler can determine that only one implementation of the method is being used, inline the call and perform object explosion, effectively removing boxing of primitives. When new implementation becomes available it dynamically recompiles affected bytecode. I don't know if the current implementation does this for invokedynamic calls, but there is a potential. It just does not feel right to invent a whole new complex optimization layer on the Clojure side until we fully use the optimization capabilities of the JVM. -- Mikhail
pgpKVfcWvSsNF.pgp
Description: PGP signature