# HG changeset patch # User Andreas Woess # Date 1334076741 -7200 # Node ID e706b132f580e9b8bf8840e2c37a9c19d4e596a6 # Parent c4381dacfca6b4c466eb26643000ca4356ed3404# Parent 155f8ca28f1142d98e0a0a2b435653f3cefbbde8 Merge diff -r c4381dacfca6 -r e706b132f580 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopTransformUtil.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopTransformUtil.java Tue Apr 10 18:51:04 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopTransformUtil.java Tue Apr 10 18:52:21 2012 +0200 @@ -57,4 +57,12 @@ } return new SuperBlock(loop.loopBegin(), loop.loopBegin(), blocks, earlyExits, loop.loopBegin()); } + + public static int estimateSize(Loop loop) { + int fixed = 0; + for (Block b : loop.blocks) { + fixed += b.getBeginNode().getBlockNodes().count(); + } + return fixed * 3; + } } diff -r c4381dacfca6 -r e706b132f580 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/SuperBlock.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/SuperBlock.java Tue Apr 10 18:51:04 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/SuperBlock.java Tue Apr 10 18:52:21 2012 +0200 @@ -204,8 +204,12 @@ private static ValueProxyNode findProxy(ValueNode value, BeginNode proxyPoint) { for (ValueProxyNode vpn : proxyPoint.proxies()) { - if (GraphUtil.unProxify(vpn) == value) { - return vpn; + ValueNode v = vpn; + while (v instanceof ValueProxyNode) { + v = ((ValueProxyNode) v).value(); + if (v == value) { + return vpn; + } } } return null; @@ -233,7 +237,7 @@ ValueProxyNode inputProxy = findProxy(value, earlyExit); if (inputProxy != null) { ValueProxyNode newInputProxy = findProxy(newValue, newEarlyExit); - assert newInputProxy != null; + assert newInputProxy != null : "no proxy for " + newValue + " at " + newEarlyExit; valuePhi.addInput(inputProxy); valuePhi.addInput(newInputProxy); } else { diff -r c4381dacfca6 -r e706b132f580 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/LoopTransformPhase.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/LoopTransformPhase.java Tue Apr 10 18:51:04 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/LoopTransformPhase.java Tue Apr 10 18:52:21 2012 +0200 @@ -46,7 +46,8 @@ }); for (Loop loop : loops) { double entryProbability = loop.loopBegin().forwardEnd().probability(); - if (entryProbability > GraalOptions.MinimumPeelProbability) { + if (entryProbability > GraalOptions.MinimumPeelProbability + && LoopTransformUtil.estimateSize(loop) + graph.getNodeCount() < GraalOptions.MaximumDesiredSize) { Debug.log("Peeling %s", loop); LoopTransformUtil.peel(loop); Debug.dump(graph, "After peeling %s", loop); diff -r c4381dacfca6 -r e706b132f580 graal/com.oracle.graal.graph/test/com/oracle/graal/graph/test/TypedNodeIteratorTest.java --- a/graal/com.oracle.graal.graph/test/com/oracle/graal/graph/test/TypedNodeIteratorTest.java Tue Apr 10 18:51:04 2012 +0200 +++ b/graal/com.oracle.graal.graph/test/com/oracle/graal/graph/test/TypedNodeIteratorTest.java Tue Apr 10 18:52:21 2012 +0200 @@ -46,7 +46,7 @@ TestNode testNode = new TestNode("a"); Graph graph = new Graph(); graph.add(testNode); - testNode.delete(); + testNode.safeDelete(); assertEquals("", toString(graph.getNodes(TestNode.class))); } @@ -56,7 +56,7 @@ Graph graph = new Graph(); graph.add(new TestNode("a")); graph.add(testNode); - testNode.delete(); + testNode.safeDelete(); assertEquals("a", toString(graph.getNodes(TestNode.class))); graph.add(new TestNode("c")); assertEquals("ac", toString(graph.getNodes(TestNode.class))); @@ -77,7 +77,7 @@ TestNode c = new TestNode("c"); graph.add(c); assertTrue(iterator.hasNext()); - c.delete(); + c.safeDelete(); assertFalse(iterator.hasNext()); } @@ -90,11 +90,11 @@ for (int i = 0; i < name.length(); ++i) { char c = name.charAt(i); if (c == 'a') { - tn.delete(); + tn.safeDelete(); graph.add(new TestNode("b")); graph.add(new TestNode("c")); } else if (c == 'b') { - tn.delete(); + tn.safeDelete(); } else if (c == 'c') { graph.add(new TestNode("d")); graph.add(new TestNode("e")); @@ -107,9 +107,9 @@ } else if (c == 'd') { for (TestNode tn2 : graph.getNodes(TestNode.class)) { if (tn2.getName().equals("e")) { - tn2.delete(); + tn2.safeDelete(); } else if (tn2.getName().equals("c")) { - tn2.delete(); + tn2.safeDelete(); } } } else if (c == 'e') { @@ -146,7 +146,7 @@ assertEquals(3, z); } - private String toString(Iterable nodes) { + private static String toString(Iterable nodes) { StringBuilder sb = new StringBuilder(); for (TestNode tn : nodes) { sb.append(tn.getName()); diff -r c4381dacfca6 -r e706b132f580 mx/projects --- a/mx/projects Tue Apr 10 18:51:04 2012 +0200 +++ b/mx/projects Tue Apr 10 18:52:21 2012 +0200 @@ -31,7 +31,7 @@ # graal.graph project@com.oracle.graal.graph@subDir=graal -project@com.oracle.graal.graph@sourceDirs=src +project@com.oracle.graal.graph@sourceDirs=src,test project@com.oracle.graal.graph@dependencies=com.oracle.graal.debug,JUNIT project@com.oracle.graal.graph@javaCompliance=1.7 diff -r c4381dacfca6 -r e706b132f580 mxtool/mx.py --- a/mxtool/mx.py Tue Apr 10 18:51:04 2012 +0200 +++ b/mxtool/mx.py Tue Apr 10 18:52:21 2012 +0200 @@ -401,14 +401,46 @@ abort('cannot redefine library ' + l.name) _libs[l.name] = l +class XMLElement(xml.dom.minidom.Element): + def writexml(self, writer, indent="", addindent="", newl=""): + writer.write(indent+"<" + self.tagName) + + attrs = self._get_attributes() + a_names = attrs.keys() + a_names.sort() + + for a_name in a_names: + writer.write(" %s=\"" % a_name) + xml.dom.minidom._write_data(writer, attrs[a_name].value) + writer.write("\"") + if self.childNodes: + if not self.ownerDocument.padTextNodeWithoutSiblings and len(self.childNodes) == 1 and isinstance(self.childNodes[0], xml.dom.minidom.Text): + # if the only child of an Element node is a Text node, then the + # text is printed without any indentation or new line padding + writer.write(">") + self.childNodes[0].writexml(writer) + writer.write("%s" % (self.tagName,newl)) + else: + writer.write(">%s"%(newl)) + for node in self.childNodes: + node.writexml(writer,indent+addindent,addindent,newl) + writer.write("%s%s" % (indent,self.tagName,newl)) + else: + writer.write("/>%s"%(newl)) -class XML(xml.dom.minidom.Document): +class XMLDoc(xml.dom.minidom.Document): def __init__(self): xml.dom.minidom.Document.__init__(self) self.current = self self.padTextNodeWithoutSiblings = False + def createElement(self, tagName): + # overwritten to create XMLElement + e = XMLElement(tagName) + e.ownerDocument = self + return e + def open(self, tag, attributes={}, data=None): element = self.createElement(tag) for key, value in attributes.items(): @@ -436,35 +468,6 @@ result = xml.sax.saxutils.escape(result, entities) return result - @staticmethod - def _Element_writexml(self, writer, indent="", addindent="", newl=""): - # Monkey patch: if the only child of an Element node is a Text node, then the - # text is printed without any indentation or new line padding - writer.write(indent+"<" + self.tagName) - - attrs = self._get_attributes() - a_names = attrs.keys() - a_names.sort() - - for a_name in a_names: - writer.write(" %s=\"" % a_name) - xml.dom.minidom._write_data(writer, attrs[a_name].value) - writer.write("\"") - if self.childNodes: - if not self.ownerDocument.padTextNodeWithoutSiblings and len(self.childNodes) == 1 and isinstance(self.childNodes[0], xml.dom.minidom.Text): - writer.write(">") - self.childNodes[0].writexml(writer) - writer.write("%s" % (self.tagName,newl)) - else: - writer.write(">%s"%(newl)) - for node in self.childNodes: - node.writexml(writer,indent+addindent,addindent,newl) - writer.write("%s%s" % (indent,self.tagName,newl)) - else: - writer.write("/>%s"%(newl)) - -xml.dom.minidom.Element.writexml = XML._Element_writexml - def get_os(): """ Get a canonical form of sys.platform. @@ -1440,17 +1443,17 @@ def _source_locator_memento(deps): - slm = XML() + slm = XMLDoc() slm.open('sourceLookupDirector') slm.open('sourceContainers', {'duplicates' : 'false'}) for dep in deps: if dep.isLibrary(): if hasattr(dep, 'eclipse.container'): - memento = XML().element('classpathContainer', {'path' : getattr(dep, 'eclipse.container')}).xml() + memento = XMLDoc().element('classpathContainer', {'path' : getattr(dep, 'eclipse.container')}).xml() slm.element('classpathContainer', {'memento' : memento, 'typeId':'org.eclipse.jdt.launching.sourceContainer.classpathContainer'}) else: - memento = XML().element('javaProject', {'name' : dep.name}).xml() + memento = XMLDoc().element('javaProject', {'name' : dep.name}).xml() slm.element('container', {'memento' : memento, 'typeId':'org.eclipse.jdt.launching.sourceContainer.javaProject'}) slm.close('sourceContainers') @@ -1462,7 +1465,7 @@ Creates an Eclipse launch configuration file for attaching to a Java process. """ slm = _source_locator_memento(deps) - launch = XML() + launch = XMLDoc() launch.open('launchConfiguration', {'type' : 'org.eclipse.jdt.launching.remoteJavaApplication'}) launch.element('stringAttribute', {'key' : 'org.eclipse.debug.core.source_locator_id', 'value' : 'org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector'}) launch.element('stringAttribute', {'key' : 'org.eclipse.debug.core.source_locator_memento', 'value' : '%s'}) @@ -1531,7 +1534,7 @@ slm = _source_locator_memento(deps) - launch = XML() + launch = XMLDoc() launch.open('launchConfiguration', {'type' : 'org.eclipse.jdt.launching.localJavaApplication'}) launch.element('stringAttribute', {'key' : 'org.eclipse.debug.core.source_locator_id', 'value' : 'org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector'}) launch.element('stringAttribute', {'key' : 'org.eclipse.debug.core.source_locator_memento', 'value' : '%s'}) @@ -1561,7 +1564,7 @@ if not exists(p.dir): os.makedirs(p.dir) - out = XML() + out = XMLDoc() out.open('classpath') for src in p.srcDirs: @@ -1602,7 +1605,7 @@ csConfig = join(project(p.checkstyleProj).dir, '.checkstyle_checks.xml') if exists(csConfig): - out = XML() + out = XMLDoc() dotCheckstyle = join(p.dir, ".checkstyle") checkstyleConfigPath = '/' + p.checkstyleProj + '/.checkstyle_checks.xml' @@ -1630,9 +1633,9 @@ out.close('filter') out.close('fileset-config') - update_file(dotCheckstyle, out.xml(indent='\t', newl='\n')) + update_file(dotCheckstyle, out.xml(indent=' ', newl='\n')) - out = XML() + out = XMLDoc() out.open('projectDescription') out.element('name', data=p.name) out.element('comment', data='') @@ -1686,14 +1689,14 @@ if not exists(join(p.dir, 'nbproject')): os.makedirs(join(p.dir, 'nbproject')) - out = XML() + out = XMLDoc() out.open('project', {'name' : p.name, 'default' : 'default', 'basedir' : '.'}) out.element('description', data='Builds, tests, and runs the project ' + p.name + '.') out.element('import', {'file' : 'nbproject/build-impl.xml'}) out.close('project') updated = update_file(join(p.dir, 'build.xml'), out.xml(indent='\t', newl='\n')) or updated - out = XML() + out = XMLDoc() out.open('project', {'xmlns' : 'http://www.netbeans.org/ns/project/1'}) out.element('type', data='org.netbeans.modules.java.j2seproject') out.open('configuration')