merged volatile memory barriers
[cacao.git] / src / vm / jit / jit.cpp
index ffd17e37b8d6b732133acafccd521e991cc64e35..b633292c04ea796831a4f08049c4052f0683432a 100644 (file)
 
 #include "md.h"
 
-#include "mm/memory.h"
+#include "mm/memory.hpp"
 
 #include "native/native.hpp"
 
-#include "toolbox/logging.h"
+#include "toolbox/logging.hpp"
 
 #include "threads/mutex.hpp"
 
 #include "vm/class.hpp"
 #include "vm/global.h"
 #include "vm/globals.hpp"
+#include "vm/hook.hpp"
 #include "vm/initialize.hpp"
 #include "vm/loader.hpp"
 #include "vm/method.hpp"
 #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
-
 #include "vm/jit/allocator/simplereg.h"
 #if defined(ENABLE_LSRA) && !defined(ENABLE_SSA)
 # include "vm/jit/allocator/lsra.h"
@@ -177,11 +170,6 @@ void jit_init(void)
 #else
        intrp_md_init();
 #endif
-
-#if defined(ENABLE_OPAGENT)
-       if (opt_EnableOpagent)
-               OprofileAgent::initialize();
-#endif
 }
 
 
@@ -193,10 +181,7 @@ void jit_init(void)
 
 void jit_close(void)
 {
-#if defined(ENABLE_OPAGENT)
-       if (opt_EnableOpagent)
-               OprofileAgent::close();
-#endif
+       /* nop */
 }
 
 
@@ -316,17 +301,6 @@ 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 */
 
@@ -404,23 +378,11 @@ u1 *jit_compile(methodinfo *m)
                /* release codeinfo */
 
                code_codeinfo_free(jd->code);
-
-#if defined(ENABLE_PROFILING)
-               /* Release memory for basic block profiling information. */
-
-               if (JITDATA_HAS_FLAG_INSTRUMENT(jd))
-                       if (jd->code->bbfrequency != NULL)
-                               MFREE(jd->code->bbfrequency, u4, jd->code->basicblockcount);
-#endif
        }
        else {
                DEBUG_JIT_COMPILEVERBOSE("Running: ");
        }
 
-#if defined (ENABLE_JITCACHE)
-       jitcache_store(m);
-#endif
-
 #if defined(ENABLE_STATISTICS)
        /* measure time */
 
@@ -428,10 +390,8 @@ u1 *jit_compile(methodinfo *m)
                compilingtime_stop();
 #endif
 
-#if defined(ENABLE_OPAGENT)
-       if (opt_EnableOpagent)
-               OprofileAgent::newmethod(m);
-#endif
+       // Hook point just after code was generated.
+       Hook::jit_generated(m, m->code);
 
        /* leave the monitor */
 
@@ -539,10 +499,8 @@ u1 *jit_recompile(methodinfo *m)
                compilingtime_stop();
 #endif
 
-#if defined(ENABLE_OPAGENT)
-       if (opt_EnableOpagent)
-               OprofileAgent::newmethod(m);
-#endif
+       // Hook point just after code was generated.
+       Hook::jit_generated(m, m->code);
 
        DEBUG_JIT_COMPILEVERBOSE("Recompiling done: ");
 
@@ -793,8 +751,10 @@ static u1 *jit_compile_intern(jitdata *jd)
           _must_ be done after loop optimization and register allocation,
           since they can change the basic block count. */
 
-       if (JITDATA_HAS_FLAG_INSTRUMENT(jd))
+       if (JITDATA_HAS_FLAG_INSTRUMENT(jd)) {
+               code->basicblockcount = jd->basicblockcount;
                code->bbfrequency = MNEW(u4, jd->basicblockcount);
+       }
 #endif
 
        DEBUG_JIT_COMPILEVERBOSE("Generating code: ");