diff options
Diffstat (limited to 'src/compiler/codegen')
| -rw-r--r-- | src/compiler/codegen/GenCommon.cc | 30 | ||||
| -rw-r--r-- | src/compiler/codegen/MethodCodegenDriver.cc | 5 |
2 files changed, 33 insertions, 2 deletions
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 diff --git a/src/compiler/codegen/MethodCodegenDriver.cc b/src/compiler/codegen/MethodCodegenDriver.cc index fb9bdc9227..5ffe3e44c2 100644 --- a/src/compiler/codegen/MethodCodegenDriver.cc +++ b/src/compiler/codegen/MethodCodegenDriver.cc @@ -364,9 +364,10 @@ bool compileDalvikInstruction(CompilationUnit* cUnit, MIR* mir, case Instruction::GOTO_16: case Instruction::GOTO_32: if (bb->taken->startOffset <= mir->offset) { - genSuspendTest(cUnit, mir); + genSuspendTestAndBranch(cUnit, mir, &labelList[bb->taken->id]); + } else { + opUnconditionalBranch(cUnit, &labelList[bb->taken->id]); } - opUnconditionalBranch(cUnit, &labelList[bb->taken->id]); break; case Instruction::PACKED_SWITCH: |