From fead293106bf15bd97c126b81479cb06668de9c8 Mon Sep 17 00:00:00 2001 From: buzbee Date: Fri, 30 Mar 2012 14:02:01 -0700 Subject: Minor suspend check tweak Rearrange the suspend check branch for unconditional backwards branches. Now, the conditional branch on rSUSPEND will go directly to the target in the common case, and fallthrough to an unconditional branch to the suspend launchpad in the uncommon case. Change-Id: Ie1a2b2fe720efde6e131a8d5274b7487fb644881 --- src/compiler/codegen/GenCommon.cc | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/compiler/codegen/GenCommon.cc') diff --git a/src/compiler/codegen/GenCommon.cc b/src/compiler/codegen/GenCommon.cc index 54b8e5f95a..3cc594cc25 100644 --- a/src/compiler/codegen/GenCommon.cc +++ b/src/compiler/codegen/GenCommon.cc @@ -2503,4 +2503,34 @@ void genSuspendTest(CompilationUnit* cUnit, MIR* mir) } } +/* Check if we need to check for pending suspend request */ +void genSuspendTestAndBranch(CompilationUnit* cUnit, MIR* mir, LIR* target) +{ + if (NO_SUSPEND || (mir->optimizationFlags & MIR_IGNORE_SUSPEND_CHECK)) { + opUnconditionalBranch(cUnit, target); + return; + } + if (cUnit->genDebugger) { + genSuspendTest(cUnit, mir); + opUnconditionalBranch(cUnit, target); + } else { +#if defined(TARGET_ARM) + // In non-debug case, only check periodically + newLIR2(cUnit, kThumbSubRI8, rSUSPEND, 1); + opCondBranch(cUnit, kCondNe, target); +#elif defined(TARGET_X86) + newLIR2(cUnit, kX86Cmp32TI, Thread::SuspendCountOffset().Int32Value(), 0); + opCondBranch(cUnit, kCondEq, target); +#else + opRegImm(cUnit, kOpSub, rSUSPEND, 1); + opCmpImmBranch(cUnit, kCondNe, rSUSPEND, 0, target); +#endif + LIR* launchPad = rawLIR(cUnit, cUnit->currentDalvikOffset, + kPseudoSuspendTarget, (intptr_t)target, mir->offset); + oatFlushAllRegs(cUnit); + opUnconditionalBranch(cUnit, launchPad); + oatInsertGrowableList(cUnit, &cUnit->suspendLaunchpads, (intptr_t)launchPad); + } +} + } // namespace art -- cgit v1.2.3-59-g8ed1b