--- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ClassDefinitionBlockFactory.java 2016-06-17 15:38:24.105325472 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ClassDefinitionBlockFactory.java 2016-06-17 15:38:24.061325473 +0300 @@ -103,7 +103,12 @@ } private void addMoreChildren(List childs, Collection content, int minDepth) - throws ProductionFailedException { + throws ProductionFailedException { + /* check situation when no stackable leaves available in all childs */ + if (childs.stream().filter(c -> c.getStackableLeaves().size() > 0).count() == 0) { + return; + } + /* not let's try to add children */ while (!childs.isEmpty() && IRNode.countDepth(content) < minDepth) { PseudoRandom.shuffle(childs); IRNode randomChild = childs.get(0); @@ -131,18 +136,17 @@ private void ensureMaxDepth(Collection content) { int maxDepth = ProductionParams.maxCfgDepth.value(); - List childs = content.stream() + List childClasses = content.stream() .filter(c -> c instanceof Klass && c.countDepth() > maxDepth) .collect(Collectors.toList()); - for (IRNode ch : childs) { - List leaves; - do { - long depth = Math.max(ch.countDepth(), maxDepth + 1); - leaves = ch.getDeviantBlocks(depth); - if(leaves.size() > 0) { - leaves.get(0).removeSelf(); + /* Now attempt to reduce depth by removing optional parts of control deviation + blocks in case IRTree has oversized depth */ + for (IRNode child : childClasses) { + 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. } - } while (!leaves.isEmpty() && ch.countDepth() > maxDepth); + } } } } --- 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();