# HG changeset patch # User Gilles Duboscq # Date 1312815757 -7200 # Node ID ada3ece59c7ff616e3b6dce2097bb2c46ac79f73 # Parent 27ccc1cb3748bd8455aa15586f50a5ef71dbce4b# Parent 600ffdb9addabcd5a44ae247c62727567722d13e Merge diff -r 27ccc1cb3748 -r ada3ece59c7f .hgignore --- a/.hgignore Mon Aug 08 16:25:26 2011 +0200 +++ b/.hgignore Mon Aug 08 17:02:37 2011 +0200 @@ -29,6 +29,7 @@ ^graal/hotspot/java$ ^scratch/ scratch/ +bin/ ^local/ ^src/share/tools/hsdis/build/ ^src/share/tools/IdealGraphVisualizer/[a-zA-Z0-9]*/build/ diff -r 27ccc1cb3748 -r ada3ece59c7f graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java Mon Aug 08 16:25:26 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java Mon Aug 08 17:02:37 2011 +0200 @@ -99,6 +99,7 @@ public static boolean Plot = ____; public static boolean PlotVerbose = ____; public static boolean PlotOnError = ____; + public static boolean PrintIdealGraphBytecodes = true; public static int PrintIdealGraphLevel = 0; public static boolean PrintIdealGraphFile = ____; public static String PrintIdealGraphAddress = "127.0.0.1"; diff -r 27ccc1cb3748 -r ada3ece59c7f graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/asm/TargetMethodAssembler.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/asm/TargetMethodAssembler.java Mon Aug 08 16:25:26 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/asm/TargetMethodAssembler.java Mon Aug 08 17:02:37 2011 +0200 @@ -163,14 +163,14 @@ CiDebugInfo debugInfo = info != null ? info.debugInfo() : null; assert lastSafepointPos < posAfter; lastSafepointPos = posAfter; - targetMethod.recordCall(posBefore, target, debugInfo, true); + targetMethod.recordCall(posBefore, posAfter - posBefore, target, debugInfo, true); } public void recordIndirectCall(int posBefore, int posAfter, Object target, LIRDebugInfo info) { CiDebugInfo debugInfo = info != null ? info.debugInfo() : null; assert lastSafepointPos < posAfter; lastSafepointPos = posAfter; - targetMethod.recordCall(posBefore, target, debugInfo, false); + targetMethod.recordCall(posBefore, posAfter - posBefore, target, debugInfo, false); } public void recordSafepoint(int pos, LIRDebugInfo info) { diff -r 27ccc1cb3748 -r ada3ece59c7f graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinter.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinter.java Mon Aug 08 16:25:26 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinter.java Mon Aug 08 17:02:37 2011 +0200 @@ -27,6 +27,7 @@ import java.util.AbstractMap.SimpleImmutableEntry; import java.util.Map.Entry; +import com.oracle.max.graal.compiler.*; import com.oracle.max.graal.compiler.ir.*; import com.oracle.max.graal.compiler.schedule.*; import com.oracle.max.graal.compiler.util.*; @@ -34,6 +35,8 @@ import com.oracle.max.graal.compiler.value.*; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.graph.collections.*; +import com.sun.cri.bytecode.*; +import com.sun.cri.ri.*; /** * Generates a representation of {@link Graph Graphs} that can be visualized and inspected with the "); stream.printf("

%s

Graal

%n", escape(name)); - stream.printf(" %n", escape(name), escape(shortName), bci); + stream.printf(" %n", escape(name), escape(shortName), bci); + if (GraalOptions.PrintIdealGraphBytecodes) { + StringBuilder sb = new StringBuilder(40); + stream.println("\n<![CDATA["); + BytecodeStream bytecodes = new BytecodeStream(method.code()); + while (bytecodes.currentBC() != Bytecodes.END) { + sb.setLength(0); + sb.append(bytecodes.currentBCI()).append(' '); + sb.append(Bytecodes.nameOf(bytecodes.currentBC())); + for (int i = bytecodes.currentBCI() + 1; i < bytecodes.nextBCI(); ++i) { + sb.append(' ').append(bytecodes.readUByte(i)); + } + stream.println(sb.toString()); + bytecodes.next(); + } + stream.println("]]>"); + } + stream.println(""); } /** diff -r 27ccc1cb3748 -r ada3ece59c7f graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinterObserver.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinterObserver.java Mon Aug 08 16:25:26 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinterObserver.java Mon Aug 08 17:02:37 2011 +0200 @@ -30,6 +30,7 @@ import com.oracle.max.graal.compiler.observer.*; import com.oracle.max.graal.compiler.value.*; import com.oracle.max.graal.graph.*; +import com.sun.cri.ri.*; /** * Observes compilation events and uses {@link IdealGraphPrinter} to generate a graph representation that can be @@ -73,14 +74,14 @@ name = name + "." + event.getMethod().name(); if (host != null) { - openNetworkPrinter(name); + openNetworkPrinter(name, event.getMethod()); } else { - openFilePrinter(name); + openFilePrinter(name, event.getMethod()); } } } - private void openFilePrinter(String name) { + private void openFilePrinter(String name, RiMethod method) { String filename = name + ".igv.xml"; filename = INVALID_CHAR.matcher(filename).replaceAll("_"); @@ -91,13 +92,13 @@ printer.addOmittedClass(FrameState.class); } printer.begin(); - printer.beginGroup(name, name, -1); + printer.beginGroup(name, name, method, -1); } catch (IOException e) { e.printStackTrace(); } } - private void openNetworkPrinter(String name) { + private void openNetworkPrinter(String name, RiMethod method) { try { socket = new Socket(host, port); if (socket.getInputStream().read() == 'y') { @@ -114,7 +115,7 @@ printer.addOmittedClass(FrameState.class); } printer.begin(); - printer.beginGroup(name, name, -1); + printer.beginGroup(name, name, method, -1); printer.flush(); if (socket.getInputStream().read() != 'y') { // server declines input for this method diff -r 27ccc1cb3748 -r ada3ece59c7f graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/MathIntrinsic.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/MathIntrinsic.java Mon Aug 08 17:02:37 2011 +0200 @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.max.graal.compiler.ir; + +import com.oracle.max.graal.compiler.util.*; +import com.oracle.max.graal.graph.*; +import com.sun.cri.ci.*; + +public class MathIntrinsic extends FloatingNode { + + public enum Operation { + SQRT + } + + @Input private Value x; + + private final Operation operation; + + public Value x() { + return x; + } + + public void setX(Value x) { + updateUsages(this.x, x); + this.x = x; + } + + public Operation operation() { + return operation; + } + + public MathIntrinsic(Value x, Operation op, Graph graph) { + super(x.kind, graph); + setX(x); + this.operation = op; + } + + // for copying + private MathIntrinsic(CiKind kind, Operation op, Graph graph) { + super(kind, graph); + this.operation = op; + } + + @Override + public void accept(ValueVisitor v) { + v.visitMathIntrinsic(this); + } + + @Override + public int valueNumber() { + return Util.hash1(operation.hashCode(), x); + } + + @Override + public boolean valueEqual(Node i) { + if (i instanceof MathIntrinsic) { + MathIntrinsic mi = (MathIntrinsic) i; + return (operation() == mi.operation && x() == mi.x()); + } + return false; + } + + @Override + public Node copy(Graph into) { + return new MathIntrinsic(kind, operation, into); + } + +} diff -r 27ccc1cb3748 -r ada3ece59c7f graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/ValueVisitor.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/ValueVisitor.java Mon Aug 08 16:25:26 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/ValueVisitor.java Mon Aug 08 17:02:37 2011 +0200 @@ -73,4 +73,5 @@ public abstract void visitLoopEnd(LoopEnd loopEnd); public abstract void visitValueAnchor(ValueAnchor valueAnchor); public abstract void visitGuardNode(GuardNode guardNode); + public abstract void visitMathIntrinsic(MathIntrinsic node); } diff -r 27ccc1cb3748 -r ada3ece59c7f graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRGenerator.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRGenerator.java Mon Aug 08 16:25:26 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRGenerator.java Mon Aug 08 17:02:37 2011 +0200 @@ -465,6 +465,21 @@ } @Override + public void visitMathIntrinsic(MathIntrinsic node) { + LIRItem opd = new LIRItem(node.x(), this); + opd.setDestroysRegister(); + opd.loadItem(); + CiVariable dest = createResultVariable(node); + switch (node.operation()) { + case SQRT: + lir.sqrt(opd.result(), dest, CiValue.IllegalValue); + break; + default: + throw Util.shouldNotReachHere(); + } + } + + @Override public Condition floatingPointCondition(Condition cond) { switch(cond) { case LT: diff -r 27ccc1cb3748 -r ada3ece59c7f graal/com.oracle.max.graal.examples/bin/META-INF/services/com.oracle.max.graal.extensions.FrameModifier --- a/graal/com.oracle.max.graal.examples/bin/META-INF/services/com.oracle.max.graal.extensions.FrameModifier Mon Aug 08 16:25:26 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -com.oracle.max.graal.examples.deopt.FrameModifierImpl \ No newline at end of file diff -r 27ccc1cb3748 -r ada3ece59c7f graal/com.oracle.max.graal.examples/bin/META-INF/services/com.oracle.max.graal.extensions.InliningGuide --- a/graal/com.oracle.max.graal.examples/bin/META-INF/services/com.oracle.max.graal.extensions.InliningGuide Mon Aug 08 16:25:26 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -com.oracle.max.graal.examples.inlining.InliningGuideImpl \ No newline at end of file diff -r 27ccc1cb3748 -r ada3ece59c7f graal/com.oracle.max.graal.examples/bin/META-INF/services/com.oracle.max.graal.extensions.Intrinsifier --- a/graal/com.oracle.max.graal.examples/bin/META-INF/services/com.oracle.max.graal.extensions.Intrinsifier Mon Aug 08 16:25:26 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -com.oracle.max.graal.examples.intrinsics.IntrinsifierImpl \ No newline at end of file diff -r 27ccc1cb3748 -r ada3ece59c7f graal/com.oracle.max.graal.examples/bin/META-INF/services/com.oracle.max.graal.extensions.Optimizer --- a/graal/com.oracle.max.graal.examples/bin/META-INF/services/com.oracle.max.graal.extensions.Optimizer Mon Aug 08 16:25:26 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -com.oracle.max.graal.examples.opt.OptimizerImpl \ No newline at end of file diff -r 27ccc1cb3748 -r ada3ece59c7f graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/HotSpotRuntime.java --- a/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/HotSpotRuntime.java Mon Aug 08 16:25:26 2011 +0200 +++ b/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/HotSpotRuntime.java Mon Aug 08 17:02:37 2011 +0200 @@ -575,6 +575,16 @@ graph.setReturn(ret); intrinsicGraphs.put(method, graph); } + } else if (holderName.equals("Ljava/lang/Math;")) { + if (fullName.equals("sqrt(D)D")) { + CompilerGraph graph = new CompilerGraph(this); + Local value = new Local(CiKind.Double, 0, graph); + MathIntrinsic min = new MathIntrinsic(value, MathIntrinsic.Operation.SQRT, graph); + Return ret = new Return(min, graph); + graph.start().setNext(ret); + graph.setReturn(ret); + intrinsicGraphs.put(method, graph); + } } if (!intrinsicGraphs.containsKey(method)) {