JDK-5067347 : dead code/loops checks and elimination.
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 1.5.1
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_9
  • CPU: sparc
  • Submitted: 2004-06-23
  • Updated: 2005-09-08
  • Resolved: 2005-09-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b51Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
I had to fix a lot of bugs related to dead loops checks missing.
When we create a new node during transformation (call Ideal() methods)
it does not have associated type. In the case of a dead loop
(when a node references itself directly or through other nodes
but not through region or phi nodes) we could try to transform
this new node again (call Ideal() in the loop in transform_old()).
And we hit assert of SEGV (in product version) when we try to 
access the node's type.

One solution is to catch the dead loop situation and stop 
transformations. This is what I did before. But each time I missed
some cases. We can try to unify somehow this.

Second suggestion is the aggressive dead code elimination.
It should be trusted (no dead code escapes it) otherwise
we should keep first solution.

Third one is to assign a bottom type for new nodes created 
during transformation to avoid the assert. This one is just
to hide the problem.

Comments
SUGGESTED FIX Fixed as part of the 6297035 fix: Webrev: http://analemma.sfbay.sun.com/net/prt-archiver.sfbay/data/archived_workspaces/main/c2_baseline/2005/20050825162747.kvn.6297035/workspace/webrevs/webrev-2005.08.25/index.html 1. Check if it is a loop when we about to subsume a phi node with one data input. If it is a loop then replace the phi node with Top node to prevent the creation of a dead loop and phi copy. There are two places were we do this - in RegionNode::Ideal() and PhiNode::Ideal(). In RegionNode::Ideal() after removing dead (null or top) region's inputs we check the case when only one input left (in addition to self reference). The new method PhaseGVN::is_unreachable_region(n) is called to determine if this region is reachable from root. If not - subsume region's phis with Top node to break a dead loop and prevent phi copies creation. Replace reference to the region with Top for all other region's users and remove the region node. In PhiNode::Ideal() phi's inputs could become dead before correspondent region's inputs so we can't use the same method. The new method PhaseGVN::is_unsafe_data_loop(n) is called to determine if this phi references itself directly or through other data nodes. If does - replace the phi with Top to break a dead loop. 2. Add new flag Flag_is_dead_loop_safe to Node::NodeFlags and new method Node::is_dead_loop_safe() for Ideal nodes which could reference itself during GVN transformations or can not be in a loop. For now they are Con, Phi, Proj, CastPP, CheckCastPP nodes. It is safe to replace the phi (with one input) with one of these nodes to reduce the number of graph walks. I mark Phi nodes as safe node not only because they can reference itself but also to prevent mistaking the fallthrough case inside an outer loop as a dead loop when the phi references itselfs through an other phi. 3. Replace all existing dead loop checks in Ideal() methods with asserts. Add new debug method PhaseGVN::dead_loop_check() to check self references for all nodes before the call to Ideal().
26-08-2005

EVALUATION ###@###.### 2004-06-23 See the description.
23-06-2004