* Updated to jitcache-arm-x86 branch d4f6023b26c5+d1b5b1c106ac
[cacao.git] / src / vm / jit / jit.cpp
index b889cd59ca5d84a701e9918505f92b7631f164dd..e7dddde59906ac26f1b5a47cb9fa7c76b584d054 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 */