- /* add the branch to the list */
-
- list_add_last_unsynced(list, br);
-}
-
-
-/* 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
- critical-section list.
-
-*******************************************************************************/
-
-#if defined(ENABLE_THREADS)
-void codegen_critical_section_new(codegendata *cd)
-{
- list_t *list;
- critical_section_ref_t *csr;
- s4 mpc;
-
- /* get the critical section list */
-
- list = cd->listcritical;
-
- /* calculate the current mpc */
-
- mpc = cd->mcodeptr - cd->mcodebase;
-
- csr = DNEW(critical_section_ref_t);
-
- /* We only can set restart right now, as start and end are set by
- the following, corresponding functions. */
-
- csr->start = -1;
- csr->end = -1;
- csr->restart = mpc;
-
- /* add the branch to the list */
-
- list_add_last_unsynced(list, csr);
-}
-#endif
-
-
-/* codegen_critical_section_start **********************************************
-
- Set the start-point of the current critical section (which is the
- last element of the list).
-
-*******************************************************************************/
-
-#if defined(ENABLE_THREADS)
-void codegen_critical_section_start(codegendata *cd)
-{
- list_t *list;
- critical_section_ref_t *csr;
- s4 mpc;
-
- /* get the critical section list */
-
- list = cd->listcritical;
-
- /* calculate the current mpc */
-
- mpc = cd->mcodeptr - cd->mcodebase;
-
- /* get the current critical section */
-
- csr = list_last_unsynced(list);
-
- /* set the start point */
-
- assert(csr->start == -1);
-
- csr->start = mpc;
-}
-#endif
-
-
-/* codegen_critical_section_end ************************************************
-
- Set the end-point of the current critical section (which is the
- last element of the list).
-
-*******************************************************************************/
-
-#if defined(ENABLE_THREADS)
-void codegen_critical_section_end(codegendata *cd)
-{
- list_t *list;
- critical_section_ref_t *csr;
- s4 mpc;
-
- /* get the critical section list */
-
- list = cd->listcritical;
-
- /* calculate the current mpc */
-
- mpc = cd->mcodeptr - cd->mcodebase;
-
- /* get the current critical section */
-
- csr = list_last_unsynced(list);
-
- /* set the end point */
-
- assert(csr->end == -1);
-
- csr->end = mpc;
-}
-#endif
-
-
-/* codegen_critical_section_finish *********************************************
-
- Finish the critical sections, create the critical section nodes for
- the AVL tree and insert them into the tree.
-
-*******************************************************************************/
-
-#if defined(ENABLE_THREADS)
-static void codegen_critical_section_finish(jitdata *jd)
-{
- codeinfo *code;
- codegendata *cd;
- list_t *list;
- critical_section_ref_t *csr;
- critical_section_node_t *csn;
-
- /* get required compiler data */
-
- code = jd->code;
- cd = jd->cd;
-
- /* get the critical section list */
-
- list = cd->listcritical;
-
- /* iterate over all critical sections */
-
- for (csr = list_first_unsynced(list); csr != NULL;
- csr = list_next_unsynced(list, csr)) {
- /* check if all points are set */
-
- assert(csr->start != -1);
- assert(csr->end != -1);
- assert(csr->restart != -1);
-
- /* allocate tree node */