ART: Remove unneeded SideEffects for fatal instructions.
Remove "CanTriggerGC" side effect for NullCheck, BoundsCheck and
DivZeroCheck - instructions which have fatal slow paths. Even though
GC might happen after going through those instructions' slow path
execution doesn't return to the next instruction after the
exceptional one so side effects can be relaxed.
Performance improvement (angler, arm64, little core):
- Geomean: 2.8%
- Particular benchmarks
- algorithm/Sort.SystemSort: 13.0%
- stanford/IntMM: 12.7%
- stanford/Puzzle: 9.5%
- benchmarksgame/revcomp: 8.9%
- reversigame/Reversi: 3.5%
Test: 510-checker-try-catch.
Test: 706-checker-scheduler.
Test: 527-checker-array-access-split.
Test: test-art-host, test-art-target.
Change-Id: I55ac011822e5dbac82c828a700213dbea87329c8
diff --git a/compiler/optimizing/code_generator.cc b/compiler/optimizing/code_generator.cc
index a13efca..095b273 100644
--- a/compiler/optimizing/code_generator.cc
+++ b/compiler/optimizing/code_generator.cc
@@ -1514,7 +1514,12 @@
<< " instruction->GetSideEffects().ToString()="
<< instruction->GetSideEffects().ToString();
} else {
- DCHECK(instruction->GetSideEffects().Includes(SideEffects::CanTriggerGC()) ||
+ // 'CanTriggerGC' side effect is used to restrict optimization of instructions which depend
+ // on GC (e.g. IntermediateAddress) - to ensure they are not alive across GC points. However
+ // if execution never returns to the compiled code from a GC point this restriction is
+ // unnecessary - in particular for fatal slow paths which might trigger GC.
+ DCHECK((slow_path->IsFatal() && !instruction->GetLocations()->WillCall()) ||
+ instruction->GetSideEffects().Includes(SideEffects::CanTriggerGC()) ||
// When (non-Baker) read barriers are enabled, some instructions
// use a slow path to emit a read barrier, which does not trigger
// GC.