merged volatile memory barriers
[cacao.git] / src / vm / jit / patcher-common.cpp
index dcafac7b7eedad04c3333d23124af04a9e970710..6acd9687c493440c8548b4509a9c584a8642b4d6 100644 (file)
@@ -45,6 +45,7 @@
 
 #include "vm/breakpoint.hpp"
 #include "vm/exceptions.hpp"
+#include "vm/hook.hpp"
 #include "vm/initialize.hpp"
 #include "vm/options.h"
 #include "vm/os.hpp"
@@ -360,7 +361,7 @@ static int patcher_depth = 0;
 #define TRACE_PATCHER_INDENT for (i=0; i<patcher_depth; i++) printf("\t")
 #endif /* !defined(NDEBUG) */
 
-java_handle_t *patcher_handler(u1 *pc)
+bool patcher_handler(u1 *pc)
 {
        codeinfo      *code;
        patchref_t    *pr;
@@ -396,7 +397,7 @@ java_handle_t *patcher_handler(u1 *pc)
                }
 #endif
                code->patchers->unlock();
-               return NULL;
+               return true;
        }
 
 #if !defined(NDEBUG)
@@ -450,24 +451,17 @@ java_handle_t *patcher_handler(u1 *pc)
        }
 #endif
 
-       // Check for return value and exit accordingly.
-       if (result == false) {
-               // Mangle the pending exception.
+       // Check return value and mangle the pending exception.
+       if (result == false)
                resolve_handle_pending_exception(true);
 
-               // Get the exception and return it.
-               java_handle_t* e = exceptions_get_and_clear_exception();
-
-               code->patchers->unlock();
-
-               return e;
-       }
-
-       pr->done = true; /* XXX this is only preliminary to prevent double-patching */
+       // XXX This is only preliminary to prevent double-patching.
+       else
+               pr->done = true;
 
        code->patchers->unlock();
 
-       return NULL;
+       return result;
 }
 
 
@@ -581,13 +575,8 @@ bool patcher_breakpoint(patchref_t *pr)
        // Get stuff from the patcher reference.
        Breakpoint* breakp = (Breakpoint*) pr->ref;
 
-#if defined(ENABLE_JVMTI)
-       methodinfo* m = breakp->method;
-       int32_t     l = breakp->location;
-
-       log_message_method("JVMTI: Reached breakpoint in method ", m);
-       log_println("JVMTI: Reached breakpoint at location %d", l);
-#endif
+       // Hook point when a breakpoint was triggered.
+       Hook::breakpoint(breakp);
 
        // In case the breakpoint wants to be kept active, we simply
        // fail to "patch" at this point.