summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Calin Juravle <calin@google.com> 2015-06-15 13:50:45 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2015-06-15 13:50:47 +0000
commit2cbeb52ca5a56f54ca2e419cd8a697f46ba8e6ae (patch)
treeb083107401d5c1cfbeafe4ad880e0453543d5bd1
parent6e41d81695531499d34345354006cf4314f4559a (diff)
parent72a5eb5d6784b318750c36e0da25c7338557ce44 (diff)
Merge "Bring ReferenceTypePropagation to ArrayGet"
-rw-r--r--compiler/optimizing/reference_type_propagation.cc14
-rw-r--r--test/450-checker-types/src/Main.java9
2 files changed, 23 insertions, 0 deletions
diff --git a/compiler/optimizing/reference_type_propagation.cc b/compiler/optimizing/reference_type_propagation.cc
index c3db55143b..a048c856c5 100644
--- a/compiler/optimizing/reference_type_propagation.cc
+++ b/compiler/optimizing/reference_type_propagation.cc
@@ -37,6 +37,7 @@ class RTPVisitor : public HGraphDelegateVisitor {
void VisitInstanceFieldGet(HInstanceFieldGet* instr) OVERRIDE;
void VisitStaticFieldGet(HStaticFieldGet* instr) OVERRIDE;
void VisitInvoke(HInvoke* instr) OVERRIDE;
+ void VisitArrayGet(HArrayGet* instr) OVERRIDE;
void UpdateReferenceTypeInfo(HInstruction* instr,
uint16_t type_idx,
const DexFile& dex_file,
@@ -327,6 +328,19 @@ void RTPVisitor::VisitInvoke(HInvoke* instr) {
SetClassAsTypeInfo(instr, klass, /* is_exact */ false);
}
+void RTPVisitor::VisitArrayGet(HArrayGet* instr) {
+ if (instr->GetType() != Primitive::kPrimNot) {
+ return;
+ }
+
+ HInstruction* parent = instr->InputAt(0);
+ ScopedObjectAccess soa(Thread::Current());
+ Handle<mirror::Class> handle = parent->GetReferenceTypeInfo().GetTypeHandle();
+ if (handle.GetReference() != nullptr && handle->IsObjectArrayClass()) {
+ SetClassAsTypeInfo(instr, handle->GetComponentType(), /* is_exact */ false);
+ }
+}
+
void ReferenceTypePropagation::UpdateBoundType(HBoundType* instr) {
ReferenceTypeInfo new_rti = instr->InputAt(0)->GetReferenceTypeInfo();
// Be sure that we don't go over the bounded type.
diff --git a/test/450-checker-types/src/Main.java b/test/450-checker-types/src/Main.java
index 9b447e9206..9070627f1c 100644
--- a/test/450-checker-types/src/Main.java
+++ b/test/450-checker-types/src/Main.java
@@ -385,6 +385,15 @@ public class Main {
Super b = $noinline$getSubclass();
((SubclassA)b).$noinline$g();
}
+ /// CHECK-START: void Main.testArrayGetSimpleRemove() instruction_simplifier_after_types (before)
+ /// CHECK: CheckCast
+
+ /// CHECK-START: void Main.testArrayGetSimpleRemove() instruction_simplifier_after_types (after)
+ /// CHECK-NOT: CheckCast
+ public void testArrayGetSimpleRemove() {
+ Super[] a = new SubclassA[10];
+ ((SubclassA)a[0]).$noinline$g();
+ }
public static void main(String[] args) {
}