* changed src/vm/jit/m68k/asmpart.S: Removed unused method
[cacao.git] / src / vm / jit / codegen-common.c
index 043043be68b775c93cc222da6519104f727551e6..f7561c55137b353084d18272bc1e6b9dce8ee69a 100644 (file)
 
 #include "vm/types.h"
 
-#if defined(ENABLE_JIT)
-/* this is required PATCHER_CALL_SIZE */
-# include "codegen.h"
-#endif
-
+#include "codegen.h"
 #include "md-abi.h"
 
 #include "mm/memory.h"
@@ -93,6 +89,7 @@
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.h"
 #include "vm/jit/jit.h"
+#include "vm/jit/linenumbertable.h"
 #include "vm/jit/md.h"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/patcher-common.h"
@@ -212,15 +209,9 @@ void codegen_setup(jitdata *jd)
        cd->datareferences = NULL;
 #endif
 
-/*     cd->patchrefs      = list_create_dump(OFFSET(patchref, linkage)); */
-       cd->patchrefs      = NULL;
        cd->brancheslabel  = list_create_dump(OFFSET(branch_label_ref_t, linkage));
        cd->listcritical   = list_create_dump(OFFSET(critical_section_ref_t, linkage));
-
-       cd->linenumberreferences = NULL;
-       cd->linenumbertablesizepos = 0;
-       cd->linenumbertablestartpos = 0;
-       cd->linenumbertab = 0;
+       cd->linenumbers    = list_create_dump(OFFSET(linenumbertable_list_entry_t, linkage));
 }
 
 
@@ -260,15 +251,9 @@ static void codegen_reset(jitdata *jd)
        cd->datareferences  = NULL;
 #endif
 
-/*     cd->patchrefs       = list_create_dump(OFFSET(patchref, linkage)); */
-       cd->patchrefs       = NULL;
        cd->brancheslabel   = list_create_dump(OFFSET(branch_label_ref_t, linkage));
        cd->listcritical    = list_create_dump(OFFSET(critical_section_ref_t, linkage));
-
-       cd->linenumberreferences    = NULL;
-       cd->linenumbertablesizepos  = 0;
-       cd->linenumbertablestartpos = 0;
-       cd->linenumbertab           = 0;
+       cd->linenumbers     = list_create_dump(OFFSET(linenumbertable_list_entry_t, linkage));
        
        /* We need to clear the mpc and the branch references from all
           basic blocks as they will definitely change. */
@@ -535,51 +520,6 @@ void codegen_branch_label_add(codegendata *cd, s4 label, s4 condition, s4 reg, u
 }
 
 
-/* codegen_add_patch_ref *******************************************************
-
-   Appends a new patcher reference to the list of patching positions.
-
-*******************************************************************************/
-
-void codegen_add_patch_ref(codegendata *cd, functionptr patcher, voidptr ref,
-                                                  s4 disp)
-{
-       patchref *pr;
-       s4        branchmpc;
-
-       branchmpc = cd->mcodeptr - cd->mcodebase;
-
-       pr = DNEW(patchref);
-
-       pr->branchpos = branchmpc;
-       pr->disp      = disp;
-       pr->patcher   = patcher;
-       pr->ref       = ref;
-
-/*     list_add_first(cd->patchrefs, pr); */
-       pr->next      = cd->patchrefs;
-       cd->patchrefs = pr;
-
-       /* Generate NOPs for opt_shownops. */
-
-       if (opt_shownops)
-               PATCHER_NOPS;
-
-#if defined(ENABLE_JIT) && (defined(__I386__) || defined(__M68K__) || defined(__MIPS__) \
- || defined(__SPARC_64__) || defined(__X86_64__))
-
-       /* On some architectures the patcher stub call instruction might
-          be longer than the actual instruction generated.  On this
-          architectures we store the last patcher call position and after
-          the basic block code generation is completed, we check the
-          range and maybe generate some nop's. */
-       /* The nops are generated in codegen_emit in each codegen */
-
-       cd->lastmcodeptr = cd->mcodeptr + PATCHER_CALL_SIZE;
-#endif
-}
-
-
 /* codegen_critical_section_new ************************************************
 
    Allocates a new critical-section reference and adds it to the
@@ -1053,36 +993,20 @@ void codegen_finish(jitdata *jd)
        }
 #endif
 
+       /* Create the exception table. */
+
+       exceptiontable_create(jd);
+
+       /* Create the linenumber table. */
+
+       linenumbertable_create(jd);
+
        /* jump table resolving */
 
        for (jr = cd->jumpreferences; jr != NULL; jr = jr->next)
                *((functionptr *) ((ptrint) epoint + jr->tablepos)) =
                        (functionptr) ((ptrint) epoint + (ptrint) jr->target->mpc);
 
-       /* line number table resolving */
-       {
-               linenumberref *lr;
-               ptrint lrtlen = 0;
-               ptrint target;
-
-               for (lr = cd->linenumberreferences; lr != NULL; lr = lr->next) {
-                       lrtlen++;
-                       target = lr->targetmpc;
-                       /* if the entry contains an mcode pointer (normal case), resolve it */
-                       /* (see doc/inlining_stacktrace.txt for details)                    */
-                       if (lr->linenumber >= -2) {
-                           target += (ptrint) epoint;
-                       }
-                       *((functionptr *) ((ptrint) epoint + (ptrint) lr->tablepos)) = 
-                               (functionptr) target;
-               }
-               
-               *((functionptr *) ((ptrint) epoint + cd->linenumbertablestartpos)) =
-                       (functionptr) ((ptrint) epoint + cd->linenumbertab);
-
-               *((ptrint *) ((ptrint) epoint + cd->linenumbertablesizepos)) = lrtlen;
-       }
-
        /* patcher resolving */
 
        pr = list_first_unsynced(code->patchers);
@@ -1254,18 +1178,11 @@ void codegen_generate_stub_builtin(methodinfo *m, builtintable_entry *bte)
 
        dumpsize = dump_size();
 
-       jd = DNEW(jitdata);
+       /* Create JIT data structure. */
 
-       jd->m     = m;
-       jd->cd    = DNEW(codegendata);
-       jd->rd    = NULL;
-       jd->flags = 0;
-
-       /* Allocate codeinfo memory from the heap as we need to keep them. */
+       jd = jit_jitdata_new(m);
 
-       jd->code  = code_codeinfo_new(m);
-
-       /* get required compiler data */
+       /* Get required compiler data. */
 
        code = jd->code;
 
@@ -1346,18 +1263,11 @@ codeinfo *codegen_generate_stub_native(methodinfo *m, functionptr f)
 
        dumpsize = dump_size();
 
-       jd = DNEW(jitdata);
-
-       jd->m     = m;
-       jd->cd    = DNEW(codegendata);
-       jd->rd    = DNEW(registerdata);
-       jd->flags = 0;
-
-       /* Allocate codeinfo memory from the heap as we need to keep them. */
+       /* Create JIT data structure. */
 
-       jd->code  = code_codeinfo_new(m);
+       jd = jit_jitdata_new(m);
 
-       /* get required compiler data */
+       /* Get required compiler data. */
 
        code = jd->code;