--- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/MainKlassFactory.java 2016-06-17 15:38:24.265325471 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/MainKlassFactory.java 2016-06-17 15:38:24.221325471 +0300 @@ -117,13 +117,14 @@ List filtered = childs.stream() .filter(c -> c.isCFDeviation() && c.countDepth() > maxDepth) .collect(Collectors.toList()); + /* Now attempt to reduce depth by removing optional parts of control deviation + blocks in case IRTree has oversized depth */ for (IRNode child : filtered) { - List leaves; - do { - long depth = Math.max(child.countDepth(), maxDepth + 1); - leaves = child.getDeviantBlocks(depth); - leaves.get(0).removeSelf(); - } while (!leaves.isEmpty() && child.countDepth() > maxDepth); + for (IRNode leaf : child.getDeviantBlocks(Math.max(child.countDepth(), maxDepth + 1))) { + if (child.countDepth() > maxDepth) { + leaf.removeSelf(); // Doesn't remove control deviation block. Just some parts. + } + } } } @@ -136,6 +137,11 @@ private void addMoreChildren(List childs, int minDepth, IRNodeBuilder builder) throws ProductionFailedException { + /* check when no stackable leaves available in all childs and skip addition for this case */ + if (childs.stream().filter(c -> c.getStackableLeaves().size() > 0).count() == 0) { + return; + } + /* now let's try to add children */ while (!childs.isEmpty() && IRNode.countDepth(childs) < minDepth) { IRNode randomChild = childs.get(PseudoRandom.randomNotNegative(childs.size())); List leaves = randomChild.getStackableLeaves();