* src/vm/jit/codegen-common.cpp (codegen_start_native_call) [__MIPS__],
[cacao.git] / src / vm / jit / codegen-common.cpp
index d592f8ad6092b61e60cd6600db04989bd36686f0..d6334aeb2216e228b074ba1fa88dab8139e0bab3 100644 (file)
 #include "md.h"
 #include "md-abi.h"
 
-#include "mm/memory.h"
+#include "mm/memory.hpp"
 
 #include "toolbox/avl.h"
-#include "toolbox/list.h"
-#include "toolbox/logging.h"
+#include "toolbox/list.hpp"
+#include "toolbox/logging.hpp"
 
 #include "native/llni.h"
-#include "native/localref.h"
-#include "native/native.h"
+#include "native/localref.hpp"
+#include "native/native.hpp"
 
 #include "threads/thread.hpp"
 
 #include "vm/jit/builtin.hpp"
 #include "vm/exceptions.hpp"
-#include "vm/method.h"
+#include "vm/method.hpp"
 #include "vm/options.h"
 #include "vm/string.hpp"
 
@@ -136,7 +136,13 @@ void codegen_setup(jitdata *jd)
 
        /* initialize members */
 
-       cd->flags        = 0;
+       // Set flags as requested.
+       if (opt_AlwaysEmitLongBranches) {
+               cd->flags = CODEGENDATA_FLAG_LONGBRANCHES;
+       }
+       else {
+               cd->flags = 0;
+       }
 
        cd->mcodebase    = (u1*) DumpMemory::allocate(MCODEINITSIZE);
        cd->mcodeend     = cd->mcodebase + MCODEINITSIZE;
@@ -172,8 +178,8 @@ void codegen_setup(jitdata *jd)
        cd->datareferences = NULL;
 #endif
 
-       cd->brancheslabel  = list_create_dump(OFFSET(branch_label_ref_t, linkage));
-       cd->linenumbers    = list_create_dump(OFFSET(linenumbertable_list_entry_t, linkage));
+       cd->brancheslabel  = new DumpList<branch_label_ref_t*>();
+       cd->linenumbers    = new DumpList<Linenumber>();
 }
 
 
@@ -213,8 +219,8 @@ static void codegen_reset(jitdata *jd)
        cd->datareferences  = NULL;
 #endif
 
-       cd->brancheslabel   = list_create_dump(OFFSET(branch_label_ref_t, linkage));
-       cd->linenumbers     = list_create_dump(OFFSET(linenumbertable_list_entry_t, linkage));
+       cd->brancheslabel   = new DumpList<branch_label_ref_t*>();
+       cd->linenumbers     = new DumpList<Linenumber>();
        
        /* We need to clear the mpc and the branch references from all
           basic blocks as they will definitely change. */
@@ -454,19 +460,10 @@ void codegen_resolve_branchrefs(codegendata *cd, basicblock *bptr)
 
 void codegen_branch_label_add(codegendata *cd, s4 label, s4 condition, s4 reg, u4 options)
 {
-       list_t             *l;
-       branch_label_ref_t *br;
-       s4                  mpc;
-
-       /* Get the label list. */
-
-       l = cd->brancheslabel;
-       
-       /* calculate the current mpc */
-
-       mpc = cd->mcodeptr - cd->mcodebase;
+       // Calculate the current mpc.
+       int32_t mpc = cd->mcodeptr - cd->mcodebase;
 
-       br = (branch_label_ref_t*) DumpMemory::allocate(sizeof(branch_label_ref_t));
+       branch_label_ref_t* br = (branch_label_ref_t*) DumpMemory::allocate(sizeof(branch_label_ref_t));
 
        br->mpc       = mpc;
        br->label     = label;
@@ -474,9 +471,8 @@ void codegen_branch_label_add(codegendata *cd, s4 label, s4 condition, s4 reg, u
        br->reg       = reg;
        br->options   = options;
 
-       /* Add the branch to the list. */
-
-       list_add_last(l, br);
+       // Add the branch to the list.
+       cd->brancheslabel->push_back(br);
 }
 
 
@@ -651,7 +647,7 @@ void codegen_finish(jitdata *jd)
 
        /* Create the linenumber table. */
 
-       linenumbertable_create(jd);
+       code->linenumbertable = new LinenumberTable(jd);
 
        /* jump table resolving */
 
@@ -758,6 +754,12 @@ java_handle_t *codegen_start_native_call(u1 *sp, u1 *pv)
        /* MIPS always uses 8 bytes to store the RA */
        datasp    = sp + framesize - 8;
        javasp    = sp + framesize;
+# if SIZEOF_VOID_P == 8
+       arg_regs  = (uint64_t *) sp;
+# else
+       arg_regs  = (uint64_t *) (sp + 5 * 8);
+# endif
+       arg_stack = (uint64_t *) javasp;
 #elif defined(__S390__)
        datasp    = sp + framesize - 8;
        javasp    = sp + framesize;
@@ -797,7 +799,7 @@ java_handle_t *codegen_start_native_call(u1 *sp, u1 *pv)
 #endif
 
 #if !defined(NDEBUG)
-# if defined(__ALPHA__) || defined(__I386__) || defined(__M68K__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__)
+# if defined(__ALPHA__) || defined(__I386__) || defined(__M68K__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__)
        /* print the call-trace if necesarry */
        /* BEFORE: filling the local reference table */
 
@@ -869,6 +871,11 @@ java_object_t *codegen_finish_native_call(u1 *sp, u1 *pv)
 #elif defined(__MIPS__)
        /* MIPS always uses 8 bytes to store the RA */
        datasp   = sp + framesize - 8;
+# if SIZEOF_VOID_P == 8
+       ret_regs = (uint64_t *) sp;
+# else
+       ret_regs = (uint64_t *) (sp + 1 * 8);
+# endif
 #elif defined(__S390__)
        datasp   = sp + framesize - 8;
        ret_regs = (uint64_t *) (sp + 96);
@@ -922,7 +929,7 @@ java_object_t *codegen_finish_native_call(u1 *sp, u1 *pv)
 #endif
 
 #if !defined(NDEBUG)
-# if defined(__ALPHA__) || defined(__I386__) || defined(__M68K__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__)
+# if defined(__ALPHA__) || defined(__I386__) || defined(__M68K__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__)
        /* print the call-trace if necesarry */
        /* AFTER: unwrapping the return value */