#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"
#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"
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));
}
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. */
}
-/* 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
}
#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);
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;
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;