-
-/* emit_patcher_stubs **********************************************************
-
- Generates the code for the patcher stubs.
-
-*******************************************************************************/
-void emit_patcher_stubs(jitdata *jd)
-{
- codegendata *cd;
- patchref *pref;
- u8 mcode;
- u1 *savedmcodeptr;
- u1 *tmpmcodeptr;
- s4 targetdisp;
- s4 disp;
-
- /* get required compiler data */
-
- cd = jd->cd;
-
- /* generate code patching stub call code */
-
- targetdisp = 0;
-
- for (pref = cd->patchrefs; pref != NULL; pref = pref->next) {
- /* check code segment size */
-
- MCODECHECK(512);
-
- /* Get machine code which is patched back in later. A
- `bsr.l' is 6 bytes long. */
-
- savedmcodeptr = cd->mcodebase + pref->branchpos;
- mcode = *((u8 *) savedmcodeptr);
-
- /* patch in `bsr.l' to call the following code */
-
- tmpmcodeptr = cd->mcodeptr; /* save current mcodeptr */
- cd->mcodeptr = savedmcodeptr; /* set mcodeptr to patch position */
-
- M_BSR_IMM(tmpmcodeptr - (savedmcodeptr + PATCHER_CALL_SIZE) + 4);
-
- cd->mcodeptr = tmpmcodeptr; /* restore the current mcodeptr */
-
- /* save REG_ITMP3 */
- M_IPUSH(REG_ITMP3); /* FIXME why, and restore where ? */
-
- /* move pointer to java_objectheader onto stack */
-
-#if defined(ENABLE_THREADS)
- (void) dseg_add_unique_address(cd, NULL); /* flcword */
- (void) dseg_add_unique_address(cd, lock_get_initial_lock_word());
- disp = dseg_add_unique_address(cd, NULL); /* vftbl */
-
- assert(0); /* The next lines are wrong */
- M_MOV_IMM(0, REG_ITMP3);
- dseg_adddata(cd);
- M_AADD_IMM(REG_ITMP3, disp);
- M_IPUSH(REG_ITMP3);
-#else
- M_IPUSH_IMM(0);
-#endif
-
- /* push move machine code bytes and classinfo pointer */
-
- M_IPUSH_IMM(mcode >> 32);
- M_IPUSH_IMM(mcode);
- M_IPUSH_IMM(pref->ref);
- M_IPUSH_IMM(pref->patcher);
-
- M_JMP_IMM(asm_patcher_wrapper);
- }
-}