Reduce how often we call FindDexCache
Before host boot.oat -j4 optimizing compile:
real 1m17.792s
user 3m26.140s
sys 0m8.340s
After:
real 1m12.324s
user 3m22.718s
sys 0m8.320s
Change-Id: If18e9e79e06cdf1676692e5efacb682bf93889c3
diff --git a/compiler/optimizing/gvn_test.cc b/compiler/optimizing/gvn_test.cc
index 42ef3ff..32f45b5 100644
--- a/compiler/optimizing/gvn_test.cc
+++ b/compiler/optimizing/gvn_test.cc
@@ -28,6 +28,7 @@
TEST(GVNTest, LocalFieldElimination) {
ArenaPool pool;
ArenaAllocator allocator(&pool);
+ NullHandle<mirror::DexCache> dex_cache;
HGraph* graph = CreateGraph(&allocator);
HBasicBlock* entry = new (&allocator) HBasicBlock(graph);
@@ -45,20 +46,23 @@
MemberOffset(42),
false,
kUnknownFieldIndex,
- graph->GetDexFile()));
+ graph->GetDexFile(),
+ dex_cache));
block->AddInstruction(new (&allocator) HInstanceFieldGet(parameter,
Primitive::kPrimNot,
MemberOffset(42),
false,
kUnknownFieldIndex,
- graph->GetDexFile()));
+ graph->GetDexFile(),
+ dex_cache));
HInstruction* to_remove = block->GetLastInstruction();
block->AddInstruction(new (&allocator) HInstanceFieldGet(parameter,
Primitive::kPrimNot,
MemberOffset(43),
false,
kUnknownFieldIndex,
- graph->GetDexFile()));
+ graph->GetDexFile(),
+ dex_cache));
HInstruction* different_offset = block->GetLastInstruction();
// Kill the value.
block->AddInstruction(new (&allocator) HInstanceFieldSet(parameter,
@@ -67,13 +71,15 @@
MemberOffset(42),
false,
kUnknownFieldIndex,
- graph->GetDexFile()));
+ graph->GetDexFile(),
+ dex_cache));
block->AddInstruction(new (&allocator) HInstanceFieldGet(parameter,
Primitive::kPrimNot,
MemberOffset(42),
false,
kUnknownFieldIndex,
- graph->GetDexFile()));
+ graph->GetDexFile(),
+ dex_cache));
HInstruction* use_after_kill = block->GetLastInstruction();
block->AddInstruction(new (&allocator) HExit());
@@ -94,6 +100,7 @@
TEST(GVNTest, GlobalFieldElimination) {
ArenaPool pool;
ArenaAllocator allocator(&pool);
+ NullHandle<mirror::DexCache> dex_cache;
HGraph* graph = CreateGraph(&allocator);
HBasicBlock* entry = new (&allocator) HBasicBlock(graph);
@@ -110,7 +117,8 @@
MemberOffset(42),
false,
kUnknownFieldIndex,
- graph->GetDexFile()));
+ graph->GetDexFile(),
+ dex_cache));
block->AddInstruction(new (&allocator) HIf(block->GetLastInstruction()));
HBasicBlock* then = new (&allocator) HBasicBlock(graph);
@@ -130,21 +138,24 @@
MemberOffset(42),
false,
kUnknownFieldIndex,
- graph->GetDexFile()));
+ graph->GetDexFile(),
+ dex_cache));
then->AddInstruction(new (&allocator) HGoto());
else_->AddInstruction(new (&allocator) HInstanceFieldGet(parameter,
Primitive::kPrimBoolean,
MemberOffset(42),
false,
kUnknownFieldIndex,
- graph->GetDexFile()));
+ graph->GetDexFile(),
+ dex_cache));
else_->AddInstruction(new (&allocator) HGoto());
join->AddInstruction(new (&allocator) HInstanceFieldGet(parameter,
Primitive::kPrimBoolean,
MemberOffset(42),
false,
kUnknownFieldIndex,
- graph->GetDexFile()));
+ graph->GetDexFile(),
+ dex_cache));
join->AddInstruction(new (&allocator) HExit());
graph->TryBuildingSsa();
@@ -161,6 +172,7 @@
TEST(GVNTest, LoopFieldElimination) {
ArenaPool pool;
ArenaAllocator allocator(&pool);
+ NullHandle<mirror::DexCache> dex_cache;
HGraph* graph = CreateGraph(&allocator);
HBasicBlock* entry = new (&allocator) HBasicBlock(graph);
@@ -178,7 +190,8 @@
MemberOffset(42),
false,
kUnknownFieldIndex,
- graph->GetDexFile()));
+ graph->GetDexFile(),
+ dex_cache));
block->AddInstruction(new (&allocator) HGoto());
HBasicBlock* loop_header = new (&allocator) HBasicBlock(graph);
@@ -198,7 +211,8 @@
MemberOffset(42),
false,
kUnknownFieldIndex,
- graph->GetDexFile()));
+ graph->GetDexFile(),
+ dex_cache));
HInstruction* field_get_in_loop_header = loop_header->GetLastInstruction();
loop_header->AddInstruction(new (&allocator) HIf(block->GetLastInstruction()));
@@ -210,14 +224,16 @@
MemberOffset(42),
false,
kUnknownFieldIndex,
- graph->GetDexFile()));
+ graph->GetDexFile(),
+ dex_cache));
HInstruction* field_set = loop_body->GetLastInstruction();
loop_body->AddInstruction(new (&allocator) HInstanceFieldGet(parameter,
Primitive::kPrimBoolean,
MemberOffset(42),
false,
kUnknownFieldIndex,
- graph->GetDexFile()));
+ graph->GetDexFile(),
+ dex_cache));
HInstruction* field_get_in_loop_body = loop_body->GetLastInstruction();
loop_body->AddInstruction(new (&allocator) HGoto());
@@ -226,7 +242,8 @@
MemberOffset(42),
false,
kUnknownFieldIndex,
- graph->GetDexFile()));
+ graph->GetDexFile(),
+ dex_cache));
HInstruction* field_get_in_exit = exit->GetLastInstruction();
exit->AddInstruction(new (&allocator) HExit());
@@ -265,6 +282,7 @@
TEST(GVNTest, LoopSideEffects) {
ArenaPool pool;
ArenaAllocator allocator(&pool);
+ NullHandle<mirror::DexCache> dex_cache;
static const SideEffects kCanTriggerGC = SideEffects::CanTriggerGC();
@@ -320,7 +338,8 @@
MemberOffset(42),
false,
kUnknownFieldIndex,
- graph->GetDexFile()));
+ graph->GetDexFile(),
+ dex_cache));
SideEffectsAnalysis side_effects(graph);
side_effects.Run();
@@ -342,7 +361,8 @@
MemberOffset(42),
false,
kUnknownFieldIndex,
- graph->GetDexFile()),
+ graph->GetDexFile(),
+ dex_cache),
outer_loop_body->GetLastInstruction());
SideEffectsAnalysis side_effects(graph);
@@ -365,7 +385,8 @@
MemberOffset(42),
false,
kUnknownFieldIndex,
- graph->GetDexFile()),
+ graph->GetDexFile(),
+ dex_cache),
inner_loop_body->GetLastInstruction());
SideEffectsAnalysis side_effects(graph);