--- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ClassDefinitionBlockFactory.java 2016-06-20 20:25:17.060105660 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ClassDefinitionBlockFactory.java 2016-06-20 20:25:17.016105661 +0300 @@ -102,11 +102,16 @@ addMoreChildren(childs, content, minDepth); } - private void addMoreChildren(List childs, Collection content, int minDepth) - throws ProductionFailedException { - while (!childs.isEmpty() && IRNode.countDepth(content) < minDepth) { - PseudoRandom.shuffle(childs); - IRNode randomChild = childs.get(0); + private void addMoreChildren(List children, Collection content, int minDepth) + throws ProductionFailedException { + /* check situation when no stackable leaves available in all children */ + if (IRNode.getModifiableNodesCount(children) == 0L) { + return; + } + /* now let's try to add children */ + while (!children.isEmpty() && IRNode.countDepth(content) < minDepth) { + PseudoRandom.shuffle(children); + IRNode randomChild = children.get(0); List leaves = randomChild.getStackableLeaves(); if (!leaves.isEmpty()) { Block randomLeaf = (Block) leaves.get(PseudoRandom.randomNotNegative(leaves.size())); @@ -131,18 +136,11 @@ private void ensureMaxDepth(Collection content) { int maxDepth = ProductionParams.maxCfgDepth.value(); - List childs = content.stream() + List childrenClasses = 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(); - } - } while (!leaves.isEmpty() && ch.countDepth() > maxDepth); - } + /* now attempt to reduce depth by removing optional parts of control deviation + blocks in case IRTree has oversized depth */ + IRNode.tryToReduceNodesDepth(childrenClasses, maxDepth); } }