summaryrefslogtreecommitdiff
path: root/compiler/optimizing
diff options
context:
space:
mode:
author Roland Levillain <rpl@google.com> 2016-03-23 16:01:27 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2016-03-23 16:01:27 +0000
commit7ee5bc54fbe1bf5218696e63a80e76cd0c8ea387 (patch)
tree67e35afa2801c31d70719686be53beb121cd17d6 /compiler/optimizing
parentdba2b19c845f6bccb43a036fa8602197c3248ff2 (diff)
parentb133ec6c39b4c953ed815ec731b0270f0d8f0ed9 (diff)
Merge "Ensure object ArraySet with null value does not need a type check."
Diffstat (limited to 'compiler/optimizing')
-rw-r--r--compiler/optimizing/graph_visualizer.cc2
-rw-r--r--compiler/optimizing/prepare_for_register_allocation.cc13
-rw-r--r--compiler/optimizing/prepare_for_register_allocation.h1
3 files changed, 16 insertions, 0 deletions
diff --git a/compiler/optimizing/graph_visualizer.cc b/compiler/optimizing/graph_visualizer.cc
index 4f1e90cd7f..3a9d242df2 100644
--- a/compiler/optimizing/graph_visualizer.cc
+++ b/compiler/optimizing/graph_visualizer.cc
@@ -382,6 +382,8 @@ class HGraphVisualizerPrinter : public HGraphDelegateVisitor {
void VisitArraySet(HArraySet* array_set) OVERRIDE {
StartAttributeStream("value_can_be_null") << std::boolalpha
<< array_set->GetValueCanBeNull() << std::noboolalpha;
+ StartAttributeStream("needs_type_check") << std::boolalpha
+ << array_set->NeedsTypeCheck() << std::noboolalpha;
}
void VisitCompare(HCompare* compare) OVERRIDE {
diff --git a/compiler/optimizing/prepare_for_register_allocation.cc b/compiler/optimizing/prepare_for_register_allocation.cc
index 0ad104eaa7..fc72727196 100644
--- a/compiler/optimizing/prepare_for_register_allocation.cc
+++ b/compiler/optimizing/prepare_for_register_allocation.cc
@@ -47,6 +47,19 @@ void PrepareForRegisterAllocation::VisitBoundType(HBoundType* bound_type) {
bound_type->GetBlock()->RemoveInstruction(bound_type);
}
+void PrepareForRegisterAllocation::VisitArraySet(HArraySet* instruction) {
+ HInstruction* value = instruction->GetValue();
+ // PrepareForRegisterAllocation::VisitBoundType may have replaced a
+ // BoundType (as value input of this ArraySet) with a NullConstant.
+ // If so, this ArraySet no longer needs a type check.
+ if (value->IsNullConstant()) {
+ DCHECK_EQ(value->GetType(), Primitive::kPrimNot);
+ if (instruction->NeedsTypeCheck()) {
+ instruction->ClearNeedsTypeCheck();
+ }
+ }
+}
+
void PrepareForRegisterAllocation::VisitClinitCheck(HClinitCheck* check) {
// Try to find a static invoke or a new-instance from which this check originated.
HInstruction* implicit_clinit = nullptr;
diff --git a/compiler/optimizing/prepare_for_register_allocation.h b/compiler/optimizing/prepare_for_register_allocation.h
index c90724c251..a6791482a7 100644
--- a/compiler/optimizing/prepare_for_register_allocation.h
+++ b/compiler/optimizing/prepare_for_register_allocation.h
@@ -40,6 +40,7 @@ class PrepareForRegisterAllocation : public HGraphDelegateVisitor {
void VisitDivZeroCheck(HDivZeroCheck* check) OVERRIDE;
void VisitBoundsCheck(HBoundsCheck* check) OVERRIDE;
void VisitBoundType(HBoundType* bound_type) OVERRIDE;
+ void VisitArraySet(HArraySet* instruction) OVERRIDE;
void VisitClinitCheck(HClinitCheck* check) OVERRIDE;
void VisitCondition(HCondition* condition) OVERRIDE;
void VisitInvokeStaticOrDirect(HInvokeStaticOrDirect* invoke) OVERRIDE;