diff options
author | 2015-04-30 11:15:40 +0000 | |
---|---|---|
committer | 2015-04-30 11:15:40 +0000 | |
commit | 2af2307f3903a75a379029c049b86f9903fc81a5 (patch) | |
tree | 89168f24337d7ec41648568c48b0dd5fb5194c39 | |
parent | 781733632637db98d79dfffad72bf063be3259be (diff) |
Revert "GVN final fields even with side effects."
This reverts commit 781733632637db98d79dfffad72bf063be3259be.
Change-Id: Id7c4591f6b8190921852044b278d11627457c570
-rw-r--r-- | compiler/optimizing/builder.cc | 19 | ||||
-rw-r--r-- | compiler/optimizing/gvn_test.cc | 24 | ||||
-rw-r--r-- | compiler/optimizing/nodes.h | 8 | ||||
-rw-r--r-- | compiler/optimizing/register_allocator_test.cc | 8 | ||||
-rw-r--r-- | test/483-checker-gvn/expected.txt | 0 | ||||
-rw-r--r-- | test/483-checker-gvn/info.txt | 1 | ||||
-rw-r--r-- | test/483-checker-gvn/src/Main.java | 62 |
7 files changed, 24 insertions, 98 deletions
diff --git a/compiler/optimizing/builder.cc b/compiler/optimizing/builder.cc index c04fe4ec76..0f44af07b8 100644 --- a/compiler/optimizing/builder.cc +++ b/compiler/optimizing/builder.cc @@ -816,7 +816,6 @@ bool HGraphBuilder::BuildInstanceFieldAccess(const Instruction& instruction, current_block_->GetLastInstruction(), field_type, resolved_field->GetOffset(), - resolved_field->IsFinal(), resolved_field->IsVolatile())); UpdateLocal(source_or_dest_reg, current_block_->GetLastInstruction()); @@ -918,19 +917,13 @@ bool HGraphBuilder::BuildStaticFieldAccess(const Instruction& instruction, temps.Add(cls); HInstruction* value = LoadLocal(source_or_dest_reg, field_type); DCHECK_EQ(value->GetType(), field_type); - current_block_->AddInstruction(new (arena_) HStaticFieldSet( - cls, - value, - field_type, - resolved_field->GetOffset(), - resolved_field->IsVolatile())); + current_block_->AddInstruction( + new (arena_) HStaticFieldSet(cls, value, field_type, resolved_field->GetOffset(), + resolved_field->IsVolatile())); } else { - current_block_->AddInstruction(new (arena_) HStaticFieldGet( - cls, - field_type, - resolved_field->GetOffset(), - resolved_field->IsFinal(), - resolved_field->IsVolatile())); + current_block_->AddInstruction( + new (arena_) HStaticFieldGet(cls, field_type, resolved_field->GetOffset(), + resolved_field->IsVolatile())); UpdateLocal(source_or_dest_reg, current_block_->GetLastInstruction()); } return true; diff --git a/compiler/optimizing/gvn_test.cc b/compiler/optimizing/gvn_test.cc index 59854d7460..a81d49aa0c 100644 --- a/compiler/optimizing/gvn_test.cc +++ b/compiler/optimizing/gvn_test.cc @@ -42,21 +42,21 @@ TEST(GVNTest, LocalFieldElimination) { block->AddInstruction( new (&allocator) HInstanceFieldGet(parameter, Primitive::kPrimNot, - MemberOffset(42), false, false)); + MemberOffset(42), false)); block->AddInstruction( new (&allocator) HInstanceFieldGet(parameter, Primitive::kPrimNot, - MemberOffset(42), false, false)); + MemberOffset(42), false)); HInstruction* to_remove = block->GetLastInstruction(); block->AddInstruction( new (&allocator) HInstanceFieldGet(parameter, Primitive::kPrimNot, - MemberOffset(43), false, false)); + MemberOffset(43), false)); HInstruction* different_offset = block->GetLastInstruction(); // Kill the value. block->AddInstruction(new (&allocator) HInstanceFieldSet( parameter, parameter, Primitive::kPrimNot, MemberOffset(42), false)); block->AddInstruction( new (&allocator) HInstanceFieldGet(parameter, Primitive::kPrimNot, - MemberOffset(42), false, false)); + MemberOffset(42), false)); HInstruction* use_after_kill = block->GetLastInstruction(); block->AddInstruction(new (&allocator) HExit()); @@ -90,7 +90,7 @@ TEST(GVNTest, GlobalFieldElimination) { entry->AddSuccessor(block); block->AddInstruction( new (&allocator) HInstanceFieldGet(parameter, Primitive::kPrimBoolean, - MemberOffset(42), false, false)); + MemberOffset(42), false)); block->AddInstruction(new (&allocator) HIf(block->GetLastInstruction())); HBasicBlock* then = new (&allocator) HBasicBlock(graph); @@ -107,15 +107,15 @@ TEST(GVNTest, GlobalFieldElimination) { then->AddInstruction( new (&allocator) HInstanceFieldGet(parameter, Primitive::kPrimBoolean, - MemberOffset(42), false, false)); + MemberOffset(42), false)); then->AddInstruction(new (&allocator) HGoto()); else_->AddInstruction( new (&allocator) HInstanceFieldGet(parameter, Primitive::kPrimBoolean, - MemberOffset(42), false, false)); + MemberOffset(42), false)); else_->AddInstruction(new (&allocator) HGoto()); join->AddInstruction( new (&allocator) HInstanceFieldGet(parameter, Primitive::kPrimBoolean, - MemberOffset(42), false, false)); + MemberOffset(42), false)); join->AddInstruction(new (&allocator) HExit()); graph->TryBuildingSsa(); @@ -146,7 +146,7 @@ TEST(GVNTest, LoopFieldElimination) { entry->AddSuccessor(block); block->AddInstruction( new (&allocator) HInstanceFieldGet(parameter, Primitive::kPrimBoolean, - MemberOffset(42), false, false)); + MemberOffset(42), false)); block->AddInstruction(new (&allocator) HGoto()); HBasicBlock* loop_header = new (&allocator) HBasicBlock(graph); @@ -163,7 +163,7 @@ TEST(GVNTest, LoopFieldElimination) { loop_header->AddInstruction( new (&allocator) HInstanceFieldGet(parameter, Primitive::kPrimBoolean, - MemberOffset(42), false, false)); + MemberOffset(42), false)); HInstruction* field_get_in_loop_header = loop_header->GetLastInstruction(); loop_header->AddInstruction(new (&allocator) HIf(block->GetLastInstruction())); @@ -174,13 +174,13 @@ TEST(GVNTest, LoopFieldElimination) { HInstruction* field_set = loop_body->GetLastInstruction(); loop_body->AddInstruction( new (&allocator) HInstanceFieldGet(parameter, Primitive::kPrimBoolean, - MemberOffset(42), false, false)); + MemberOffset(42), false)); HInstruction* field_get_in_loop_body = loop_body->GetLastInstruction(); loop_body->AddInstruction(new (&allocator) HGoto()); exit->AddInstruction( new (&allocator) HInstanceFieldGet(parameter, Primitive::kPrimBoolean, - MemberOffset(42), false, false)); + MemberOffset(42), false)); HInstruction* field_get_in_exit = exit->GetLastInstruction(); exit->AddInstruction(new (&allocator) HExit()); diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h index 51c68e93ca..3fe23e1816 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -2993,10 +2993,8 @@ class HInstanceFieldGet : public HExpression<1> { HInstanceFieldGet(HInstruction* value, Primitive::Type field_type, MemberOffset field_offset, - bool is_final, bool is_volatile) - : HExpression(field_type, - is_final ? SideEffects::None() : SideEffects::DependsOnSomething()), + : HExpression(field_type, SideEffects::DependsOnSomething()), field_info_(field_offset, field_type, is_volatile) { SetRawInputAt(0, value); } @@ -3406,10 +3404,8 @@ class HStaticFieldGet : public HExpression<1> { HStaticFieldGet(HInstruction* cls, Primitive::Type field_type, MemberOffset field_offset, - bool is_final, bool is_volatile) - : HExpression(field_type, - is_final ? SideEffects::None() : SideEffects::DependsOnSomething()), + : HExpression(field_type, SideEffects::DependsOnSomething()), field_info_(field_offset, field_type, is_volatile) { SetRawInputAt(0, cls); } diff --git a/compiler/optimizing/register_allocator_test.cc b/compiler/optimizing/register_allocator_test.cc index 61afb99bf6..8c6d904a4c 100644 --- a/compiler/optimizing/register_allocator_test.cc +++ b/compiler/optimizing/register_allocator_test.cc @@ -475,7 +475,7 @@ static HGraph* BuildIfElseWithPhi(ArenaAllocator* allocator, entry->AddSuccessor(block); HInstruction* test = new (allocator) HInstanceFieldGet( - parameter, Primitive::kPrimBoolean, MemberOffset(22), false, false); + parameter, Primitive::kPrimBoolean, MemberOffset(22), false); block->AddInstruction(test); block->AddInstruction(new (allocator) HIf(test)); HBasicBlock* then = new (allocator) HBasicBlock(graph); @@ -495,9 +495,9 @@ static HGraph* BuildIfElseWithPhi(ArenaAllocator* allocator, *phi = new (allocator) HPhi(allocator, 0, 0, Primitive::kPrimInt); join->AddPhi(*phi); *input1 = new (allocator) HInstanceFieldGet(parameter, Primitive::kPrimInt, - MemberOffset(42), false, false); + MemberOffset(42), false); *input2 = new (allocator) HInstanceFieldGet(parameter, Primitive::kPrimInt, - MemberOffset(42), false, false); + MemberOffset(42), false); then->AddInstruction(*input1); else_->AddInstruction(*input2); join->AddInstruction(new (allocator) HExit()); @@ -605,7 +605,7 @@ static HGraph* BuildFieldReturn(ArenaAllocator* allocator, entry->AddSuccessor(block); *field = new (allocator) HInstanceFieldGet(parameter, Primitive::kPrimInt, - MemberOffset(42), false, false); + MemberOffset(42), false); block->AddInstruction(*field); *ret = new (allocator) HReturn(*field); block->AddInstruction(*ret); diff --git a/test/483-checker-gvn/expected.txt b/test/483-checker-gvn/expected.txt deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/483-checker-gvn/expected.txt +++ /dev/null diff --git a/test/483-checker-gvn/info.txt b/test/483-checker-gvn/info.txt deleted file mode 100644 index 3ff7a8c676..0000000000 --- a/test/483-checker-gvn/info.txt +++ /dev/null @@ -1 +0,0 @@ -Tests that final fields can be GVNed even with side effects. diff --git a/test/483-checker-gvn/src/Main.java b/test/483-checker-gvn/src/Main.java deleted file mode 100644 index ed474aaebb..0000000000 --- a/test/483-checker-gvn/src/Main.java +++ /dev/null @@ -1,62 +0,0 @@ -/* -* Copyright (C) 2015 The Android Open Source Project -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -public class Main { - - public static final int staticField; - public final int instanceField; - - Main() { - instanceField = 42; - } - - static { - staticField = 42; - } - - // CHECK-START: int Main.addStatic() GVN (before) - // CHECK-DAG: StaticFieldGet - // CHECK-DAG: StaticFieldGet - - // CHECK-START: int Main.addStatic() GVN (after) - // CHECK-DAG: StaticFieldGet - // CHECK-NOT: StaticFieldGet - public static int addStatic() { - return staticField + doACall() + staticField; - } - - // CHECK-START: int Main.addInstance() GVN (before) - // CHECK-DAG: InstanceFieldGet - // CHECK-DAG: InstanceFieldGet - - // CHECK-START: int Main.addInstance() GVN (after) - // CHECK-DAG: InstanceFieldGet - // CHECK-NOT: InstanceFieldGet - public int addInstance() { - return instanceField + doACall() + instanceField; - } - - public static int doACall() { - try { - // Defeat inlining. - Thread.sleep(0); - } catch (Throwable t ) {} - return (int) System.currentTimeMillis(); - } - - public static void main(String[] args) { - } -} |