* src/vm/jit/replace.cpp (replace_handler): Adapted replacement handler to take
authorMichael Starzinger <michi@complang.tuwien.ac.at>
Thu, 22 Oct 2009 11:31:05 +0000 (13:31 +0200)
committerMichael Starzinger <michi@complang.tuwien.ac.at>
Thu, 22 Oct 2009 11:31:05 +0000 (13:31 +0200)
an executionstate from the trap handler. Fixes -XX:+TestReplacement again.
* src/vm/jit/replace.hpp: Likewise.
* src/vm/jit/trap.cpp (trap_handle): Adapted to above change.

src/vm/jit/replace.cpp
src/vm/jit/replace.hpp
src/vm/jit/trap.cpp

index 1e6650f2048eb196a7210ee6cf4b4a6261aaaff0..395ad1d792236b20551798082333a4bb6e322454 100644 (file)
@@ -1,6 +1,6 @@
 /* src/vm/jit/replace.cpp - on-stack replacement of methods
 
 /* src/vm/jit/replace.cpp - on-stack replacement of methods
 
-   Copyright (C) 1996-2005, 2006, 2007, 2008
+   Copyright (C) 1996-2005, 2006, 2007, 2008, 2009
    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
@@ -2935,7 +2935,7 @@ static void replace_me(rplpoint *rp, executionstate_t *es)
 }
 
 
 }
 
 
-/* replace_me_wrapper **********************************************************
+/* replace_handler *************************************************************
 
    This function is called by the signal handler. It determines if there
    is an active replacement point pending at the given PC and returns
 
    This function is called by the signal handler. It determines if there
    is an active replacement point pending at the given PC and returns
@@ -2945,23 +2945,22 @@ static void replace_me(rplpoint *rp, executionstate_t *es)
 
    IN:
        pc...............the program counter that triggered the replacement.
 
    IN:
        pc...............the program counter that triggered the replacement.
-       context..........the context (machine state) to which the
+       es...............the execution state (machine state) to which the
                            replacement should be applied.
 
    OUT:
                            replacement should be applied.
 
    OUT:
-       context..........the context after replacement finished.
+       es...............the execution state after replacement finished.
 
    RETURN VALUE:
        true.............replacement done, everything went ok
 
    RETURN VALUE:
        true.............replacement done, everything went ok
-       false............no replacement done, context unchanged
+       false............no replacement done, execution state unchanged
 
 *******************************************************************************/
 
 
 *******************************************************************************/
 
-bool replace_me_wrapper(u1 *pc, void *context)
+bool replace_handler(u1 *pc, executionstate_t *es)
 {
        codeinfo         *code;
        rplpoint         *rp;
 {
        codeinfo         *code;
        rplpoint         *rp;
-       executionstate_t  es;
 #if defined(ENABLE_RT_TIMING)
        struct timespec time_start, time_end;
 #endif
 #if defined(ENABLE_RT_TIMING)
        struct timespec time_start, time_end;
 #endif
@@ -2982,20 +2981,9 @@ bool replace_me_wrapper(u1 *pc, void *context)
 
                DOLOG( printf("valid replacement point\n"); );
 
 
                DOLOG( printf("valid replacement point\n"); );
 
-#if !defined(NDEBUG)
-               executionstate_sanity_check(context);
-#endif
-
                /* set codeinfo pointer in execution state */
 
                /* set codeinfo pointer in execution state */
 
-               es.code = code;
-
-               /* read execution state from current context */
-
-               md_executionstate_read(&es, context);
-
-               DOLOG( printf("REPLACEMENT READ: ");
-                          executionstate_println(&es); );
+               es->code = code;
 
                /* do the actual replacement */
 
 
                /* do the actual replacement */
 
@@ -3003,20 +2991,13 @@ bool replace_me_wrapper(u1 *pc, void *context)
                RT_TIMING_GET_TIME(time_start);
 #endif
 
                RT_TIMING_GET_TIME(time_start);
 #endif
 
-               replace_me(rp, &es);
+               replace_me(rp, es);
 
 #if defined(ENABLE_RT_TIMING)
                RT_TIMING_GET_TIME(time_end);
                RT_TIMING_TIME_DIFF(time_start, time_end, RT_TIMING_REPLACE);
 #endif
 
 
 #if defined(ENABLE_RT_TIMING)
                RT_TIMING_GET_TIME(time_end);
                RT_TIMING_TIME_DIFF(time_start, time_end, RT_TIMING_REPLACE);
 #endif
 
-               /* write execution state to current context */
-
-               md_executionstate_write(&es, context);
-
-               DOLOG( printf("REPLACEMENT WRITE: ");
-                          executionstate_println(&es); );
-
                /* new code is entered after returning */
 
                DOLOG( printf("JUMPING IN!\n"); fflush(stdout); );
                /* new code is entered after returning */
 
                DOLOG( printf("JUMPING IN!\n"); fflush(stdout); );
index 5c520d5ec462c9eb6a8cdbe67886dd4e1c13c0d6..e83134904b8a49ad4f1016bb9ff27913266b9a20 100644 (file)
@@ -59,6 +59,7 @@ typedef union  replace_val_t replace_val_t;
 
 #include "vm/method.hpp"
 
 
 #include "vm/method.hpp"
 
+#include "vm/jit/executionstate.h"
 #include "vm/jit/reg.h"
 #include "vm/jit/stacktrace.hpp"
 
 #include "vm/jit/reg.h"
 #include "vm/jit/stacktrace.hpp"
 
@@ -249,7 +250,7 @@ void replace_free_replacement_points(codeinfo *code);
 void replace_activate_replacement_points(codeinfo *code, bool mappable);
 void replace_deactivate_replacement_points(codeinfo *code);
 
 void replace_activate_replacement_points(codeinfo *code, bool mappable);
 void replace_deactivate_replacement_points(codeinfo *code);
 
-bool replace_me_wrapper(u1 *pc, void *context);
+bool replace_handler(u1 *pc, executionstate_t *es);
 
 #if !defined(NDEBUG)
 void replace_show_replacement_points(codeinfo *code);
 
 #if !defined(NDEBUG)
 void replace_show_replacement_points(codeinfo *code);
index 8520214deaa35f7fa65e15270ae89858ffd78808..57af425e2e00d91c976b989fe80305bdb499e2a8 100644 (file)
@@ -259,7 +259,7 @@ void trap_handle(int sig, void *xpc, void *context)
        case TRAP_PATCHER:
                p = NULL;
 #if defined(ENABLE_REPLACEMENT)
        case TRAP_PATCHER:
                p = NULL;
 #if defined(ENABLE_REPLACEMENT)
-               was_replaced = replace_me_wrapper((uint8_t*) xpc, context);
+               was_replaced = replace_handler((uint8_t*) xpc, &es);
                if (was_replaced)
                        break;
 #endif
                if (was_replaced)
                        break;
 #endif
@@ -275,7 +275,7 @@ void trap_handle(int sig, void *xpc, void *context)
 # warning Port the below stuff to use the patching subsystem.
        case TRAP_COUNTDOWN:
                p = NULL;
 # warning Port the below stuff to use the patching subsystem.
        case TRAP_COUNTDOWN:
                p = NULL;
-               (void) replace_me_wrapper((uint8_t*) xpc - 13, context);
+               (void) replace_handler((uint8_t*) xpc - 13, &es);
                break;
 #endif
 
                break;
 #endif