summaryrefslogtreecommitdiff
path: root/src/compiler/codegen/GenCommon.cc
diff options
context:
space:
mode:
author buzbee <buzbee@google.com> 2012-03-30 14:02:01 -0700
committer buzbee <buzbee@google.com> 2012-03-30 14:02:01 -0700
commitfead293106bf15bd97c126b81479cb06668de9c8 (patch)
treebddc8ea3a26eafe7e5421eaafeb56904ee150f69 /src/compiler/codegen/GenCommon.cc
parentba7a3ecc0c7342a19951f076474c41d43168f68e (diff)
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
Diffstat (limited to 'src/compiler/codegen/GenCommon.cc')
-rw-r--r--src/compiler/codegen/GenCommon.cc30
1 files changed, 30 insertions, 0 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