diff options
author | Vladimir Marko <vmarko@google.com> | 2017-09-21 22:50:39 +0100 |
---|---|---|
committer | Vladimir Marko <vmarko@google.com> | 2017-09-25 15:45:01 +0100 |
commit | 0ebe0d83138bba1996e9c8007969b5381d972b32 (patch) | |
tree | a5ee66ebc5b587ade97e56ac8fc7d832fbbed4af /compiler/optimizing/load_store_analysis_test.cc | |
parent | e1e347dace0ded83774999bb26c37527dcdb1d5a (diff) |
ART: Introduce compiler data type.
Replace most uses of the runtime's Primitive in compiler
with a new class DataType. This prepares for introducing
new types, such as Uint8, that the runtime does not need
to know about.
Test: m test-art-host-gtest
Test: testrunner.py --host
Bug: 23964345
Change-Id: Iec2ad82454eec678fffcd8279a9746b90feb9b0c
Diffstat (limited to 'compiler/optimizing/load_store_analysis_test.cc')
-rw-r--r-- | compiler/optimizing/load_store_analysis_test.cc | 98 |
1 files changed, 54 insertions, 44 deletions
diff --git a/compiler/optimizing/load_store_analysis_test.cc b/compiler/optimizing/load_store_analysis_test.cc index 81344b52f6..0df2f27e82 100644 --- a/compiler/optimizing/load_store_analysis_test.cc +++ b/compiler/optimizing/load_store_analysis_test.cc @@ -49,16 +49,17 @@ TEST_F(LoadStoreAnalysisTest, ArrayHeapLocations) { // array_set1 ArraySet [array, c1, c3] // array_set2 ArraySet [array, index, c3] HInstruction* array = new (&allocator_) HParameterValue( - graph_->GetDexFile(), dex::TypeIndex(0), 0, Primitive::kPrimNot); + graph_->GetDexFile(), dex::TypeIndex(0), 0, DataType::Type::kReference); HInstruction* index = new (&allocator_) HParameterValue( - graph_->GetDexFile(), dex::TypeIndex(1), 1, Primitive::kPrimInt); + graph_->GetDexFile(), dex::TypeIndex(1), 1, DataType::Type::kInt32); HInstruction* c1 = graph_->GetIntConstant(1); HInstruction* c2 = graph_->GetIntConstant(2); HInstruction* c3 = graph_->GetIntConstant(3); - HInstruction* array_get1 = new (&allocator_) HArrayGet(array, c1, Primitive::kPrimInt, 0); - HInstruction* array_get2 = new (&allocator_) HArrayGet(array, c2, Primitive::kPrimInt, 0); - HInstruction* array_set1 = new (&allocator_) HArraySet(array, c1, c3, Primitive::kPrimInt, 0); - HInstruction* array_set2 = new (&allocator_) HArraySet(array, index, c3, Primitive::kPrimInt, 0); + HInstruction* array_get1 = new (&allocator_) HArrayGet(array, c1, DataType::Type::kInt32, 0); + HInstruction* array_get2 = new (&allocator_) HArrayGet(array, c2, DataType::Type::kInt32, 0); + HInstruction* array_set1 = new (&allocator_) HArraySet(array, c1, c3, DataType::Type::kInt32, 0); + HInstruction* array_set2 = + new (&allocator_) HArraySet(array, index, c3, DataType::Type::kInt32, 0); entry->AddInstruction(array); entry->AddInstruction(index); entry->AddInstruction(array_get1); @@ -121,11 +122,11 @@ TEST_F(LoadStoreAnalysisTest, FieldHeapLocations) { HInstruction* object = new (&allocator_) HParameterValue(graph_->GetDexFile(), dex::TypeIndex(0), 0, - Primitive::kPrimNot); + DataType::Type::kReference); HInstanceFieldSet* set_field10 = new (&allocator_) HInstanceFieldSet(object, c1, nullptr, - Primitive::kPrimInt, + DataType::Type::kInt32, MemberOffset(10), false, kUnknownFieldIndex, @@ -134,7 +135,7 @@ TEST_F(LoadStoreAnalysisTest, FieldHeapLocations) { 0); HInstanceFieldGet* get_field10 = new (&allocator_) HInstanceFieldGet(object, nullptr, - Primitive::kPrimInt, + DataType::Type::kInt32, MemberOffset(10), false, kUnknownFieldIndex, @@ -143,7 +144,7 @@ TEST_F(LoadStoreAnalysisTest, FieldHeapLocations) { 0); HInstanceFieldGet* get_field20 = new (&allocator_) HInstanceFieldGet(object, nullptr, - Primitive::kPrimInt, + DataType::Type::kInt32, MemberOffset(20), false, kUnknownFieldIndex, @@ -191,26 +192,28 @@ TEST_F(LoadStoreAnalysisTest, ArrayIndexAliasingTest) { graph_->BuildDominatorTree(); HInstruction* array = new (&allocator_) HParameterValue( - graph_->GetDexFile(), dex::TypeIndex(0), 0, Primitive::kPrimNot); + graph_->GetDexFile(), dex::TypeIndex(0), 0, DataType::Type::kReference); HInstruction* index = new (&allocator_) HParameterValue( - graph_->GetDexFile(), dex::TypeIndex(1), 1, Primitive::kPrimInt); + graph_->GetDexFile(), dex::TypeIndex(1), 1, DataType::Type::kInt32); HInstruction* c0 = graph_->GetIntConstant(0); HInstruction* c1 = graph_->GetIntConstant(1); HInstruction* c_neg1 = graph_->GetIntConstant(-1); - HInstruction* add0 = new (&allocator_) HAdd(Primitive::kPrimInt, index, c0); - HInstruction* add1 = new (&allocator_) HAdd(Primitive::kPrimInt, index, c1); - HInstruction* sub0 = new (&allocator_) HSub(Primitive::kPrimInt, index, c0); - HInstruction* sub1 = new (&allocator_) HSub(Primitive::kPrimInt, index, c1); - HInstruction* sub_neg1 = new (&allocator_) HSub(Primitive::kPrimInt, index, c_neg1); - HInstruction* rev_sub1 = new (&allocator_) HSub(Primitive::kPrimInt, c1, index); - HInstruction* arr_set1 = new (&allocator_) HArraySet(array, c0, c0, Primitive::kPrimInt, 0); - HInstruction* arr_set2 = new (&allocator_) HArraySet(array, c1, c0, Primitive::kPrimInt, 0); - HInstruction* arr_set3 = new (&allocator_) HArraySet(array, add0, c0, Primitive::kPrimInt, 0); - HInstruction* arr_set4 = new (&allocator_) HArraySet(array, add1, c0, Primitive::kPrimInt, 0); - HInstruction* arr_set5 = new (&allocator_) HArraySet(array, sub0, c0, Primitive::kPrimInt, 0); - HInstruction* arr_set6 = new (&allocator_) HArraySet(array, sub1, c0, Primitive::kPrimInt, 0); - HInstruction* arr_set7 = new (&allocator_) HArraySet(array, rev_sub1, c0, Primitive::kPrimInt, 0); - HInstruction* arr_set8 = new (&allocator_) HArraySet(array, sub_neg1, c0, Primitive::kPrimInt, 0); + HInstruction* add0 = new (&allocator_) HAdd(DataType::Type::kInt32, index, c0); + HInstruction* add1 = new (&allocator_) HAdd(DataType::Type::kInt32, index, c1); + HInstruction* sub0 = new (&allocator_) HSub(DataType::Type::kInt32, index, c0); + HInstruction* sub1 = new (&allocator_) HSub(DataType::Type::kInt32, index, c1); + HInstruction* sub_neg1 = new (&allocator_) HSub(DataType::Type::kInt32, index, c_neg1); + HInstruction* rev_sub1 = new (&allocator_) HSub(DataType::Type::kInt32, c1, index); + HInstruction* arr_set1 = new (&allocator_) HArraySet(array, c0, c0, DataType::Type::kInt32, 0); + HInstruction* arr_set2 = new (&allocator_) HArraySet(array, c1, c0, DataType::Type::kInt32, 0); + HInstruction* arr_set3 = new (&allocator_) HArraySet(array, add0, c0, DataType::Type::kInt32, 0); + HInstruction* arr_set4 = new (&allocator_) HArraySet(array, add1, c0, DataType::Type::kInt32, 0); + HInstruction* arr_set5 = new (&allocator_) HArraySet(array, sub0, c0, DataType::Type::kInt32, 0); + HInstruction* arr_set6 = new (&allocator_) HArraySet(array, sub1, c0, DataType::Type::kInt32, 0); + HInstruction* arr_set7 = + new (&allocator_) HArraySet(array, rev_sub1, c0, DataType::Type::kInt32, 0); + HInstruction* arr_set8 = + new (&allocator_) HArraySet(array, sub_neg1, c0, DataType::Type::kInt32, 0); entry->AddInstruction(array); entry->AddInstruction(index); @@ -275,9 +278,9 @@ TEST_F(LoadStoreAnalysisTest, ArrayIndexCalculationOverflowTest) { graph_->BuildDominatorTree(); HInstruction* array = new (&allocator_) HParameterValue( - graph_->GetDexFile(), dex::TypeIndex(0), 0, Primitive::kPrimNot); + graph_->GetDexFile(), dex::TypeIndex(0), 0, DataType::Type::kReference); HInstruction* index = new (&allocator_) HParameterValue( - graph_->GetDexFile(), dex::TypeIndex(1), 1, Primitive::kPrimInt); + graph_->GetDexFile(), dex::TypeIndex(1), 1, DataType::Type::kInt32); HInstruction* c0 = graph_->GetIntConstant(0); HInstruction* c_0x80000000 = graph_->GetIntConstant(0x80000000); @@ -287,34 +290,41 @@ TEST_F(LoadStoreAnalysisTest, ArrayIndexCalculationOverflowTest) { HInstruction* c_0x80000001 = graph_->GetIntConstant(0x80000001); // `index+0x80000000` and `index-0x80000000` array indices MAY alias. - HInstruction* add_0x80000000 = new (&allocator_) HAdd(Primitive::kPrimInt, index, c_0x80000000); - HInstruction* sub_0x80000000 = new (&allocator_) HSub(Primitive::kPrimInt, index, c_0x80000000); + HInstruction* add_0x80000000 = new (&allocator_) HAdd( + DataType::Type::kInt32, index, c_0x80000000); + HInstruction* sub_0x80000000 = new (&allocator_) HSub( + DataType::Type::kInt32, index, c_0x80000000); HInstruction* arr_set_1 = new (&allocator_) HArraySet( - array, add_0x80000000, c0, Primitive::kPrimInt, 0); + array, add_0x80000000, c0, DataType::Type::kInt32, 0); HInstruction* arr_set_2 = new (&allocator_) HArraySet( - array, sub_0x80000000, c0, Primitive::kPrimInt, 0); + array, sub_0x80000000, c0, DataType::Type::kInt32, 0); // `index+0x10` and `index-0xFFFFFFF0` array indices MAY alias. - HInstruction* add_0x10 = new (&allocator_) HAdd(Primitive::kPrimInt, index, c_0x10); - HInstruction* sub_0xFFFFFFF0 = new (&allocator_) HSub(Primitive::kPrimInt, index, c_0xFFFFFFF0); + HInstruction* add_0x10 = new (&allocator_) HAdd(DataType::Type::kInt32, index, c_0x10); + HInstruction* sub_0xFFFFFFF0 = new (&allocator_) HSub( + DataType::Type::kInt32, index, c_0xFFFFFFF0); HInstruction* arr_set_3 = new (&allocator_) HArraySet( - array, add_0x10, c0, Primitive::kPrimInt, 0); + array, add_0x10, c0, DataType::Type::kInt32, 0); HInstruction* arr_set_4 = new (&allocator_) HArraySet( - array, sub_0xFFFFFFF0, c0, Primitive::kPrimInt, 0); + array, sub_0xFFFFFFF0, c0, DataType::Type::kInt32, 0); // `index+0x7FFFFFFF` and `index-0x80000001` array indices MAY alias. - HInstruction* add_0x7FFFFFFF = new (&allocator_) HAdd(Primitive::kPrimInt, index, c_0x7FFFFFFF); - HInstruction* sub_0x80000001 = new (&allocator_) HSub(Primitive::kPrimInt, index, c_0x80000001); + HInstruction* add_0x7FFFFFFF = new (&allocator_) HAdd( + DataType::Type::kInt32, index, c_0x7FFFFFFF); + HInstruction* sub_0x80000001 = new (&allocator_) HSub( + DataType::Type::kInt32, index, c_0x80000001); HInstruction* arr_set_5 = new (&allocator_) HArraySet( - array, add_0x7FFFFFFF, c0, Primitive::kPrimInt, 0); + array, add_0x7FFFFFFF, c0, DataType::Type::kInt32, 0); HInstruction* arr_set_6 = new (&allocator_) HArraySet( - array, sub_0x80000001, c0, Primitive::kPrimInt, 0); + array, sub_0x80000001, c0, DataType::Type::kInt32, 0); // `index+0` and `index-0` array indices MAY alias. - HInstruction* add_0 = new (&allocator_) HAdd(Primitive::kPrimInt, index, c0); - HInstruction* sub_0 = new (&allocator_) HSub(Primitive::kPrimInt, index, c0); - HInstruction* arr_set_7 = new (&allocator_) HArraySet(array, add_0, c0, Primitive::kPrimInt, 0); - HInstruction* arr_set_8 = new (&allocator_) HArraySet(array, sub_0, c0, Primitive::kPrimInt, 0); + HInstruction* add_0 = new (&allocator_) HAdd(DataType::Type::kInt32, index, c0); + HInstruction* sub_0 = new (&allocator_) HSub(DataType::Type::kInt32, index, c0); + HInstruction* arr_set_7 = new (&allocator_) HArraySet( + array, add_0, c0, DataType::Type::kInt32, 0); + HInstruction* arr_set_8 = new (&allocator_) HArraySet( + array, sub_0, c0, DataType::Type::kInt32, 0); entry->AddInstruction(array); entry->AddInstruction(index); |