summaryrefslogtreecommitdiff
path: root/compiler/optimizing/ssa_liveness_analysis.h
diff options
context:
space:
mode:
author Hans Boehm <hboehm@google.com> 2018-12-05 11:11:33 -0800
committer Hans Boehm <hboehm@google.com> 2019-01-28 09:37:57 -0800
commit206348cea8b086a484b8bde37b2e281e5f7db638 (patch)
tree1e83b6484dbd9218ace7c94d266dc90ed7e66505 /compiler/optimizing/ssa_liveness_analysis.h
parent58a268aa3569d8ad4f0e831de578620e1079ed59 (diff)
Selectively allow dead reference elimination
Allow dead reference elimination in methods not containing @ReachabilitySensitive accesses or calls, when the class is marked @DeadReferenceSafe. Add 1339-dead-reference-safe to aggressively check that everything works as intended. Bug: 111453875 Test: art/test/testrunner/testrunner.py --host --64 -t 1339-dead-reference-safe Detect ReachabilitySensitive annotations. Change-Id: I70c20431fdbcfcfd2692b2255d12ad59e37cb669
Diffstat (limited to 'compiler/optimizing/ssa_liveness_analysis.h')
-rw-r--r--compiler/optimizing/ssa_liveness_analysis.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/compiler/optimizing/ssa_liveness_analysis.h b/compiler/optimizing/ssa_liveness_analysis.h
index 92d0b08301..c88390775c 100644
--- a/compiler/optimizing/ssa_liveness_analysis.h
+++ b/compiler/optimizing/ssa_liveness_analysis.h
@@ -1155,10 +1155,11 @@ class LiveInterval : public ArenaObject<kArenaAllocSsaLiveness> {
*
* (a) Non-environment uses of an instruction always make
* the instruction live.
- * (b) Environment uses of an instruction whose type is
- * object (that is, non-primitive), make the instruction live.
- * This is due to having to keep alive objects that have
- * finalizers deleting native objects.
+ * (b) Environment uses of an instruction whose type is object (that is, non-primitive), make the
+ * instruction live, unless the class has an @DeadReferenceSafe annotation.
+ * This avoids unexpected premature reference enqueuing or finalization, which could
+ * result in premature deletion of native objects. In the presence of @DeadReferenceSafe,
+ * object references are treated like primitive types.
* (c) When the graph has the debuggable property, environment uses
* of an instruction that has a primitive type make the instruction live.
* If the graph does not have the debuggable property, the environment
@@ -1287,6 +1288,7 @@ class SsaLivenessAnalysis : public ValueObject {
// When compiling in OSR mode, all loops in the compiled method may be entered
// from the interpreter via SuspendCheck; thus we need to preserve the environment.
if (env_holder->IsSuspendCheck() && graph->IsCompilingOsr()) return true;
+ if (graph -> IsDeadReferenceSafe()) return false;
return instruction->GetType() == DataType::Type::kReference;
}