* Removed all Id tags.
[cacao.git] / src / vm / jit / arm / md.c
index 80c6b2fd2cc238365f7c225c7bc8ac2a06d0e1d5..5d89dd8a6d85ba3d63b036422fb13cc1824a7d16 100644 (file)
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Michael Starzinger
-            Christian Thalinger
-
-   $Id: md.c 6591 2007-01-02 19:14:25Z twisti $
-
 */
 
 
 
 #include <assert.h>
 
-#include "vm/global.h"
 #include "vm/types.h"
 
 #include "vm/jit/arm/md-abi.h"
 
 #include "vm/exceptions.h"
-#include "vm/stringlocal.h"
+#include "vm/global.h"
+
 #include "vm/jit/asmpart.h"
+#include "vm/jit/md.h"
+
+#include "vm/jit/codegen-common.h" /* REMOVE ME: for codegendata */
 
 
 /* md_init *********************************************************************
@@ -58,34 +54,6 @@ void md_init(void)
 }
 
 
-/* md_codegen_patch_branch *****************************************************
-
-   Back-patches a branch instruction.
-
-*******************************************************************************/
-
-void md_codegen_patch_branch(codegendata *cd, s4 branchmpc, s4 targetmpc)
-{
-       s4 *mcodeptr;
-       s4  disp;                           /* branch displacement                */
-
-       /* calculate the patch position */
-
-       mcodeptr = (s4 *) (cd->mcodebase + branchmpc);
-
-       /* Calculate the branch displacement. */
-
-       disp = (targetmpc - branchmpc - 4) >> 2;
-
-       if ((disp < (s4) 0xff000000) || (disp > (s4) 0x00ffffff))
-               vm_abort("md_codegen_patch_branch: branch displacement out of range: %d > +/-%d", disp, 0x00ffffff);
-
-       /* patch the branch instruction before the mcodeptr */
-
-       mcodeptr[-1] |= (disp & 0x00ffffff);
-}
-
-
 /* md_stacktrace_get_returnaddress *********************************************
 
    Returns the return address of the current stackframe, specified by
@@ -97,14 +65,12 @@ u1 *md_stacktrace_get_returnaddress(u1 *sp, u4 framesize)
 {
        u1 *ra;
 
-       /*printf("md_stacktrace_get_returnaddress(): called (sp=%x, framesize=%d)\n", sp, framesize);*/
+       /* On ARM the return address is located on the top of the
+          stackframe. */
+       /* ATTENTION: This is only true for non-leaf methods!!! */
 
-       /* on ARM the return address is located on the top of the stackframe */
-       /* ATTENTION: this is only true for non-leaf methods !!! */
        ra = *((u1 **) (sp + framesize - SIZEOF_VOID_P));
 
-       /*printf("md_stacktrace_get_returnaddress(): result (ra=%x)\n", ra);*/
-
        return ra;
 }
 
@@ -160,6 +126,11 @@ u1 *md_get_method_patch_address(u1 *ra, stackframeinfo *sfi, u1 *mptr)
 
                assert((mcode & 0x00800000) == 0x00800000);
 
+               /* return NULL if no mptr was specified (used for replacement) */
+
+               if (mptr == NULL)
+                       return NULL;
+
                /* we loaded from REG_METHODPTR */
 
                pa = mptr + offset;
@@ -209,9 +180,7 @@ u1 *md_codegen_get_pv_from_pc(u1 *ra)
                pv -= (s4) (mcode1 & 0x000000ff);
        else {
                /* if this happens, we got an unexpected instruction at (*ra) */
-               throw_cacao_exception_exit(string_java_lang_InternalError,
-                  "Unable to find method: %p (instr=%x)\n",
-                  ra, mcode1);
+               vm_abort("Unable to find method: %p (instr=%x)", ra, mcode1);
        }
 
        /* if we have a RECOMPUTE_IP there can be more than one instruction */