I would like to know what are the loop optimizations performed by Oracle Java 7 (or 8) Hotspot VM?
Loop optimizations Oracle Java 7-8 Hotspot VM
Asked Answered
The compiler writers possibly could ... but I doubt that they would. Anyway, if you really need to know you can always download the OpenJDK source tree and figure it out for yourself. –
Longevous
The main ones will probably be deadcode elimination, loop unrolling and variable hoisting. –
Ethylene
@ The close voters: In how far is this asking for an off-site resource? Look at the current answer. (Of course, it has lots of links in it, but these are only pointers to a durable resource (namely, the OpenJDK source), and intended for further research). –
Sair
@ The close voters: I have edited my question 2 days a go. Can you check this please? Thanks –
Sang
- Range Check Elimination - eliminates range checks for loop-invariant arrays. See PhaseIdealLoop::do_range_check for details. The optimization is controlled by the flag
-XX:+RangeCheckElimination
- Loop Peeling - splits first iteration from the loop and performs it outside of the loop body. See amazing description here PhaseIdealLoop::do_peeling. This optimization is controlled by the flag
-XX:PartialPeelLoop=true
- Loop Predication - eliminates the condition checks from inside the loop body. Currently, loop predication optimization has been applied to remove array range check and loop invariant checks (such as null checks and array checks). Loop predication is controlled by the
-XX:+UseLoopPredicate
. See code PhaseIdealLoop::loop_predication_impl - Loop Unrolling - is used as first step of Superword Level Parallelism. See PhaseIdealLoop::do_unroll. Loop unrolling is controlled by the following properties:
-XX:LoopMaxUnroll=16
and-XX:LoopUnrollMin=4
- Array Filling - replaces any fill patterns with an intrisc. See PhaseIdealLoop::do_intrinsify_fill. JVM option
-XX:+OptimizeFill
- Vectorization - replaces array initialization, copy and arithmetic with vector operations in unrolled loops. The Hotspot compiler implements the concept of Superword Level Parallelism in superword.cpp. See also JVM option
-XX:+UseSuperWord
you did a hell of research here! +Integer.MaxInt to you! –
Sang
Very helpful! Her's some complementary info: VectorizaAon in HotSpot JVM by Vladimir Ivanov, HotSpot JVM Compiler, Oracle Corp. April 8, 2017 –
Bastard
More recent version of that great presentation: cr.openjdk.java.net/~vlivanov/talks/… –
Elflock
© 2022 - 2024 — McMap. All rights reserved.