* merged default branch into jitcache-arm-x86 branch
[cacao.git] / src / vm / jit / jit.cpp
index 095e9840155dba245ac7ec97a0a07909feaa1efb..09c9e862eb6798d7cdffc17aa234b89e7b861da2 100644 (file)
 #include "vm/jit/stack.h"
 #include "vm/jit/stubs.hpp"
 
+#if defined(ENABLE_JITCACHE)
+# include "vm/jit/jitcache.hpp"
+#endif
+
 #if defined(ENABLE_OPAGENT)
 #include "vm/jit/oprofile-agent.hpp"
 #endif
@@ -312,6 +316,17 @@ u1 *jit_compile(methodinfo *m)
 
        STATISTICS(count_methods++);
 
+#if defined (ENABLE_JITCACHE)
+
+       if (jitcache_load (m))
+       {
+               m->mutex->unlock();
+
+               return m->code->entrypoint;
+       }
+
+#endif
+
 #if defined(ENABLE_STATISTICS)
        /* measure time */
 
@@ -402,6 +417,10 @@ u1 *jit_compile(methodinfo *m)
                DEBUG_JIT_COMPILEVERBOSE("Running: ");
        }
 
+#if defined (ENABLE_JITCACHE)
+       jitcache_store(m);
+#endif
+
 #if defined(ENABLE_STATISTICS)
        /* measure time */