From 99ec0d88d1335a5222c764842f202d5a07a18e83 Mon Sep 17 00:00:00 2001 From: twisti Date: Thu, 3 May 2007 22:32:11 +0000 Subject: [PATCH] * src/vm/jit/x86_64/codegen.c (codegen_emit): Use CODEGEN_CRITICAL_SECTION_* macros. * src/vm/jit/x86_64/linux/md-os.c (thread_restartcriticalsection): Renamed to md_critical_section_restart. --- src/vm/jit/x86_64/codegen.c | 37 ++++++++++++++------------------- src/vm/jit/x86_64/linux/md-os.c | 22 +++++++++++++++----- 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/src/vm/jit/x86_64/codegen.c b/src/vm/jit/x86_64/codegen.c index cc68156a3..49932d5db 100644 --- a/src/vm/jit/x86_64/codegen.c +++ b/src/vm/jit/x86_64/codegen.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: codegen.c 7813 2007-04-25 19:20:13Z twisti $ + $Id: codegen.c 7866 2007-05-03 22:32:11Z twisti $ */ @@ -2544,9 +2544,9 @@ gen_method: supervftbl = super->vftbl; } -#if defined(ENABLE_THREADS) - codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase); -#endif + if ((super == NULL) || !(super->flags & ACC_INTERFACE)) + CODEGEN_CRITICAL_SECTION_NEW; + s1 = emit_load_s1(jd, iptr, REG_ITMP1); /* if class is not resolved, check which code to call */ @@ -2616,9 +2616,9 @@ gen_method: } M_MOV_IMM(supervftbl, REG_ITMP3); -#if defined(ENABLE_THREADS) - codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase); -#endif + + CODEGEN_CRITICAL_SECTION_START; + M_ILD32(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, baseval)); /* if (s1 != REG_ITMP1) { */ @@ -2640,9 +2640,9 @@ gen_method: M_MOV_IMM(supervftbl, REG_ITMP3); M_ILD(REG_ITMP3, REG_ITMP3, OFFSET(vftbl_t, diffval)); /* } */ -#if defined(ENABLE_THREADS) - codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase); -#endif + + CODEGEN_CRITICAL_SECTION_END; + M_ICMP(REG_ITMP3, REG_ITMP2); emit_classcast_check(cd, iptr, BRANCH_UGT, REG_ITMP3, s1); @@ -2695,16 +2695,15 @@ gen_method: super = NULL; superindex = 0; supervftbl = NULL; - - } else { + } + else { super = iptr->sx.s23.s3.c.cls; superindex = super->index; supervftbl = super->vftbl; } -#if defined(ENABLE_THREADS) - codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase); -#endif + if ((super == NULL) || !(super->flags & ACC_INTERFACE)) + CODEGEN_CRITICAL_SECTION_NEW; s1 = emit_load_s1(jd, iptr, REG_ITMP1); d = codegen_reg_of_dst(jd, iptr, REG_ITMP2); @@ -2784,17 +2783,13 @@ gen_method: M_MOV_IMM(supervftbl, REG_ITMP2); -#if defined(ENABLE_THREADS) - codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase); -#endif + CODEGEN_CRITICAL_SECTION_START; M_ILD(REG_ITMP1, REG_ITMP1, OFFSET(vftbl_t, baseval)); M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, diffval)); M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, baseval)); -#if defined(ENABLE_THREADS) - codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase); -#endif + CODEGEN_CRITICAL_SECTION_END; M_ISUB(REG_ITMP2, REG_ITMP1); M_CLR(d); /* may be REG_ITMP2 */ diff --git a/src/vm/jit/x86_64/linux/md-os.c b/src/vm/jit/x86_64/linux/md-os.c index 9a109c01e..f675dab46 100644 --- a/src/vm/jit/x86_64/linux/md-os.c +++ b/src/vm/jit/x86_64/linux/md-os.c @@ -245,21 +245,33 @@ void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p) #endif +/* md_critical_section_restart ************************************************* + + Search the critical sections tree for a matching section and set + the PC to the restart point, if necessary. + +*******************************************************************************/ + #if defined(ENABLE_THREADS) -void thread_restartcriticalsection(ucontext_t *_uc) +void md_critical_section_restart(ucontext_t *_uc) { mcontext_t *_mc; u1 *pc; - void *critical; + void *npc; _mc = &_uc->uc_mcontext; + /* ATTENTION: Don't use CACAO's internal REG_* defines as they are + different to the ones in . */ + pc = (u1 *) _mc->gregs[REG_RIP]; - critical = critical_find_restart_point(pc); + npc = critical_find_restart_point(pc); - if (critical != NULL) - _mc->gregs[REG_RIP] = (ptrint) critical; + if (npc != NULL) { + log_println("md_critical_section_restart: pc=%p, npc=%p", pc, npc); + _mc->gregs[REG_RIP] = (ptrint) npc; + } } #endif -- 2.25.1