summaryrefslogtreecommitdiff
path: root/compiler/optimizing/nodes.h
diff options
context:
space:
mode:
author Stelios Ioannou <stelios.ioannou@linaro.org> 2021-07-09 17:06:03 +0100
committer Treehugger Robot <treehugger-gerrit@google.com> 2022-06-08 14:06:51 +0000
commitc54cc7cb18262fe77ed8da6a56acbf00d5bc5a71 (patch)
tree1567e04711f45ddee7ab65c27a38fa9f7f17f7d5 /compiler/optimizing/nodes.h
parent4ea489a240cf6d241a7b0313c2981bf5f32f7d7f (diff)
Revert^2 "ART: Removes SuspendCheck for plain
loops with a low trip count." This change removes SuspendCheck for plain loops with a low trip count. The SuspendCheck in the codegen makes sure that the thread can be interrupted during execution for GC. Not being able to do so might decrease the responsiveness of GC in the case when a very long loop or a long recursion is being executed. However, for plain loops with a small trip count, the removal of SuspendCheck should not affect the GC's responsiveness by a large margin. Consequently, since the thread won't be interrupted for plain loops, it is assumed that the performance might increase by removing SuspendCheck. Also add explicit checks to existing code to ensure that SuspendCheck is never null when it is used. This reverts commit 8f6b99fba2d043265a84d599a967d52f66738ad6 Reason for revert: Included fix for CHAGuardVisitor::HoistGuard crash by disabling codegen for optimized SuspendCheck nodes instead of removing the SuspendCheck node itself. Test: art/test.py -v -j12 --host --64 -t 2233-checker\ -remove-loop-suspend-check --run-test --optimizing Change-Id: Id6296aded91e1cf49b8f3f339dc83613cbedf876
Diffstat (limited to 'compiler/optimizing/nodes.h')
-rw-r--r--compiler/optimizing/nodes.h25
1 files changed, 23 insertions, 2 deletions
diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h
index 7a0059f616..0767bf5580 100644
--- a/compiler/optimizing/nodes.h
+++ b/compiler/optimizing/nodes.h
@@ -678,6 +678,13 @@ class HGraph : public ArenaObject<kArenaAllocGraph> {
return cha_single_implementation_list_;
}
+ // In case of OSR we intend to use SuspendChecks as an entry point to the
+ // function; for debuggable graphs we might deoptimize to interpreter from
+ // SuspendChecks. In these cases we should always generate code for them.
+ bool SuspendChecksAreAllowedToNoOp() const {
+ return !IsDebuggable() && !IsCompilingOsr();
+ }
+
void AddCHASingleImplementationDependency(ArtMethod* method) {
cha_single_implementation_list_.insert(method);
}
@@ -719,7 +726,7 @@ class HGraph : public ArenaObject<kArenaAllocGraph> {
return ReferenceTypeInfo::Create(handle_cache_.GetObjectClassHandle(), /* is_exact= */ false);
}
- uint32_t GetNumberOfCHAGuards() { return number_of_cha_guards_; }
+ uint32_t GetNumberOfCHAGuards() const { return number_of_cha_guards_; }
void SetNumberOfCHAGuards(uint32_t num) { number_of_cha_guards_ = num; }
void IncrementNumberOfCHAGuards() { number_of_cha_guards_++; }
@@ -6714,9 +6721,10 @@ class HBoundsCheck final : public HExpression<2> {
class HSuspendCheck final : public HExpression<0> {
public:
- explicit HSuspendCheck(uint32_t dex_pc = kNoDexPc)
+ explicit HSuspendCheck(uint32_t dex_pc = kNoDexPc, bool is_no_op = false)
: HExpression(kSuspendCheck, SideEffects::CanTriggerGC(), dex_pc),
slow_path_(nullptr) {
+ SetPackedFlag<kFlagIsNoOp>(is_no_op);
}
bool IsClonable() const override { return true; }
@@ -6725,6 +6733,10 @@ class HSuspendCheck final : public HExpression<0> {
return true;
}
+ void SetIsNoOp(bool is_no_op) { SetPackedFlag<kFlagIsNoOp>(is_no_op); }
+ bool IsNoOp() const { return GetPackedFlag<kFlagIsNoOp>(); }
+
+
void SetSlowPath(SlowPathCode* slow_path) { slow_path_ = slow_path; }
SlowPathCode* GetSlowPath() const { return slow_path_; }
@@ -6733,6 +6745,15 @@ class HSuspendCheck final : public HExpression<0> {
protected:
DEFAULT_COPY_CONSTRUCTOR(SuspendCheck);
+ // True if the HSuspendCheck should not emit any code during codegen. It is
+ // not possible to simply remove this instruction to disable codegen, as
+ // other optimizations (e.g: CHAGuardVisitor::HoistGuard) depend on
+ // HSuspendCheck being present in every loop.
+ static constexpr size_t kFlagIsNoOp = kNumberOfGenericPackedBits;
+ static constexpr size_t kNumberOfSuspendCheckPackedBits = kFlagIsNoOp + 1;
+ static_assert(kNumberOfSuspendCheckPackedBits <= HInstruction::kMaxNumberOfPackedBits,
+ "Too many packed fields.");
+
private:
// Only used for code generation, in order to share the same slow path between back edges
// of a same loop.