* Removed all Id tags.
[cacao.git] / src / vm / jit / replace.c
index 15b9ac78ffb9605c21a1a3837eb0ef75308f91be..03969f4a6125b2fcbb3ce0235002ae29d050b437 100644 (file)
@@ -22,8 +22,6 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id$
-
 */
 
 #include "config.h"
@@ -1026,15 +1024,15 @@ static void replace_write_value(executionstate_t *es,
 }
 
 
-/* replace_read_executionstate *************************************************
+/* replace_new_sourceframe *****************************************************
 
-   Read the given executions state and translate it to a source frame.
+   Allocate a new source frame and insert it at the front of the frame list.
    
    IN:
           ss...............the source state
 
    OUT:
-          ss->frames.......set to new frame
+          ss->frames.......set to new frame (the new head of the frame list).
 
    RETURN VALUE:
        returns the new frame
@@ -1057,15 +1055,20 @@ static sourceframe_t *replace_new_sourceframe(sourcestate_t *ss)
 
 /* replace_read_executionstate *************************************************
 
-   Read the given executions state and translate it to a source frame.
+   Read a source frame from the given executions state.
+   The new source frame is pushed to the front of the frame list of the
+   source state.
 
    IN:
        rp...............replacement point at which `es` was taken
           es...............execution state
-          ss...............where to put the source state
+          ss...............the source state to add the source frame to
+          topframe.........true, if the first (top-most) source frame on the
+                           stack is to be read
 
    OUT:
-       *ss..............the source state derived from the execution state
+       *ss..............the source state with the newly created source frame
+                           added
   
 *******************************************************************************/
 
@@ -1288,13 +1291,16 @@ static void replace_read_executionstate(rplpoint *rp,
 
 /* replace_write_executionstate ************************************************
 
-   Translate the given source state into an execution state.
-   
+   Pop a source frame from the front of the frame list of the given source state
+   and write its values into the execution state.
+
    IN:
        rp...............replacement point for which execution state should be
-                           creates
-          es...............where to put the execution state
+                           created
+          es...............the execution state to modify
           ss...............the given source state
+          topframe.........true, if this is the last (top-most) source frame to be
+                           translated
 
    OUT:
        *es..............the execution state derived from the source state
@@ -1758,15 +1764,15 @@ void replace_patch_future_calls(u1 *ra,
                                                                sourceframe_t *callerframe,
                                                                sourceframe_t *calleeframe)
 {
-       u1                *patchpos;
-       methodptr          entrypoint;
-       methodptr          oldentrypoint;
-       bool               atentry;
-       stackframeinfo     sfi;
-       codeinfo          *calleecode;
-       methodinfo        *calleem;
-       java_objectheader *obj;
-       vftbl_t           *vftbl;
+       u1             *patchpos;
+       methodptr       entrypoint;
+       methodptr       oldentrypoint;
+       bool            atentry;
+       stackframeinfo  sfi;
+       codeinfo       *calleecode;
+       methodinfo     *calleem;
+       java_object_t  *obj;
+       vftbl_t        *vftbl;
 
        assert(ra);
        assert(callerframe->down == calleeframe);
@@ -2728,6 +2734,55 @@ void replace_free_safestack(replace_safestack_t *st, executionstate_t *tmpes)
 }
 
 
+/* replace_me_wrapper **********************************************************
+
+   TODO: Document me!
+
+*******************************************************************************/
+
+bool replace_me_wrapper(u1 *pc)
+{
+       codeinfo         *code;
+       rplpoint         *rp;
+       executionstate_t  es;
+
+       /* search the codeinfo for the given PC */
+
+       code = code_find_codeinfo_for_pc(pc);
+       assert(code);
+
+       /* search for a replacement point at the given PC */
+
+#if 0
+       rp = replace_find_replacement_point_for_pc(code, pc);
+       assert(rp == NULL || rp->pc == pc);
+#else
+       {
+               int i;
+               rplpoint *rp2;
+               rp = NULL;
+               for (i=0,rp2=code->rplpoints; i<code->rplpointcount; i++,rp2++) {
+                       if (rp2->pc == pc)
+                               rp = rp2;
+               }
+       }
+#endif
+
+       /* check if the replacement point is active */
+
+       if (rp != NULL && (rp->flags & RPLPOINT_FLAG_ACTIVE)) {
+
+               /*md_replace_executionstate_read(&es, context);*/
+
+               replace_me(rp, &es);
+
+               return true;
+       }
+       else
+               return false;
+}
+
+
 /* replace_me ******************************************************************
  
    This function is called by asm_replacement_out when a thread reaches
@@ -2808,7 +2863,7 @@ void replace_me(rplpoint *rp, executionstate_t *es)
        /* call the assembler code for the last phase of replacement */
 
 #if (defined(__I386__) || defined(__X86_64__) || defined(__ALPHA__) || defined(__POWERPC__) || defined(__MIPS__) || defined(__S390__)) && defined(ENABLE_JIT)
-       asm_replacement_in(&(safestack->es), safestack);
+       /*asm_replacement_in(&(safestack->es), safestack);*/
 #endif
 
        abort(); /* NOT REACHED */
@@ -3157,8 +3212,8 @@ void replace_executionstate_println(executionstate_t *es)
 #if !defined(NDEBUG)
 static void java_value_print(s4 type, replace_val_t value)
 {
-       java_objectheader *obj;
-       utf               *u;
+       java_object_t *obj;
+       utf           *u;
 
        printf("%016llx",(unsigned long long) value.l);