# HG changeset patch # User Thomas Wuerthinger # Date 1312931556 -7200 # Node ID dc426882882653ea6e93b563ec9b0779415b7f52 # Parent da773e1b6d9f8197871c6c0d6a275cb34220292b Fourth round of refactoring. diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/.classpath --- a/graal/com.oracle.max.graal.compiler/.classpath Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/.classpath Wed Aug 10 01:12:36 2011 +0200 @@ -1,10 +1,12 @@ - - - - - - - - - - + + + + + + + + + + + + diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompilation.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompilation.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompilation.java Wed Aug 10 01:12:36 2011 +0200 @@ -34,7 +34,7 @@ import com.oracle.max.graal.compiler.graph.*; import com.oracle.max.graal.compiler.lir.*; import com.oracle.max.graal.compiler.observer.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; import com.sun.cri.ci.*; import com.sun.cri.ri.*; diff -r da773e1b6d9f -r dc4268828826 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 Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java Wed Aug 10 01:12:36 2011 +0200 @@ -60,7 +60,6 @@ // escape analysis settings public static boolean EscapeAnalysis = ____; public static int ForcedInlineEscapeWeight = 100; - public static int MaximumEscapeAnalysisArrayLength = 32; public static boolean PrintEscapeAnalysis = ____; // absolute probability analysis diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LinearScan.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LinearScan.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LinearScan.java Wed Aug 10 01:12:36 2011 +0200 @@ -41,8 +41,8 @@ import com.oracle.max.graal.compiler.util.*; import com.oracle.max.graal.extensions.*; import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.base.FrameState.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.FrameState.ValueProcedure; import com.oracle.max.graal.nodes.calc.*; import com.oracle.max.graal.nodes.virtual.*; import com.sun.cri.ci.*; @@ -647,7 +647,7 @@ if (!liveKill.get(operandNum)) { liveGen.set(operandNum); if (GraalOptions.TraceLinearScanLevel >= 4) { - TTY.println(" Setting liveGen for value %s, LIR opId %d, operand %d because of state for %s", Util.valueString(value), op.id(), operandNum, op); + TTY.println(" Setting liveGen for value %s, LIR opId %d, operand %d because of state for %s", ValueUtil.valueString(value), op.id(), operandNum, op); } } } else if (operand.isRegister()) { diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/OperandPool.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/OperandPool.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/OperandPool.java Wed Aug 10 01:12:36 2011 +0200 @@ -26,7 +26,7 @@ import com.oracle.max.graal.compiler.*; import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; import com.sun.cri.ci.*; /** diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/BlockPrinter.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/BlockPrinter.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/BlockPrinter.java Wed Aug 10 01:12:36 2011 +0200 @@ -24,9 +24,8 @@ import com.oracle.max.graal.compiler.graph.*; import com.oracle.max.graal.compiler.schedule.*; -import com.oracle.max.graal.compiler.util.*; import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; /** * Prints a listing for a {@linkplain MergeNode block}. @@ -81,7 +80,7 @@ out.print(", "); } ValueNode value = newFrameState.stackAt(i); - out.print(i + ":" + Util.valueString(value)); + out.print(i + ":" + ValueUtil.valueString(value)); if (value == null) { i++; } else { @@ -113,7 +112,7 @@ // synchronized methods push null on the lock stack out.print("this"); } else { - out.print(Util.valueString(value)); + out.print(ValueUtil.valueString(value)); } } out.print("]"); diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/CFGPrinter.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/CFGPrinter.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/CFGPrinter.java Wed Aug 10 01:12:36 2011 +0200 @@ -32,9 +32,8 @@ import com.oracle.max.graal.compiler.lir.*; import com.oracle.max.graal.compiler.lir.LIRInstruction.OperandFormatter; import com.oracle.max.graal.compiler.schedule.*; -import com.oracle.max.graal.compiler.util.*; import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; import com.sun.cri.ci.*; import com.sun.cri.ci.CiAddress.Scale; import com.sun.cri.ri.*; @@ -292,7 +291,7 @@ private String stateValueToString(ValueNode value, OperandFormatter operandFmt) { if (operandFmt == null) { - return Util.valueString(value); + return ValueUtil.valueString(value); } if (value == null) { return "-"; diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/GraphvizPrinterObserver.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/GraphvizPrinterObserver.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/GraphvizPrinterObserver.java Wed Aug 10 01:12:36 2011 +0200 @@ -29,7 +29,7 @@ import com.oracle.max.graal.compiler.observer.*; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.graphviz.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; /** * Observes compilation events and uses {@link GraphvizPrinter} to produce a control flow graph in the DOT language diff -r da773e1b6d9f -r dc4268828826 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 Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinter.java Wed Aug 10 01:12:36 2011 +0200 @@ -33,7 +33,7 @@ import com.oracle.max.graal.compiler.util.LoopUtil.Loop; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.graph.collections.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; import com.oracle.max.graal.nodes.loop.*; import com.sun.cri.bytecode.*; import com.sun.cri.ri.*; diff -r da773e1b6d9f -r dc4268828826 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 Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinterObserver.java Wed Aug 10 01:12:36 2011 +0200 @@ -29,7 +29,7 @@ import com.oracle.max.graal.compiler.*; import com.oracle.max.graal.compiler.observer.*; import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; import com.sun.cri.ri.*; /** diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/InstructionPrinter.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/InstructionPrinter.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/InstructionPrinter.java Wed Aug 10 01:12:36 2011 +0200 @@ -24,7 +24,7 @@ import static com.oracle.max.graal.compiler.debug.InstructionPrinter.InstructionLineColumn.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; import com.oracle.max.graal.nodes.spi.*; /** diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/LogStream.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/LogStream.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/LogStream.java Wed Aug 10 01:12:36 2011 +0200 @@ -25,8 +25,7 @@ import java.io.*; import java.util.*; -import com.oracle.max.graal.compiler.util.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; /** * A utility for printing compiler debug and informational output to an output stream. @@ -451,7 +450,7 @@ } /** - * Writes an instruction formatted as a {@linkplain com.oracle.max.graal.compiler.util.Util#valueString(com.oracle.max.graal.nodes.base.ValueNode) value} to this stream. + * Writes an instruction formatted as a {@linkplain com.oracle.max.graal.compiler.util.Util#valueString(com.oracle.max.graal.nodes.ValueNode) value} to this stream. * * @param value the instruction to print * @return this {@code LogStream} instance @@ -459,13 +458,13 @@ public LogStream print(ValueNode value) { if (ps != null) { indent(); - lineBuffer.append(Util.valueString(value)); + lineBuffer.append(ValueUtil.valueString(value)); } return this; } /** - * Writes an instruction formatted as a {@linkplain com.oracle.max.graal.compiler.util.Util#valueString(com.oracle.max.graal.nodes.base.ValueNode) value} to this stream + * Writes an instruction formatted as a {@linkplain com.oracle.max.graal.compiler.util.Util#valueString(com.oracle.max.graal.nodes.ValueNode) value} to this stream * followed by a {@linkplain #LINE_SEPARATOR line separator}. * * @param value the instruction to print diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java Wed Aug 10 01:12:36 2011 +0200 @@ -40,10 +40,10 @@ import com.oracle.max.graal.compiler.lir.*; import com.oracle.max.graal.compiler.util.*; import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.base.DeoptimizeNode.*; -import com.oracle.max.graal.nodes.base.FrameState.*; -import com.oracle.max.graal.nodes.base.PhiNode.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.DeoptimizeNode.DeoptAction; +import com.oracle.max.graal.nodes.FrameState.ValueProcedure; +import com.oracle.max.graal.nodes.PhiNode.PhiType; import com.oracle.max.graal.nodes.calc.*; import com.oracle.max.graal.nodes.extended.*; import com.oracle.max.graal.nodes.java.*; diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRItem.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRItem.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRItem.java Wed Aug 10 01:12:36 2011 +0200 @@ -24,7 +24,7 @@ import com.oracle.max.graal.compiler.alloc.OperandPool.VariableFlag; import com.oracle.max.graal.compiler.util.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; import com.sun.cri.ci.*; /** diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/PhiResolver.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/PhiResolver.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/PhiResolver.java Wed Aug 10 01:12:36 2011 +0200 @@ -26,7 +26,7 @@ import java.util.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; import com.sun.cri.ci.*; /** diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/PhiSimplifier.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/PhiSimplifier.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/PhiSimplifier.java Wed Aug 10 01:12:36 2011 +0200 @@ -24,7 +24,7 @@ import com.oracle.max.graal.graph.*; import com.oracle.max.graal.graph.collections.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; /** * The {@code PhiSimplifier} class is a helper class that can reduce phi instructions. diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/BlockMap.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/BlockMap.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/BlockMap.java Wed Aug 10 01:12:36 2011 +0200 @@ -28,7 +28,7 @@ import com.oracle.max.graal.compiler.*; import com.oracle.max.graal.compiler.debug.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; import com.sun.cri.bytecode.*; import com.sun.cri.ci.*; import com.sun.cri.ri.*; diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/CompilerGraph.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/CompilerGraph.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -/* - * 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.graph; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.sun.cri.ci.*; -import com.sun.cri.ri.*; - - -public class CompilerGraph extends Graph { - - private RiRuntime runtime; - private ReturnNode returnSingleton; - private UnwindNode unwindSingleton; - private CiAssumptions assumptions = new CiAssumptions(); - - public CompilerGraph(RiRuntime runtime) { - this.runtime = runtime; - } - - public void setReturn(ReturnNode returnNode) { - assert returnSingleton == null; - returnSingleton = returnNode; - } - - public ReturnNode getReturn() { - return returnSingleton; - } - - public void setUnwind(UnwindNode unwind) { - assert unwindSingleton == null; - unwindSingleton = unwind; - } - - public UnwindNode getUnwind() { - return unwindSingleton; - } - - public RiRuntime runtime() { - return runtime; - } - - public CiAssumptions assumptions() { - return assumptions; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/IR.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/IR.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/IR.java Wed Aug 10 01:12:36 2011 +0200 @@ -32,7 +32,7 @@ import com.oracle.max.graal.compiler.schedule.*; import com.oracle.max.graal.extensions.*; import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; /** * This class implements the overall container for the HIR (high-level IR) graph diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/MergeableState.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/MergeableState.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/MergeableState.java Wed Aug 10 01:12:36 2011 +0200 @@ -24,7 +24,7 @@ import java.util.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; public interface MergeableState { T clone(); diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/PostOrderNodeIterator.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/PostOrderNodeIterator.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/PostOrderNodeIterator.java Wed Aug 10 01:12:36 2011 +0200 @@ -26,7 +26,7 @@ import com.oracle.max.graal.graph.*; import com.oracle.max.graal.graph.collections.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; public abstract class PostOrderNodeIterator> { diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRBlock.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRBlock.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRBlock.java Wed Aug 10 01:12:36 2011 +0200 @@ -29,7 +29,7 @@ import com.oracle.max.graal.compiler.debug.*; import com.oracle.max.graal.compiler.util.*; import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; import com.oracle.max.graal.nodes.java.*; /** diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRDebugInfo.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRDebugInfo.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRDebugInfo.java Wed Aug 10 01:12:36 2011 +0200 @@ -24,7 +24,7 @@ import com.oracle.max.graal.compiler.*; import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; import com.sun.cri.ci.*; /** diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/package-info.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/package-info.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/package-info.java Wed Aug 10 01:12:36 2011 +0200 @@ -75,7 +75,7 @@ * *
  • * Add a field to optionally store an {@link com.oracle.max.graal.compiler.ir.Info} object for each HIR node, and remove the - * {@link com.oracle.max.graal.nodes.base.FixedWithNextNode#exceptionHandlers} field, the {@link com.oracle.max.graal.nodes.base.FixedWithNextNode#bci} field, and any fields to store the Java + * {@link com.oracle.max.graal.nodes.FixedWithNextNode#exceptionHandlers} field, the {@link com.oracle.max.graal.nodes.FixedWithNextNode#bci} field, and any fields to store the Java * frame state in subclasses. Benefit: saves space if most HIR nodes do not have exception handlers, a bci or Java frame * state. Removes virtual dispatch on accessing debug information for nodes. Allows any node, regardless of its type, to * have info attached.
  • diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/ComputeProbabilityPhase.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/ComputeProbabilityPhase.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/ComputeProbabilityPhase.java Wed Aug 10 01:12:36 2011 +0200 @@ -29,7 +29,7 @@ import com.oracle.max.graal.compiler.graph.*; import com.oracle.max.graal.compiler.observer.*; import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; public class ComputeProbabilityPhase extends Phase { private static final double EPSILON = 1d / Integer.MAX_VALUE; diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/DeadCodeEliminationPhase.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/DeadCodeEliminationPhase.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/DeadCodeEliminationPhase.java Wed Aug 10 01:12:36 2011 +0200 @@ -27,7 +27,7 @@ import com.oracle.max.graal.compiler.gen.*; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.graph.collections.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; import com.oracle.max.graal.nodes.extended.*; diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/DuplicationPhase.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/DuplicationPhase.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/DuplicationPhase.java Wed Aug 10 01:12:36 2011 +0200 @@ -24,8 +24,8 @@ import java.util.*; -import com.oracle.max.graal.compiler.graph.*; import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; /** * Duplicates every node in the graph to test the implementation of the {@link com.oracle.max.graal.graph.Node#copy()} method in node subclasses. diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/EscapeAnalysisPhase.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/EscapeAnalysisPhase.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/EscapeAnalysisPhase.java Wed Aug 10 01:12:36 2011 +0200 @@ -31,8 +31,8 @@ import com.oracle.max.graal.compiler.observer.*; import com.oracle.max.graal.compiler.schedule.*; import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.base.PhiNode.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.PhiNode.PhiType; import com.oracle.max.graal.nodes.calc.*; import com.oracle.max.graal.nodes.spi.*; import com.oracle.max.graal.nodes.virtual.*; diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GraphBuilderPhase.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GraphBuilderPhase.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GraphBuilderPhase.java Wed Aug 10 01:12:36 2011 +0200 @@ -41,11 +41,12 @@ import com.oracle.max.graal.compiler.value.*; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.graph.collections.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.base.DeoptimizeNode.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.DeoptimizeNode.DeoptAction; import com.oracle.max.graal.nodes.calc.*; import com.oracle.max.graal.nodes.extended.*; import com.oracle.max.graal.nodes.java.*; +import com.oracle.max.graal.nodes.spi.*; import com.sun.cri.bytecode.*; import com.sun.cri.ci.*; import com.sun.cri.ri.*; diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java Wed Aug 10 01:12:36 2011 +0200 @@ -30,8 +30,8 @@ import com.oracle.max.graal.compiler.graph.*; import com.oracle.max.graal.extensions.*; import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.base.DeoptimizeNode.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.DeoptimizeNode.DeoptAction; import com.oracle.max.graal.nodes.calc.*; import com.oracle.max.graal.nodes.java.*; import com.sun.cri.bytecode.*; diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/LoopPhase.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/LoopPhase.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/LoopPhase.java Wed Aug 10 01:12:36 2011 +0200 @@ -30,7 +30,7 @@ import com.oracle.max.graal.compiler.util.LoopUtil.Loop; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.graph.collections.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; import com.oracle.max.graal.nodes.calc.*; import com.oracle.max.graal.nodes.loop.*; import com.sun.cri.ci.*; diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/LoweringPhase.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/LoweringPhase.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/LoweringPhase.java Wed Aug 10 01:12:36 2011 +0200 @@ -27,7 +27,7 @@ import com.oracle.max.graal.compiler.schedule.*; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.graph.collections.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; import com.oracle.max.graal.nodes.spi.*; import com.sun.cri.ci.*; import com.sun.cri.ri.*; diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/MemoryPhase.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/MemoryPhase.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/MemoryPhase.java Wed Aug 10 01:12:36 2011 +0200 @@ -30,8 +30,8 @@ import com.oracle.max.graal.compiler.schedule.*; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.graph.collections.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.base.PhiNode.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.PhiNode.PhiType; import com.oracle.max.graal.nodes.extended.*; import com.sun.cri.ci.*; diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/Block.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/Block.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/Block.java Wed Aug 10 01:12:36 2011 +0200 @@ -25,7 +25,7 @@ import java.util.*; import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; import com.oracle.max.graal.nodes.java.*; diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/BlockList.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/BlockList.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/BlockList.java Wed Aug 10 01:12:36 2011 +0200 @@ -24,7 +24,7 @@ import java.util.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; /** * The {@code BlockList} class implements a specialized list data structure for representing diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/IdentifyBlocksPhase.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/IdentifyBlocksPhase.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/IdentifyBlocksPhase.java Wed Aug 10 01:12:36 2011 +0200 @@ -31,7 +31,7 @@ import com.oracle.max.graal.graph.NodeClass.NodeClassIterator; import com.oracle.max.graal.graph.NodeClass.Position; import com.oracle.max.graal.graph.collections.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; import com.oracle.max.graal.nodes.extended.*; import com.oracle.max.graal.nodes.loop.*; import com.oracle.max.graal.nodes.virtual.*; diff -r da773e1b6d9f -r dc4268828826 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 Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRGenerator.java Wed Aug 10 01:12:36 2011 +0200 @@ -30,7 +30,7 @@ import com.oracle.max.graal.compiler.globalstub.*; import com.oracle.max.graal.compiler.lir.*; import com.oracle.max.graal.compiler.util.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; import com.oracle.max.graal.nodes.calc.*; import com.oracle.max.graal.nodes.extended.*; import com.oracle.max.graal.nodes.java.*; diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/BlockWorkList.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/BlockWorkList.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/BlockWorkList.java Wed Aug 10 01:12:36 2011 +0200 @@ -22,7 +22,7 @@ */ package com.oracle.max.graal.compiler.util; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; /** * This class implements a worklist for dealing with blocks. The worklist can diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/GraphUtil.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/GraphUtil.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/GraphUtil.java Wed Aug 10 01:12:36 2011 +0200 @@ -32,8 +32,8 @@ import com.oracle.max.graal.graph.NodeClass.Position; import com.oracle.max.graal.graph.collections.*; import com.oracle.max.graal.graph.collections.NodeWorkList.InfiniteWorkException; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.base.PhiNode.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.PhiNode.PhiType; import com.oracle.max.graal.nodes.extended.*; public class GraphUtil { diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/LoopUtil.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/LoopUtil.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/LoopUtil.java Wed Aug 10 01:12:36 2011 +0200 @@ -34,8 +34,8 @@ import com.oracle.max.graal.graph.NodeClass.NodeClassIterator; import com.oracle.max.graal.graph.NodeClass.Position; import com.oracle.max.graal.graph.collections.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.base.PhiNode.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.PhiNode.PhiType; import com.oracle.max.graal.nodes.extended.*; import com.oracle.max.graal.nodes.loop.*; import com.sun.cri.ci.*; diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/Util.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/Util.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/Util.java Wed Aug 10 01:12:36 2011 +0200 @@ -26,8 +26,7 @@ import com.oracle.max.graal.compiler.*; import com.oracle.max.graal.compiler.debug.*; -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; import com.sun.cri.ci.*; import com.sun.cri.ri.*; @@ -57,7 +56,7 @@ } public static RuntimeException shouldNotReachHere(String msg) { - throw new InternalError("Should not reach here: " + msg); + throw new InternalError("should not reach here: " + msg); } public static boolean replaceInList(T a, T b, List list) { @@ -413,27 +412,4 @@ } return false; } - - /** - * Converts a given instruction to a value string. The representation of an instruction as - * a value is formed by concatenating the {@linkplain com.sun.cri.ci.CiKind#typeChar character} denoting its - * {@linkplain ValueNode#kind kind} and its {@linkplain ValueNode#id()}. For example, {@code "i13"}. - * - * @param value the instruction to convert to a value string. If {@code value == null}, then "-" is returned. - * @return the instruction representation as a string - */ - public static String valueString(ValueNode value) { - return (value == null) ? "-" : ("" + value.kind.typeChar + value.id()); - } - - @SuppressWarnings("unchecked") - public static Collection filter(Iterable nodes, Class clazz) { - ArrayList phis = new ArrayList(); - for (Node node : nodes) { - if (clazz.isInstance(node)) { - phis.add((T) node); - } - } - return phis; - } } diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/value/FrameStateAccess.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/value/FrameStateAccess.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -/* - * 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.value; - -import com.oracle.max.graal.nodes.base.*; - -public interface FrameStateAccess { - - FrameState duplicate(int newBci); - - int localsSize(); - - int stackSize(); - - int locksSize(); - - boolean rethrowException(); - - ValueNode valueAt(int i); - - ValueNode localAt(int i); - - ValueNode lockAt(int i); - - ValueNode stackAt(int i); - - void setValueAt(int j, ValueNode v); - - void setRethrowException(boolean b); - - ValueNode outerFrameState(); - - FrameState duplicateWithException(int bci, ValueNode exceptionObject); - -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/value/FrameStateBuilder.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/value/FrameStateBuilder.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/value/FrameStateBuilder.java Wed Aug 10 01:12:36 2011 +0200 @@ -22,14 +22,15 @@ */ package com.oracle.max.graal.compiler.value; -import static com.oracle.max.graal.compiler.value.ValueUtil.*; +import static com.oracle.max.graal.nodes.ValueUtil.*; import static java.lang.reflect.Modifier.*; import java.util.*; import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.base.PhiNode.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.PhiNode.PhiType; +import com.oracle.max.graal.nodes.spi.*; import com.sun.cri.ci.*; import com.sun.cri.ri.*; diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/value/ValueUtil.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/value/ValueUtil.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,84 +0,0 @@ -/* - * 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.value; - -import com.oracle.max.graal.compiler.util.*; -import com.oracle.max.graal.nodes.base.*; -import com.sun.cri.ci.*; - - -public class ValueUtil { - - public static ValueNode assertKind(CiKind kind, ValueNode x) { - assert x != null && (x.kind == kind) : "kind=" + kind + ", value=" + x + ((x == null) ? "" : ", value.kind=" + x.kind); - return x; - } - - public static ValueNode assertLong(ValueNode x) { - assert x != null && (x.kind == CiKind.Long); - return x; - } - - public static ValueNode assertJsr(ValueNode x) { - assert x != null && (x.kind == CiKind.Jsr); - return x; - } - - public static ValueNode assertInt(ValueNode x) { - assert x != null && (x.kind == CiKind.Int); - return x; - } - - public static ValueNode assertFloat(ValueNode x) { - assert x != null && (x.kind == CiKind.Float); - return x; - } - - public static ValueNode assertObject(ValueNode x) { - assert x != null && (x.kind == CiKind.Object); - return x; - } - - public static ValueNode assertWord(ValueNode x) { - assert x != null && (x.kind == CiKind.Word); - return x; - } - - public static ValueNode assertDouble(ValueNode x) { - assert x != null && (x.kind == CiKind.Double); - return x; - } - - public static void assertHigh(ValueNode x) { - assert x == null; - } - - public static boolean typeMismatch(ValueNode x, ValueNode y) { - return y == null || !Util.archKindsEqual(x, y); - } - - public static boolean isDoubleWord(ValueNode x) { - return x != null && x.kind.isDoubleWord(); - } - -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/extensions/FrameModifier.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/extensions/FrameModifier.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2011, 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.extensions; - -import com.sun.cri.ci.*; -import com.sun.cri.ri.*; - - -public interface FrameModifier { - CiFrame getFrame(RiRuntime runtime, CiFrame frame); -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/extensions/InliningGuide.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/extensions/InliningGuide.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2011, 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.extensions; - -import com.sun.cri.ri.*; - - -public interface InliningGuide { - InliningHint getHint(int depth, RiMethod caller, int bci, RiMethod target); -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/extensions/InliningHint.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/extensions/InliningHint.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2011, 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.extensions; - - -public enum InliningHint { - NONE, - NEVER, - LESS, - MORE, - ALWAYS -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/extensions/Intrinsifier.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/extensions/Intrinsifier.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2011, 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.extensions; - -import java.util.*; - -import com.oracle.max.graal.graph.*; -import com.sun.cri.ri.*; - - -public interface Intrinsifier { - Graph intrinsicGraph(RiRuntime runtime, RiMethod caller, int bci, RiMethod method, List parameters); -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/extensions/Optimizer.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/extensions/Optimizer.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2011, 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.extensions; - -import com.oracle.max.graal.graph.*; -import com.sun.cri.ri.*; - - -public interface Optimizer { - void optimize(RiRuntime runtime, Graph graph); -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/AnchorNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/AnchorNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.base; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - -/** - * The {@code Anchor} instruction represents the end of a block with an unconditional jump to another block. - */ -public final class AnchorNode extends FixedWithNextNode { - - @Input private final NodeInputList guards = new NodeInputList(this); - - public AnchorNode(Graph graph) { - super(CiKind.Illegal, graph); - } - - public void addGuard(GuardNode x) { - guards.add(x); - } - - @Override - public void accept(ValueVisitor v) { - v.visitAnchor(this); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/BooleanNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/BooleanNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -/* - * 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.nodes.base; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.calc.*; -import com.sun.cri.ci.*; - - -public abstract class BooleanNode extends FloatingNode { - - public BooleanNode(CiKind kind, Graph graph) { - super(kind, graph); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/CastNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/CastNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -/* - * 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.nodes.base; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.calc.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - - -public final class CastNode extends FloatingNode { - @Input private ValueNode value; - - public ValueNode value() { - return value; - } - - public void setValue(ValueNode x) { - updateUsages(value, x); - value = x; - } - - public CastNode(CiKind kind, ValueNode n, Graph graph) { - super(kind, graph); - setValue(n); - } - - @Override - public void accept(ValueVisitor v) { - } - - - @SuppressWarnings("unchecked") - @Override - public T lookup(Class clazz) { - if (clazz == LIRGeneratorOp.class) { - return (T) new LIRGeneratorOp() { - @Override - public void generate(Node n, LIRGeneratorTool generator) { - CastNode conv = (CastNode) n; - conv.setOperand(generator.load(conv.value())); - } - }; - } - return super.lookup(clazz); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/ConstantNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/ConstantNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,180 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.base; - -import static com.oracle.max.graal.compiler.GraalCompilation.*; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; -import com.sun.cri.ri.*; - -/** - * The {@code Constant} instruction represents a constant such as an integer value, - * long, float, object reference, address, etc. - */ -public final class ConstantNode extends BooleanNode { - - @Data public final CiConstant value; - - /** - * Constructs a new instruction representing the specified constant. - * @param value the constant - * @param graph - */ - public ConstantNode(CiConstant value, Graph graph) { - super(value.kind.stackKind(), graph); - this.value = value; - } - - @Override - public void accept(ValueVisitor v) { - v.visitConstant(this); - } - - /** - * Creates an instruction for a double constant. - * @param d the double value for which to create the instruction - * @param graph - * @return an instruction representing the double - */ - public static ConstantNode forDouble(double d, Graph graph) { - return new ConstantNode(CiConstant.forDouble(d), graph); - } - - /** - * Creates an instruction for a float constant. - * @param f the float value for which to create the instruction - * @return an instruction representing the float - */ - public static ConstantNode forFloat(float f, Graph graph) { - return new ConstantNode(CiConstant.forFloat(f), graph); - } - - /** - * Creates an instruction for an long constant. - * @param i the long value for which to create the instruction - * @return an instruction representing the long - */ - public static ConstantNode forLong(long i, Graph graph) { - return new ConstantNode(CiConstant.forLong(i), graph); - } - - /** - * Creates an instruction for an integer constant. - * @param i the integer value for which to create the instruction - * @return an instruction representing the integer - */ - public static ConstantNode forInt(int i, Graph graph) { - return new ConstantNode(CiConstant.forInt(i), graph); - } - - /** - * Creates an instruction for a boolean constant. - * @param i the boolean value for which to create the instruction - * @return an instruction representing the boolean - */ - public static ConstantNode forBoolean(boolean i, Graph graph) { - return new ConstantNode(CiConstant.forBoolean(i), graph); - } - - /** - * Creates an instruction for an address (jsr/ret address) constant. - * @param i the address value for which to create the instruction - * @return an instruction representing the address - */ - public static ConstantNode forJsr(int i, Graph graph) { - return new ConstantNode(CiConstant.forJsr(i), graph); - } - - /** - * Creates an instruction for an object constant. - * @param o the object value for which to create the instruction - * @return an instruction representing the object - */ - public static ConstantNode forObject(Object o, Graph graph) { - return new ConstantNode(CiConstant.forObject(o), graph); - } - - /** - * Creates an instruction for a word constant. - * @param val the word value for which to create the instruction - * @return an instruction representing the word - */ - public static ConstantNode forWord(long val, Graph graph) { - return new ConstantNode(CiConstant.forWord(val), graph); - } - - public static ConstantNode defaultForKind(CiKind kind, Graph graph) { - switch(kind) { - case Boolean: - return ConstantNode.forBoolean(false, graph); - case Byte: - case Char: - case Short: - case Int: - return ConstantNode.forInt(0, graph); - case Double: - return ConstantNode.forDouble(0.0, graph); - case Float: - return ConstantNode.forFloat(0.0f, graph); - case Long: - return ConstantNode.forLong(0L, graph); - case Object: - return ConstantNode.forObject(null, graph); - case Word: - return ConstantNode.forWord(0L, graph); - default: - return null; - } - } - - @Override - public String toString() { - return super.toString() + "(" + value + ")"; - } - - @Override - public int valueNumber() { - return 0x50000000 | value.hashCode(); - } - - @Override - public RiType declaredType() { - RiRuntime runtime = compilation().runtime; - if (kind.isPrimitive()) { - return runtime.asRiType(kind); - } - return runtime.getTypeOf(asConstant()); - } - - @Override - public RiType exactType() { - return declaredType(); - } - - @Override - public String shortName() { - return value.name(); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/ControlSplitNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/ControlSplitNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.base; - -import java.util.*; - -import com.oracle.max.graal.graph.*; -import com.sun.cri.ci.*; - -/** - * The {@code BlockEnd} instruction is a base class for all instructions that end a basic - * block, including branches, switches, throws, and goto's. - */ -public abstract class ControlSplitNode extends FixedNode { - - @Successor private final NodeSuccessorList blockSuccessors; - - public FixedNode blockSuccessor(int index) { - return blockSuccessors.get(index); - } - - public void setBlockSuccessor(int index, FixedNode x) { - blockSuccessors.set(index, x); - } - - public int blockSuccessorCount() { - return blockSuccessors.size(); - } - - protected final double[] branchProbability; - - /** - * Constructs a new block end with the specified value type. - * @param kind the type of the value produced by this instruction - * @param successors the list of successor blocks. If {@code null}, a new one will be created. - */ - public ControlSplitNode(CiKind kind, List blockSuccessors, double[] branchProbability, Graph graph) { - this(kind, blockSuccessors.size(), branchProbability, graph); - for (int i = 0; i < blockSuccessors.size(); i++) { - setBlockSuccessor(i, blockSuccessors.get(i)); - } - } - - public ControlSplitNode(CiKind kind, int blockSuccessorCount, double[] branchProbability, Graph graph) { - super(kind, graph); - this.blockSuccessors = new NodeSuccessorList(this, blockSuccessorCount); - assert branchProbability.length == blockSuccessorCount; - this.branchProbability = branchProbability; - } - - public double probability(int successorIndex) { - return branchProbability[successorIndex]; - } - - public void setProbability(int successorIndex, double x) { - branchProbability[successorIndex] = x; - } - - /** - * Gets the successor corresponding to the default (fall through) case. - * @return the default successor - */ - public FixedNode defaultSuccessor() { - return blockSuccessor(blockSuccessorCount() - 1); - } - - public Iterable blockSuccessors() { - return new Iterable() { - @Override - public Iterator iterator() { - return new Iterator() { - int i = 0; - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - @Override - public FixedNode next() { - return ControlSplitNode.this.blockSuccessor(i++); - } - - @Override - public boolean hasNext() { - return i < ControlSplitNode.this.blockSuccessorCount(); - } - }; - } - }; - } - - @Override - public Map getDebugProperties() { - Map properties = super.getDebugProperties(); - StringBuilder str = new StringBuilder(); - for (int i = 0; i < branchProbability.length; i++) { - str.append(i == 0 ? "" : ", ").append(String.format("%7.5f", branchProbability[i])); - } - properties.put("branchProbability", str.toString()); - return properties; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/DeoptimizeNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/DeoptimizeNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.base; - -import java.util.*; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - -@NodeInfo(shortName = "Deopt") -public class DeoptimizeNode extends FixedNode { - - public static enum DeoptAction { - None, // just interpret, do not invalidate nmethod - Recompile, // recompile the nmethod; need not invalidate - InvalidateReprofile, // invalidate the nmethod, reset IC, maybe recompile - InvalidateRecompile, // invalidate the nmethod, recompile (probably) - InvalidateStopCompiling, // invalidate the nmethod and do not compile - } - - private String message; - private final DeoptAction action; - - public DeoptimizeNode(DeoptAction action, Graph graph) { - super(CiKind.Illegal, graph); - this.action = action; - } - - public void setMessage(String message) { - this.message = message; - } - - public String message() { - return message; - } - - public DeoptAction action() { - return action; - } - - @Override - public void accept(ValueVisitor v) { - v.visitDeoptimize(this); - } - - @Override - public Map getDebugProperties() { - Map properties = super.getDebugProperties(); - properties.put("message", message); - properties.put("action", action); - return properties; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/EndNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/EndNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ -/* - * 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.nodes.base; - -import java.util.*; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - - -public final class EndNode extends FixedNode { - - public EndNode(Graph graph) { - super(CiKind.Illegal, graph); - } - - @Override - public void accept(ValueVisitor v) { - v.visitEndNode(this); - } - - public MergeNode merge() { - if (usages().size() == 0) { - return null; - } else { - assert usages().size() == 1; - return (MergeNode) usages().iterator().next(); - } - } - - @Override - public boolean verify() { - assertTrue(usages().size() <= 1, "at most one usage"); - return true; - } - - @Override - public Iterable< ? extends Node> dataUsages() { - return Collections.emptyList(); - } - - @Override - public Iterable< ? extends Node> cfgSuccessors() { - MergeNode merge = this.merge(); - if (merge == null) { - return Collections.emptyList(); - } - return Arrays.asList(merge); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/FixedGuardNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/FixedGuardNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -/* - * 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.nodes.base; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.DeoptimizeNode.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - -public final class FixedGuardNode extends FixedWithNextNode implements Canonicalizable { - - @Input private final NodeInputList conditions = new NodeInputList(this); - - public FixedGuardNode(BooleanNode node, Graph graph) { - this(graph); - addNode(node); - } - - public FixedGuardNode(Graph graph) { - super(CiKind.Illegal, graph); - } - - @Override - public void accept(ValueVisitor v) { - v.visitFixedGuard(this); - } - - public void addNode(BooleanNode x) { - conditions.add(x); - } - - @Override - public Node canonical(NotifyReProcess reProcess) { - for (BooleanNode n : conditions.snapshot()) { - if (n instanceof ConstantNode) { - ConstantNode c = (ConstantNode) n; - if (c.asConstant().asBoolean()) { - conditions.remove(n); - } else { - return new DeoptimizeNode(DeoptAction.InvalidateRecompile, graph()); - } - } - } - - if (conditions.isEmpty()) { - return next(); - } - return this; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/FixedNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/FixedNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* - * 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.nodes.base; - -import java.util.*; - -import com.oracle.max.graal.graph.*; -import com.sun.cri.ci.*; - -public abstract class FixedNode extends ValueNode { - - private double probability; - - public FixedNode(CiKind kind, Graph graph) { - super(kind, graph); - } - - public double probability() { - return probability; - } - - public void setProbability(double probability) { - this.probability = probability; - } - - protected void copyInto(FixedNode newNode) { - newNode.setProbability(probability); - } - - @Override - public Map getDebugProperties() { - Map properties = super.getDebugProperties(); - properties.put("probability", String.format(Locale.ENGLISH, "%7.5f", probability)); - return properties; - } - -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/FixedWithNextNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/FixedWithNextNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2009, 2010, 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.nodes.base; - -import com.oracle.max.graal.graph.*; -import com.sun.cri.ci.*; - -public abstract class FixedWithNextNode extends FixedNode { - - @Successor private FixedNode next; - - public FixedNode next() { - return next; - } - - public void setNext(FixedNode x) { - updatePredecessors(next, x); - next = x; - } - - public static final int SYNCHRONIZATION_ENTRY_BCI = -1; - - /** - * Constructs a new instruction with the specified value type. - * @param kind the value type for this instruction - */ - public FixedWithNextNode(CiKind kind, Graph graph) { - super(kind, graph); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/FrameState.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/FrameState.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,674 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.base; - -import static com.oracle.max.graal.compiler.value.ValueUtil.*; - -import java.util.*; - -import com.oracle.max.graal.compiler.value.*; -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.PhiNode.*; -import com.oracle.max.graal.nodes.calc.*; -import com.oracle.max.graal.nodes.spi.*; -import com.oracle.max.graal.nodes.virtual.*; -import com.sun.cri.ci.*; -import com.sun.cri.ri.*; - -/** - * The {@code FrameState} class encapsulates the frame state (i.e. local variables and - * operand stack) at a particular point in the abstract interpretation. - */ -public final class FrameState extends ValueNode implements FrameStateAccess { - - protected final int localsSize; - - protected final int stackSize; - - protected final int locksSize; - - private boolean rethrowException; - - public static final int BEFORE_BCI = -2; - public static final int AFTER_BCI = -3; - - @Input private FrameState outerFrameState; - - @Input private final NodeInputList values; - - @Input private final NodeInputList virtualObjectMappings; - - public FrameState outerFrameState() { - return outerFrameState; - } - - public void setOuterFrameState(FrameState x) { - updateUsages(this.outerFrameState, x); - this.outerFrameState = x; - } - - @Override - public void setValueAt(int i, ValueNode x) { - values.set(i, x); - } - - /** - * The bytecode index to which this frame state applies. This will be {@code -1} - * iff this state is mutable. - */ - public final int bci; - - public final RiMethod method; - - /** - * Creates a {@code FrameState} for the given scope and maximum number of stack and local variables. - * - * @param bci the bytecode index of the frame state - * @param localsSize number of locals - * @param stackSize size of the stack - * @param lockSize number of locks - */ - public FrameState(RiMethod method, int bci, int localsSize, int stackSize, int locksSize, boolean rethrowException, Graph graph) { - super(CiKind.Illegal, graph); - this.method = method; - this.bci = bci; - this.localsSize = localsSize; - this.stackSize = stackSize; - this.locksSize = locksSize; - this.values = new NodeInputList(this, localsSize + stackSize + locksSize); - this.virtualObjectMappings = new NodeInputList(this); - this.rethrowException = rethrowException; - //GraalMetrics.FrameStatesCreated++; - //GraalMetrics.FrameStateValuesCreated += localsSize + stackSize + locksSize; - } - - public FrameState(RiMethod method, int bci, ValueNode[] locals, ValueNode[] stack, int stackSize, ArrayList locks, boolean rethrowException, Graph graph) { - this(method, bci, locals.length, stackSize, locks.size(), rethrowException, graph); - for (int i = 0; i < locals.length; i++) { - setValueAt(i, locals[i]); - } - for (int i = 0; i < stackSize; i++) { - setValueAt(localsSize + i, stack[i]); - } - for (int i = 0; i < locks.size(); i++) { - setValueAt(locals.length + stackSize + i, locks.get(i)); - } - } - - public boolean rethrowException() { - return rethrowException; - } - - public RiMethod method() { - return method; - } - - public void addVirtualObjectMapping(Node virtualObject) { - assert virtualObject instanceof VirtualObjectFieldNode || virtualObject instanceof PhiNode : virtualObject; - virtualObjectMappings.add(virtualObject); - } - - public int virtualObjectMappingCount() { - return virtualObjectMappings.size(); - } - - public Node virtualObjectMappingAt(int i) { - return virtualObjectMappings.get(i); - } - - public Iterable virtualObjectMappings() { - return virtualObjectMappings; - } - - /** - * Gets a copy of this frame state. - */ - public FrameState duplicate(int bci) { - return duplicate(bci, false); - } - - public FrameState duplicate(int bci, boolean duplicateOuter) { - FrameState other = new FrameState(method, bci, localsSize, stackSize, locksSize, rethrowException, graph()); - other.values.setAll(values); - other.virtualObjectMappings.setAll(virtualObjectMappings); - FrameState outerFrameState = outerFrameState(); - if (duplicateOuter && outerFrameState != null) { - outerFrameState = outerFrameState.duplicate(outerFrameState.bci, duplicateOuter); - } - other.setOuterFrameState(outerFrameState); - return other; - } - - @Override - public FrameState duplicateWithException(int bci, ValueNode exceptionObject) { - return duplicateModified(bci, true, CiKind.Void, exceptionObject); - } - - /** - * Creates a copy of this frame state with one stack element of type popKind popped from the stack and the - * values in pushedValues pushed on the stack. The pushedValues are expected to be in slot encoding: a long - * or double is followed by a null slot. - */ - public FrameState duplicateModified(int bci, boolean rethrowException, CiKind popKind, ValueNode... pushedValues) { - int popSlots = popKind.sizeInSlots(); - int pushSlots = pushedValues.length; - FrameState other = new FrameState(method, bci, localsSize, stackSize - popSlots + pushSlots, locksSize(), rethrowException, graph()); - for (int i = 0; i < localsSize; i++) { - other.setValueAt(i, localAt(i)); - } - for (int i = 0; i < stackSize - popSlots; i++) { - other.setValueAt(localsSize + i, stackAt(i)); - } - int slot = localsSize + stackSize - popSlots; - for (int i = 0; i < pushSlots; i++) { - other.setValueAt(slot++, pushedValues[i]); - } - for (int i = 0; i < locksSize; i++) { - other.setValueAt(localsSize + other.stackSize + i, lockAt(i)); - } - other.virtualObjectMappings.setAll(virtualObjectMappings); - other.setOuterFrameState(outerFrameState()); - return other; - } - - public boolean isCompatibleWith(FrameStateAccess other) { - if (stackSize() != other.stackSize() || localsSize() != other.localsSize() || locksSize() != other.locksSize()) { - return false; - } - for (int i = 0; i < stackSize(); i++) { - ValueNode x = stackAt(i); - ValueNode y = other.stackAt(i); - if (x != y && typeMismatch(x, y)) { - return false; - } - } - for (int i = 0; i < locksSize(); i++) { - if (lockAt(i) != other.lockAt(i)) { - return false; - } - } - if (other.outerFrameState() != outerFrameState()) { - return false; - } - return true; - } - - public boolean equals(FrameStateAccess other) { - if (stackSize() != other.stackSize() || localsSize() != other.localsSize() || locksSize() != other.locksSize()) { - return false; - } - for (int i = 0; i < stackSize(); i++) { - ValueNode x = stackAt(i); - ValueNode y = other.stackAt(i); - if (x != y) { - return false; - } - } - for (int i = 0; i < locksSize(); i++) { - if (lockAt(i) != other.lockAt(i)) { - return false; - } - } - if (other.outerFrameState() != outerFrameState()) { - return false; - } - return true; - } - - /** - * Gets the size of the local variables. - */ - public int localsSize() { - return localsSize; - } - - /** - * Gets the current size (height) of the stack. - */ - public int stackSize() { - return stackSize; - } - - /** - * Gets number of locks held by this frame state. - */ - public int locksSize() { - return locksSize; - } - - /** - * Invalidates the local variable at the specified index. If the specified index refers to a doubleword local, then - * invalidates the high word as well. - * - * @param i the index of the local to invalidate - */ - public void invalidateLocal(int i) { - // note that for double word locals, the high slot should already be null - // unless the local is actually dead and the high slot is being reused; - // in either case, it is not necessary to null the high slot - setValueAt(i, null); - } - - /** - * Stores a given local variable at the specified index. If the value is a {@linkplain CiKind#isDoubleWord() double word}, - * then the next local variable index is also overwritten. - * - * @param i the index at which to store - * @param x the instruction which produces the value for the local - */ - public void storeLocal(int i, ValueNode x) { - assert i < localsSize : "local variable index out of range: " + i; - invalidateLocal(i); - setValueAt(i, x); - if (isDoubleWord(x)) { - // (tw) if this was a double word then kill i+1 - setValueAt(i + 1, null); - } - if (i > 0) { - // if there was a double word at i - 1, then kill it - ValueNode p = localAt(i - 1); - if (isDoubleWord(p)) { - setValueAt(i - 1, null); - } - } - } - - /** - * Gets the value in the local variables at the specified index. - * - * @param i the index into the locals - * @return the instruction that produced the value for the specified local - */ - public ValueNode localAt(int i) { - assert i < localsSize : "local variable index out of range: " + i; - return valueAt(i); - } - - /** - * Get the value on the stack at the specified stack index. - * - * @param i the index into the stack, with {@code 0} being the bottom of the stack - * @return the instruction at the specified position in the stack - */ - public ValueNode stackAt(int i) { - assert i >= 0 && i < (localsSize + stackSize); - return valueAt(localsSize + i); - } - - /** - * Retrieves the lock at the specified index in the lock stack. - * @param i the index into the lock stack - * @return the instruction which produced the object at the specified location in the lock stack - */ - public ValueNode lockAt(int i) { - assert i >= 0; - return valueAt(localsSize + stackSize + i); - } - - /** - * Inserts a phi statement into the stack at the specified stack index. - * @param block the block begin for which we are creating the phi - * @param i the index into the stack for which to create a phi - */ - public PhiNode setupPhiForStack(MergeNode block, int i) { - ValueNode p = stackAt(i); - if (p != null) { - if (p instanceof PhiNode) { - PhiNode phi = (PhiNode) p; - if (phi.merge() == block) { - return phi; - } - } - PhiNode phi = new PhiNode(p.kind, block, PhiType.Value, graph()); - setValueAt(localsSize + i, phi); - return phi; - } - return null; - } - - /** - * Inserts a phi statement for the local at the specified index. - * @param block the block begin for which we are creating the phi - * @param i the index of the local variable for which to create the phi - */ - public PhiNode setupPhiForLocal(MergeNode block, int i) { - ValueNode p = localAt(i); - if (p instanceof PhiNode) { - PhiNode phi = (PhiNode) p; - if (phi.merge() == block) { - return phi; - } - } - PhiNode phi = new PhiNode(p.kind, block, PhiType.Value, graph()); - storeLocal(i, phi); - return phi; - } - - /** - * Gets the value at a specified index in the set of operand stack and local values represented by this frame. - * This method should only be used to iterate over all the values in this frame, irrespective of whether - * they are on the stack or in local variables. - * To iterate the stack slots, the {@link #stackAt(int)} and {@link #stackSize()} methods should be used. - * To iterate the local variables, the {@link #localAt(int)} and {@link #localsSize()} methods should be used. - * - * @param i a value in the range {@code [0 .. valuesSize()]} - * @return the value at index {@code i} which may be {@code null} - */ - public ValueNode valueAt(int i) { - assert i < (localsSize + stackSize + locksSize); - return values.isEmpty() ? null : values.get(i); - } - - /** - * The number of operand stack slots and local variables in this frame. - * This method should typically only be used in conjunction with {@link #valueAt(int)}. - * To iterate the stack slots, the {@link #stackAt(int)} and {@link #stackSize()} methods should be used. - * To iterate the local variables, the {@link #localAt(int)} and {@link #localsSize()} methods should be used. - * - * @return the number of local variables in this frame - */ - public int valuesSize() { - return localsSize + stackSize; - } - - private void checkSize(FrameStateAccess other) { - if (other.stackSize() != stackSize()) { - throw new CiBailout("stack sizes do not match"); - } else if (other.localsSize() != localsSize) { - throw new CiBailout("local sizes do not match"); - } - } - - public void merge(MergeNode block, FrameStateAccess other) { - checkSize(other); - for (int i = 0; i < valuesSize(); i++) { - ValueNode x = valueAt(i); - if (x != null) { - ValueNode y = other.valueAt(i); - if (x != y || ((x instanceof PhiNode) && ((PhiNode) x).merge() == block)) { - if (typeMismatch(x, y)) { - if ((x instanceof PhiNode) && ((PhiNode) x).merge() == block) { - x.replaceAtUsages(null); - x.delete(); - } - setValueAt(i, null); - continue; - } - PhiNode phi = null; - if (i < localsSize) { - // this a local - phi = setupPhiForLocal(block, i); - } else { - // this is a stack slot - phi = setupPhiForStack(block, i - localsSize); - } - - if (phi.valueCount() == 0) { - int size = block.phiPredecessorCount(); - for (int j = 0; j < size; ++j) { - phi.addInput(x); - } - phi.addInput((x == y) ? phi : y); - } else { - phi.addInput((x == y) ? phi : y); - } - - assert phi.valueCount() == block.phiPredecessorCount() + (block instanceof LoopBeginNode ? 0 : 1) : "valueCount=" + phi.valueCount() + " predSize= " + block.phiPredecessorCount(); - } - } - } - } - - public MergeNode block() { - for (Node n : usages()) { - if (n instanceof MergeNode) { - return (MergeNode) n; - } - } - return null; - } - - public StateSplit stateSplit() { - for (Node n : usages()) { - if (n instanceof StateSplit) { - return (StateSplit) n; - } - } - return null; - } - - public Iterable innerFrameStates() { - final Iterator iterator = usages().iterator(); - return new Iterable() { - @Override - public Iterator iterator() { - return new Iterator() { - private Node next; - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - @Override - public FrameState next() { - forward(); - if (!hasNext()) { - throw new NoSuchElementException(); - } - FrameState res = (FrameState) next; - next = null; - return res; - } - @Override - public boolean hasNext() { - forward(); - return next != null; - } - private void forward() { - while (!(next instanceof FrameState) && iterator.hasNext()) { - next = iterator.next(); - } - } - }; - } - }; - } - - /** - * The interface implemented by a client of {@link FrameState#forEachPhi(MergeNode, PhiProcedure)} and - * {@link FrameState#forEachLivePhi(MergeNode, PhiProcedure)}. - */ - public static interface PhiProcedure { - boolean doPhi(PhiNode phi); - } - - /** - * Checks whether this frame state has any {@linkplain PhiNode phi} statements. - */ - public boolean hasPhis() { - for (int i = 0; i < valuesSize(); i++) { - ValueNode value = valueAt(i); - if (value instanceof PhiNode) { - return true; - } - } - return false; - } - - /** - * The interface implemented by a client of {@link FrameState#forEachLiveStateValue(ValueProcedure)}. - */ - public static interface ValueProcedure { - void doValue(ValueNode value); - } - - /** - * Traverses all {@linkplain ValueNode#isLive() live values} of this frame state. - * - * @param proc the call back called to process each live value traversed - */ - public void forEachLiveStateValue(ValueProcedure proc) { - HashSet vobjs = null; - FrameState current = this; - do { - for (int i = 0; i < current.valuesSize(); i++) { - ValueNode value = current.valueAt(i); - if (value instanceof VirtualObjectNode) { - if (vobjs == null) { - vobjs = new HashSet(); - } - vobjs.add((VirtualObjectNode) value); - } else if (value != null) { - proc.doValue(value); - } - } - current = current.outerFrameState(); - } while (current != null); - - if (vobjs != null) { - // collect all VirtualObjectField instances: - HashMap objectStates = new HashMap(); - current = this; - do { - for (int i = 0; i < current.virtualObjectMappingCount(); i++) { - VirtualObjectFieldNode field = (VirtualObjectFieldNode) current.virtualObjectMappingAt(i); - // null states occur for objects with 0 fields - if (field != null && !objectStates.containsKey(field.object())) { - objectStates.put(field.object(), field); - } - } - current = current.outerFrameState(); - } while (current != null); - - do { - HashSet vobjsCopy = new HashSet(vobjs); - for (VirtualObjectNode vobj : vobjsCopy) { - if (vobj.fields().length > 0) { - boolean[] fieldState = new boolean[vobj.fields().length]; - FloatingNode currentField = objectStates.get(vobj); - assert currentField != null : this; - do { - if (currentField instanceof VirtualObjectFieldNode) { - int index = ((VirtualObjectFieldNode) currentField).index(); - ValueNode value = ((VirtualObjectFieldNode) currentField).input(); - if (!fieldState[index]) { - fieldState[index] = true; - if (value instanceof VirtualObjectNode) { - vobjs.add((VirtualObjectNode) value); - } else { - proc.doValue(value); - } - } - currentField = ((VirtualObjectFieldNode) currentField).lastState(); - } else { - assert currentField instanceof PhiNode : currentField; - currentField = (FloatingNode) ((PhiNode) currentField).valueAt(0); - } - } while (currentField != null); - } - vobjs.remove(vobj); - } - } while (!vobjs.isEmpty()); - assert vobjs.isEmpty() : "at FrameState " + this; - } - } - - @Override - public String toString() { - return super.toString(); - } - - public String toDetailedString() { - StringBuilder sb = new StringBuilder(); - String nl = String.format("%n"); - sb.append("[bci: ").append(bci).append("]"); - if (rethrowException()) { - sb.append(" rethrows Exception"); - } - sb.append(nl); - for (int i = 0; i < localsSize(); ++i) { - ValueNode value = localAt(i); - sb.append(String.format(" local[%d] = %-8s : %s%n", i, value == null ? "bogus" : value.kind.javaName, value)); - } - for (int i = 0; i < stackSize(); ++i) { - ValueNode value = stackAt(i); - sb.append(String.format(" stack[%d] = %-8s : %s%n", i, value == null ? "bogus" : value.kind.javaName, value)); - } - for (int i = 0; i < locksSize(); ++i) { - ValueNode value = lockAt(i); - sb.append(String.format(" lock[%d] = %-8s : %s%n", i, value == null ? "bogus" : value.kind.javaName, value)); - } - return sb.toString(); - } - - @Override - public void accept(ValueVisitor v) { - v.visitFrameState(this); - } - - @Override - public String shortName() { - return "FrameState@" + bci; - } - - public void visitFrameState(FrameState i) { - // nothing to do for now - } - - @Override - public Map getDebugProperties() { - Map properties = super.getDebugProperties(); - properties.put("bci", bci); - properties.put("method", CiUtil.format("%H.%n(%p):%r", method, false)); - StringBuilder str = new StringBuilder(); - for (int i = 0; i < localsSize(); i++) { - str.append(i == 0 ? "" : ", ").append(localAt(i) == null ? "_" : localAt(i).id()); - } - properties.put("locals", str.toString()); - str = new StringBuilder(); - for (int i = 0; i < stackSize(); i++) { - str.append(i == 0 ? "" : ", ").append(stackAt(i) == null ? "_" : stackAt(i).id()); - } - properties.put("stack", str.toString()); - str = new StringBuilder(); - for (int i = 0; i < locksSize(); i++) { - str.append(i == 0 ? "" : ", ").append(lockAt(i) == null ? "_" : lockAt(i).id()); - } - properties.put("locks", str.toString()); - properties.put("rethrowException", rethrowException); - return properties; - } - - @Override - public void delete() { - FrameState outerFrameState = outerFrameState(); - super.delete(); - if (outerFrameState != null && outerFrameState.usages().isEmpty()) { - outerFrameState.delete(); - } - } - - @Override - public void setRethrowException(boolean b) { - rethrowException = b; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/GuardNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/GuardNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -/* - * 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.nodes.base; - -import com.oracle.max.graal.compiler.*; -import com.oracle.max.graal.compiler.debug.*; -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.calc.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - -public final class GuardNode extends FloatingNode implements Canonicalizable { - - @Input private FixedNode anchor; - @Input private BooleanNode node; - - public FixedNode anchor() { - return anchor; - } - - public void setAnchor(FixedNode x) { - updateUsages(anchor, x); - anchor = x; - } - - /** - * The instruction that produces the tested boolean value. - */ - public BooleanNode node() { - return node; - } - - public void setNode(BooleanNode x) { - updateUsages(node, x); - node = x; - } - - public GuardNode(BooleanNode node, Graph graph) { - super(CiKind.Illegal, graph); - setNode(node); - } - - @Override - public void accept(ValueVisitor v) { - v.visitGuardNode(this); - } - - @Override - public Node canonical(NotifyReProcess reProcess) { - if (node() instanceof ConstantNode) { - ConstantNode c = (ConstantNode) node(); - if (c.asConstant().asBoolean()) { - if (GraalOptions.TraceCanonicalizer) { - TTY.println("Removing redundant floating guard " + this); - } - return Node.Null; - } - } - return this; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/IfNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/IfNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.base; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - -/** - * The {@code If} instruction represents a branch that can go one of two directions depending on the outcome of a - * comparison. - */ -public final class IfNode extends ControlSplitNode implements Canonicalizable { - - @Input private BooleanNode compare; - - public BooleanNode compare() { - return compare; - } - - public void setCompare(BooleanNode x) { - updateUsages(compare, x); - compare = x; - } - - public IfNode(BooleanNode condition, double probability, Graph graph) { - super(CiKind.Illegal, 2, new double[] {probability, 1 - probability}, graph); - setCompare(condition); - } - - /** - * Gets the block corresponding to the true successor. - * - * @return the true successor - */ - public FixedNode trueSuccessor() { - return blockSuccessor(0); - } - - /** - * Gets the block corresponding to the false successor. - * - * @return the false successor - */ - public FixedNode falseSuccessor() { - return blockSuccessor(1); - } - - public void setTrueSuccessor(FixedNode node) { - setBlockSuccessor(0, node); - } - - public void setFalseSuccessor(FixedNode node) { - setBlockSuccessor(1, node); - } - - /** - * Gets the block corresponding to the specified outcome of the branch. - * - * @param istrue {@code true} if the true successor is requested, {@code false} otherwise - * @return the corresponding successor - */ - public FixedNode successor(boolean istrue) { - return blockSuccessor(istrue ? 0 : 1); - } - - @Override - public void accept(ValueVisitor v) { - v.visitIf(this); - } - - @Override - public boolean verify() { - assertTrue(compare() != null); - assertTrue(trueSuccessor() != null); - assertTrue(falseSuccessor() != null); - return true; - } - - @Override - public Node canonical(NotifyReProcess reProcess) { - if (compare() instanceof ConstantNode) { - ConstantNode c = (ConstantNode) compare(); - if (c.asConstant().asBoolean()) { - return trueSuccessor(); - } else { - return falseSuccessor(); - } - } - if (trueSuccessor() instanceof EndNode && falseSuccessor() instanceof EndNode) { - EndNode trueEnd = (EndNode) trueSuccessor(); - EndNode falseEnd = (EndNode) falseSuccessor(); - MergeNode merge = trueEnd.merge(); - if (merge == falseEnd.merge() && merge.phis().size() == 0 && merge.endCount() == 2) { - FixedNode next = merge.next(); - merge.setNext(null); // disconnect to avoid next from having 2 preds - return next; - } - } - return this; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/InvokeNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/InvokeNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.base; - -import java.util.*; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.extended.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.bytecode.*; -import com.sun.cri.ci.*; -import com.sun.cri.ri.*; - -/** - * The {@code Invoke} instruction represents all kinds of method calls. - */ -public final class InvokeNode extends AbstractMemoryCheckpointNode implements ExceptionExit { - - @Successor private FixedNode exceptionEdge; - - @Input private final NodeInputList arguments; - - @Override - public FixedNode exceptionEdge() { - return exceptionEdge; - } - - public void setExceptionEdge(FixedNode x) { - updatePredecessors(exceptionEdge, x); - exceptionEdge = x; - } - - private final int argumentCount; - - private boolean canInline = true; - - public boolean canInline() { - return canInline; - } - - public void setCanInline(boolean b) { - canInline = b; - } - - public NodeInputList arguments() { - return arguments; - } - - public final int opcode; - public final RiMethod target; - public final RiType returnType; - public final int bci; // XXX needed because we can not compute the bci from the sateBefore bci of this Invoke was optimized from INVOKEINTERFACE to INVOKESPECIAL - - /** - * Constructs a new Invoke instruction. - * - * @param opcode the opcode of the invoke - * @param result the result type - * @param args the list of instructions producing arguments to the invocation, including the receiver object - * @param isStatic {@code true} if this call is static (no receiver object) - * @param target the target method being called - */ - public InvokeNode(int bci, int opcode, CiKind result, ValueNode[] args, RiMethod target, RiType returnType, Graph graph) { - super(result, graph); - arguments = new NodeInputList(this, args.length); - this.opcode = opcode; - this.target = target; - this.returnType = returnType; - this.bci = bci; - - this.argumentCount = args.length; - for (int i = 0; i < args.length; i++) { - arguments().set(i, args[i]); - } - } - - /** - * Gets the opcode of this invoke instruction. - * @return the opcode - */ - public int opcode() { - return opcode; - } - - /** - * Checks whether this is an invocation of a static method. - * @return {@code true} if the invocation is a static invocation - */ - public boolean isStatic() { - return opcode == Bytecodes.INVOKESTATIC; - } - - @Override - public RiType declaredType() { - return returnType; - } - - /** - * Gets the instruction that produces the receiver object for this invocation, if any. - * @return the instruction that produces the receiver object for this invocation if any, {@code null} if this - * invocation does not take a receiver object - */ - public ValueNode receiver() { - assert !isStatic(); - return arguments().get(0); - } - - /** - * Gets the target method for this invocation instruction. - * @return the target method - */ - public RiMethod target() { - return target; - } - - /** - * Checks whether this invocation has a receiver object. - * @return {@code true} if this invocation has a receiver object; {@code false} otherwise, if this is a - * static call - */ - public boolean hasReceiver() { - return !isStatic(); - } - - @Override - public void accept(ValueVisitor v) { - v.visitInvoke(this); - } - - @Override - public String toString() { - return super.toString() + target; - } - - @Override - public Map getDebugProperties() { - Map properties = super.getDebugProperties(); - properties.put("opcode", Bytecodes.nameOf(opcode)); - properties.put("target", CiUtil.format("%H.%n(%p):%r", target, false)); - properties.put("bci", bci); - return properties; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/LocalNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/LocalNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.base; - -import java.util.*; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.calc.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; -import com.sun.cri.ri.*; - -/** - * The {@code Local} instruction is a placeholder for an incoming argument - * to a function call. - */ -public final class LocalNode extends FloatingNode { - - @Input private StartNode start; - - public StartNode start() { - return start; - } - - public void setStart(StartNode x) { - updateUsages(start, x); - start = x; - } - - private final int index; - private RiType declaredType; - - public LocalNode(CiKind kind, int javaIndex, Graph graph) { - super(kind, graph); - this.index = javaIndex; - setStart(graph.start()); - } - - /** - * Gets the index of this local. - * @return the index - */ - public int index() { - return index; - } - - /** - * Sets the declared type of this local, e.g. derived from the signature of the method. - * @param declaredType the declared type of the local variable - */ - public void setDeclaredType(RiType declaredType) { - this.declaredType = declaredType; - } - - /** - * Computes the declared type of the result of this instruction, if possible. - * @return the declared type of the result of this instruction, if it is known; {@code null} otherwise - */ - @Override - public RiType declaredType() { - return declaredType; - } - - @Override - public void accept(ValueVisitor v) { - v.visitLocal(this); - } - - @Override - public Map getDebugProperties() { - Map properties = super.getDebugProperties(); - properties.put("index", index()); - return properties; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/LoopBeginNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/LoopBeginNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,147 +0,0 @@ -/* - * 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.nodes.base; - -import java.util.*; - -import com.oracle.max.graal.compiler.util.*; -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.loop.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - -public class LoopBeginNode extends MergeNode { - - private double loopFrequency; - - public LoopBeginNode(Graph graph) { - super(graph); - loopFrequency = 1; - } - - public double loopFrequency() { - return loopFrequency; - } - - public void setLoopFrequency(double loopFrequency) { - this.loopFrequency = loopFrequency; - } - - public LoopEndNode loopEnd() { - for (Node usage : usages()) { - if (usage instanceof LoopEndNode) { - LoopEndNode end = (LoopEndNode) usage; - if (end.loopBegin() == this) { - return end; - } - } - } - return null; - } - - @Override - public void accept(ValueVisitor v) { - v.visitLoopBegin(this); - } - - @Override - public int phiPredecessorCount() { - return 2; - } - - @Override - public int phiPredecessorIndex(Node pred) { - if (pred == forwardEdge()) { - return 0; - } else if (pred == this.loopEnd()) { - return 1; - } - throw Util.shouldNotReachHere("unknown pred : " + pred + "(sp=" + forwardEdge() + ", le=" + this.loopEnd() + ")"); - } - - @Override - public Node phiPredecessorAt(int index) { - if (index == 0) { - return forwardEdge(); - } else if (index == 1) { - return loopEnd(); - } - throw Util.shouldNotReachHere(); - } - - public Collection inductionVariables() { - return Util.filter(this.usages(), InductionVariableNode.class); - } - - @Override - public Iterable phiPredecessors() { - return Arrays.asList(new Node[]{this.forwardEdge(), this.loopEnd()}); - } - - public EndNode forwardEdge() { - return this.endAt(0); - } - - public LoopCounterNode loopCounter() { - return loopCounter(CiKind.Long); - } - - public LoopCounterNode loopCounter(CiKind kind) { - for (Node usage : usages()) { - if (usage instanceof LoopCounterNode && ((LoopCounterNode) usage).kind == kind) { - return (LoopCounterNode) usage; - } - } - return new LoopCounterNode(kind, this, graph()); - } - - @Override - public boolean verify() { - assertTrue(loopEnd() != null); - assertTrue(forwardEdge() != null); - return true; - } - - @Override - public String toString() { - return "LoopBegin: " + super.toString(); - } - - @Override - public Iterable< ? extends Node> dataUsages() { - final Iterator< ? extends Node> dataUsages = super.dataUsages().iterator(); - return new Iterable() { - @Override - public Iterator iterator() { - return new StateSplit.FilteringIterator(dataUsages, LoopEndNode.class); - } - }; - } - - @Override - public Map getDebugProperties() { - Map properties = super.getDebugProperties(); - properties.put("loopFrequency", String.format("%7.1f", loopFrequency)); - return properties; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/LoopEndNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/LoopEndNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -/* - * 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.nodes.base; - -import java.util.*; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - - -public class LoopEndNode extends FixedNode { - - @Input private LoopBeginNode loopBegin; - - public LoopBeginNode loopBegin() { - return loopBegin; - } - - public void setLoopBegin(LoopBeginNode x) { - updateUsages(this.loopBegin, x); - this.loopBegin = x; - } - - public LoopEndNode(Graph graph) { - super(CiKind.Illegal, graph); - } - - @Override - public void accept(ValueVisitor v) { - v.visitLoopEnd(this); - } - - @Override - public Iterable< ? extends Node> dataInputs() { - return Collections.emptyList(); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/MaterializeNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/MaterializeNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.base; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.calc.*; - -public final class MaterializeNode extends ConditionalNode { - public MaterializeNode(BooleanNode value, Graph graph) { - super(value, ConstantNode.forInt(1, graph), ConstantNode.forInt(0, graph), graph); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/MergeNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/MergeNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,219 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.base; - -import java.util.*; - -import com.oracle.max.graal.compiler.debug.*; -import com.oracle.max.graal.compiler.util.*; -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - -/** - * Denotes the beginning of a basic block, and holds information - * about the basic block, including the successor and - * predecessor blocks, exception handlers, liveness information, etc. - */ -public class MergeNode extends StateSplit { - - @Input private final NodeInputList ends = new NodeInputList(this); - - public MergeNode(Graph graph) { - super(CiKind.Illegal, graph); - } - - @Override - public boolean needsStateAfter() { - return false; - } - - @Override - public void accept(ValueVisitor v) { - v.visitMerge(this); - } - - public int endIndex(EndNode end) { - return ends.indexOf(end); - } - - public void addEnd(EndNode end) { - ends.add(end); - } - - public int endCount() { - return ends.size(); - } - - public EndNode endAt(int index) { - return ends.get(index); - } - - public Iterable phiPredecessors() { - return ends; - } - - @Override - public Iterable cfgPredecessors() { - return ends; - } - - @Override - public Iterable< ? extends Node> dataInputs() { - return Collections.emptyList(); - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("merge #"); - builder.append(id()); - builder.append(" ["); - - builder.append("]"); - - builder.append(" -> "); - boolean hasSucc = false; - for (Node s : this.successors()) { - if (hasSucc) { - builder.append(", "); - } - builder.append("#"); - if (s != null) { - builder.append(s.id()); - } else { - builder.append("null"); - } - hasSucc = true; - } - return builder.toString(); - } - - public void printWithoutPhis(LogStream out) { - // print block id - out.print("B").print(id()).print(" "); - - // print flags - StringBuilder sb = new StringBuilder(8); - if (sb.length() != 0) { - out.print('(').print(sb.toString()).print(')'); - } - - // print block bci range - out.print('[').print(-1).print(", ").print(-1).print(']'); - - // print block successors - //if (end != null && end.blockSuccessors().size() > 0) { - out.print(" ."); - for (Node successor : this.successors()) { - if (successor instanceof ValueNode) { - out.print((ValueNode) successor); - } else { - out.print(successor.toString()); - } - } - //} - - // print predecessors -// if (!blockPredecessors().isEmpty()) { -// out.print(" pred:"); -// for (Instruction pred : blockPredecessors()) { -// out.print(pred.block()); -// } -// } - } - - /** - * Determines if a given instruction is a phi whose {@linkplain PhiNode#merge() join block} is a given block. - * - * @param value the instruction to test - * @param block the block that may be the join block of {@code value} if {@code value} is a phi - * @return {@code true} if {@code value} is a phi and its join block is {@code block} - */ - private boolean isPhiAtBlock(ValueNode value) { - return value instanceof PhiNode && ((PhiNode) value).merge() == this; - } - - - /** - * Formats a given instruction as a value in a {@linkplain FrameState frame state}. If the instruction is a phi defined at a given - * block, its {@linkplain PhiNode#valueCount() inputs} are appended to the returned string. - * - * @param index the index of the value in the frame state - * @param value the frame state value - * @param block if {@code value} is a phi, then its inputs are formatted if {@code block} is its - * {@linkplain PhiNode#merge() join point} - * @return the instruction representation as a string - */ - public String stateString(int index, ValueNode value) { - StringBuilder sb = new StringBuilder(30); - sb.append(String.format("%2d %s", index, Util.valueString(value))); - if (value instanceof PhiNode) { - PhiNode phi = (PhiNode) value; - // print phi operands - if (phi.merge() == this) { - sb.append(" ["); - for (int j = 0; j < phi.valueCount(); j++) { - sb.append(' '); - ValueNode operand = phi.valueAt(j); - if (operand != null) { - sb.append(Util.valueString(operand)); - } else { - sb.append("NULL"); - } - } - sb.append("] "); - } - } - return sb.toString(); - } - - public void removeEnd(EndNode pred) { - int predIndex = ends.indexOf(pred); - assert predIndex != -1; - ends.remove(predIndex); - - for (Node usage : usages()) { - if (usage instanceof PhiNode) { - ((PhiNode) usage).removeInput(predIndex); - } - } - } - - public int phiPredecessorCount() { - return endCount(); - } - - public int phiPredecessorIndex(Node pred) { - EndNode end = (EndNode) pred; - return endIndex(end); - } - - public Node phiPredecessorAt(int index) { - return endAt(index); - } - - public Collection phis() { - return Util.filter(this.usages(), PhiNode.class); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/PhiNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/PhiNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,186 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.base; - -import java.util.*; - -import com.oracle.max.graal.compiler.*; -import com.oracle.max.graal.compiler.debug.*; -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.StateSplit.*; -import com.oracle.max.graal.nodes.calc.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - -/** - * The {@code Phi} instruction represents the merging of dataflow in the instruction graph. It refers to a join block - * and a variable. - */ -public final class PhiNode extends FloatingNode implements Canonicalizable { - - @Input private MergeNode merge; - - @Input private final NodeInputList values = new NodeInputList(this); - - public MergeNode merge() { - return merge; - } - - public void setMerge(MergeNode x) { - updateUsages(merge, x); - merge = x; - } - - public static enum PhiType { - Value, // normal value phis - Memory, // memory phis - Virtual // phis used for VirtualObjectField merges - } - - private final PhiType type; - - public PhiNode(CiKind kind, MergeNode merge, PhiType type, Graph graph) { - super(kind, graph); - this.type = type; - setMerge(merge); - } - - private PhiNode(CiKind kind, PhiType type, Graph graph) { - super(kind, graph); - this.type = type; - } - - public PhiType type() { - return type; - } - - @Override - public boolean verify() { - assertTrue(merge() != null); - assertTrue(merge().phiPredecessorCount() == valueCount(), merge().phiPredecessorCount() + "==" + valueCount()); - return true; - } - - /** - * Get the instruction that produces the value associated with the i'th predecessor of the join block. - * - * @param i the index of the predecessor - * @return the instruction that produced the value in the i'th predecessor - */ - public ValueNode valueAt(int i) { - return values.get(i); - } - - public void setValueAt(int i, ValueNode x) { - values.set(i, x); - } - - /** - * Get the number of inputs to this phi (i.e. the number of predecessors to the join block). - * - * @return the number of inputs in this phi - */ - public int valueCount() { - return values.size(); - } - - @Override - public void accept(ValueVisitor v) { - v.visitPhi(this); - } - - @Override - public String shortName() { - StringBuilder str = new StringBuilder(); - for (int i = 0; i < valueCount(); ++i) { - if (i != 0) { - str.append(' '); - } - str.append(valueAt(i) == null ? "-" : valueAt(i).id()); - } - if (type == PhiType.Value) { - return "Phi: (" + str + ")"; - } else { - return type + "Phi: (" + str + ")"; - } - } - - public void addInput(ValueNode x) { - values.add(x); - } - - public void removeInput(int index) { - values.remove(index); - } - - @Override - public Iterable< ? extends Node> dataInputs() { - final Iterator< ? extends Node> input = super.dataInputs().iterator(); - return new Iterable() { - - @Override - public Iterator iterator() { - return new FilteringIterator(input, MergeNode.class); - } - }; - } - - @Override - public Node canonical(NotifyReProcess reProcess) { - if (valueCount() != 2 || merge().endCount() != 2) { - return this; - } - if (merge().phis().size() > 1) { // XXX (gd) disable canonicalization of multiple conditional while we are not able to fuse them and the potentially leftover If in the backend - return this; - } - Node end0 = merge().endAt(0); - Node end1 = merge().endAt(1); - Node endPred0 = end0.predecessor(); - Node endPred1 = end1.predecessor(); - if (endPred0 != endPred1 || !(endPred0 instanceof IfNode)) { - return this; - } - IfNode ifNode = (IfNode) endPred0; - boolean inverted = ifNode.trueSuccessor() == end1; - ValueNode trueValue = valueAt(inverted ? 1 : 0); - ValueNode falseValue = valueAt(inverted ? 0 : 1); - if ((trueValue.kind != CiKind.Int && trueValue.kind != CiKind.Long) || (falseValue.kind != CiKind.Int && falseValue.kind != CiKind.Long)) { - return this; - } - if ((!(trueValue instanceof ConstantNode) && trueValue.usages().size() == 1) || (!(falseValue instanceof ConstantNode) && falseValue.usages().size() == 1)) { - return this; - } - BooleanNode compare = ifNode.compare(); - while (compare instanceof NegateBooleanNode) { - compare = ((NegateBooleanNode) compare).value(); - } - if (!(compare instanceof CompareNode || compare instanceof IsNonNullNode || compare instanceof NegateBooleanNode || compare instanceof ConstantNode)) { - return this; - } - if (GraalOptions.TraceCanonicalizer) { - TTY.println("> Phi canon'ed to Conditional"); - } - reProcess.reProccess(ifNode); - return new ConditionalNode(ifNode.compare(), trueValue, falseValue, graph()); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/PlaceholderNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/PlaceholderNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* - * 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.nodes.base; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - - -public class PlaceholderNode extends StateSplit { - - public PlaceholderNode(Graph graph) { - super(CiKind.Void, graph); - } - - @Override - public void accept(ValueVisitor v) { - //assert false; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/ReturnNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/ReturnNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.base; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - -/** - * The {@code Return} class definition. - */ -public final class ReturnNode extends FixedNode { - - @Input private ValueNode result; - - public ValueNode result() { - return result; - } - - public void setResult(ValueNode x) { - updateUsages(this.result, x); - this.result = x; - } - - /** - * Constructs a new Return instruction. - * @param result the instruction producing the result for this return; {@code null} if this - * is a void return - * @param graph - */ - public ReturnNode(ValueNode result, Graph graph) { - super(result == null ? CiKind.Void : result.kind, graph); - setResult(result); - } - - // for copying - private ReturnNode(CiKind kind, Graph graph) { - super(kind, graph); - } - - @Override - public void accept(ValueVisitor v) { - v.visitReturn(this); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/StateSplit.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/StateSplit.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.base; - -import java.util.*; - -import com.oracle.max.graal.graph.*; -import com.sun.cri.ci.*; - -/** - * The {@code StateSplit} class is the abstract base class of all instructions - * that store an immutable copy of the frame state. - */ -public abstract class StateSplit extends FixedWithNextNode { - - @Input private FrameState stateAfter; - - public FrameState stateAfter() { - return stateAfter; - } - - public void setStateAfter(FrameState x) { - updateUsages(stateAfter, x); - stateAfter = x; - } - - /** - * Creates a new state split with the specified value type. - * @param kind the type of the value that this instruction produces - * @param graph - */ - public StateSplit(CiKind kind, Graph graph) { - super(kind, graph); - } - - public boolean needsStateAfter() { - return true; - } - - @Override - public void delete() { - FrameState stateAfter = stateAfter(); - super.delete(); - if (stateAfter != null) { - if (stateAfter.usages().isEmpty()) { - stateAfter.delete(); - } - } - } - - @Override - public Iterable< ? extends Node> dataInputs() { - final Iterator< ? extends Node> dataInputs = super.dataInputs().iterator(); - return new Iterable() { - @Override - public Iterator iterator() { - return new FilteringIterator(dataInputs, FrameState.class); - } - }; - } - - public static final class FilteringIterator implements Iterator { - - private final Iterator< ? extends Node> input; - private Node next; - private Class< ? > clazz; - - public FilteringIterator(Iterator< ? extends Node> input, Class clazz) { - this.input = input; - this.clazz = clazz; - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - - @Override - public Node next() { - forward(); - if (!hasNext()) { - throw new NoSuchElementException(); - } - Node res = next; - next = null; - return res; - } - - @Override - public boolean hasNext() { - forward(); - return next != null; - } - - private void forward() { - while (next == null && input.hasNext()) { - next = input.next(); - if (clazz.isInstance(next)) { - next = null; - } - } - } - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/UnwindNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/UnwindNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -/* - * 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.nodes.base; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - -/** - * Unwind takes an exception object, destroys the current stack frame and passes the exception object to the system's exception dispatch code. - */ -public final class UnwindNode extends FixedNode { - - @Input private ValueNode exception; - - public ValueNode exception() { - return exception; - } - - public void setException(ValueNode x) { - assert x == null || x.kind == CiKind.Object; - updateUsages(this.exception, x); - this.exception = x; - } - - public UnwindNode(ValueNode exception, Graph graph) { - super(CiKind.Object, graph); - setException(exception); - } - - @Override - public void accept(ValueVisitor v) { - v.visitUnwind(this); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/ValueNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/ValueNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,190 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.base; - -import java.util.*; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.spi.*; -import com.oracle.max.graal.nodes.virtual.*; -import com.sun.cri.ci.*; -import com.sun.cri.ri.*; - -/** - * This class represents a value within the HIR graph, including local variables, phis, and - * all other instructions. - */ -public abstract class ValueNode extends Node { - - /** - * The kind of this value. This is {@link CiKind#Void} for instructions that produce no value. - * This kind is guaranteed to be a {@linkplain CiKind#stackKind() stack kind}. - */ - @Data public final CiKind kind; - - protected CiValue operand = CiValue.IllegalValue; - - /** - * Creates a new value with the specified kind. - * @param kind the type of this value - * @param inputCount - * @param successorCount - * @param graph - */ - public ValueNode(CiKind kind, Graph graph) { - super(graph); - assert kind != null && kind == kind.stackKind() : kind + " != " + kind.stackKind(); - this.kind = kind; - } - - /** - * Checks whether this value is a constant (i.e. it is of type {@link ConstantNode}. - * @return {@code true} if this value is a constant - */ - public final boolean isConstant() { - return this instanceof ConstantNode; - } - - /** - * Checks whether this value represents the null constant. - * @return {@code true} if this value represents the null constant - */ - public final boolean isNullConstant() { - return this instanceof ConstantNode && ((ConstantNode) this).value.isNull(); - } - - /** - * Convert this value to a constant if it is a constant, otherwise return null. - * @return the {@link CiConstant} represented by this value if it is a constant; {@code null} - * otherwise - */ - public final CiConstant asConstant() { - if (this instanceof ConstantNode) { - return ((ConstantNode) this).value; - } - return null; - } - - /** - * Gets the LIR operand associated with this instruction. - * @return the LIR operand for this instruction - */ - public final CiValue operand() { - return operand; - } - - /** - * Sets the LIR operand associated with this instruction. - * @param operand the operand to associate with this instruction - */ - public final void setOperand(CiValue operand) { - assert this.operand.isIllegal() : "operand cannot be set twice"; - assert operand != null && operand.isLegal() : "operand must be legal"; - assert operand.kind.stackKind() == this.kind; - assert !(this instanceof VirtualObjectNode); - this.operand = operand; - } - - /** - * Clears the LIR operand associated with this instruction. - */ - public final void clearOperand() { - this.operand = CiValue.IllegalValue; - } - - /** - * Computes the exact type of the result of this instruction, if possible. - * @return the exact type of the result of this instruction, if it is known; {@code null} otherwise - */ - public RiType exactType() { - return null; // default: unknown exact type - } - - /** - * Computes the declared type of the result of this instruction, if possible. - * @return the declared type of the result of this instruction, if it is known; {@code null} otherwise - */ - public RiType declaredType() { - return null; // default: unknown declared type - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("#"); - builder.append(id()); - builder.append(' '); - if (id() < 10) { - builder.append(' '); - } - builder.append(getClass().getSimpleName()); - builder.append(" [").append(flagsToString()).append("]"); - return builder.toString(); - } - - public String flagsToString() { - StringBuilder sb = new StringBuilder(); - return sb.toString(); - } - - /** - * This method supports the visitor pattern by accepting a visitor and calling the - * appropriate {@code visit()} method. - * - * @param v the visitor to accept - */ - public void accept(ValueVisitor v) { - throw new IllegalStateException("No visit method for this node (" + this.getClass().getSimpleName() + ")"); - } - - public static final LoweringOp DELEGATE_TO_RUNTIME = new LoweringOp() { - @Override - public void lower(Node n, CiLoweringTool tool) { - tool.getRuntime().lower(n, tool); - } - }; - - public static final LIRGeneratorOp DELEGATE_TO_VALUE_VISITOR = new LIRGeneratorOp() { - @Override - public void generate(Node n, LIRGeneratorTool generator) { - ((ValueNode) n).accept(generator); - } - }; - - @SuppressWarnings("unchecked") - @Override - public T lookup(Class clazz) { - if (clazz == LIRGeneratorOp.class) { - return (T) DELEGATE_TO_VALUE_VISITOR; - } - return super.lookup(clazz); - } - - @Override - public Map getDebugProperties() { - Map properties = super.getDebugProperties(); - properties.put("kind", kind.toString()); - properties.put("operand", operand == null ? "null" : operand.toString()); - return properties; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/AndNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/AndNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -/* - * 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.nodes.calc; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.bytecode.*; -import com.sun.cri.ci.*; - -@NodeInfo(shortName = "&") -public final class AndNode extends LogicNode implements Canonicalizable { - - public AndNode(CiKind kind, ValueNode x, ValueNode y, Graph graph) { - super(kind, kind == CiKind.Int ? Bytecodes.IAND : Bytecodes.LAND, x, y, graph); - } - - @Override - public Node canonical(NotifyReProcess reProcess) { - if (x() == y()) { - return x(); - } - if (x().isConstant() && !y().isConstant()) { - swapOperands(); - } - if (x().isConstant()) { - if (kind == CiKind.Int) { - return ConstantNode.forInt(x().asConstant().asInt() & y().asConstant().asInt(), graph()); - } else { - assert kind == CiKind.Long; - return ConstantNode.forLong(x().asConstant().asLong() & y().asConstant().asLong(), graph()); - } - } else if (y().isConstant()) { - if (kind == CiKind.Int) { - int c = y().asConstant().asInt(); - if (c == -1) { - return x(); - } - if (c == 0) { - return ConstantNode.forInt(0, graph()); - } - } else { - assert kind == CiKind.Long; - long c = y().asConstant().asLong(); - if (c == -1) { - return x(); - } - if (c == 0) { - return ConstantNode.forLong(0, graph()); - } - } - } - return this; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/ArithmeticNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/ArithmeticNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.calc; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.bytecode.*; -import com.sun.cri.ci.*; - -/** - * The {@code ArithmeticOp} class represents arithmetic operations such as addition, subtraction, etc. - */ -public abstract class ArithmeticNode extends BinaryNode { - - private final boolean isStrictFP; - - /** - * Creates a new arithmetic operation. - * @param opcode the bytecode opcode - * @param kind the result kind of the operation - * @param x the first input instruction - * @param y the second input instruction - * @param isStrictFP indicates this operation has strict rounding semantics - */ - public ArithmeticNode(CiKind kind, int opcode, ValueNode x, ValueNode y, boolean isStrictFP, Graph graph) { - super(kind, opcode, x, y, graph); - this.isStrictFP = isStrictFP; - } - - /** - * Checks whether this instruction has strict fp semantics. - * @return {@code true} if this instruction has strict fp semantics - */ - public boolean isStrictFP() { - return isStrictFP; - } - - @Override - public void accept(ValueVisitor v) { - v.visitArithmetic(this); - } - - public boolean isCommutative() { - return Bytecodes.isCommutative(opcode); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/BinaryNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/BinaryNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.calc; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.sun.cri.bytecode.*; -import com.sun.cri.ci.*; - -/** - * The {@code Op2} class is the base of arithmetic and logic operations with two inputs. - */ -public abstract class BinaryNode extends FloatingNode { - - @Input private ValueNode x; - @Input private ValueNode y; - @Data public final int opcode; - - public ValueNode x() { - return x; - } - - public void setX(ValueNode x) { - updateUsages(this.x, x); - this.x = x; - } - - public ValueNode y() { - return y; - } - - public void setY(ValueNode x) { - updateUsages(y, x); - this.y = x; - } - - /** - * Creates a new Op2 instance. - * @param kind the result type of this instruction - * @param opcode the bytecode opcode - * @param x the first input instruction - * @param y the second input instruction - */ - public BinaryNode(CiKind kind, int opcode, ValueNode x, ValueNode y, Graph graph) { - super(kind, graph); - this.opcode = opcode; - setX(x); - setY(y); - } - - /** - * Swaps the operands of this instruction. This is only legal for commutative operations. - */ - public void swapOperands() { - assert Bytecodes.isCommutative(opcode); - ValueNode t = x(); - setX(y()); - setY(t); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/CompareNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/CompareNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,212 +0,0 @@ -/* - * Copyright (c) 2011, 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.nodes.calc; - -import java.util.*; - -import com.oracle.max.graal.compiler.graph.*; -import com.oracle.max.graal.compiler.util.*; -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - -/* (tw/gd) For high-level optimization purpose the compare node should be a boolean *value* (it is currently only a helper node) - * But in the back-end the comparison should not always be materialized (for example in x86 the comparison result will not be in a register but in a flag) - * - * Compare should probably be made a value (so that it can be canonicalized for example) and in later stages some Compare usage should be transformed - * into variants that do not materialize the value (CompareIf, CompareGuard...) - * - */ -public final class CompareNode extends BooleanNode implements Canonicalizable { - - @Input private ValueNode x; - @Input private ValueNode y; - - @Data private Condition condition; - @Data private boolean unorderedIsTrue; - - public ValueNode x() { - return x; - } - - public void setX(ValueNode x) { - updateUsages(this.x, x); - this.x = x; - } - - public ValueNode y() { - return y; - } - - public void setY(ValueNode x) { - updateUsages(y, x); - this.y = x; - } - - /** - * Constructs a new Compare instruction. - * - * @param x the instruction producing the first input to the instruction - * @param condition the condition (comparison operation) - * @param y the instruction that produces the second input to this instruction - * @param graph - */ - public CompareNode(ValueNode x, Condition condition, ValueNode y, Graph graph) { - super(CiKind.Illegal, graph); - assert (x == null && y == null) || Util.archKindsEqual(x, y); - this.condition = condition; - setX(x); - setY(y); - } - - /** - * Gets the condition (comparison operation) for this instruction. - * - * @return the condition - */ - public Condition condition() { - return condition; - } - - /** - * Checks whether unordered inputs mean true or false. - * - * @return {@code true} if unordered inputs produce true - */ - public boolean unorderedIsTrue() { - return unorderedIsTrue; - } - - public void setUnorderedIsTrue(boolean unorderedIsTrue) { - this.unorderedIsTrue = unorderedIsTrue; - } - - /** - * Swaps the operands to this if and mirrors the condition (e.g. > becomes <). - * - * @see Condition#mirror() - */ - public void swapOperands() { - condition = condition.mirror(); - ValueNode t = x(); - setX(y()); - setY(t); - } - - public void negate() { - condition = condition.negate(); - unorderedIsTrue = !unorderedIsTrue; - } - - @Override - public void accept(ValueVisitor v) { - } - - @Override - public String shortName() { - return "Comp " + condition.operator; - } - - @Override - public Map getDebugProperties() { - Map properties = super.getDebugProperties(); - properties.put("unorderedIsTrue", unorderedIsTrue()); - return properties; - } - - private Node optimizeMaterialize(CiConstant constant, MaterializeNode materializeNode) { - if (constant.kind == CiKind.Int) { - boolean isFalseCheck = (constant.asInt() == 0); - if (condition == Condition.EQ || condition == Condition.NE) { - if (condition == Condition.NE) { - isFalseCheck = !isFalseCheck; - } - BooleanNode result = materializeNode.condition(); - if (isFalseCheck) { - result = new NegateBooleanNode(result, graph()); - } - return result; - } - } - return this; - } - - private Node optimizeNormalizeCmp(CiConstant constant, NormalizeCompareNode normalizeNode) { - if (constant.kind == CiKind.Int && constant.asInt() == 0) { - Condition condition = condition(); - if (normalizeNode == y()) { - condition = condition.mirror(); - } - CompareNode result = new CompareNode(normalizeNode.x(), condition, normalizeNode.y(), graph()); - boolean isLess = condition == Condition.LE || condition == Condition.LT || condition == Condition.BE || condition == Condition.BT; - result.unorderedIsTrue = condition != Condition.EQ && (condition == Condition.NE || !(isLess ^ normalizeNode.isUnorderedLess())); - return result; - } - return this; - } - - @Override - public Node canonical(NotifyReProcess reProcess) { - if (x().isConstant() && !y().isConstant()) { // move constants to the left (y) - swapOperands(); - } else if (x().isConstant() && y().isConstant()) { - CiConstant constX = x().asConstant(); - CiConstant constY = y().asConstant(); - Boolean result = condition().foldCondition(constX, constY, ((CompilerGraph) graph()).runtime(), unorderedIsTrue()); - if (result != null) { - return ConstantNode.forBoolean(result, graph()); - } - } - - if (y().isConstant()) { - if (x() instanceof MaterializeNode) { - return optimizeMaterialize(y().asConstant(), (MaterializeNode) x()); - } else if (x() instanceof NormalizeCompareNode) { - return optimizeNormalizeCmp(y().asConstant(), (NormalizeCompareNode) x()); - } - } - - if (x() == y() && x().kind != CiKind.Float && x().kind != CiKind.Double) { - return ConstantNode.forBoolean(condition().check(1, 1), graph()); - } - if ((condition == Condition.NE || condition == Condition.EQ) && x().kind == CiKind.Object) { - ValueNode object = null; - if (x().isNullConstant()) { - object = y(); - } else if (y().isNullConstant()) { - object = x(); - } - if (object != null) { - IsNonNullNode nonNull = new IsNonNullNode(object, graph()); - if (condition == Condition.NE) { - return nonNull; - } else { - assert condition == Condition.EQ; - return new NegateBooleanNode(nonNull, graph()); - } - } - } - return this; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/Condition.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/Condition.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,262 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.calc; - -import com.sun.cri.ci.*; -import com.sun.cri.ri.*; - -/** - * Condition codes used in conditionals. - */ -public enum Condition { - /** - * Equal. - */ - EQ("=="), - - /** - * Not equal. - */ - NE("!="), - - /** - * Signed less than. - */ - LT("<"), - - /** - * Signed less than or equal. - */ - LE("<="), - - /** - * Signed greater than. - */ - GT(">"), - - /** - * Signed greater than or equal. - */ - GE(">="), - - /** - * Unsigned greater than or equal ("above than or equal"). - */ - AE("|>=|"), - - /** - * Unsigned less than or equal ("below than or equal"). - */ - BE("|<=|"), - - /** - * Unsigned greater than ("above than"). - */ - AT("|>|"), - - /** - * Unsigned less than ("below than"). - */ - BT("|<|"), - - /** - * Operation produced an overflow. - */ - OF("overflow"), - - /** - * Operation did not produce an overflow. - */ - NOF("noOverflow"), - - TRUE("TRUE"); - - public final String operator; - - private Condition(String operator) { - this.operator = operator; - } - - public boolean check(int left, int right) { - switch (this) { - case EQ: return left == right; - case NE: return left != right; - case LT: return left < right; - case LE: return left <= right; - case GT: return left > right; - case GE: return left >= right; - case BT: return (left & 0xffffffffL) < (right & 0xffffffffL); - case BE: return (left & 0xffffffffL) <= (right & 0xffffffffL); - case AT: return (left & 0xffffffffL) > (right & 0xffffffffL); - case AE: return (left & 0xffffffffL) >= (right & 0xffffffffL); - } - throw new IllegalArgumentException(); - } - - /** - * Negate this conditional. - * @return the condition that represents the negation - */ - public final Condition negate() { - switch (this) { - case EQ: return NE; - case NE: return EQ; - case LT: return GE; - case LE: return GT; - case GT: return LE; - case GE: return LT; - case BT: return AE; - case BE: return AT; - case AT: return BE; - case AE: return BT; - case OF: return NOF; - case NOF: return OF; - } - throw new IllegalArgumentException(this.toString()); - } - - /** - * Mirror this conditional (i.e. commute "a op b" to "b op' a") - * @return the condition representing the equivalent commuted operation - */ - public final Condition mirror() { - switch (this) { - case EQ: return EQ; - case NE: return NE; - case LT: return GT; - case LE: return GE; - case GT: return LT; - case GE: return LE; - case BT: return AT; - case BE: return AE; - case AT: return BT; - case AE: return BE; - } - throw new IllegalArgumentException(); - } - - /** - * Checks if this conditional operation is commutative. - * @return {@code true} if this operation is commutative - */ - public final boolean isCommutative() { - return this == EQ || this == NE; - } - - /** - * Attempts to fold a comparison between two constants and return the result. - * @param lt the constant on the left side of the comparison - * @param rt the constant on the right side of the comparison - * @param runtime the RiRuntime (might be needed to compare runtime-specific types) - * @return {@link Boolean#TRUE} if the comparison is known to be true, - * {@link Boolean#FALSE} if the comparison is known to be false, {@code null} otherwise. - */ - public Boolean foldCondition(CiConstant lt, CiConstant rt, RiRuntime runtime, boolean unorderedIsTrue) { - switch (lt.kind) { - case Boolean: - case Int: { - int x = lt.asInt(); - int y = rt.asInt(); - switch (this) { - case EQ: return x == y; - case NE: return x != y; - case LT: return x < y; - case LE: return x <= y; - case GT: return x > y; - case GE: return x >= y; - case AE: return toUnsigned(x) >= toUnsigned(y); - case BE: return toUnsigned(x) <= toUnsigned(y); - case AT: return toUnsigned(x) > toUnsigned(y); - case BT: return toUnsigned(x) < toUnsigned(y); - } - break; - } - case Long: { - long x = lt.asLong(); - long y = rt.asLong(); - switch (this) { - case EQ: return x == y; - case NE: return x != y; - case LT: return x < y; - case LE: return x <= y; - case GT: return x > y; - case GE: return x >= y; - } - break; - } - case Object: { - switch (this) { - case EQ: return runtime.areConstantObjectsEqual(lt, rt); - case NE: return !runtime.areConstantObjectsEqual(lt, rt); - } - break; - } - case Float: { - float x = lt.asFloat(); - float y = rt.asFloat(); - if (Float.isNaN(x) || Float.isNaN(y)) { - return unorderedIsTrue; - } - switch (this) { - case EQ: return x == y; - case NE: return x != y; - case BT: - case LT: return x < y; - case BE: - case LE: return x <= y; - case AT: - case GT: return x > y; - case AE: - case GE: return x >= y; - } - } - case Double: { - double x = lt.asDouble(); - double y = rt.asDouble(); - if (Double.isNaN(x) || Double.isNaN(y)) { - return unorderedIsTrue; - } - switch (this) { - case EQ: return x == y; - case NE: return x != y; - case BT: - case LT: return x < y; - case BE: - case LE: return x <= y; - case AT: - case GT: return x > y; - case AE: - case GE: return x >= y; - } - } - } - return null; - } - - private long toUnsigned(int x) { - if (x < 0) { - return ((long) (x & 0x7FFFFFFF)) + ((long) Integer.MAX_VALUE) + 1; - } - return x; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/ConditionalNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/ConditionalNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.calc; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.base.PhiNode.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.bytecode.*; -import com.sun.cri.ci.*; - -/** - * The {@code Conditional} class represents a comparison that yields one of two values. Note that these nodes are not - * built directly from the bytecode but are introduced by conditional expression elimination. - */ -public class ConditionalNode extends BinaryNode implements Canonicalizable { - - @Input private BooleanNode condition; - - public BooleanNode condition() { - return condition; - } - - public void setCondition(BooleanNode n) { - updateUsages(condition, n); - condition = n; - } - - /** - * Constructs a new IfOp. - * - * @param x the instruction producing the first value to be compared - * @param condition the condition of the comparison - * @param y the instruction producing the second value to be compared - * @param trueValue the value produced if the condition is true - * @param falseValue the value produced if the condition is false - */ - public ConditionalNode(BooleanNode condition, ValueNode trueValue, ValueNode falseValue, Graph graph) { - // TODO: return the appropriate bytecode IF_ICMPEQ, etc - super(trueValue.kind.meet(falseValue.kind), Bytecodes.ILLEGAL, trueValue, falseValue, graph); - setCondition(condition); - } - - // for copying - private ConditionalNode(CiKind kind, Graph graph) { - super(kind, Bytecodes.ILLEGAL, null, null, graph); - } - - public ValueNode trueValue() { - return x(); - } - - public ValueNode falseValue() { - return y(); - } - - public void setTrueValue(ValueNode value) { - setX(value); - } - - public void setFalseValue(ValueNode value) { - setY(value); - } - - @SuppressWarnings("unchecked") - @Override - public T lookup(Class clazz) { - if (clazz == LIRGeneratorOp.class) { - return (T) LIRGEN; - } - return super.lookup(clazz); - } - - public static class ConditionalStructure { - - public final IfNode ifNode; - public final PhiNode phi; - public final MergeNode merge; - - public ConditionalStructure(IfNode ifNode, PhiNode phi, MergeNode merge) { - this.ifNode = ifNode; - this.phi = phi; - this.merge = merge; - } - } - - public static ConditionalStructure createConditionalStructure(BooleanNode condition, ValueNode trueValue, ValueNode falseValue) { - return createConditionalStructure(condition, trueValue, falseValue, 0.5); - } - - public static ConditionalStructure createConditionalStructure(BooleanNode condition, ValueNode trueValue, ValueNode falseValue, double trueProbability) { - Graph graph = condition.graph(); - CiKind kind = trueValue.kind.meet(falseValue.kind); - IfNode ifNode = new IfNode(condition, trueProbability, graph); - EndNode trueEnd = new EndNode(graph); - EndNode falseEnd = new EndNode(graph); - ifNode.setTrueSuccessor(trueEnd); - ifNode.setFalseSuccessor(falseEnd); - MergeNode merge = new MergeNode(graph); - merge.addEnd(trueEnd); - merge.addEnd(falseEnd); - PhiNode phi = new PhiNode(kind, merge, PhiType.Value, graph); - phi.addInput(trueValue); - phi.addInput(falseValue); - return new ConditionalStructure(ifNode, phi, merge); - } - - private static final LIRGeneratorOp LIRGEN = new LIRGeneratorOp() { - - @Override - public void generate(Node n, LIRGeneratorTool generator) { - generator.visitConditional((ConditionalNode) n); - } - }; - - @Override - public Node canonical(NotifyReProcess reProcess) { - if (condition instanceof ConstantNode) { - ConstantNode c = (ConstantNode) condition; - if (c.asConstant().asBoolean()) { - return trueValue(); - } else { - return falseValue(); - } - } - if (trueValue() == falseValue()) { - return trueValue(); - } - if (!(this instanceof MaterializeNode) && trueValue() instanceof ConstantNode && falseValue() instanceof ConstantNode && trueValue().kind == CiKind.Int && falseValue().kind == CiKind.Int) { - int trueInt = trueValue().asConstant().asInt(); - int falseInt = falseValue().asConstant().asInt(); - if (trueInt == 0 && falseInt == 1) { - reProcess.reProccess(condition); // because we negate it - return new MaterializeNode(new NegateBooleanNode(condition, graph()), graph()); - } else if (trueInt == 1 && falseInt == 0) { - return new MaterializeNode(condition, graph()); - } - } else if (falseValue() instanceof ConstantNode && !(trueValue() instanceof ConstantNode)) { - ValueNode temp = trueValue(); - setTrueValue(falseValue()); - setFalseValue(temp); - condition = new NegateBooleanNode(condition, graph()); - setCondition(condition); - } - return this; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/ConvertNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/ConvertNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.calc; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - -/** - * The {@code Convert} class represents a conversion between primitive types. - */ -public final class ConvertNode extends FloatingNode { - @Input private ValueNode value; - - @Data public final int opcode; - - public ValueNode value() { - return value; - } - - public void setValue(ValueNode x) { - updateUsages(value, x); - value = x; - } - - /** - * Constructs a new Convert instance. - * @param opcode the bytecode representing the operation - * @param value the instruction producing the input value - * @param kind the result type of this instruction - * @param graph - */ - public ConvertNode(int opcode, ValueNode value, CiKind kind, Graph graph) { - super(kind, graph); - this.opcode = opcode; - setValue(value); - } - - @Override - public void accept(ValueVisitor v) { - v.visitConvert(this); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/FloatAddNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/FloatAddNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -/* - * 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.nodes.calc; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.bytecode.*; -import com.sun.cri.ci.*; - -@NodeInfo(shortName = "+") -public final class FloatAddNode extends FloatArithmeticNode implements Canonicalizable { - - public FloatAddNode(CiKind kind, ValueNode x, ValueNode y, boolean isStrictFP, Graph graph) { - super(kind, kind == CiKind.Double ? Bytecodes.DADD : Bytecodes.FADD, x, y, isStrictFP, graph); - } - - @Override - public Node canonical(NotifyReProcess reProcess) { - if (x().isConstant() && !y().isConstant()) { - swapOperands(); - } - if (x().isConstant()) { - if (kind == CiKind.Float) { - return ConstantNode.forFloat(x().asConstant().asFloat() + y().asConstant().asFloat(), graph()); - } else { - assert kind == CiKind.Double; - return ConstantNode.forDouble(x().asConstant().asDouble() + y().asConstant().asDouble(), graph()); - } - } else if (y().isConstant()) { - if (kind == CiKind.Float) { - float c = y().asConstant().asFloat(); - if (c == 0.0f) { - return x(); - } - } else { - assert kind == CiKind.Double; - double c = y().asConstant().asDouble(); - if (c == 0.0) { - return x(); - } - } - } - return this; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/FloatArithmeticNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/FloatArithmeticNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -/* - * 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.nodes.calc; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.sun.cri.ci.*; - -public abstract class FloatArithmeticNode extends ArithmeticNode { - - public FloatArithmeticNode(CiKind kind, int opcode, ValueNode x, ValueNode y, boolean isStrictFP, Graph graph) { - super(kind, opcode, x, y, isStrictFP, graph); - } - -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/FloatDivNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/FloatDivNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* - * 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.nodes.calc; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.bytecode.*; -import com.sun.cri.ci.*; - -@NodeInfo(shortName = "/") -public final class FloatDivNode extends FloatArithmeticNode implements Canonicalizable { - - public FloatDivNode(CiKind kind, ValueNode x, ValueNode y, boolean isStrictFP, Graph graph) { - super(kind, kind == CiKind.Double ? Bytecodes.DDIV : Bytecodes.FDIV, x, y, isStrictFP, graph); - } - - @Override - public Node canonical(NotifyReProcess reProcess) { - if (x().isConstant() && y().isConstant()) { - if (kind == CiKind.Float) { - return ConstantNode.forFloat(x().asConstant().asFloat() / y().asConstant().asFloat(), graph()); - } else { - assert kind == CiKind.Double; - return ConstantNode.forDouble(x().asConstant().asDouble() / y().asConstant().asDouble(), graph()); - } - } - return this; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/FloatMulNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/FloatMulNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -/* - * 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.nodes.calc; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.bytecode.*; -import com.sun.cri.ci.*; - -@NodeInfo(shortName = "*") -public final class FloatMulNode extends FloatArithmeticNode implements Canonicalizable { - - public FloatMulNode(CiKind kind, ValueNode x, ValueNode y, boolean isStrictFP, Graph graph) { - super(kind, kind == CiKind.Double ? Bytecodes.DMUL : Bytecodes.FMUL, x, y, isStrictFP, graph); - } - - @Override - public Node canonical(NotifyReProcess reProcess) { - if (x().isConstant() && !y().isConstant()) { - swapOperands(); - } - if (x().isConstant()) { - if (kind == CiKind.Float) { - return ConstantNode.forFloat(x().asConstant().asFloat() * y().asConstant().asFloat(), graph()); - } else { - assert kind == CiKind.Double; - return ConstantNode.forDouble(x().asConstant().asDouble() * y().asConstant().asDouble(), graph()); - } - } else if (y().isConstant()) { - if (kind == CiKind.Float) { - float c = y().asConstant().asFloat(); - if (c == 0.0f) { - return ConstantNode.forFloat(0.0f, graph()); - } - } else { - assert kind == CiKind.Double; - double c = y().asConstant().asDouble(); - if (c == 0.0) { - return ConstantNode.forDouble(0.0, graph()); - } - } - } - return this; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/FloatRemNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/FloatRemNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* - * 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.nodes.calc; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.bytecode.*; -import com.sun.cri.ci.*; - -@NodeInfo(shortName = "%") -public final class FloatRemNode extends FloatArithmeticNode implements Canonicalizable { - - public FloatRemNode(CiKind kind, ValueNode x, ValueNode y, boolean isStrictFP, Graph graph) { - super(kind, kind == CiKind.Double ? Bytecodes.DREM : Bytecodes.FREM, x, y, isStrictFP, graph); - } - - @Override - public Node canonical(NotifyReProcess reProcess) { - if (x().isConstant() && y().isConstant()) { - if (kind == CiKind.Float) { - return ConstantNode.forFloat(x().asConstant().asFloat() % y().asConstant().asFloat(), graph()); - } else { - assert kind == CiKind.Double; - return ConstantNode.forDouble(x().asConstant().asDouble() % y().asConstant().asDouble(), graph()); - } - } - return this; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/FloatSubNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/FloatSubNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -/* - * 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.nodes.calc; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.bytecode.*; -import com.sun.cri.ci.*; - -@NodeInfo(shortName = "-") -public final class FloatSubNode extends FloatArithmeticNode implements Canonicalizable { - - public FloatSubNode(CiKind kind, ValueNode x, ValueNode y, boolean isStrictFP, Graph graph) { - super(kind, kind == CiKind.Double ? Bytecodes.DSUB : Bytecodes.FSUB, x, y, isStrictFP, graph); - } - - @Override - public Node canonical(NotifyReProcess reProcess) { - if (x() == y()) { - if (kind == CiKind.Float) { - return ConstantNode.forFloat(0.0f, graph()); - } else { - assert kind == CiKind.Double; - return ConstantNode.forDouble(0.0, graph()); - } - } - if (x().isConstant() && y().isConstant()) { - if (kind == CiKind.Float) { - return ConstantNode.forFloat(x().asConstant().asFloat() - y().asConstant().asFloat(), graph()); - } else { - assert kind == CiKind.Double; - return ConstantNode.forDouble(x().asConstant().asDouble() - y().asConstant().asDouble(), graph()); - } - } else if (y().isConstant()) { - if (kind == CiKind.Float) { - float c = y().asConstant().asFloat(); - if (c == 0.0f) { - return x(); - } - return new FloatAddNode(kind, x(), ConstantNode.forFloat(-c, graph()), isStrictFP(), graph()); - } else { - assert kind == CiKind.Double; - double c = y().asConstant().asDouble(); - if (c == 0.0) { - return x(); - } - return new FloatAddNode(kind, x(), ConstantNode.forDouble(-c, graph()), isStrictFP(), graph()); - } - } - return this; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/FloatingNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/FloatingNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -/* - * 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.nodes.calc; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.sun.cri.ci.*; - -public abstract class FloatingNode extends ValueNode implements Node.ValueNumberable { - public FloatingNode(CiKind kind, Graph graph) { - super(kind, graph); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/IntegerAddNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/IntegerAddNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2011, 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.nodes.calc; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.bytecode.*; -import com.sun.cri.ci.*; - -@NodeInfo(shortName = "+") -public final class IntegerAddNode extends IntegerArithmeticNode implements Canonicalizable { - - public IntegerAddNode(CiKind kind, ValueNode x, ValueNode y, Graph graph) { - super(kind, kind == CiKind.Int ? Bytecodes.IADD : Bytecodes.LADD, x, y, graph); - } - - @Override - public Node canonical(NotifyReProcess reProcess) { - if (x().isConstant() && !y().isConstant()) { - swapOperands(); - } - if (x().isConstant()) { - if (kind == CiKind.Int) { - return ConstantNode.forInt(x().asConstant().asInt() + y().asConstant().asInt(), graph()); - } else { - assert kind == CiKind.Long; - return ConstantNode.forLong(x().asConstant().asLong() + y().asConstant().asLong(), graph()); - } - } else if (y().isConstant()) { - if (kind == CiKind.Int) { - int c = y().asConstant().asInt(); - if (c == 0) { - return x(); - } - } else { - assert kind == CiKind.Long; - long c = y().asConstant().asLong(); - if (c == 0) { - return x(); - } - } - } - return this; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/IntegerAddVectorNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/IntegerAddVectorNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -/* - * 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.nodes.calc; - -import java.util.*; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.extended.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - - -public final class IntegerAddVectorNode extends AbstractVectorNode { - @Input private ValueNode value; - - public ValueNode value() { - return value; - } - - public void setValue(ValueNode x) { - updateUsages(value, x); - value = x; - } - - public IntegerAddVectorNode(AbstractVectorNode vector, ValueNode value, Graph graph) { - super(CiKind.Illegal, vector, graph); - setValue(value); - } - - @Override - public T lookup(Class clazz) { - if (clazz == LIRGeneratorOp.class) { - return null; - } - return super.lookup(clazz); - } - - @Override - public void addToLoop(LoopBeginNode loop, IdentityHashMap nodes) { - nodes.put(this, new IntegerAddNode(CiKind.Int, nodes.get(vector()), value(), graph())); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/IntegerArithmeticNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/IntegerArithmeticNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2011, 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.nodes.calc; - -import com.oracle.max.graal.compiler.util.*; -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.sun.cri.ci.*; - - -public abstract class IntegerArithmeticNode extends ArithmeticNode { - - public IntegerArithmeticNode(CiKind kind, int opcode, ValueNode x, ValueNode y, Graph graph) { - super(kind, opcode, x, y, false, graph); - assert kind == CiKind.Int || kind == CiKind.Long; - } - - public static IntegerArithmeticNode add(ValueNode v1, ValueNode v2) { - assert v1.kind == v2.kind && v1.graph() == v2.graph(); - Graph graph = v1.graph(); - //TODO (gd) handle conversions here instead of strong assert ? - switch(v1.kind) { - case Int: - return new IntegerAddNode(CiKind.Int, v1, v2, graph); - case Long: - return new IntegerAddNode(CiKind.Long, v1, v2, graph); - default: - throw Util.shouldNotReachHere(); - } - } - - public static IntegerArithmeticNode mul(ValueNode v1, ValueNode v2) { - assert v1.kind == v2.kind && v1.graph() == v2.graph(); - Graph graph = v1.graph(); - //TODO (gd) handle conversions here instead of strong assert ? - switch(v1.kind) { - case Int: - return new IntegerMulNode(CiKind.Int, v1, v2, graph); - case Long: - return new IntegerMulNode(CiKind.Long, v1, v2, graph); - default: - throw Util.shouldNotReachHere(); - } - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/IntegerDivNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/IntegerDivNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/* - * 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.nodes.calc; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.bytecode.*; -import com.sun.cri.ci.*; - -@NodeInfo(shortName = "/") -public final class IntegerDivNode extends IntegerArithmeticNode implements Canonicalizable { - - public IntegerDivNode(CiKind kind, ValueNode x, ValueNode y, Graph graph) { - super(kind, kind == CiKind.Int ? Bytecodes.IDIV : Bytecodes.LDIV, x, y, graph); - } - - @Override - public Node canonical(NotifyReProcess reProcess) { - if (x().isConstant() && y().isConstant()) { - long yConst = y().asConstant().asLong(); - if (yConst == 0) { - return this; // this will trap, can not canonicalize - } - if (kind == CiKind.Int) { - return ConstantNode.forInt(x().asConstant().asInt() / (int) yConst, graph()); - } else { - assert kind == CiKind.Long; - return ConstantNode.forLong(x().asConstant().asLong() / yConst, graph()); - } - } else if (y().isConstant()) { - long c = y().asConstant().asLong(); - if (c == 1) { - return x(); - } - } - return this; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/IntegerMulNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/IntegerMulNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -/* - * 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.nodes.calc; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.bytecode.*; -import com.sun.cri.ci.*; - -@NodeInfo(shortName = "*") -public final class IntegerMulNode extends IntegerArithmeticNode implements Canonicalizable { - - public IntegerMulNode(CiKind kind, ValueNode x, ValueNode y, Graph graph) { - super(kind, kind == CiKind.Int ? Bytecodes.IMUL : Bytecodes.LMUL, x, y, graph); - } - - @Override - public Node canonical(NotifyReProcess reProcess) { - if (x().isConstant() && !y().isConstant()) { - swapOperands(); - } - if (x().isConstant()) { - if (kind == CiKind.Int) { - return ConstantNode.forInt(x().asConstant().asInt() * y().asConstant().asInt(), graph()); - } else { - assert kind == CiKind.Long; - return ConstantNode.forLong(x().asConstant().asLong() * y().asConstant().asLong(), graph()); - } - } else if (y().isConstant()) { - long c = y().asConstant().asLong(); - if (c == 1) { - return x(); - } - if (c == 0) { - return ConstantNode.forInt(0, graph()); - } - if (c > 0 && CiUtil.isPowerOf2(c)) { - return new LeftShiftNode(kind, x(), ConstantNode.forInt(CiUtil.log2(c), graph()), graph()); - } - } - return this; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/IntegerRemNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/IntegerRemNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -/* - * 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.nodes.calc; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.bytecode.*; -import com.sun.cri.ci.*; - -@NodeInfo(shortName = "%") -public final class IntegerRemNode extends IntegerArithmeticNode implements Canonicalizable { - - public IntegerRemNode(CiKind kind, ValueNode x, ValueNode y, Graph graph) { - super(kind, kind == CiKind.Int ? Bytecodes.IREM : Bytecodes.LREM, x, y, graph); - } - - @Override - public Node canonical(NotifyReProcess reProcess) { - if (x().isConstant() && y().isConstant()) { - long yConst = y().asConstant().asLong(); - if (yConst == 0) { - return this; // this will trap, can not canonicalize - } - if (kind == CiKind.Int) { - return ConstantNode.forInt(x().asConstant().asInt() % (int) yConst, graph()); - } else { - assert kind == CiKind.Long; - return ConstantNode.forLong(x().asConstant().asLong() % yConst, graph()); - } - } else if (y().isConstant()) { - long c = y().asConstant().asLong(); - if (c == 1 || c == -1) { - if (kind == CiKind.Int) { - return ConstantNode.forInt(0, graph()); - } else { - assert kind == CiKind.Long; - return ConstantNode.forLong(0, graph()); - } - } - } - return this; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/IntegerSubNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/IntegerSubNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -/* - * 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.nodes.calc; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.bytecode.*; -import com.sun.cri.ci.*; - -@NodeInfo(shortName = "-") -public final class IntegerSubNode extends IntegerArithmeticNode implements Canonicalizable { - - public IntegerSubNode(CiKind kind, ValueNode x, ValueNode y, Graph graph) { - super(kind, kind == CiKind.Int ? Bytecodes.ISUB : Bytecodes.LSUB, x, y, graph); - } - - @Override - public Node canonical(NotifyReProcess reProcess) { - if (x() == y()) { - if (kind == CiKind.Int) { - return ConstantNode.forInt(0, graph()); - } else { - assert kind == CiKind.Long; - return ConstantNode.forLong(0, graph()); - } - } - if (x().isConstant() && y().isConstant()) { - if (kind == CiKind.Int) { - return ConstantNode.forInt(x().asConstant().asInt() - y().asConstant().asInt(), graph()); - } else { - assert kind == CiKind.Long; - return ConstantNode.forLong(x().asConstant().asLong() - y().asConstant().asLong(), graph()); - } - } else if (y().isConstant()) { - long c = y().asConstant().asLong(); - if (c == 0) { - return x(); - } - if (kind == CiKind.Int) { - return new IntegerAddNode(kind, x(), ConstantNode.forInt((int) -c, graph()), graph()); - } else { - assert kind == CiKind.Long; - return new IntegerAddNode(kind, x(), ConstantNode.forLong(-c, graph()), graph()); - } - } else if (x().isConstant()) { - long c = x().asConstant().asLong(); - if (c == 0) { - return new NegateNode(y(), graph()); - } - } - return this; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/IsNonNullNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/IsNonNullNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.calc; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.java.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; -import com.sun.cri.ri.*; - -/** - * The {@code NullCheck} class represents an explicit null check instruction. - */ -public final class IsNonNullNode extends BooleanNode implements Canonicalizable { - - @Input private ValueNode object; - - public ValueNode object() { - return object; - } - - public void setObject(ValueNode x) { - updateUsages(object, x); - object = x; - } - - /** - * Constructs a new NullCheck instruction. - * - * @param object the instruction producing the object to check against null - * @param graph - */ - public IsNonNullNode(ValueNode object, Graph graph) { - super(CiKind.Object, graph); - assert object == null || object.kind == CiKind.Object : object; - setObject(object); - } - - @Override - public void accept(ValueVisitor v) { - // Nothing to do. - } - - @Override - public RiType declaredType() { - // null check does not alter the type of the object - return object().declaredType(); - } - - @Override - public RiType exactType() { - // null check does not alter the type of the object - return object().exactType(); - } - - @Override - public Node canonical(NotifyReProcess reProcess) { - if (object() instanceof NewInstanceNode || object() instanceof NewArrayNode) { - return ConstantNode.forBoolean(true, graph()); - } - CiConstant constant = object().asConstant(); - if (constant != null) { - assert constant.kind == CiKind.Object; - return ConstantNode.forBoolean(constant.isNonNull(), graph()); - } - return this; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/LeftShiftNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/LeftShiftNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,88 +0,0 @@ -/* - * 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.nodes.calc; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.bytecode.*; -import com.sun.cri.ci.*; - -@NodeInfo(shortName = "<<") -public final class LeftShiftNode extends ShiftNode implements Canonicalizable { - - public LeftShiftNode(CiKind kind, ValueNode x, ValueNode y, Graph graph) { - super(kind, kind == CiKind.Int ? Bytecodes.ISHL : Bytecodes.LSHL, x, y, graph); - } - - @Override - public Node canonical(NotifyReProcess reProcess) { - if (y().isConstant()) { - int amount = y().asConstant().asInt(); - int originalAmout = amount; - int mask; - if (kind == CiKind.Int) { - mask = 0x1f; - } else { - assert kind == CiKind.Long; - mask = 0x3f; - } - amount &= mask; - if (x().isConstant()) { - if (kind == CiKind.Int) { - return ConstantNode.forInt(x().asConstant().asInt() << amount, graph()); - } else { - assert kind == CiKind.Long; - return ConstantNode.forLong(x().asConstant().asLong() << amount, graph()); - } - } - if (amount == 0) { - return x(); - } - if (x() instanceof ShiftNode) { - ShiftNode other = (ShiftNode) x(); - if (other.y().isConstant()) { - int otherAmount = other.y().asConstant().asInt() & mask; - if (other instanceof LeftShiftNode) { - int total = amount + otherAmount; - if (total != (total & mask)) { - return ConstantNode.forInt(0, graph()); - } - return new LeftShiftNode(kind, other.x(), ConstantNode.forInt(total, graph()), graph()); - } else if ((other instanceof RightShiftNode || other instanceof UnsignedRightShiftNode) && otherAmount == amount) { - if (kind == CiKind.Long) { - return new AndNode(kind, other.x(), ConstantNode.forLong(-1L << amount, graph()), graph()); - } else { - assert kind == CiKind.Int; - return new AndNode(kind, other.x(), ConstantNode.forInt(-1 << amount, graph()), graph()); - } - } - } - } - if (originalAmout != amount) { - return new LeftShiftNode(kind, x(), ConstantNode.forInt(amount, graph()), graph()); - } - } - return this; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/LogicNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/LogicNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.calc; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - -/** - * The {@code LogicOp} class definition. - */ -public abstract class LogicNode extends BinaryNode { - - /** - * Constructs a new logic operation instruction. - * @param opcode the opcode of the logic operation - * @param x the first input into this instruction - * @param y the second input into this instruction - */ - public LogicNode(CiKind kind, int opcode, ValueNode x, ValueNode y, Graph graph) { - super(kind, opcode, x, y, graph); - } - - @Override - public void accept(ValueVisitor v) { - v.visitLogic(this); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/NegateBooleanNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/NegateBooleanNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.calc; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - -public final class NegateBooleanNode extends BooleanNode implements Canonicalizable { - - @Input private BooleanNode value; - - public BooleanNode value() { - return value; - } - - public void setValue(BooleanNode x) { - updateUsages(value, x); - value = x; - } - - public NegateBooleanNode(BooleanNode value, Graph graph) { - super(CiKind.Int, graph); - setValue(value); - } - - @Override - public void accept(ValueVisitor v) { - } - - @Override - public Node canonical(NotifyReProcess reProcess) { - if (value() instanceof NegateBooleanNode) { - return ((NegateBooleanNode) value()).value(); - } else if (value() instanceof ConstantNode) { - return ConstantNode.forBoolean(!value().asConstant().asBoolean(), graph()); - } - return this; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/NegateNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/NegateNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.calc; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - -/** - * The {@code NegateOp} instruction negates its operand. - */ -public final class NegateNode extends FloatingNode implements Canonicalizable { - - @Input - private ValueNode x; - - public ValueNode x() { - return x; - } - - public void setX(ValueNode x) { - updateUsages(this.x, x); - this.x = x; - } - - /** - * Creates new NegateOp instance. - * - * @param x the instruction producing the value that is input to this instruction - */ - public NegateNode(ValueNode x, Graph graph) { - super(x.kind, graph); - setX(x); - } - - // for copying - private NegateNode(CiKind kind, Graph graph) { - super(kind, graph); - } - - @Override - public void accept(ValueVisitor v) { - v.visitNegate(this); - } - - @Override - public Node canonical(NotifyReProcess reProcess) { - if (x().isConstant()) { - switch (x().kind) { - case Int: - return ConstantNode.forInt(-x().asConstant().asInt(), graph()); - case Long: - return ConstantNode.forLong(-x().asConstant().asLong(), graph()); - case Float: - return ConstantNode.forFloat(-x().asConstant().asFloat(), graph()); - case Double: - return ConstantNode.forDouble(-x().asConstant().asDouble(), graph()); - } - } - if (x() instanceof NegateNode) { - return ((NegateNode) x()).x(); - } - return this; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/NormalizeCompareNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/NormalizeCompareNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.calc; - -import java.util.*; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.bytecode.*; -import com.sun.cri.ci.*; - -/** - * Returns -1, 0, or 1 if either x > y, x == y, or x < y. - */ -public final class NormalizeCompareNode extends BinaryNode { - - /** - * Creates a new compare operation. - * @param opcode the bytecode opcode - * @param kind the result kind - * @param x the first input - * @param y the second input - */ - public NormalizeCompareNode(int opcode, CiKind kind, ValueNode x, ValueNode y, Graph graph) { - super(kind, opcode, x, y, graph); - } - - @Override - public void accept(ValueVisitor v) { - v.visitNormalizeCompare(this); - } - - @Override - public Map getDebugProperties() { - Map properties = super.getDebugProperties(); - properties.put("isUnorderedLess", isUnorderedLess()); - return properties; - } - - public boolean isUnorderedLess() { - return this.opcode == Bytecodes.FCMPL || this.opcode == Bytecodes.DCMPL; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/OrNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/OrNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -/* - * 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.nodes.calc; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.bytecode.*; -import com.sun.cri.ci.*; - -@NodeInfo(shortName = "|") -public final class OrNode extends LogicNode implements Canonicalizable { - - public OrNode(CiKind kind, ValueNode x, ValueNode y, Graph graph) { - super(kind, kind == CiKind.Int ? Bytecodes.IOR : Bytecodes.LOR, x, y, graph); - } - - @Override - public Node canonical(NotifyReProcess reProcess) { - if (x() == y()) { - return x(); - } - if (x().isConstant() && !y().isConstant()) { - swapOperands(); - } - if (x().isConstant()) { - if (kind == CiKind.Int) { - return ConstantNode.forInt(x().asConstant().asInt() | y().asConstant().asInt(), graph()); - } else { - assert kind == CiKind.Long; - return ConstantNode.forLong(x().asConstant().asLong() | y().asConstant().asLong(), graph()); - } - } else if (y().isConstant()) { - if (kind == CiKind.Int) { - int c = y().asConstant().asInt(); - if (c == -1) { - return ConstantNode.forInt(-1, graph()); - } - if (c == 0) { - return x(); - } - } else { - assert kind == CiKind.Long; - long c = y().asConstant().asLong(); - if (c == -1) { - return ConstantNode.forLong(-1, graph()); - } - if (c == 0) { - return x(); - } - } - } - return this; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/RightShiftNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/RightShiftNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -/* - * 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.nodes.calc; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.bytecode.*; -import com.sun.cri.ci.*; - -@NodeInfo(shortName = ">>") -public final class RightShiftNode extends ShiftNode implements Canonicalizable { - - public RightShiftNode(CiKind kind, ValueNode x, ValueNode y, Graph graph) { - super(kind, kind == CiKind.Int ? Bytecodes.ISHR : Bytecodes.LSHR, x, y, graph); - } - - @Override - public Node canonical(NotifyReProcess reProcess) { - if (y().isConstant()) { - int amount = y().asConstant().asInt(); - int originalAmout = amount; - int mask; - if (kind == CiKind.Int) { - mask = 0x1f; - } else { - assert kind == CiKind.Long; - mask = 0x3f; - } - amount &= mask; - if (x().isConstant()) { - if (kind == CiKind.Int) { - return ConstantNode.forInt(x().asConstant().asInt() >> amount, graph()); - } else { - assert kind == CiKind.Long; - return ConstantNode.forLong(x().asConstant().asLong() >> amount, graph()); - } - } - if (amount == 0) { - return x(); - } - if (x() instanceof ShiftNode) { - ShiftNode other = (ShiftNode) x(); - if (other.y().isConstant()) { - int otherAmount = other.y().asConstant().asInt() & mask; - if (other instanceof RightShiftNode) { - int total = amount + otherAmount; - if (total != (total & mask)) { - return ConstantNode.forInt(0, graph()); - } - return new RightShiftNode(kind, other.x(), ConstantNode.forInt(total, graph()), graph()); - } - } - } - if (originalAmout != amount) { - return new RightShiftNode(kind, x(), ConstantNode.forInt(amount, graph()), graph()); - } - } - return this; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/ShiftNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/ShiftNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.calc; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - -/** - * The {@code ShiftOp} class represents shift operations. - */ -public abstract class ShiftNode extends BinaryNode { - - /** - * Creates a new shift operation. - * @param opcode the opcode of the shift - * @param x the first input value - * @param s the second input value - */ - public ShiftNode(CiKind kind, int opcode, ValueNode x, ValueNode s, Graph graph) { - super(kind, opcode, x, s, graph); - assert x == null || x.kind == kind; - } - - @Override - public void accept(ValueVisitor v) { - v.visitShift(this); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/UnsignedRightShiftNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/UnsignedRightShiftNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,88 +0,0 @@ -/* - * 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.nodes.calc; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.bytecode.*; -import com.sun.cri.ci.*; - -@NodeInfo(shortName = ">>>") -public final class UnsignedRightShiftNode extends ShiftNode implements Canonicalizable { - - public UnsignedRightShiftNode(CiKind kind, ValueNode x, ValueNode y, Graph graph) { - super(kind, kind == CiKind.Int ? Bytecodes.IUSHR : Bytecodes.LUSHR, x, y, graph); - } - - @Override - public Node canonical(NotifyReProcess reProcess) { - if (y().isConstant()) { - int amount = y().asConstant().asInt(); - int originalAmout = amount; - int mask; - if (kind == CiKind.Int) { - mask = 0x1f; - } else { - assert kind == CiKind.Long; - mask = 0x3f; - } - amount &= mask; - if (x().isConstant()) { - if (kind == CiKind.Int) { - return ConstantNode.forInt(x().asConstant().asInt() >>> amount, graph()); - } else { - assert kind == CiKind.Long; - return ConstantNode.forLong(x().asConstant().asLong() >>> amount, graph()); - } - } - if (amount == 0) { - return x(); - } - if (x() instanceof ShiftNode) { - ShiftNode other = (ShiftNode) x(); - if (other.y().isConstant()) { - int otherAmount = other.y().asConstant().asInt() & mask; - if (other instanceof UnsignedRightShiftNode) { - int total = amount + otherAmount; - if (total != (total & mask)) { - return ConstantNode.forInt(0, graph()); - } - return new UnsignedRightShiftNode(kind, other.x(), ConstantNode.forInt(total, graph()), graph()); - } else if (other instanceof LeftShiftNode && otherAmount == amount) { - if (kind == CiKind.Long) { - return new AndNode(kind, other.x(), ConstantNode.forLong(-1L >>> amount, graph()), graph()); - } else { - assert kind == CiKind.Int; - return new AndNode(kind, other.x(), ConstantNode.forInt(-1 >>> amount, graph()), graph()); - } - } - } - } - if (originalAmout != amount) { - return new UnsignedRightShiftNode(kind, x(), ConstantNode.forInt(amount, graph()), graph()); - } - } - return this; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/XorNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/calc/XorNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -/* - * 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.nodes.calc; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.bytecode.*; -import com.sun.cri.ci.*; - -@NodeInfo(shortName = "^") -public final class XorNode extends LogicNode implements Canonicalizable { - - public XorNode(CiKind kind, ValueNode x, ValueNode y, Graph graph) { - super(kind, kind == CiKind.Int ? Bytecodes.IXOR : Bytecodes.LXOR, x, y, graph); - } - - @Override - public Node canonical(NotifyReProcess reProcess) { - if (x() == y()) { - if (kind == CiKind.Int) { - return ConstantNode.forInt(0, graph()); - } else { - assert kind == CiKind.Long; - return ConstantNode.forLong(0L, graph()); - } - } - if (x().isConstant() && !y().isConstant()) { - swapOperands(); - } - if (x().isConstant()) { - if (kind == CiKind.Int) { - return ConstantNode.forInt(x().asConstant().asInt() ^ y().asConstant().asInt(), graph()); - } else { - assert kind == CiKind.Long; - return ConstantNode.forLong(x().asConstant().asLong() ^ y().asConstant().asLong(), graph()); - } - } else if (y().isConstant()) { - if (kind == CiKind.Int) { - int c = y().asConstant().asInt(); - if (c == 0) { - return x(); - } - } else { - assert kind == CiKind.Long; - long c = y().asConstant().asLong(); - if (c == 0) { - return x(); - } - } - } - return this; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/extended/AbstractMemoryCheckpointNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/extended/AbstractMemoryCheckpointNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* - * 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.nodes.extended; - -import java.util.*; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.sun.cri.ci.*; - - -public abstract class AbstractMemoryCheckpointNode extends StateSplit { - - @Input private final NodeInputList mergedNodes = new NodeInputList(this); - - private static final int SUCCESSOR_COUNT = 0; - private static final int INPUT_COUNT = 0; - - public AbstractMemoryCheckpointNode(Graph graph) { - this(CiKind.Illegal, graph); - } - - public AbstractMemoryCheckpointNode(CiKind result, Graph graph) { - super(result, graph); - } - - @Override - public Map getDebugProperties() { - Map debugProperties = super.getDebugProperties(); - debugProperties.put("memoryCheckpoint", "true"); - return debugProperties; - } - - public NodeInputList mergedNodes() { - return mergedNodes; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/extended/AbstractVectorNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/extended/AbstractVectorNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,83 +0,0 @@ -/* - * 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.nodes.extended; - -import java.util.*; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.sun.cri.ci.*; - - -public abstract class AbstractVectorNode extends StateSplit { - @Input private AbstractVectorNode vector; - - public AbstractVectorNode vector() { - return vector; - } - - public void setVector(AbstractVectorNode x) { - updateUsages(vector, x); - vector = x; - } - - public AbstractVectorNode(CiKind kind, AbstractVectorNode vector, Graph graph) { - super(kind, graph); - setVector(vector); - } - - protected static AbstractVectorNode findCommonNode(AbstractVectorNode left, AbstractVectorNode right, List leftList, List rightList) { - Set occured = new HashSet(); - AbstractVectorNode common = null; - AbstractVectorNode cur = left; - while (cur != null) { - occured.add(cur); - cur = cur.vector(); - } - - cur = right; - while (cur != null) { - if (occured.contains(cur)) { - common = cur; - break; - } - cur = cur.vector(); - } - - fillUntil(left, cur, leftList); - fillUntil(right, cur, rightList); - return common; - } - - private static void fillUntil(AbstractVectorNode left, AbstractVectorNode until, List leftList) { - AbstractVectorNode cur = left; - while (cur != null && cur != until) { - leftList.add(cur); - cur = cur.vector(); - } - } - - public void addToLoop(LoopBeginNode loop, IdentityHashMap nodes) { - throw new IllegalStateException("unimplemented"); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/extended/AccessNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/extended/AccessNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ -/* - * 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.nodes.extended; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.sun.cri.ci.*; - - -public abstract class AccessNode extends AbstractMemoryCheckpointNode { - @Input private ValueNode object; - @Input private GuardNode guard; - @Input private LocationNode location; - @Input private final NodeInputList dependencies = new NodeInputList(this); - - public ValueNode object() { - return object; - } - - public void setObject(ValueNode x) { - updateUsages(object, x); - object = x; - } - - public GuardNode guard() { - return guard; - } - - public void setGuard(GuardNode x) { - updateUsages(guard, x); - guard = x; - } - - public LocationNode location() { - return location; - } - - public void setLocation(LocationNode x) { - updateUsages(location, x); - location = x; - } - - public AccessNode(CiKind kind, ValueNode object, LocationNode location, Graph graph) { - super(kind, graph); - setLocation(location); - setObject(object); - } - - public void addDependency(Node x) { - dependencies.add(x); - } - - public NodeInputList dependencies() { - return dependencies; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/extended/AccessVectorNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/extended/AccessVectorNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -/* - * 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.nodes.extended; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.sun.cri.ci.*; - - -public abstract class AccessVectorNode extends AbstractVectorNode { - @Input private ValueNode object; - @Input private LocationNode location; - @Input private final NodeInputList dependencies = new NodeInputList(this); - - public ValueNode object() { - return object; - } - - public void setObject(ValueNode x) { - updateUsages(object, x); - object = x; - } - - public LocationNode location() { - return location; - } - - public void setLocation(LocationNode x) { - updateUsages(location, x); - location = x; - } - - public AccessVectorNode(CiKind kind, AbstractVectorNode vector, ValueNode object, LocationNode location, Graph graph) { - super(kind, vector, graph); - setObject(object); - setLocation(location); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/extended/CreateVectorNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/extended/CreateVectorNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,154 +0,0 @@ -/* - * 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.nodes.extended; - -import java.util.*; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.base.PhiNode.*; -import com.oracle.max.graal.nodes.calc.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - - -public final class CreateVectorNode extends AbstractVectorNode { - @Input private ValueNode length; - - public ValueNode length() { - return length; - } - - public void setLength(ValueNode x) { - updateUsages(length, x); - length = x; - } - - private boolean reversed; - - public boolean reversed() { - return reversed; - } - - public void setReversed(boolean r) { - reversed = r; - } - - public CreateVectorNode(boolean reversed, ValueNode length, Graph graph) { - super(CiKind.Illegal, null, graph); - setLength(length); - setReversed(reversed); - } - - @Override - public Map getDebugProperties() { - Map debugProperties = super.getDebugProperties(); - debugProperties.put("reversed", reversed); - return debugProperties; - } - - @SuppressWarnings("unchecked") - @Override - public T lookup(Class clazz) { - if (clazz == LIRGeneratorOp.class) { - return null; - } else if (clazz == LoweringOp.class) { - return (T) LOWERING_OP; - } - return super.lookup(clazz); - } - - private LoopBeginNode createLoop(Map map) { - EndNode end = new EndNode(graph()); - LoopBeginNode loopBegin = new LoopBeginNode(graph()); - loopBegin.addEnd(end); - PhiNode loopVariable = new PhiNode(CiKind.Int, loopBegin, PhiType.Value, graph()); - - if (reversed) { - IntegerSubNode add = new IntegerSubNode(CiKind.Int, loopVariable, ConstantNode.forInt(1, graph()), graph()); - loopVariable.addInput(new IntegerSubNode(CiKind.Int, length(), ConstantNode.forInt(1, graph()), graph())); - loopVariable.addInput(add); - } else { - IntegerAddNode add = new IntegerAddNode(CiKind.Int, loopVariable, ConstantNode.forInt(1, graph()), graph()); - loopVariable.addInput(ConstantNode.forInt(0, graph())); - loopVariable.addInput(add); - } - - LoopEndNode loopEnd = new LoopEndNode(graph()); - loopEnd.setLoopBegin(loopBegin); - loopBegin.setStateAfter(stateAfter()); - CompareNode condition; - if (reversed) { - condition = new CompareNode(loopVariable, Condition.GE, ConstantNode.forInt(0, graph()), graph()); - } else { - condition = new CompareNode(loopVariable, Condition.LT, length(), graph()); - } - int expectedLength = 100; // TODO: it may be possible to get a more accurate estimate...? - if (length().isConstant()) { - expectedLength = length().asConstant().asInt(); - } - IfNode ifNode = new IfNode(condition, 1.0 / expectedLength, graph()); - loopBegin.setNext(ifNode); - ifNode.setTrueSuccessor(loopEnd); - this.replaceAtPredecessors(end); - ifNode.setFalseSuccessor(this); - map.put(this, loopVariable); - return loopBegin; - } - - private static final LoweringOp LOWERING_OP = new LoweringOp() { - @Override - public void lower(Node n, CiLoweringTool tool) { - CreateVectorNode vectorNode = (CreateVectorNode) n; - - IdentityHashMap nodes = new IdentityHashMap(); - LoopBeginNode begin = vectorNode.createLoop(nodes); - for (Node use : vectorNode.usages()) { - processUse(begin, use, nodes); - } - } - - private void processUse(LoopBeginNode loop, Node use, IdentityHashMap nodes) { - AbstractVectorNode vectorNode = (AbstractVectorNode) use; - if (nodes.containsKey(vectorNode)) { - return; - } - nodes.put(vectorNode, null); - - // Make sure inputs are evaluated. - for (Node input : use.inputs()) { - if (input instanceof AbstractVectorNode) { - AbstractVectorNode abstractVectorNodeInput = (AbstractVectorNode) input; - processUse(loop, abstractVectorNodeInput, nodes); - } - } - - vectorNode.addToLoop(loop, nodes); - - // Go on to usages. - for (Node usage : use.usages()) { - processUse(loop, usage, nodes); - } - } - }; -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/extended/LocationNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/extended/LocationNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,114 +0,0 @@ -/* - * 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.nodes.extended; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.calc.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; -import com.sun.cri.ci.CiAddress.Scale; - - -public final class LocationNode extends FloatingNode { - @Input private ValueNode index; - - @Data private int displacement; - @Data private boolean indexScalingEnabled = true; - @Data private CiKind valueKind; - @Data private Object locationIdentity; - - public ValueNode index() { - return index; - } - - public void setIndex(ValueNode x) { - updateUsages(index, x); - index = x; - } - - public static final Object UNSAFE_ACCESS_LOCATION = new Object(); - public static final Object FINAL_LOCATION = new Object(); - - public static Object getArrayLocation(CiKind elementKind) { - return elementKind; - } - - public int displacement() { - return displacement; - } - - /** - * @return whether scaling of the index by the value kind's size is enabled (the default) or disabled. - */ - public boolean indexScalingEnabled() { - return indexScalingEnabled; - } - - /** - * Enables or disables scaling of the index by the value kind's size. Has no effect if the index input is not used. - */ - public void setIndexScalingEnabled(boolean enable) { - this.indexScalingEnabled = enable; - } - - public static LocationNode create(Object identity, CiKind kind, int displacement, Graph graph) { - LocationNode result = new LocationNode(identity, kind, displacement, graph); - return graph.value(result); - } - - private LocationNode(Object identity, CiKind kind, int displacement, Graph graph) { - super(CiKind.Illegal, graph); - this.displacement = displacement; - this.valueKind = kind; - this.locationIdentity = identity; - } - - @Override - public T lookup(Class clazz) { - if (clazz == LIRGeneratorOp.class) { - return null; - } - return super.lookup(clazz); - } - - public CiKind getValueKind() { - return valueKind; - } - - public CiAddress createAddress(LIRGeneratorTool lirGenerator, ValueNode object) { - CiValue indexValue = CiValue.IllegalValue; - Scale indexScale = Scale.Times1; - if (this.index() != null) { - indexValue = lirGenerator.load(this.index()); - if (indexScalingEnabled) { - indexScale = Scale.fromInt(valueKind.sizeInBytes(lirGenerator.target().wordSize)); - } - } - return new CiAddress(valueKind, lirGenerator.load(object), indexValue, indexScale, displacement); - } - - public Object locationIdentity() { - return locationIdentity; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/extended/LookupSwitchNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/extended/LookupSwitchNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.extended; - -import java.util.*; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; - -/** - * The {@code LookupSwitch} instruction represents a lookup switch bytecode, which has a sorted - * array of key values. - */ -public final class LookupSwitchNode extends SwitchNode { - - private static final int INPUT_COUNT = 0; - private static final int SUCCESSOR_COUNT = 0; - - final int[] keys; - - /** - * Constructs a new LookupSwitch instruction. - * @param value the instruction producing the value being switched on - * @param successors the list of successors - * @param keys the list of keys, sorted - * @param stateAfter the state after the switch - * @param graph - */ - public LookupSwitchNode(ValueNode value, List successors, int[] keys, double[] probability, Graph graph) { - super(value, successors, probability, INPUT_COUNT, SUCCESSOR_COUNT, graph); - this.keys = keys; - } - - /** - * Gets the key at the specified index. - * @param i the index - * @return the key at that index - */ - public int keyAt(int i) { - return keys[i]; - } - - public int keysLength() { - return keys.length; - } - - @Override - public void accept(ValueVisitor v) { - v.visitLookupSwitch(this); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/extended/ReadNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/extended/ReadNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -/* - * 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.nodes.extended; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - - -public final class ReadNode extends AccessNode implements Node.ValueNumberable { - - public ReadNode(CiKind kind, ValueNode object, LocationNode location, Graph graph) { - super(kind, object, location, graph); - } - - @Override - public void accept(ValueVisitor v) { - v.visitMemoryRead(this); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/extended/ReadVectorNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/extended/ReadVectorNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -/* - * 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.nodes.extended; - -import java.util.*; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - - -public final class ReadVectorNode extends AccessVectorNode { - - public ReadVectorNode(AbstractVectorNode vector, ValueNode object, LocationNode location, Graph graph) { - super(CiKind.Illegal, vector, object, location, graph); - } - - @Override - public T lookup(Class clazz) { - if (clazz == LIRGeneratorOp.class) { - return null; - } - return super.lookup(clazz); - } - - @Override - public void addToLoop(LoopBeginNode loop, IdentityHashMap nodes) { - LocationNode newLocation = LocationNode.create(LocationNode.getArrayLocation(location().getValueKind()), location().getValueKind(), location().displacement(), graph()); - ValueNode index = nodes.get(vector()); - assert index != null; - newLocation.setIndex(index); - ReadNode readNode = new ReadNode(location().getValueKind().stackKind(), object(), newLocation, graph()); - loop.loopEnd().replaceAtPredecessors(readNode); - readNode.setNext(loop.loopEnd()); - nodes.put(this, readNode); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/extended/SwitchNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/extended/SwitchNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2009, 2010, 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.nodes.extended; - -import java.util.*; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.sun.cri.ci.*; - -/** - * The {@code Switch} class is the base of both lookup and table switches. - */ -public abstract class SwitchNode extends ControlSplitNode { - - @Input private ValueNode value; - - public ValueNode value() { - return value; - } - - public void setValue(ValueNode x) { - updateUsages(value, x); - value = x; - } - - /** - * Constructs a new Switch. - * @param value the instruction that provides the value to be switched over - * @param successors the list of successors of this switch - * @param stateAfter the state after the switch - * @param graph - */ - public SwitchNode(ValueNode value, List successors, double[] probability, int inputCount, int successorCount, Graph graph) { - super(CiKind.Illegal, successors, probability, graph); - setValue(value); - } - - /** - * Gets the number of cases that this switch covers (excluding the default case). - * @return the number of cases - */ - public int numberOfCases() { - return blockSuccessorCount() - 1; - } - -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/extended/TableSwitchNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/extended/TableSwitchNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.extended; - -import java.util.*; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; - -/** - * The {@code TableSwitch} instruction represents a table switch. - */ -public final class TableSwitchNode extends SwitchNode { - - private static final int INPUT_COUNT = 0; - private static final int SUCCESSOR_COUNT = 0; - - final int lowKey; - - /** - * Constructs a new TableSwitch instruction. - * @param value the instruction producing the value being switched on - * @param successors the list of successors - * @param lowKey the lowest integer key in the table - * @param stateAfter the state after the switch - * @param graph - */ - public TableSwitchNode(ValueNode value, List successors, int lowKey, double[] probability, Graph graph) { - super(value, successors, probability, INPUT_COUNT, SUCCESSOR_COUNT, graph); - this.lowKey = lowKey; - } - - /** - * Gets the lowest key in the table switch (inclusive). - * @return the low key - */ - public int lowKey() { - return lowKey; - } - - /** - * Gets the highest key in the table switch (exclusive). - * @return the high key - */ - public int highKey() { - return lowKey + numberOfCases(); - } - - @Override - public void accept(ValueVisitor v) { - v.visitTableSwitch(this); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/extended/ValueAnchorNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/extended/ValueAnchorNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -/* - * 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.nodes.extended; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - -/** - * The ValueAnchor instruction keeps non-CFG nodes above a certain point in the graph. - */ -public final class ValueAnchorNode extends FixedWithNextNode { - @Input private ValueNode object; - - public ValueNode object() { - return object; - } - - public void setObject(ValueNode x) { - updateUsages(object, x); - object = x; - } - - public ValueAnchorNode(ValueNode object, Graph graph) { - super(CiKind.Illegal, graph); - setObject(object); - } - - @Override - public void accept(ValueVisitor v) { - v.visitValueAnchor(this); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/extended/WriteMemoryCheckpointNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/extended/WriteMemoryCheckpointNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/* - * 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.nodes.extended; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - - -public final class WriteMemoryCheckpointNode extends AbstractMemoryCheckpointNode { - - public WriteMemoryCheckpointNode(Graph graph) { - this(CiKind.Illegal, graph); - } - - public WriteMemoryCheckpointNode(CiKind result, Graph graph) { - super(result, graph); - } - - @Override - public T lookup(Class clazz) { - if (clazz == LIRGeneratorOp.class) { - return null; - } - return super.lookup(clazz); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/extended/WriteNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/extended/WriteNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -/* - * 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.nodes.extended; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - - -public final class WriteNode extends AccessNode { - @Input private ValueNode value; - - public ValueNode value() { - return value; - } - - public void setValue(ValueNode x) { - updateUsages(value, x); - value = x; - } - - public WriteNode(CiKind kind, ValueNode object, ValueNode value, LocationNode location, Graph graph) { - super(kind, object, location, graph); - setValue(value); - } - - @Override - public void accept(ValueVisitor v) { - v.visitMemoryWrite(this); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/extended/WriteVectorNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/extended/WriteVectorNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -/* - * 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.nodes.extended; - -import java.util.*; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - - -public final class WriteVectorNode extends AccessVectorNode { - @Input private AbstractVectorNode values; - - public AbstractVectorNode values() { - return values; - } - - public void setValues(AbstractVectorNode x) { - updateUsages(values, x); - values = x; - } - - public WriteVectorNode(AbstractVectorNode vector, ValueNode object, LocationNode location, AbstractVectorNode values, Graph graph) { - super(CiKind.Illegal, vector, object, location, graph); - setValues(values); - } - - @Override - public T lookup(Class clazz) { - if (clazz == LIRGeneratorOp.class) { - return null; - } - return super.lookup(clazz); - } - - @Override - public void addToLoop(LoopBeginNode loop, IdentityHashMap nodes) { - LocationNode newLocation = LocationNode.create(LocationNode.getArrayLocation(location().getValueKind()), location().getValueKind(), location().displacement(), graph()); - ValueNode index = nodes.get(vector()); - ValueNode value = nodes.get(values()); - assert index != null; - assert value != null; - newLocation.setIndex(index); - WriteNode writeNode = new WriteNode(location().getValueKind().stackKind(), object(), value, newLocation, graph()); - loop.loopEnd().replaceAtPredecessors(writeNode); - writeNode.setNext(loop.loopEnd()); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/AccessArrayNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/AccessArrayNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.java; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.sun.cri.ci.*; - -/** - * This the base class of all array operations. - */ -public abstract class AccessArrayNode extends StateSplit { - - @Input private ValueNode array; - - public ValueNode array() { - return array; - } - - public void setArray(ValueNode x) { - updateUsages(array, x); - array = x; - } - - /** - * Creates a new AccessArray instruction. - * @param kind the type of the result of this instruction - * @param array the instruction that produces the array object value - * @param graph - */ - public AccessArrayNode(CiKind kind, ValueNode array, Graph graph) { - super(kind, graph); - setArray(array); - } - -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/AccessFieldNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/AccessFieldNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.java; - -import java.lang.reflect.*; -import java.util.*; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.sun.cri.ci.*; -import com.sun.cri.ri.*; - -/** - * The base class of all instructions that access fields. - */ -public abstract class AccessFieldNode extends StateSplit { - - @Input private ValueNode object; - - public ValueNode object() { - return object; - } - - public void setObject(ValueNode x) { - updateUsages(object, x); - object = x; - } - - protected final RiField field; - - /** - * Constructs a new access field object. - * @param kind the result kind of the access - * @param object the instruction producing the receiver object - * @param field the compiler interface representation of the field - * @param graph - */ - public AccessFieldNode(CiKind kind, ValueNode object, RiField field, Graph graph) { - super(kind, graph); - this.field = field; - setObject(object); - assert field.isResolved(); - assert field.holder().isInitialized(); - } - - /** - * Gets the compiler interface field for this field access. - * @return the compiler interface field for this field access - */ - public RiField field() { - return field; - } - - /** - * Checks whether this field access is an access to a static field. - * @return {@code true} if this field access is to a static field - */ - public boolean isStatic() { - return Modifier.isStatic(field.accessFlags()); - } - - /** - * Checks whether this field is declared volatile. - * @return {@code true} if the field is resolved and declared volatile - */ - public boolean isVolatile() { - return Modifier.isVolatile(field.accessFlags()); - } - - @Override - public Map getDebugProperties() { - Map properties = super.getDebugProperties(); - properties.put("field", field); - return properties; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/AccessIndexedNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/AccessIndexedNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.java; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.sun.cri.ci.*; - -/** - * The {@code AccessIndexed} class is the base class of instructions that read or write - * elements of an array. - */ -public abstract class AccessIndexedNode extends AccessArrayNode { - - @Input private ValueNode index; - - @Input private ValueNode length; - - public ValueNode index() { - return index; - } - - public void setIndex(ValueNode x) { - updateUsages(index, x); - index = x; - } - - public ValueNode length() { - return length; - } - - public void setLength(ValueNode x) { - updateUsages(length, x); - length = x; - } - - private final CiKind elementType; - - /** - * Create an new AccessIndexed instruction. - * @param kind the result kind of the access - * @param array the instruction producing the array - * @param index the instruction producing the index - * @param length the instruction producing the length (used in bounds check elimination?) - * @param elementKind the type of the elements of the array - * @param graph - */ - protected AccessIndexedNode(CiKind kind, ValueNode array, ValueNode index, ValueNode length, CiKind elementKind, Graph graph) { - super(kind, array, graph); - setIndex(index); - setLength(length); - this.elementType = elementKind; - } - - /** - * Gets the element type of the array. - * @return the element type - */ - public CiKind elementKind() { - return elementType; - } - -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/AccessMonitorNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/AccessMonitorNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.java; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.extended.*; -import com.sun.cri.ci.*; - -/** - * The {@code AccessMonitor} instruction is the base class of both monitor acquisition and release. - */ -public abstract class AccessMonitorNode extends AbstractMemoryCheckpointNode { - - @Input private ValueNode object; - @Input private ValueNode lockAddress; - - public ValueNode object() { - return object; - } - - public void setObject(ValueNode x) { - updateUsages(object, x); - object = x; - } - - public ValueNode lockAddress() { - return lockAddress; - } - - public void setLockAddress(ValueNode x) { - updateUsages(lockAddress, x); - lockAddress = x; - } - - /** - * The lock number of this monitor access. - */ - public final int lockNumber; - - /** - * Creates a new AccessMonitor instruction. - * - * @param object the instruction producing the object - * @param lockAddress the address of the on-stack lock object or {@code null} if the runtime does not place locks on the stack - * @param lockNumber the number of the lock being acquired - * @param graph - */ - public AccessMonitorNode(ValueNode object, ValueNode lockAddress, int lockNumber, Graph graph) { - super(CiKind.Illegal, graph); - this.lockNumber = lockNumber; - setObject(object); - setLockAddress(lockAddress); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/ArrayLengthNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/ArrayLengthNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.java; - -import com.oracle.max.graal.compiler.graph.*; -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.calc.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; -import com.sun.cri.ri.*; - -/** - * The {@code ArrayLength} instruction gets the length of an array. - */ -public final class ArrayLengthNode extends FloatingNode implements Canonicalizable { - - @Input private ValueNode array; - - public ValueNode array() { - return array; - } - - public void setArray(ValueNode x) { - updateUsages(array, x); - array = x; - } - - /** - * Constructs a new ArrayLength instruction. - * - * @param array the instruction producing the array - * @param newFrameState the state after executing this instruction - */ - public ArrayLengthNode(ValueNode array, Graph graph) { - super(CiKind.Int, graph); - setArray(array); - } - - @Override - public void accept(ValueVisitor v) { - v.visitArrayLength(this); - } - - @Override - public Node canonical(NotifyReProcess reProcess) { - if (array() instanceof NewArrayNode) { - ValueNode length = ((NewArrayNode) array()).dimension(0); - assert length != null; - return length; - } - CiConstant constantValue = null; - if (array().isConstant()) { - constantValue = array().asConstant(); - if (constantValue != null && constantValue.isNonNull()) { - if (graph() instanceof CompilerGraph) { - RiRuntime runtime = ((CompilerGraph) graph()).runtime(); - return ConstantNode.forInt(runtime.getArrayLength(constantValue), graph()); - } - } - } - return this; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/CheckCastNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/CheckCastNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.java; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.bytecode.*; -import com.sun.cri.ci.*; -import com.sun.cri.ri.*; - -/** - * The {@code CheckCast} instruction represents a {@link Bytecodes#CHECKCAST}. - */ -public final class CheckCastNode extends TypeCheckNode implements Canonicalizable { - - /** - * Creates a new CheckCast instruction. - * - * @param targetClass the class being cast to - * @param object the instruction producing the object - * @param graph - */ - public CheckCastNode(ValueNode targetClassInstruction, ValueNode object, Graph graph) { - super(targetClassInstruction, object, CiKind.Object, graph); - } - - /** - * Gets the declared type of the result of this instruction. - * - * @return the declared type of the result - */ - @Override - public RiType declaredType() { - return targetClass(); - } - - /** - * Gets the exact type of the result of this instruction. - * - * @return the exact type of the result - */ - @Override - public RiType exactType() { - return targetClass().isResolved() ? targetClass().exactType() : null; - } - - @Override - public void accept(ValueVisitor v) { - v.visitCheckCast(this); - } - - @Override - public Node canonical(NotifyReProcess reProcess) { - if (object().exactType() != null) { - return object(); - } - CiConstant constant = object().asConstant(); - if (constant != null) { - assert constant.kind == CiKind.Object; - if (constant.isNull()) { - return object(); - } else { - // this should never happen - non-null constants are always expected to provide an exactType - assert false; - } - } - return this; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/ExceptionObjectNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/ExceptionObjectNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.java; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - -/** - * The {@code ExceptionObject} instruction represents the incoming exception object to an exception handler. - */ -public final class ExceptionObjectNode extends StateSplit { - - /** - * Constructs a new ExceptionObject instruction. - * @param graph - */ - public ExceptionObjectNode(Graph graph) { - super(CiKind.Object, graph); - } - - @Override - public void accept(ValueVisitor v) { - v.visitExceptionObject(this); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/InstanceOfNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/InstanceOfNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.java; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - -/** - * The {@code InstanceOf} instruction represents an instanceof test. - */ -public final class InstanceOfNode extends TypeCheckNode implements Canonicalizable { - - /** - * Constructs a new InstanceOf instruction. - * - * @param targetClass the target class of the instanceof check - * @param object the instruction producing the object input to this instruction - * @param graph - */ - public InstanceOfNode(ConstantNode targetClassInstruction, ValueNode object, boolean nullIsTrue, Graph graph) { - super(targetClassInstruction, object, CiKind.Illegal, graph); - } - - @Override - public void accept(ValueVisitor v) { - } - - @Override - public Node canonical(NotifyReProcess reProcess) { - if (object().exactType() != null) { - return ConstantNode.forBoolean(object().exactType().isSubtypeOf(targetClass()), graph()); - } - CiConstant constant = object().asConstant(); - if (constant != null) { - assert constant.kind == CiKind.Object; - if (constant.isNull()) { - return ConstantNode.forBoolean(false, graph()); - } else { - // this should never happen - non-null constants are always expected to provide an exactType - assert false; - } - } - return this; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/IsTypeNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/IsTypeNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.java; - -import java.util.*; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; -import com.sun.cri.ri.*; - -/** - * The {@code TypeCheck} class represents an explicit type check instruction. - */ -public final class IsTypeNode extends BooleanNode implements Canonicalizable { - - @Input private ValueNode object; - - public ValueNode object() { - return object; - } - - public void setObject(ValueNode x) { - updateUsages(object, x); - object = x; - } - - private final RiType type; - - /** - * Constructs a new IsType instruction. - * - * @param object the instruction producing the object to check against the given type - * @param graph - */ - public IsTypeNode(ValueNode object, RiType type, Graph graph) { - super(CiKind.Object, graph); - assert type.isResolved(); - assert object == null || object.kind == CiKind.Object; - this.type = type; - setObject(object); - } - - public RiType type() { - return type; - } - - @Override - public void accept(ValueVisitor v) { - // Nothing to do. - } - - @Override - public RiType declaredType() { - // type check does not alter the type of the object - return object().declaredType(); - } - - @Override - public RiType exactType() { - return type; - } - - @Override - public Map getDebugProperties() { - Map properties = super.getDebugProperties(); - properties.put("type", type); - return properties; - } - - @Override - public Node canonical(NotifyReProcess reProcess) { - if (object().exactType() != null) { - return ConstantNode.forBoolean(object().exactType() == type(), graph()); - } - // constants return the correct exactType, so they are handled by the code above - return this; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/LoadFieldNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/LoadFieldNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.java; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; -import com.sun.cri.ri.*; - -/** - * The {@code LoadField} instruction represents a read of a static or instance field. - */ -public final class LoadFieldNode extends AccessFieldNode implements Canonicalizable { - - /** - * Creates a new LoadField instance. - * - * @param object the receiver object - * @param field the compiler interface field - * @param isStatic indicates if the field is static - * @param stateAfter the state after the field access - * @param graph - * @param isLoaded indicates if the class is loaded - */ - public LoadFieldNode(ValueNode object, RiField field, Graph graph) { - super(field.kind().stackKind(), object, field, graph); - } - - /** - * Gets the declared type of the field being accessed. - * - * @return the declared type of the field being accessed. - */ - @Override - public RiType declaredType() { - return field().type(); - } - - /** - * Gets the exact type of the field being accessed. If the field type is a primitive array or an instance class and - * the class is loaded and final, then the exact type is the same as the declared type. Otherwise it is {@code null} - * - * @return the exact type of the field if known; {@code null} otherwise - */ - @Override - public RiType exactType() { - RiType declared = declaredType(); - return declared != null && declared.isResolved() ? declared.exactType() : null; - } - - @Override - public void accept(ValueVisitor v) { - v.visitLoadField(this); - } - - @Override - public boolean needsStateAfter() { - return false; - } - - /** - * Gets a constant value to which this load can be reduced. - * - * @return {@code null} if this load cannot be reduced to a constant - */ - private CiConstant constantValue() { - if (isStatic()) { - return field.constantValue(null); - } else if (object().isConstant()) { - return field.constantValue(object().asConstant()); - } - return null; - } - - @Override - public Node canonical(NotifyReProcess reProcess) { - CiConstant constant = null; - if (isStatic()) { - constant = field().constantValue(null); - } else if (object().isConstant()) { - constant = field().constantValue(object().asConstant()); - } - if (constant != null) { - return new ConstantNode(constant, graph()); - } - return this; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/LoadIndexedNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/LoadIndexedNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.java; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; -import com.sun.cri.ri.*; - -/** - * The {@code LoadIndexed} instruction represents a read from an element of an array. - */ -public final class LoadIndexedNode extends AccessIndexedNode { - - /** - * Creates a new LoadIndexed instruction. - * @param array the instruction producing the array - * @param index the instruction producing the index - * @param length the instruction producing the length - * @param elementKind the element type - * @param graph - */ - public LoadIndexedNode(ValueNode array, ValueNode index, ValueNode length, CiKind elementKind, Graph graph) { - super(elementKind.stackKind(), array, index, length, elementKind, graph); - } - - /** - * Gets the declared type of this instruction's result. - * @return the declared type - */ - @Override - public RiType declaredType() { - RiType arrayType = array().declaredType(); - if (arrayType == null) { - return null; - } - return arrayType.componentType(); - } - - /** - * Gets the exact type of this instruction's result. - * @return the exact type - */ - @Override - public RiType exactType() { - RiType declared = declaredType(); - return declared != null && declared.isResolved() ? declared.exactType() : null; - } - - @Override - public void accept(ValueVisitor v) { - v.visitLoadIndexed(this); - } - - @Override - public boolean needsStateAfter() { - return false; - } - - @SuppressWarnings("unchecked") - @Override - public T lookup(Class clazz) { - if (clazz == LoweringOp.class) { - return (T) DELEGATE_TO_RUNTIME; - } - return super.lookup(clazz); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/MathIntrinsicNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/MathIntrinsicNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -/* - * 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.nodes.java; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.calc.*; -import com.oracle.max.graal.nodes.spi.*; - -public class MathIntrinsicNode extends FloatingNode { - - @Input private ValueNode x; - @Data private final Operation operation; - - public enum Operation { - ABS, SQRT, - } - - public ValueNode x() { - return x; - } - - private void setX(ValueNode x) { - updateUsages(this.x, x); - this.x = x; - } - - public Operation operation() { - return operation; - } - - public MathIntrinsicNode(ValueNode x, Operation op, Graph graph) { - super(x.kind, graph); - setX(x); - this.operation = op; - } - - @Override - public void accept(ValueVisitor v) { - v.visitMathIntrinsic(this); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/MonitorAddressNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/MonitorAddressNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2010, 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.nodes.java; - -import java.util.*; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - -/** - * Instruction that is used to refer to the address of an on-stack monitor. - */ -public final class MonitorAddressNode extends ValueNode { - - private int monitorIndex; - - public MonitorAddressNode(int monitorIndex, Graph graph) { - super(CiKind.Word, graph); - this.monitorIndex = monitorIndex; - } - - @Override - public void accept(ValueVisitor v) { - v.visitMonitorAddress(this); - } - - public int monitorIndex() { - return monitorIndex; - } - - public void setMonitorIndex(int monitorIndex) { - this.monitorIndex = monitorIndex; - } - - @Override - public Map getDebugProperties() { - Map properties = super.getDebugProperties(); - properties.put("monitorIndex", monitorIndex); - return properties; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/MonitorEnterNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/MonitorEnterNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.java; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; - -/** - * The {@code MonitorEnter} instruction represents the acquisition of a monitor. - */ -public final class MonitorEnterNode extends AccessMonitorNode { - - /** - * Creates a new MonitorEnter instruction. - * - * @param object the instruction producing the object - * @param lockAddress the address of the on-stack lock object or {@code null} if the runtime does not place locks on the stack - * @param lockNumber the number of the lock - * @param graph - */ - public MonitorEnterNode(ValueNode object, ValueNode lockAddress, int lockNumber, Graph graph) { - super(object, lockAddress, lockNumber, graph); - } - - @Override - public void accept(ValueVisitor v) { - v.visitMonitorEnter(this); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/MonitorExitNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/MonitorExitNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.java; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; - -/** - * The {@code MonitorExit} instruction represents a monitor release. - */ -public final class MonitorExitNode extends AccessMonitorNode { - - /** - * Creates a new MonitorExit instruction. - * - * @param object the instruction produces the object value - * @param lockAddress the address of the on-stack lock object or {@code null} if the runtime does not place locks on the stack - * @param lockNumber the number of the lock - * @param graph - */ - public MonitorExitNode(ValueNode object, ValueNode lockAddress, int lockNumber, Graph graph) { - super(object, lockAddress, lockNumber, graph); - } - - @Override - public void accept(ValueVisitor v) { - v.visitMonitorExit(this); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/NewArrayNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/NewArrayNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,179 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.java; - -import java.util.*; - -import com.oracle.max.graal.compiler.*; -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.oracle.max.graal.nodes.virtual.*; -import com.sun.cri.ci.*; - -/** - * The {@code NewArray} class is the base of all instructions that allocate arrays. - */ -public abstract class NewArrayNode extends FixedWithNextNode { - - @Input private ValueNode length; - - public ValueNode length() { - return length; - } - - public void setLength(ValueNode x) { - updateUsages(this.length, x); - this.length = x; - } - - /** - * Constructs a new NewArray instruction. - * @param length the instruction that produces the length for this allocation - * @param graph - */ - protected NewArrayNode(ValueNode length, Graph graph) { - super(CiKind.Object, graph); - setLength(length); - } - - /** - * The list of instructions which produce input for this instruction. - */ - public ValueNode dimension(int index) { - assert index == 0; - return length(); - } - - /** - * The rank of the array allocated by this instruction, i.e. how many array dimensions. - */ - public int dimensionCount() { - return 1; - } - - public abstract CiKind elementKind(); - - @Override - public Map getDebugProperties() { - Map properties = super.getDebugProperties(); - properties.put("exactType", exactType()); - return properties; - } - - @SuppressWarnings("unchecked") - @Override - public T lookup(Class clazz) { - if (clazz == EscapeOp.class) { - return (T) ESCAPE; - } - return super.lookup(clazz); - } - - private static final EscapeOp ESCAPE = new EscapeOp() { - - @Override - public boolean canAnalyze(Node node) { - NewArrayNode x = (NewArrayNode) node; - CiConstant length = x.dimension(0).asConstant(); - return length != null && length.asInt() >= 0 && length.asInt() < GraalOptions.MaximumEscapeAnalysisArrayLength; - } - - @Override - public boolean escape(Node node, Node usage) { - if (usage instanceof LoadIndexedNode) { - LoadIndexedNode x = (LoadIndexedNode) usage; - assert x.array() == node; - CiConstant index = x.index().asConstant(); - CiConstant length = ((NewArrayNode) node).dimension(0).asConstant(); - if (index == null || length == null || index.asInt() < 0 || index.asInt() >= length.asInt()) { - return true; - } - return false; - } else if (usage instanceof StoreFieldNode) { - StoreFieldNode x = (StoreFieldNode) usage; - assert x.value() == node; - return true; - } else if (usage instanceof StoreIndexedNode) { - StoreIndexedNode x = (StoreIndexedNode) usage; - CiConstant index = x.index().asConstant(); - CiConstant length = ((NewArrayNode) node).dimension(0).asConstant(); - if (index == null || length == null || index.asInt() < 0 || index.asInt() >= length.asInt()) { - return true; - } - return x.value() == node && x.array() != node; - } else if (usage instanceof ArrayLengthNode) { - ArrayLengthNode x = (ArrayLengthNode) usage; - assert x.array() == node; - return false; - } else if (usage instanceof VirtualObjectFieldNode) { - return false; - } else { - return super.escape(node, usage); - } - } - - @Override - public EscapeField[] fields(Node node) { - NewArrayNode x = (NewArrayNode) node; - int length = x.dimension(0).asConstant().asInt(); - EscapeField[] fields = new EscapeField[length]; - for (int i = 0; i < length; i++) { - Integer representation = i; - fields[i] = new EscapeField("[" + i + "]", representation, ((NewArrayNode) node).elementKind()); - } - return fields; - } - - @Override - public void beforeUpdate(Node node, Node usage) { - if (usage instanceof ArrayLengthNode) { - ArrayLengthNode x = (ArrayLengthNode) usage; - x.replaceAndDelete(((NewArrayNode) node).dimension(0)); - } else { - super.beforeUpdate(node, usage); - } - } - - @Override - public int updateState(Node node, Node current, Map fieldIndex, ValueNode[] fieldState) { - if (current instanceof AccessIndexedNode) { - AccessIndexedNode x = (AccessIndexedNode) current; - if (x.array() == node) { - int index = ((AccessIndexedNode) current).index().asConstant().asInt(); - if (current instanceof LoadIndexedNode) { - x.replaceAtUsages(fieldState[index]); - assert x.usages().size() == 0; - x.replaceAndDelete(x.next()); - } else if (current instanceof StoreIndexedNode) { - fieldState[index] = ((StoreIndexedNode) x).value(); - assert x.usages().size() == 0; - x.replaceAndDelete(x.next()); - return index; - } - } - } - return -1; - } - }; -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/NewInstanceNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/NewInstanceNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,171 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.java; - -import java.util.*; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.oracle.max.graal.nodes.virtual.*; -import com.sun.cri.ci.*; -import com.sun.cri.ri.*; - -/** - * The {@code NewInstance} instruction represents the allocation of an instance class object. - */ -public final class NewInstanceNode extends FixedWithNextNode { - - final RiType instanceClass; - public final int cpi; - public final RiConstantPool constantPool; - - /** - * Constructs a NewInstance instruction. - * @param type the class being allocated - * @param cpi the constant pool index - * @param graph - */ - public NewInstanceNode(RiType type, int cpi, RiConstantPool constantPool, Graph graph) { - super(CiKind.Object, graph); - this.instanceClass = type; - this.cpi = cpi; - this.constantPool = constantPool; - } - - /** - * Gets the instance class being allocated by this instruction. - * @return the instance class allocated - */ - public RiType instanceClass() { - return instanceClass; - } - - /** - * Gets the exact type produced by this instruction. For allocations of instance classes, this is - * always the class allocated. - * @return the exact type produced by this instruction - */ - @Override - public RiType exactType() { - return instanceClass; - } - - @Override - public void accept(ValueVisitor v) { - v.visitNewInstance(this); - } - - @Override - public Map getDebugProperties() { - Map properties = super.getDebugProperties(); - properties.put("instanceClass", instanceClass); - properties.put("cpi", cpi); - return properties; - } - - @SuppressWarnings("unchecked") - @Override - public T lookup(Class clazz) { - if (clazz == EscapeOp.class) { - return (T) ESCAPE; - } - return super.lookup(clazz); - } - - private static final EscapeOp ESCAPE = new EscapeOp() { - - @Override - public boolean canAnalyze(Node node) { - return ((NewInstanceNode) node).instanceClass().isResolved(); - } - - @Override - public boolean escape(Node node, Node usage) { - if (usage instanceof LoadFieldNode) { - LoadFieldNode x = (LoadFieldNode) usage; - assert x.object() == node; - return x.field().isResolved() == false; - } else if (usage instanceof StoreFieldNode) { - StoreFieldNode x = (StoreFieldNode) usage; - return x.value() == node && x.object() != node; - } else if (usage instanceof StoreIndexedNode) { - StoreIndexedNode x = (StoreIndexedNode) usage; - assert x.value() == node; - return true; - } else if (usage instanceof VirtualObjectFieldNode) { - return false; - } else if (usage instanceof RegisterFinalizerNode) { - RegisterFinalizerNode x = (RegisterFinalizerNode) usage; - assert x.object() == node; - return false; - } else { - return super.escape(node, usage); - } - } - - @Override - public EscapeField[] fields(Node node) { - NewInstanceNode x = (NewInstanceNode) node; - RiField[] riFields = x.instanceClass().fields(); - EscapeField[] fields = new EscapeField[riFields.length]; - for (int i = 0; i < riFields.length; i++) { - RiField field = riFields[i]; - fields[i] = new EscapeField(field.name(), field, field.kind().stackKind()); - } - return fields; - } - - @Override - public void beforeUpdate(Node node, Node usage) { - if (usage instanceof RegisterFinalizerNode) { - RegisterFinalizerNode x = (RegisterFinalizerNode) usage; - x.replaceAndDelete(x.next()); - } else { - super.beforeUpdate(node, usage); - } - } - - @Override - public int updateState(Node node, Node current, Map fieldIndex, ValueNode[] fieldState) { - if (current instanceof AccessFieldNode) { - AccessFieldNode x = (AccessFieldNode) current; - if (x.object() == node) { - int field = fieldIndex.get(((AccessFieldNode) current).field()); - if (current instanceof LoadFieldNode) { - assert fieldState[field] != null : field + ", " + ((AccessFieldNode) current).field(); - x.replaceAtUsages(fieldState[field]); - assert x.usages().size() == 0; - x.replaceAndDelete(x.next()); - } else if (current instanceof StoreFieldNode) { - fieldState[field] = ((StoreFieldNode) x).value(); - assert x.usages().size() == 0; - x.replaceAndDelete(x.next()); - return field; - } - } - } - return -1; - } - }; -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/NewMultiArrayNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/NewMultiArrayNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.java; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; -import com.sun.cri.ri.*; - -/** - * The {@code NewMultiArray} instruction represents an allocation of a multi-dimensional object - * array. - */ -public final class NewMultiArrayNode extends NewArrayNode { - - @Input private final NodeInputList dimensions; - - @Override - public ValueNode dimension(int index) { - return dimensions.get(index); - } - - public void setDimension(int index, ValueNode x) { - dimensions.set(index, x); - } - - /** - * The rank of the array allocated by this instruction, i.e. how many array dimensions. - */ - @Override - public int dimensionCount() { - return dimensions.size(); - } - - public final RiType elementType; - public final int cpi; - public final RiConstantPool constantPool; - - /** - * Constructs a new NewMultiArray instruction. - * @param elementType the element type of the array - * @param dimensions the instructions which produce the dimensions for this array - * @param cpi the constant pool index for resolution - * @param riConstantPool the constant pool for resolution - * @param graph - */ - public NewMultiArrayNode(RiType elementType, ValueNode[] dimensions, int cpi, RiConstantPool riConstantPool, Graph graph) { - super(null, graph); - this.constantPool = riConstantPool; - this.elementType = elementType; - this.cpi = cpi; - - this.dimensions = new NodeInputList(this, dimensions.length); - for (int i = 0; i < dimensions.length; i++) { - setDimension(i, dimensions[i]); - } - } - - @Override - public void accept(ValueVisitor v) { - v.visitNewMultiArray(this); - } - - /** - * Gets the element type of the array. - * @return the element type of the array - */ - public RiType elementType() { - return elementType; - } - - @Override - public CiKind elementKind() { - return elementType.kind(); - } - - @Override - public RiType exactType() { - return elementType.arrayOf(); - } - - @Override - public RiType declaredType() { - return exactType(); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/NewObjectArrayNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/NewObjectArrayNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.java; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; -import com.sun.cri.ri.*; - -/** - * The {@code NewObjectArray} instruction represents an allocation of an object array. - */ -public final class NewObjectArrayNode extends NewArrayNode { - - final RiType elementClass; - - /** - * Constructs a new NewObjectArray instruction. - * @param elementClass the class of elements in this array - * @param length the instruction producing the length of the array - * @param graph - */ - public NewObjectArrayNode(RiType elementClass, ValueNode length, Graph graph) { - super(length, graph); - this.elementClass = elementClass; - } - - /** - * Gets the type of the elements of the array. - * @return the element type of the array - */ - public RiType elementType() { - return elementClass; - } - - @Override - public CiKind elementKind() { - return elementClass.kind(); - } - - @Override - public RiType exactType() { - return elementClass.arrayOf(); - } - - @Override - public RiType declaredType() { - return exactType(); - } - - @Override - public void accept(ValueVisitor v) { - v.visitNewObjectArray(this); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/NewTypeArrayNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/NewTypeArrayNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.java; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; -import com.sun.cri.ri.*; - -/** - * The {@code NewTypeArray} class definition. - */ -public final class NewTypeArrayNode extends NewArrayNode { - - final RiType elementType; - - public NewTypeArrayNode(ValueNode length, RiType elementType, Graph graph) { - super(length, graph); - this.elementType = elementType; - } - - @Override - public CiKind elementKind() { - return elementType.kind(); - } - - @Override - public RiType declaredType() { - return elementType.arrayOf(); - } - - @Override - public RiType exactType() { - return elementType.arrayOf(); - } - - @Override - public void accept(ValueVisitor v) { - v.visitNewTypeArray(this); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/RegisterFinalizerNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/RegisterFinalizerNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2011, 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.nodes.java; - -import com.oracle.max.graal.compiler.*; -import com.oracle.max.graal.compiler.debug.*; -import com.oracle.max.graal.compiler.graph.*; -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; -import com.sun.cri.ri.*; - -/** - * This instruction is used to perform the finalizer registration at the end of the java.lang.Object constructor. - */ -public final class RegisterFinalizerNode extends StateSplit implements Canonicalizable { - - @Input private ValueNode object; - - public ValueNode object() { - return object; - } - - public void setObject(ValueNode x) { - updateUsages(object, x); - object = x; - } - - public RegisterFinalizerNode(ValueNode object, Graph graph) { - super(CiKind.Void, graph); - setObject(object); - } - - @Override - public void accept(ValueVisitor v) { - v.visitRegisterFinalizer(this); - } - - @Override - public Node canonical(NotifyReProcess reProcess) { - RiType declaredType = object.declaredType(); - RiType exactType = object.exactType(); - if (exactType == null && declaredType != null) { - exactType = declaredType.exactType(); - } - - boolean needsCheck = true; - if (exactType != null) { - // we have an exact type - needsCheck = exactType.hasFinalizer(); - } else { - // if either the declared type of receiver or the holder can be assumed to have no finalizers - if (declaredType != null && !declaredType.hasFinalizableSubclass()) { - if (((CompilerGraph) graph()).assumptions().recordNoFinalizableSubclassAssumption(declaredType)) { - needsCheck = false; - } - } - } - - if (needsCheck) { - if (GraalOptions.TraceCanonicalizer) { - TTY.println("Could not canonicalize finalizer " + object + " (declaredType=" + declaredType + ", exactType=" + exactType + ")"); - } - } else { - if (GraalOptions.TraceCanonicalizer) { - TTY.println("Canonicalized finalizer for object " + object); - } - return next(); - } - - return this; - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/StoreFieldNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/StoreFieldNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.java; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; -import com.sun.cri.ri.*; - -/** - * The {@code StoreField} instruction represents a write to a static or instance field. - */ -public final class StoreFieldNode extends AccessFieldNode { - - @Input private ValueNode value; - - public ValueNode value() { - return value; - } - - public void setValue(ValueNode x) { - updateUsages(value, x); - value = x; - } - - /** - * Creates a new LoadField instance. - * @param object the receiver object - * @param field the compiler interface field - * @param value the instruction representing the value to store to the field - * @param stateAfter the state after the field access - * @param graph - */ - public StoreFieldNode(ValueNode object, RiField field, ValueNode value, Graph graph) { - super(CiKind.Void, object, field, graph); - setValue(value); - } - - @Override - public void accept(ValueVisitor v) { - v.visitStoreField(this); - } - - @SuppressWarnings("unchecked") - @Override - public T lookup(java.lang.Class clazz) { - if (clazz == LoweringOp.class) { - return (T) DELEGATE_TO_RUNTIME; - } - return super.lookup(clazz); - }; -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/StoreIndexedNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/StoreIndexedNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.java; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - -/** - * The {@code StoreIndexed} instruction represents a write to an array element. - */ -public final class StoreIndexedNode extends AccessIndexedNode { - - @Input private ValueNode value; - - public ValueNode value() { - return value; - } - - public void setValue(ValueNode x) { - updateUsages(value, x); - value = x; - } - - /** - * Creates a new StoreIndexed instruction. - * @param array the instruction producing the array - * @param index the instruction producing the index - * @param length the instruction producing the length - * @param elementKind the element type - * @param value the value to store into the array - * @param stateAfter the state after executing this instruction - * @param graph - */ - public StoreIndexedNode(ValueNode array, ValueNode index, ValueNode length, CiKind elementKind, ValueNode value, Graph graph) { - super(CiKind.Void, array, index, length, elementKind, graph); - setValue(value); - } - - @Override - public void accept(ValueVisitor v) { - v.visitStoreIndexed(this); - } - - @SuppressWarnings("unchecked") - @Override - public T lookup(Class clazz) { - if (clazz == LoweringOp.class) { - return (T) DELEGATE_TO_RUNTIME; - } - return super.lookup(clazz); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/TypeCheckNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/java/TypeCheckNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.java; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.sun.cri.ci.*; -import com.sun.cri.ri.*; - -/** - * The {@code TypeCheck} instruction is the base class of casts and instanceof tests. - */ -public abstract class TypeCheckNode extends BooleanNode { - @Input private ValueNode object; - @Input private ValueNode targetClassInstruction; - - public ValueNode object() { - return object; - } - - public void setObject(ValueNode x) { - updateUsages(object, x); - object = x; - } - - public ValueNode targetClassInstruction() { - return targetClassInstruction; - } - - public void setTargetClassInstruction(ValueNode x) { - updateUsages(targetClassInstruction, x); - targetClassInstruction = x; - } - - /** - * Gets the target class, i.e. the class being cast to, or the class being tested against. - * @return the target class - */ - public RiType targetClass() { - return targetClassInstruction() instanceof ConstantNode ? (RiType) targetClassInstruction().asConstant().asObject() : null; - } - - /** - * Creates a new TypeCheck instruction. - * @param targetClass the class which is being casted to or checked against - * @param object the instruction which produces the object - * @param kind the result type of this instruction - * @param graph - */ - public TypeCheckNode(ValueNode targetClassInstruction, ValueNode object, CiKind kind, Graph graph) { - super(kind, graph); - setObject(object); - setTargetClassInstruction(targetClassInstruction); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/loop/BasicInductionVariableNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/loop/BasicInductionVariableNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,125 +0,0 @@ -/* - * 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.nodes.loop; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.base.PhiNode.*; -import com.oracle.max.graal.nodes.calc.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - - -/** - * LinearInductionVariable that is computed in the loops thanks to Phi(init, this + stride). - * This will keep at least one register busy in the whole loop body - */ -public class BasicInductionVariableNode extends LinearInductionVariableNode implements Canonicalizable{ - public static final BIVLoweringOp LOWERING = new BIVLoweringOp(); - @Input private LoopCounterNode loopCounter; - - public BasicInductionVariableNode(CiKind kind, ValueNode init, ValueNode stride, LoopCounterNode counter, Graph graph) { - super(kind, init, stride, graph); - setLoopCounter(counter); - } - - public LoopCounterNode loopCounter() { - return loopCounter; - } - - public void setLoopCounter(LoopCounterNode loopCounter) { - updateUsages(this.loopCounter, loopCounter); - this.loopCounter = loopCounter; - } - - public ValueNode init() { - return a(); - } - - public void setInit(ValueNode init) { - setA(init); - } - - public ValueNode stride() { - return b(); - } - - public void setStride(ValueNode stride) { - setB(stride); - } - - @Override - public LoopBeginNode loopBegin() { - return loopCounter().loopBegin(); - } - - @Override - public void peelOneIteration() { - this.setInit(IntegerArithmeticNode.add(init(), stride())); - } - - /** - * Will lessen the register pressure but augment the code complexity with a multiplication. - * @return the new DerivedInductionVariable - */ - public DerivedInductionVariableNode toDerivedInductionVariable() { - DerivedInductionVariableNode newDIV = new DerivedInductionVariableNode(kind, init(), stride(), loopCounter(), graph()); - this.replaceAndDelete(newDIV); - return newDIV; - } - - @Override - public Node canonical(NotifyReProcess reProcess) { - if (this.init().isConstant() && this.init().asConstant().asLong() == 0 - && this.stride().isConstant() && this.stride().asConstant().asLong() == 1) { - return this.loopCounter(); - } - return this; - } - - @SuppressWarnings("unchecked") - @Override - public T lookup(Class clazz) { - if (clazz == LoweringOp.class) { - return (T) LOWERING; - } - return super.lookup(clazz); - } - - public static class BIVLoweringOp implements LoweringOp { - @Override - public void lower(Node n, CiLoweringTool tool) { - BasicInductionVariableNode biv = (BasicInductionVariableNode) n; - PhiNode phi = this.ivToPhi(biv.loopBegin(), biv.init(), biv.stride(), biv.kind); - biv.replaceAtNonIVUsages(phi); - } - - public PhiNode ivToPhi(LoopBeginNode loopBegin, ValueNode init, ValueNode stride, CiKind kind) { - PhiNode phi = new PhiNode(kind, loopBegin, PhiType.Value, loopBegin.graph()); - IntegerArithmeticNode after = IntegerArithmeticNode.add(phi, stride); - phi.addInput(init); - phi.addInput(after); - return phi; - } - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/loop/DerivedInductionVariableNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/loop/DerivedInductionVariableNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,125 +0,0 @@ -/* - * 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.nodes.loop; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.calc.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - - -/** - * LinearInductionVariable that is computed in the loops with offset + scale * base. - * This is computed in the loop only when necessary, puts less pressure on registers. - */ -public class DerivedInductionVariableNode extends LinearInductionVariableNode { - @Input private InductionVariableNode base; - - public DerivedInductionVariableNode(CiKind kind, ValueNode offset, ValueNode scale, InductionVariableNode base, Graph graph) { - super(kind, offset, scale, graph); - setBase(base); - } - - public InductionVariableNode base() { - return base; - } - - public void setBase(InductionVariableNode base) { - updateUsages(this.base, base); - this.base = base; - } - - public ValueNode offset() { - return a(); - } - - public void setOffset(ValueNode offset) { - setA(offset); - } - - public ValueNode scale() { - return b(); - } - - public void setScale(ValueNode scale) { - setB(scale); - } - - @Override - public LoopBeginNode loopBegin() { - return base().loopBegin(); - } - - @Override - public void peelOneIteration() { - // nop - } - - /** - * This will apply strength reduction to this induction variable but will augment register pressure in the loop. - * @return the new BasicInductionVariable - */ - public BasicInductionVariableNode toBasicInductionVariable() { - InductionVariableNode base = base(); - if (base instanceof DerivedInductionVariableNode) { - base = ((DerivedInductionVariableNode) base).toBasicInductionVariable(); - } - ValueNode init; - ValueNode stride; - LoopCounterNode counter; - if (base instanceof BasicInductionVariableNode) { - BasicInductionVariableNode basic = (BasicInductionVariableNode) base; - // let the canonicalizer do its job with this - init = IntegerArithmeticNode.add(offset(), IntegerArithmeticNode.mul(scale(), basic.init())); - stride = IntegerArithmeticNode.mul(scale(), basic.stride()); - counter = basic.loopCounter(); - } else { - assert base instanceof LoopCounterNode; - init = offset(); - stride = scale(); - counter = (LoopCounterNode) base; - } - BasicInductionVariableNode newBIV = new BasicInductionVariableNode(kind, init, stride, counter, graph()); - this.replaceAndDelete(newBIV); - return newBIV; - } - - @SuppressWarnings("unchecked") - @Override - public T lookup(Class clazz) { - if (clazz == LoweringOp.class) { - return (T) LOWERING; - } - return super.lookup(clazz); - } - - private static final LoweringOp LOWERING = new LoweringOp() { - @Override - public void lower(Node n, CiLoweringTool tool) { - DerivedInductionVariableNode div = (DerivedInductionVariableNode) n; - IntegerArithmeticNode computed = IntegerArithmeticNode.add(div.offset(), IntegerArithmeticNode.mul(div.scale(), div.base())); - div.replaceAtNonIVUsages(computed); - } - }; -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/loop/InductionVariableNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/loop/InductionVariableNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -/* - * 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.nodes.loop; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.calc.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - -public abstract class InductionVariableNode extends FloatingNode { - - public InductionVariableNode(CiKind kind, Graph graph) { - super(kind, graph); - assert kind.isInt() || kind.isLong(); - } - - public abstract LoopBeginNode loopBegin(); - - public abstract void peelOneIteration(); - - public void replaceAtNonIVUsages(Node other) { - for (Node usage : this.usages().snapshot()) { - if (!(usage instanceof InductionVariableNode)) { - usage.replaceFirstInput(this, other); - } - } - } - - @Override - public void accept(ValueVisitor v) { - // nop - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/loop/LinearInductionVariableNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/loop/LinearInductionVariableNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -/* - * 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.nodes.loop; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.sun.cri.ci.*; - -/** - * InductionVariable of the form a+b*x. - */ -public abstract class LinearInductionVariableNode extends InductionVariableNode { - @Input private ValueNode a; - @Input private ValueNode b; - - public LinearInductionVariableNode(CiKind kind, ValueNode a, ValueNode b, Graph graph) { - super(kind, graph); - setA(a); - setB(b); - } - - protected ValueNode a() { - return a; - } - - protected ValueNode b() { - return b; - } - - protected void setA(ValueNode a) { - updateUsages(this.a, a); - this.a = a; - } - - - protected void setB(ValueNode b) { - updateUsages(this.b, b); - this.b = b; - } - - public boolean isLinearInductionVariableInput(Node n) { - return n == a() || n == b(); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/loop/LoopCounterNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/loop/LoopCounterNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -/* - * 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.nodes.loop; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - -/** - * Counts loop iterations from 0 to Niter. - * If used directly (and not just by BasicInductionVariables) computed with Phi(0, this + 1) - */ -public final class LoopCounterNode extends InductionVariableNode { - @Input private LoopBeginNode loopBegin; - - @Override - public LoopBeginNode loopBegin() { - return loopBegin; - } - - public void setLoopBegin(LoopBeginNode x) { - updateUsages(loopBegin, x); - loopBegin = x; - } - - public LoopCounterNode(CiKind kind, LoopBeginNode loop, Graph graph) { - super(kind, graph); - setLoopBegin(loop); - } - - @Override - public void peelOneIteration() { - BasicInductionVariableNode biv = null; - for (Node usage : usages()) { - if (!(usage instanceof InductionVariableNode && ((InductionVariableNode) usage).loopBegin() == this.loopBegin())) { - if (biv == null) { - biv = createBasicInductionVariable(); - biv.peelOneIteration(); - } - usage.inputs().replace(this, biv); - } - } - } - - @SuppressWarnings("unchecked") - @Override - public T lookup(Class clazz) { - if (clazz == LoweringOp.class) { - return (T) LOWERING; - } - return super.lookup(clazz); - } - - private BasicInductionVariableNode createBasicInductionVariable() { - Graph graph = graph(); - return new BasicInductionVariableNode(kind, ConstantNode.forInt(0, graph), ConstantNode.forInt(1, graph), this, graph); - } - - private static final LoweringOp LOWERING = new LoweringOp() { - @Override - public void lower(Node n, CiLoweringTool tool) { - LoopCounterNode loopCounter = (LoopCounterNode) n; - Graph graph = n.graph(); - PhiNode phi = BasicInductionVariableNode.LOWERING.ivToPhi(loopCounter.loopBegin(), ConstantNode.forInt(0, graph), ConstantNode.forInt(1, graph), loopCounter.kind); - loopCounter.replaceAtNonIVUsages(phi); - } - }; -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/spi/Canonicalizable.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/spi/Canonicalizable.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -/* - * 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.nodes.spi; - -import com.oracle.max.graal.graph.*; - - -public interface Canonicalizable { - Node canonical(NotifyReProcess reProcess); -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/spi/EscapeField.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/spi/EscapeField.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -/* - * 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.nodes.spi; - -import com.sun.cri.ci.*; - -public class EscapeField { - - private String name; - private Object representation; - private CiKind kind; - - public EscapeField(String name, Object representation, CiKind kind) { - this.name = name; - this.representation = representation; - this.kind = kind; - } - - public String name() { - return name; - } - - public Object representation() { - return representation; - } - - public CiKind kind() { - return kind; - } - - @Override - public String toString() { - return name(); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/spi/EscapeOp.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/spi/EscapeOp.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,79 +0,0 @@ -/* - * 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.nodes.spi; - -import java.util.*; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.calc.*; -import com.oracle.max.graal.nodes.java.*; - - -public abstract class EscapeOp implements Op { - - public abstract boolean canAnalyze(Node node); - - public boolean escape(Node node, Node usage) { - if (usage instanceof IsNonNullNode) { - IsNonNullNode x = (IsNonNullNode) usage; - assert x.object() == node; - return false; - } else if (usage instanceof IsTypeNode) { - IsTypeNode x = (IsTypeNode) usage; - assert x.object() == node; - return false; - } else if (usage instanceof FrameState) { - FrameState x = (FrameState) usage; - assert x.inputContains(node); - return true; - } else if (usage instanceof AccessMonitorNode) { - AccessMonitorNode x = (AccessMonitorNode) usage; - assert x.object() == node; - return false; - } else { - return true; - } - } - - public abstract EscapeField[] fields(Node node); - - public void beforeUpdate(Node node, Node usage) { - if (usage instanceof IsNonNullNode) { - IsNonNullNode x = (IsNonNullNode) usage; - // TODO (ls) not sure about this... - x.replaceAndDelete(ConstantNode.forBoolean(true, node.graph())); - } else if (usage instanceof IsTypeNode) { - IsTypeNode x = (IsTypeNode) usage; - assert x.type() == ((ValueNode) node).exactType(); - // TODO (ls) not sure about this... - x.replaceAndDelete(ConstantNode.forBoolean(true, node.graph())); - } else if (usage instanceof AccessMonitorNode) { - AccessMonitorNode x = (AccessMonitorNode) usage; - x.replaceAndDelete(x.next()); - } - } - - public abstract int updateState(Node node, Node current, Map fieldIndex, ValueNode[] fieldState); - -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/spi/ExceptionExit.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/spi/ExceptionExit.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -/* - * 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.nodes.spi; - -import com.oracle.max.graal.nodes.base.*; - - -public interface ExceptionExit { - FixedNode exceptionEdge(); -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/spi/LIRGeneratorOp.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/spi/LIRGeneratorOp.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -/* - * 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.nodes.spi; - -import com.oracle.max.graal.graph.*; - -public interface LIRGeneratorOp extends Op { - void generate(Node n, LIRGeneratorTool generator); -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/spi/LIRGeneratorTool.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/spi/LIRGeneratorTool.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -/* - * 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.nodes.spi; - -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.calc.*; -import com.sun.cri.ci.*; - -public abstract class LIRGeneratorTool extends ValueVisitor { - public abstract CiValue load(ValueNode value); - public abstract CiVariable createResultVariable(ValueNode conv); - public abstract CiValue forceToSpill(CiValue value, CiKind kind, boolean b); - public abstract void emitMove(CiValue tmp, CiValue reg); - public abstract void integerAdd(ValueNode result, ValueNode x, ValueNode y); - public abstract void deoptimizeOn(Condition of); - public abstract CiVariable newVariable(CiKind kind); - public abstract CiTarget target(); - public abstract void emitLea(CiAddress address, CiVariable dest); - public abstract CiValue makeOperand(ValueNode object); - public abstract void emitUnsignedShiftRight(CiValue value, CiValue count, CiValue dst, CiValue tmp); - public abstract void emitAdd(CiValue a, CiValue b, CiValue dest); -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/spi/LoweringOp.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/spi/LoweringOp.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -/* - * 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.nodes.spi; - -import com.oracle.max.graal.graph.*; -import com.sun.cri.ci.*; - - -public interface LoweringOp extends Op { - void lower(Node n, CiLoweringTool tool); -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/spi/NotifyReProcess.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/spi/NotifyReProcess.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -/* - * 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.nodes.spi; - -import com.oracle.max.graal.graph.*; - - -public interface NotifyReProcess { - void reProccess(Node n); -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/spi/ValueVisitor.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/spi/ValueVisitor.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2009, 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.nodes.spi; - -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.calc.*; -import com.oracle.max.graal.nodes.extended.*; -import com.oracle.max.graal.nodes.java.*; - -/** - * The {@link ValueVisitor} implements one half of the visitor - * pattern for {@linkplain ValueNode IR values}, allowing clients to implement functionality - * depending on the type of an value without doing type tests. - */ -public abstract class ValueVisitor { - // Checkstyle: stop - public abstract void visitArithmetic(ArithmeticNode i); - public abstract void visitArrayLength(ArrayLengthNode i); - public abstract void visitMerge(MergeNode i); - public abstract void visitCheckCast(CheckCastNode i); - public abstract void visitNormalizeCompare(NormalizeCompareNode i); - public abstract void visitConstant(ConstantNode i); - public abstract void visitConvert(ConvertNode i); - public abstract void visitConditional(ConditionalNode i); - public abstract void visitExceptionObject(ExceptionObjectNode i); - public abstract void visitEndNode(EndNode i); - public abstract void visitFrameState(FrameState i); - public abstract void visitAnchor(AnchorNode i); - public abstract void visitIf(IfNode i); - public abstract void visitInvoke(InvokeNode i); - public abstract void visitLoadField(LoadFieldNode i); - public abstract void visitLoadIndexed(LoadIndexedNode i); - public abstract void visitLocal(LocalNode i); - public abstract void visitLogic(LogicNode i); - public abstract void visitLookupSwitch(LookupSwitchNode i); - public abstract void visitMemoryRead(ReadNode i); - public abstract void visitMemoryWrite(WriteNode i); - public abstract void visitMonitorAddress(MonitorAddressNode monitorAddress); - public abstract void visitMonitorEnter(MonitorEnterNode i); - public abstract void visitMonitorExit(MonitorExitNode i); - public abstract void visitNegate(NegateNode i); - public abstract void visitNewInstance(NewInstanceNode i); - public abstract void visitNewMultiArray(NewMultiArrayNode i); - public abstract void visitNewObjectArray(NewObjectArrayNode i); - public abstract void visitNewTypeArray(NewTypeArrayNode i); - public abstract void visitFixedGuard(FixedGuardNode fixedGuard); - public abstract void visitPhi(PhiNode i); - public abstract void visitRegisterFinalizer(RegisterFinalizerNode i); - public abstract void visitReturn(ReturnNode i); - public abstract void visitShift(ShiftNode i); - public abstract void visitStoreField(StoreFieldNode i); - public abstract void visitStoreIndexed(StoreIndexedNode i); - public abstract void visitTableSwitch(TableSwitchNode i); - public abstract void visitDeoptimize(DeoptimizeNode deoptimize); - public abstract void visitUnwind(UnwindNode unwind); - public abstract void visitLoopBegin(LoopBeginNode loopBegin); - public abstract void visitLoopEnd(LoopEndNode loopEnd); - public abstract void visitValueAnchor(ValueAnchorNode valueAnchor); - public abstract void visitGuardNode(GuardNode guardNode); - public abstract void visitMathIntrinsic(MathIntrinsicNode node); -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/virtual/VirtualObjectFieldNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/virtual/VirtualObjectFieldNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,102 +0,0 @@ -/* - * 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.nodes.virtual; - -import java.util.*; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; -import com.oracle.max.graal.nodes.calc.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; - - -public class VirtualObjectFieldNode extends FloatingNode { - - @Input private VirtualObjectNode object; - @Input private FloatingNode lastState; - @Input private ValueNode input; - - public VirtualObjectNode object() { - return object; - } - - public void setObject(VirtualObjectNode x) { - updateUsages(object, x); - object = x; - } - - public FloatingNode lastState() { - return lastState; - } - - public void setLastState(FloatingNode x) { - updateUsages(lastState, x); - lastState = x; - } - - public ValueNode input() { - return input; - } - - public void setInput(ValueNode x) { - updateUsages(input, x); - input = x; - } - - private int index; - - /** - * Constructs a new ArrayLength instruction. - * @param array the instruction producing the array - * @param newFrameState the state after executing this instruction - */ - public VirtualObjectFieldNode(VirtualObjectNode object, FloatingNode lastState, ValueNode input, int index, Graph graph) { - super(CiKind.Int, graph); - this.index = index; - setObject(object); - setLastState(lastState); - setInput(input); - } - - public int index() { - return index; - } - - @Override - public void accept(ValueVisitor v) { - // nothing to do... - } - - @Override - public Map getDebugProperties() { - Map properties = super.getDebugProperties(); - properties.put("index", index); - return properties; - } - - @Override - public String shortName() { - return "VirtualObjectField " + object().fields()[index].name(); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/virtual/VirtualObjectNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/virtual/VirtualObjectNode.java Wed Aug 10 00:47:53 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ -/* - * 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.nodes.virtual; - -import java.util.*; - -import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.calc.*; -import com.oracle.max.graal.nodes.spi.*; -import com.sun.cri.ci.*; -import com.sun.cri.ri.*; - - -public class VirtualObjectNode extends FloatingNode { - - - - private EscapeField[] fields; - private RiType type; - - public VirtualObjectNode(RiType type, EscapeField[] fields, Graph graph) { - super(CiKind.Int, graph); - this.type = type; - this.fields = fields; - } - - public RiType type() { - return type; - } - - public EscapeField[] fields() { - return fields; - } - - @Override - public void accept(ValueVisitor v) { - // nothing to do... - } - - @Override - public Map getDebugProperties() { - Map properties = super.getDebugProperties(); - properties.put("type", type); - return properties; - } - - @Override - public String shortName() { - return "VirtualObject " + type.name(); - } -} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.examples/.classpath --- a/graal/com.oracle.max.graal.examples/.classpath Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.examples/.classpath Wed Aug 10 01:12:36 2011 +0200 @@ -8,5 +8,7 @@ + + diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.examples/src/com/oracle/max/graal/examples/intrinsics/IntrinsifierImpl.java --- a/graal/com.oracle.max.graal.examples/src/com/oracle/max/graal/examples/intrinsics/IntrinsifierImpl.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.examples/src/com/oracle/max/graal/examples/intrinsics/IntrinsifierImpl.java Wed Aug 10 01:12:36 2011 +0200 @@ -24,10 +24,9 @@ import java.util.*; -import com.oracle.max.graal.compiler.graph.*; import com.oracle.max.graal.extensions.*; import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; import com.sun.cri.ci.*; import com.sun.cri.ri.*; diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.examples/src/com/oracle/max/graal/examples/intrinsics/SafeAddNode.java --- a/graal/com.oracle.max.graal.examples/src/com/oracle/max/graal/examples/intrinsics/SafeAddNode.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.examples/src/com/oracle/max/graal/examples/intrinsics/SafeAddNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -23,7 +23,7 @@ package com.oracle.max.graal.examples.intrinsics; import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; import com.oracle.max.graal.nodes.calc.*; import com.oracle.max.graal.nodes.spi.*; import com.sun.cri.bytecode.*; diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.examples/src/com/oracle/max/graal/examples/opt/OptimizerImpl.java --- a/graal/com.oracle.max.graal.examples/src/com/oracle/max/graal/examples/opt/OptimizerImpl.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.examples/src/com/oracle/max/graal/examples/opt/OptimizerImpl.java Wed Aug 10 01:12:36 2011 +0200 @@ -28,7 +28,7 @@ import com.oracle.max.graal.extensions.*; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.graph.collections.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; import com.oracle.max.graal.nodes.calc.*; import com.sun.cri.ci.*; import com.sun.cri.ri.*; diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.extensions/src/com/oracle/max/graal/extensions/FrameModifier.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.extensions/src/com/oracle/max/graal/extensions/FrameModifier.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2011, 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.extensions; + +import com.sun.cri.ci.*; +import com.sun.cri.ri.*; + + +public interface FrameModifier { + CiFrame getFrame(RiRuntime runtime, CiFrame frame); +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.extensions/src/com/oracle/max/graal/extensions/InliningGuide.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.extensions/src/com/oracle/max/graal/extensions/InliningGuide.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2011, 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.extensions; + +import com.sun.cri.ri.*; + + +public interface InliningGuide { + InliningHint getHint(int depth, RiMethod caller, int bci, RiMethod target); +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.extensions/src/com/oracle/max/graal/extensions/InliningHint.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.extensions/src/com/oracle/max/graal/extensions/InliningHint.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2011, 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.extensions; + + +public enum InliningHint { + NONE, + NEVER, + LESS, + MORE, + ALWAYS +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.extensions/src/com/oracle/max/graal/extensions/Intrinsifier.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.extensions/src/com/oracle/max/graal/extensions/Intrinsifier.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2011, 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.extensions; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.sun.cri.ri.*; + + +public interface Intrinsifier { + Graph intrinsicGraph(RiRuntime runtime, RiMethod caller, int bci, RiMethod method, List parameters); +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.extensions/src/com/oracle/max/graal/extensions/Optimizer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.extensions/src/com/oracle/max/graal/extensions/Optimizer.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2011, 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.extensions; + +import com.oracle.max.graal.graph.*; +import com.sun.cri.ri.*; + + +public interface Optimizer { + void optimize(RiRuntime runtime, Graph graph); +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/AnchorNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/AnchorNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2009, 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.nodes; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + +/** + * The {@code Anchor} instruction represents the end of a block with an unconditional jump to another block. + */ +public final class AnchorNode extends FixedWithNextNode { + + @Input private final NodeInputList guards = new NodeInputList(this); + + public AnchorNode(Graph graph) { + super(CiKind.Illegal, graph); + } + + public void addGuard(GuardNode x) { + guards.add(x); + } + + @Override + public void accept(ValueVisitor v) { + v.visitAnchor(this); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/BooleanNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/BooleanNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,35 @@ +/* + * 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.nodes; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.calc.*; +import com.sun.cri.ci.*; + + +public abstract class BooleanNode extends FloatingNode { + + public BooleanNode(CiKind kind, Graph graph) { + super(kind, graph); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/CastNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/CastNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,67 @@ +/* + * 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.nodes; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.calc.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + + +public final class CastNode extends FloatingNode { + @Input private ValueNode value; + + public ValueNode value() { + return value; + } + + public void setValue(ValueNode x) { + updateUsages(value, x); + value = x; + } + + public CastNode(CiKind kind, ValueNode n, Graph graph) { + super(kind, graph); + setValue(n); + } + + @Override + public void accept(ValueVisitor v) { + } + + + @SuppressWarnings("unchecked") + @Override + public T lookup(Class clazz) { + if (clazz == LIRGeneratorOp.class) { + return (T) new LIRGeneratorOp() { + @Override + public void generate(Node n, LIRGeneratorTool generator) { + CastNode conv = (CastNode) n; + conv.setOperand(generator.load(conv.value())); + } + }; + } + return super.lookup(clazz); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/CompilerGraph.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/CompilerGraph.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,66 @@ +/* + * 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.nodes; + +import com.oracle.max.graal.graph.*; +import com.sun.cri.ci.*; +import com.sun.cri.ri.*; + + +public class CompilerGraph extends Graph { + + private RiRuntime runtime; + private ReturnNode returnSingleton; + private UnwindNode unwindSingleton; + private CiAssumptions assumptions = new CiAssumptions(); + + public CompilerGraph(RiRuntime runtime) { + this.runtime = runtime; + } + + public void setReturn(ReturnNode returnNode) { + assert returnSingleton == null; + returnSingleton = returnNode; + } + + public ReturnNode getReturn() { + return returnSingleton; + } + + public void setUnwind(UnwindNode unwind) { + assert unwindSingleton == null; + unwindSingleton = unwind; + } + + public UnwindNode getUnwind() { + return unwindSingleton; + } + + public RiRuntime runtime() { + return runtime; + } + + public CiAssumptions assumptions() { + return assumptions; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/ConstantNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/ConstantNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2009, 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.nodes; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; +import com.sun.cri.ri.*; + +/** + * The {@code Constant} instruction represents a constant such as an integer value, + * long, float, object reference, address, etc. + */ +public final class ConstantNode extends BooleanNode { + + @Data public final CiConstant value; + + /** + * Constructs a new instruction representing the specified constant. + * @param value the constant + * @param graph + */ + public ConstantNode(CiConstant value, Graph graph) { + super(value.kind.stackKind(), graph); + this.value = value; + } + + @Override + public void accept(ValueVisitor v) { + v.visitConstant(this); + } + + /** + * Creates an instruction for a double constant. + * @param d the double value for which to create the instruction + * @param graph + * @return an instruction representing the double + */ + public static ConstantNode forDouble(double d, Graph graph) { + return new ConstantNode(CiConstant.forDouble(d), graph); + } + + /** + * Creates an instruction for a float constant. + * @param f the float value for which to create the instruction + * @return an instruction representing the float + */ + public static ConstantNode forFloat(float f, Graph graph) { + return new ConstantNode(CiConstant.forFloat(f), graph); + } + + /** + * Creates an instruction for an long constant. + * @param i the long value for which to create the instruction + * @return an instruction representing the long + */ + public static ConstantNode forLong(long i, Graph graph) { + return new ConstantNode(CiConstant.forLong(i), graph); + } + + /** + * Creates an instruction for an integer constant. + * @param i the integer value for which to create the instruction + * @return an instruction representing the integer + */ + public static ConstantNode forInt(int i, Graph graph) { + return new ConstantNode(CiConstant.forInt(i), graph); + } + + /** + * Creates an instruction for a boolean constant. + * @param i the boolean value for which to create the instruction + * @return an instruction representing the boolean + */ + public static ConstantNode forBoolean(boolean i, Graph graph) { + return new ConstantNode(CiConstant.forBoolean(i), graph); + } + + /** + * Creates an instruction for an address (jsr/ret address) constant. + * @param i the address value for which to create the instruction + * @return an instruction representing the address + */ + public static ConstantNode forJsr(int i, Graph graph) { + return new ConstantNode(CiConstant.forJsr(i), graph); + } + + /** + * Creates an instruction for an object constant. + * @param o the object value for which to create the instruction + * @return an instruction representing the object + */ + public static ConstantNode forObject(Object o, Graph graph) { + return new ConstantNode(CiConstant.forObject(o), graph); + } + + /** + * Creates an instruction for a word constant. + * @param val the word value for which to create the instruction + * @return an instruction representing the word + */ + public static ConstantNode forWord(long val, Graph graph) { + return new ConstantNode(CiConstant.forWord(val), graph); + } + + public static ConstantNode defaultForKind(CiKind kind, Graph graph) { + switch(kind) { + case Boolean: + return ConstantNode.forBoolean(false, graph); + case Byte: + case Char: + case Short: + case Int: + return ConstantNode.forInt(0, graph); + case Double: + return ConstantNode.forDouble(0.0, graph); + case Float: + return ConstantNode.forFloat(0.0f, graph); + case Long: + return ConstantNode.forLong(0L, graph); + case Object: + return ConstantNode.forObject(null, graph); + case Word: + return ConstantNode.forWord(0L, graph); + default: + return null; + } + } + + @Override + public String toString() { + return super.toString() + "(" + value + ")"; + } + + @Override + public int valueNumber() { + return 0x50000000 | value.hashCode(); + } + + @Override + public RiType declaredType() { + RiRuntime runtime = ((CompilerGraph) graph()).runtime(); + if (kind.isPrimitive()) { + return runtime.asRiType(kind); + } + return runtime.getTypeOf(asConstant()); + } + + @Override + public RiType exactType() { + return declaredType(); + } + + @Override + public String shortName() { + return value.name(); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/ControlSplitNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/ControlSplitNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2009, 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.nodes; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.sun.cri.ci.*; + +/** + * The {@code BlockEnd} instruction is a base class for all instructions that end a basic + * block, including branches, switches, throws, and goto's. + */ +public abstract class ControlSplitNode extends FixedNode { + + @Successor private final NodeSuccessorList blockSuccessors; + + public FixedNode blockSuccessor(int index) { + return blockSuccessors.get(index); + } + + public void setBlockSuccessor(int index, FixedNode x) { + blockSuccessors.set(index, x); + } + + public int blockSuccessorCount() { + return blockSuccessors.size(); + } + + protected final double[] branchProbability; + + /** + * Constructs a new block end with the specified value type. + * @param kind the type of the value produced by this instruction + * @param successors the list of successor blocks. If {@code null}, a new one will be created. + */ + public ControlSplitNode(CiKind kind, List blockSuccessors, double[] branchProbability, Graph graph) { + this(kind, blockSuccessors.size(), branchProbability, graph); + for (int i = 0; i < blockSuccessors.size(); i++) { + setBlockSuccessor(i, blockSuccessors.get(i)); + } + } + + public ControlSplitNode(CiKind kind, int blockSuccessorCount, double[] branchProbability, Graph graph) { + super(kind, graph); + this.blockSuccessors = new NodeSuccessorList(this, blockSuccessorCount); + assert branchProbability.length == blockSuccessorCount; + this.branchProbability = branchProbability; + } + + public double probability(int successorIndex) { + return branchProbability[successorIndex]; + } + + public void setProbability(int successorIndex, double x) { + branchProbability[successorIndex] = x; + } + + /** + * Gets the successor corresponding to the default (fall through) case. + * @return the default successor + */ + public FixedNode defaultSuccessor() { + return blockSuccessor(blockSuccessorCount() - 1); + } + + public Iterable blockSuccessors() { + return new Iterable() { + @Override + public Iterator iterator() { + return new Iterator() { + int i = 0; + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + @Override + public FixedNode next() { + return ControlSplitNode.this.blockSuccessor(i++); + } + + @Override + public boolean hasNext() { + return i < ControlSplitNode.this.blockSuccessorCount(); + } + }; + } + }; + } + + @Override + public Map getDebugProperties() { + Map properties = super.getDebugProperties(); + StringBuilder str = new StringBuilder(); + for (int i = 0; i < branchProbability.length; i++) { + str.append(i == 0 ? "" : ", ").append(String.format("%7.5f", branchProbability[i])); + } + properties.put("branchProbability", str.toString()); + return properties; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/DeoptimizeNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/DeoptimizeNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2009, 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.nodes; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + +@NodeInfo(shortName = "Deopt") +public class DeoptimizeNode extends FixedNode { + + public static enum DeoptAction { + None, // just interpret, do not invalidate nmethod + Recompile, // recompile the nmethod; need not invalidate + InvalidateReprofile, // invalidate the nmethod, reset IC, maybe recompile + InvalidateRecompile, // invalidate the nmethod, recompile (probably) + InvalidateStopCompiling, // invalidate the nmethod and do not compile + } + + private String message; + private final DeoptAction action; + + public DeoptimizeNode(DeoptAction action, Graph graph) { + super(CiKind.Illegal, graph); + this.action = action; + } + + public void setMessage(String message) { + this.message = message; + } + + public String message() { + return message; + } + + public DeoptAction action() { + return action; + } + + @Override + public void accept(ValueVisitor v) { + v.visitDeoptimize(this); + } + + @Override + public Map getDebugProperties() { + Map properties = super.getDebugProperties(); + properties.put("message", message); + properties.put("action", action); + return properties; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/EndNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/EndNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,71 @@ +/* + * 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.nodes; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + + +public final class EndNode extends FixedNode { + + public EndNode(Graph graph) { + super(CiKind.Illegal, graph); + } + + @Override + public void accept(ValueVisitor v) { + v.visitEndNode(this); + } + + public MergeNode merge() { + if (usages().size() == 0) { + return null; + } else { + assert usages().size() == 1; + return (MergeNode) usages().iterator().next(); + } + } + + @Override + public boolean verify() { + assertTrue(usages().size() <= 1, "at most one usage"); + return true; + } + + @Override + public Iterable< ? extends Node> dataUsages() { + return Collections.emptyList(); + } + + @Override + public Iterable< ? extends Node> cfgSuccessors() { + MergeNode merge = this.merge(); + if (merge == null) { + return Collections.emptyList(); + } + return Arrays.asList(merge); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/FixedGuardNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/FixedGuardNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,70 @@ +/* + * 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.nodes; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.DeoptimizeNode.DeoptAction; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + +public final class FixedGuardNode extends FixedWithNextNode implements Canonicalizable { + + @Input private final NodeInputList conditions = new NodeInputList(this); + + public FixedGuardNode(BooleanNode node, Graph graph) { + this(graph); + addNode(node); + } + + public FixedGuardNode(Graph graph) { + super(CiKind.Illegal, graph); + } + + @Override + public void accept(ValueVisitor v) { + v.visitFixedGuard(this); + } + + public void addNode(BooleanNode x) { + conditions.add(x); + } + + @Override + public Node canonical(NotifyReProcess reProcess) { + for (BooleanNode n : conditions.snapshot()) { + if (n instanceof ConstantNode) { + ConstantNode c = (ConstantNode) n; + if (c.asConstant().asBoolean()) { + conditions.remove(n); + } else { + return new DeoptimizeNode(DeoptAction.InvalidateRecompile, graph()); + } + } + } + + if (conditions.isEmpty()) { + return next(); + } + return this; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/FixedNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/FixedNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,57 @@ +/* + * 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.nodes; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.sun.cri.ci.*; + +public abstract class FixedNode extends ValueNode { + + private double probability; + + public FixedNode(CiKind kind, Graph graph) { + super(kind, graph); + } + + public double probability() { + return probability; + } + + public void setProbability(double probability) { + this.probability = probability; + } + + protected void copyInto(FixedNode newNode) { + newNode.setProbability(probability); + } + + @Override + public Map getDebugProperties() { + Map properties = super.getDebugProperties(); + properties.put("probability", String.format(Locale.ENGLISH, "%7.5f", probability)); + return properties; + } + +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/FixedWithNextNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/FixedWithNextNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2009, 2010, 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.nodes; + +import com.oracle.max.graal.graph.*; +import com.sun.cri.ci.*; + +public abstract class FixedWithNextNode extends FixedNode { + + @Successor private FixedNode next; + + public FixedNode next() { + return next; + } + + public void setNext(FixedNode x) { + updatePredecessors(next, x); + next = x; + } + + public static final int SYNCHRONIZATION_ENTRY_BCI = -1; + + /** + * Constructs a new instruction with the specified value type. + * @param kind the value type for this instruction + */ + public FixedWithNextNode(CiKind kind, Graph graph) { + super(kind, graph); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/FrameState.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/FrameState.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,671 @@ +/* + * Copyright (c) 2009, 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.nodes; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.PhiNode.PhiType; +import com.oracle.max.graal.nodes.calc.*; +import com.oracle.max.graal.nodes.spi.*; +import com.oracle.max.graal.nodes.virtual.*; +import com.sun.cri.ci.*; +import com.sun.cri.ri.*; + +/** + * The {@code FrameState} class encapsulates the frame state (i.e. local variables and + * operand stack) at a particular point in the abstract interpretation. + */ +public final class FrameState extends ValueNode implements FrameStateAccess { + + protected final int localsSize; + + protected final int stackSize; + + protected final int locksSize; + + private boolean rethrowException; + + public static final int BEFORE_BCI = -2; + public static final int AFTER_BCI = -3; + + @Input private FrameState outerFrameState; + + @Input private final NodeInputList values; + + @Input private final NodeInputList virtualObjectMappings; + + public FrameState outerFrameState() { + return outerFrameState; + } + + public void setOuterFrameState(FrameState x) { + updateUsages(this.outerFrameState, x); + this.outerFrameState = x; + } + + @Override + public void setValueAt(int i, ValueNode x) { + values.set(i, x); + } + + /** + * The bytecode index to which this frame state applies. This will be {@code -1} + * iff this state is mutable. + */ + public final int bci; + + public final RiMethod method; + + /** + * Creates a {@code FrameState} for the given scope and maximum number of stack and local variables. + * + * @param bci the bytecode index of the frame state + * @param localsSize number of locals + * @param stackSize size of the stack + * @param lockSize number of locks + */ + public FrameState(RiMethod method, int bci, int localsSize, int stackSize, int locksSize, boolean rethrowException, Graph graph) { + super(CiKind.Illegal, graph); + this.method = method; + this.bci = bci; + this.localsSize = localsSize; + this.stackSize = stackSize; + this.locksSize = locksSize; + this.values = new NodeInputList(this, localsSize + stackSize + locksSize); + this.virtualObjectMappings = new NodeInputList(this); + this.rethrowException = rethrowException; + //GraalMetrics.FrameStatesCreated++; + //GraalMetrics.FrameStateValuesCreated += localsSize + stackSize + locksSize; + } + + public FrameState(RiMethod method, int bci, ValueNode[] locals, ValueNode[] stack, int stackSize, ArrayList locks, boolean rethrowException, Graph graph) { + this(method, bci, locals.length, stackSize, locks.size(), rethrowException, graph); + for (int i = 0; i < locals.length; i++) { + setValueAt(i, locals[i]); + } + for (int i = 0; i < stackSize; i++) { + setValueAt(localsSize + i, stack[i]); + } + for (int i = 0; i < locks.size(); i++) { + setValueAt(locals.length + stackSize + i, locks.get(i)); + } + } + + public boolean rethrowException() { + return rethrowException; + } + + public RiMethod method() { + return method; + } + + public void addVirtualObjectMapping(Node virtualObject) { + assert virtualObject instanceof VirtualObjectFieldNode || virtualObject instanceof PhiNode : virtualObject; + virtualObjectMappings.add(virtualObject); + } + + public int virtualObjectMappingCount() { + return virtualObjectMappings.size(); + } + + public Node virtualObjectMappingAt(int i) { + return virtualObjectMappings.get(i); + } + + public Iterable virtualObjectMappings() { + return virtualObjectMappings; + } + + /** + * Gets a copy of this frame state. + */ + public FrameState duplicate(int bci) { + return duplicate(bci, false); + } + + public FrameState duplicate(int bci, boolean duplicateOuter) { + FrameState other = new FrameState(method, bci, localsSize, stackSize, locksSize, rethrowException, graph()); + other.values.setAll(values); + other.virtualObjectMappings.setAll(virtualObjectMappings); + FrameState outerFrameState = outerFrameState(); + if (duplicateOuter && outerFrameState != null) { + outerFrameState = outerFrameState.duplicate(outerFrameState.bci, duplicateOuter); + } + other.setOuterFrameState(outerFrameState); + return other; + } + + @Override + public FrameState duplicateWithException(int bci, ValueNode exceptionObject) { + return duplicateModified(bci, true, CiKind.Void, exceptionObject); + } + + /** + * Creates a copy of this frame state with one stack element of type popKind popped from the stack and the + * values in pushedValues pushed on the stack. The pushedValues are expected to be in slot encoding: a long + * or double is followed by a null slot. + */ + public FrameState duplicateModified(int bci, boolean rethrowException, CiKind popKind, ValueNode... pushedValues) { + int popSlots = popKind.sizeInSlots(); + int pushSlots = pushedValues.length; + FrameState other = new FrameState(method, bci, localsSize, stackSize - popSlots + pushSlots, locksSize(), rethrowException, graph()); + for (int i = 0; i < localsSize; i++) { + other.setValueAt(i, localAt(i)); + } + for (int i = 0; i < stackSize - popSlots; i++) { + other.setValueAt(localsSize + i, stackAt(i)); + } + int slot = localsSize + stackSize - popSlots; + for (int i = 0; i < pushSlots; i++) { + other.setValueAt(slot++, pushedValues[i]); + } + for (int i = 0; i < locksSize; i++) { + other.setValueAt(localsSize + other.stackSize + i, lockAt(i)); + } + other.virtualObjectMappings.setAll(virtualObjectMappings); + other.setOuterFrameState(outerFrameState()); + return other; + } + + public boolean isCompatibleWith(FrameStateAccess other) { + if (stackSize() != other.stackSize() || localsSize() != other.localsSize() || locksSize() != other.locksSize()) { + return false; + } + for (int i = 0; i < stackSize(); i++) { + ValueNode x = stackAt(i); + ValueNode y = other.stackAt(i); + if (x != y && ValueUtil.typeMismatch(x, y)) { + return false; + } + } + for (int i = 0; i < locksSize(); i++) { + if (lockAt(i) != other.lockAt(i)) { + return false; + } + } + if (other.outerFrameState() != outerFrameState()) { + return false; + } + return true; + } + + public boolean equals(FrameStateAccess other) { + if (stackSize() != other.stackSize() || localsSize() != other.localsSize() || locksSize() != other.locksSize()) { + return false; + } + for (int i = 0; i < stackSize(); i++) { + ValueNode x = stackAt(i); + ValueNode y = other.stackAt(i); + if (x != y) { + return false; + } + } + for (int i = 0; i < locksSize(); i++) { + if (lockAt(i) != other.lockAt(i)) { + return false; + } + } + if (other.outerFrameState() != outerFrameState()) { + return false; + } + return true; + } + + /** + * Gets the size of the local variables. + */ + public int localsSize() { + return localsSize; + } + + /** + * Gets the current size (height) of the stack. + */ + public int stackSize() { + return stackSize; + } + + /** + * Gets number of locks held by this frame state. + */ + public int locksSize() { + return locksSize; + } + + /** + * Invalidates the local variable at the specified index. If the specified index refers to a doubleword local, then + * invalidates the high word as well. + * + * @param i the index of the local to invalidate + */ + public void invalidateLocal(int i) { + // note that for double word locals, the high slot should already be null + // unless the local is actually dead and the high slot is being reused; + // in either case, it is not necessary to null the high slot + setValueAt(i, null); + } + + /** + * Stores a given local variable at the specified index. If the value is a {@linkplain CiKind#isDoubleWord() double word}, + * then the next local variable index is also overwritten. + * + * @param i the index at which to store + * @param x the instruction which produces the value for the local + */ + public void storeLocal(int i, ValueNode x) { + assert i < localsSize : "local variable index out of range: " + i; + invalidateLocal(i); + setValueAt(i, x); + if (ValueUtil.isDoubleWord(x)) { + // (tw) if this was a double word then kill i+1 + setValueAt(i + 1, null); + } + if (i > 0) { + // if there was a double word at i - 1, then kill it + ValueNode p = localAt(i - 1); + if (ValueUtil.isDoubleWord(p)) { + setValueAt(i - 1, null); + } + } + } + + /** + * Gets the value in the local variables at the specified index. + * + * @param i the index into the locals + * @return the instruction that produced the value for the specified local + */ + public ValueNode localAt(int i) { + assert i < localsSize : "local variable index out of range: " + i; + return valueAt(i); + } + + /** + * Get the value on the stack at the specified stack index. + * + * @param i the index into the stack, with {@code 0} being the bottom of the stack + * @return the instruction at the specified position in the stack + */ + public ValueNode stackAt(int i) { + assert i >= 0 && i < (localsSize + stackSize); + return valueAt(localsSize + i); + } + + /** + * Retrieves the lock at the specified index in the lock stack. + * @param i the index into the lock stack + * @return the instruction which produced the object at the specified location in the lock stack + */ + public ValueNode lockAt(int i) { + assert i >= 0; + return valueAt(localsSize + stackSize + i); + } + + /** + * Inserts a phi statement into the stack at the specified stack index. + * @param block the block begin for which we are creating the phi + * @param i the index into the stack for which to create a phi + */ + public PhiNode setupPhiForStack(MergeNode block, int i) { + ValueNode p = stackAt(i); + if (p != null) { + if (p instanceof PhiNode) { + PhiNode phi = (PhiNode) p; + if (phi.merge() == block) { + return phi; + } + } + PhiNode phi = new PhiNode(p.kind, block, PhiType.Value, graph()); + setValueAt(localsSize + i, phi); + return phi; + } + return null; + } + + /** + * Inserts a phi statement for the local at the specified index. + * @param block the block begin for which we are creating the phi + * @param i the index of the local variable for which to create the phi + */ + public PhiNode setupPhiForLocal(MergeNode block, int i) { + ValueNode p = localAt(i); + if (p instanceof PhiNode) { + PhiNode phi = (PhiNode) p; + if (phi.merge() == block) { + return phi; + } + } + PhiNode phi = new PhiNode(p.kind, block, PhiType.Value, graph()); + storeLocal(i, phi); + return phi; + } + + /** + * Gets the value at a specified index in the set of operand stack and local values represented by this frame. + * This method should only be used to iterate over all the values in this frame, irrespective of whether + * they are on the stack or in local variables. + * To iterate the stack slots, the {@link #stackAt(int)} and {@link #stackSize()} methods should be used. + * To iterate the local variables, the {@link #localAt(int)} and {@link #localsSize()} methods should be used. + * + * @param i a value in the range {@code [0 .. valuesSize()]} + * @return the value at index {@code i} which may be {@code null} + */ + public ValueNode valueAt(int i) { + assert i < (localsSize + stackSize + locksSize); + return values.isEmpty() ? null : values.get(i); + } + + /** + * The number of operand stack slots and local variables in this frame. + * This method should typically only be used in conjunction with {@link #valueAt(int)}. + * To iterate the stack slots, the {@link #stackAt(int)} and {@link #stackSize()} methods should be used. + * To iterate the local variables, the {@link #localAt(int)} and {@link #localsSize()} methods should be used. + * + * @return the number of local variables in this frame + */ + public int valuesSize() { + return localsSize + stackSize; + } + + private void checkSize(FrameStateAccess other) { + if (other.stackSize() != stackSize()) { + throw new CiBailout("stack sizes do not match"); + } else if (other.localsSize() != localsSize) { + throw new CiBailout("local sizes do not match"); + } + } + + public void merge(MergeNode block, FrameStateAccess other) { + checkSize(other); + for (int i = 0; i < valuesSize(); i++) { + ValueNode x = valueAt(i); + if (x != null) { + ValueNode y = other.valueAt(i); + if (x != y || ((x instanceof PhiNode) && ((PhiNode) x).merge() == block)) { + if (ValueUtil.typeMismatch(x, y)) { + if ((x instanceof PhiNode) && ((PhiNode) x).merge() == block) { + x.replaceAtUsages(null); + x.delete(); + } + setValueAt(i, null); + continue; + } + PhiNode phi = null; + if (i < localsSize) { + // this a local + phi = setupPhiForLocal(block, i); + } else { + // this is a stack slot + phi = setupPhiForStack(block, i - localsSize); + } + + if (phi.valueCount() == 0) { + int size = block.phiPredecessorCount(); + for (int j = 0; j < size; ++j) { + phi.addInput(x); + } + phi.addInput((x == y) ? phi : y); + } else { + phi.addInput((x == y) ? phi : y); + } + + assert phi.valueCount() == block.phiPredecessorCount() + (block instanceof LoopBeginNode ? 0 : 1) : "valueCount=" + phi.valueCount() + " predSize= " + block.phiPredecessorCount(); + } + } + } + } + + public MergeNode block() { + for (Node n : usages()) { + if (n instanceof MergeNode) { + return (MergeNode) n; + } + } + return null; + } + + public StateSplit stateSplit() { + for (Node n : usages()) { + if (n instanceof StateSplit) { + return (StateSplit) n; + } + } + return null; + } + + public Iterable innerFrameStates() { + final Iterator iterator = usages().iterator(); + return new Iterable() { + @Override + public Iterator iterator() { + return new Iterator() { + private Node next; + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + @Override + public FrameState next() { + forward(); + if (!hasNext()) { + throw new NoSuchElementException(); + } + FrameState res = (FrameState) next; + next = null; + return res; + } + @Override + public boolean hasNext() { + forward(); + return next != null; + } + private void forward() { + while (!(next instanceof FrameState) && iterator.hasNext()) { + next = iterator.next(); + } + } + }; + } + }; + } + + /** + * The interface implemented by a client of {@link FrameState#forEachPhi(MergeNode, PhiProcedure)} and + * {@link FrameState#forEachLivePhi(MergeNode, PhiProcedure)}. + */ + public static interface PhiProcedure { + boolean doPhi(PhiNode phi); + } + + /** + * Checks whether this frame state has any {@linkplain PhiNode phi} statements. + */ + public boolean hasPhis() { + for (int i = 0; i < valuesSize(); i++) { + ValueNode value = valueAt(i); + if (value instanceof PhiNode) { + return true; + } + } + return false; + } + + /** + * The interface implemented by a client of {@link FrameState#forEachLiveStateValue(ValueProcedure)}. + */ + public static interface ValueProcedure { + void doValue(ValueNode value); + } + + /** + * Traverses all {@linkplain ValueNode#isLive() live values} of this frame state. + * + * @param proc the call back called to process each live value traversed + */ + public void forEachLiveStateValue(ValueProcedure proc) { + HashSet vobjs = null; + FrameState current = this; + do { + for (int i = 0; i < current.valuesSize(); i++) { + ValueNode value = current.valueAt(i); + if (value instanceof VirtualObjectNode) { + if (vobjs == null) { + vobjs = new HashSet(); + } + vobjs.add((VirtualObjectNode) value); + } else if (value != null) { + proc.doValue(value); + } + } + current = current.outerFrameState(); + } while (current != null); + + if (vobjs != null) { + // collect all VirtualObjectField instances: + HashMap objectStates = new HashMap(); + current = this; + do { + for (int i = 0; i < current.virtualObjectMappingCount(); i++) { + VirtualObjectFieldNode field = (VirtualObjectFieldNode) current.virtualObjectMappingAt(i); + // null states occur for objects with 0 fields + if (field != null && !objectStates.containsKey(field.object())) { + objectStates.put(field.object(), field); + } + } + current = current.outerFrameState(); + } while (current != null); + + do { + HashSet vobjsCopy = new HashSet(vobjs); + for (VirtualObjectNode vobj : vobjsCopy) { + if (vobj.fields().length > 0) { + boolean[] fieldState = new boolean[vobj.fields().length]; + FloatingNode currentField = objectStates.get(vobj); + assert currentField != null : this; + do { + if (currentField instanceof VirtualObjectFieldNode) { + int index = ((VirtualObjectFieldNode) currentField).index(); + ValueNode value = ((VirtualObjectFieldNode) currentField).input(); + if (!fieldState[index]) { + fieldState[index] = true; + if (value instanceof VirtualObjectNode) { + vobjs.add((VirtualObjectNode) value); + } else { + proc.doValue(value); + } + } + currentField = ((VirtualObjectFieldNode) currentField).lastState(); + } else { + assert currentField instanceof PhiNode : currentField; + currentField = (FloatingNode) ((PhiNode) currentField).valueAt(0); + } + } while (currentField != null); + } + vobjs.remove(vobj); + } + } while (!vobjs.isEmpty()); + assert vobjs.isEmpty() : "at FrameState " + this; + } + } + + @Override + public String toString() { + return super.toString(); + } + + public String toDetailedString() { + StringBuilder sb = new StringBuilder(); + String nl = String.format("%n"); + sb.append("[bci: ").append(bci).append("]"); + if (rethrowException()) { + sb.append(" rethrows Exception"); + } + sb.append(nl); + for (int i = 0; i < localsSize(); ++i) { + ValueNode value = localAt(i); + sb.append(String.format(" local[%d] = %-8s : %s%n", i, value == null ? "bogus" : value.kind.javaName, value)); + } + for (int i = 0; i < stackSize(); ++i) { + ValueNode value = stackAt(i); + sb.append(String.format(" stack[%d] = %-8s : %s%n", i, value == null ? "bogus" : value.kind.javaName, value)); + } + for (int i = 0; i < locksSize(); ++i) { + ValueNode value = lockAt(i); + sb.append(String.format(" lock[%d] = %-8s : %s%n", i, value == null ? "bogus" : value.kind.javaName, value)); + } + return sb.toString(); + } + + @Override + public void accept(ValueVisitor v) { + v.visitFrameState(this); + } + + @Override + public String shortName() { + return "FrameState@" + bci; + } + + public void visitFrameState(FrameState i) { + // nothing to do for now + } + + @Override + public Map getDebugProperties() { + Map properties = super.getDebugProperties(); + properties.put("bci", bci); + properties.put("method", CiUtil.format("%H.%n(%p):%r", method, false)); + StringBuilder str = new StringBuilder(); + for (int i = 0; i < localsSize(); i++) { + str.append(i == 0 ? "" : ", ").append(localAt(i) == null ? "_" : localAt(i).id()); + } + properties.put("locals", str.toString()); + str = new StringBuilder(); + for (int i = 0; i < stackSize(); i++) { + str.append(i == 0 ? "" : ", ").append(stackAt(i) == null ? "_" : stackAt(i).id()); + } + properties.put("stack", str.toString()); + str = new StringBuilder(); + for (int i = 0; i < locksSize(); i++) { + str.append(i == 0 ? "" : ", ").append(lockAt(i) == null ? "_" : lockAt(i).id()); + } + properties.put("locks", str.toString()); + properties.put("rethrowException", rethrowException); + return properties; + } + + @Override + public void delete() { + FrameState outerFrameState = outerFrameState(); + super.delete(); + if (outerFrameState != null && outerFrameState.usages().isEmpty()) { + outerFrameState.delete(); + } + } + + @Override + public void setRethrowException(boolean b) { + rethrowException = b; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/GuardNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/GuardNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,76 @@ +/* + * 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.nodes; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.calc.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + +public final class GuardNode extends FloatingNode implements Canonicalizable { + + @Input private FixedNode anchor; + @Input private BooleanNode node; + + public FixedNode anchor() { + return anchor; + } + + public void setAnchor(FixedNode x) { + updateUsages(anchor, x); + anchor = x; + } + + /** + * The instruction that produces the tested boolean value. + */ + public BooleanNode node() { + return node; + } + + public void setNode(BooleanNode x) { + updateUsages(node, x); + node = x; + } + + public GuardNode(BooleanNode node, Graph graph) { + super(CiKind.Illegal, graph); + setNode(node); + } + + @Override + public void accept(ValueVisitor v) { + v.visitGuardNode(this); + } + + @Override + public Node canonical(NotifyReProcess reProcess) { + if (node() instanceof ConstantNode) { + ConstantNode c = (ConstantNode) node(); + if (c.asConstant().asBoolean()) { + return Node.Null; + } + } + return this; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/IfNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/IfNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2009, 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.nodes; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + +/** + * The {@code If} instruction represents a branch that can go one of two directions depending on the outcome of a + * comparison. + */ +public final class IfNode extends ControlSplitNode implements Canonicalizable { + + @Input private BooleanNode compare; + + public BooleanNode compare() { + return compare; + } + + public void setCompare(BooleanNode x) { + updateUsages(compare, x); + compare = x; + } + + public IfNode(BooleanNode condition, double probability, Graph graph) { + super(CiKind.Illegal, 2, new double[] {probability, 1 - probability}, graph); + setCompare(condition); + } + + /** + * Gets the block corresponding to the true successor. + * + * @return the true successor + */ + public FixedNode trueSuccessor() { + return blockSuccessor(0); + } + + /** + * Gets the block corresponding to the false successor. + * + * @return the false successor + */ + public FixedNode falseSuccessor() { + return blockSuccessor(1); + } + + public void setTrueSuccessor(FixedNode node) { + setBlockSuccessor(0, node); + } + + public void setFalseSuccessor(FixedNode node) { + setBlockSuccessor(1, node); + } + + /** + * Gets the block corresponding to the specified outcome of the branch. + * + * @param istrue {@code true} if the true successor is requested, {@code false} otherwise + * @return the corresponding successor + */ + public FixedNode successor(boolean istrue) { + return blockSuccessor(istrue ? 0 : 1); + } + + @Override + public void accept(ValueVisitor v) { + v.visitIf(this); + } + + @Override + public boolean verify() { + assertTrue(compare() != null); + assertTrue(trueSuccessor() != null); + assertTrue(falseSuccessor() != null); + return true; + } + + @Override + public Node canonical(NotifyReProcess reProcess) { + if (compare() instanceof ConstantNode) { + ConstantNode c = (ConstantNode) compare(); + if (c.asConstant().asBoolean()) { + return trueSuccessor(); + } else { + return falseSuccessor(); + } + } + if (trueSuccessor() instanceof EndNode && falseSuccessor() instanceof EndNode) { + EndNode trueEnd = (EndNode) trueSuccessor(); + EndNode falseEnd = (EndNode) falseSuccessor(); + MergeNode merge = trueEnd.merge(); + if (merge == falseEnd.merge() && merge.phis().size() == 0 && merge.endCount() == 2) { + FixedNode next = merge.next(); + merge.setNext(null); // disconnect to avoid next from having 2 preds + return next; + } + } + return this; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/InvokeNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/InvokeNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2009, 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.nodes; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.extended.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.bytecode.*; +import com.sun.cri.ci.*; +import com.sun.cri.ri.*; + +/** + * The {@code Invoke} instruction represents all kinds of method calls. + */ +public final class InvokeNode extends AbstractMemoryCheckpointNode implements ExceptionExit { + + @Successor private FixedNode exceptionEdge; + + @Input private final NodeInputList arguments; + + @Override + public FixedNode exceptionEdge() { + return exceptionEdge; + } + + public void setExceptionEdge(FixedNode x) { + updatePredecessors(exceptionEdge, x); + exceptionEdge = x; + } + + private final int argumentCount; + + private boolean canInline = true; + + public boolean canInline() { + return canInline; + } + + public void setCanInline(boolean b) { + canInline = b; + } + + public NodeInputList arguments() { + return arguments; + } + + public final int opcode; + public final RiMethod target; + public final RiType returnType; + public final int bci; // XXX needed because we can not compute the bci from the sateBefore bci of this Invoke was optimized from INVOKEINTERFACE to INVOKESPECIAL + + /** + * Constructs a new Invoke instruction. + * + * @param opcode the opcode of the invoke + * @param result the result type + * @param args the list of instructions producing arguments to the invocation, including the receiver object + * @param isStatic {@code true} if this call is static (no receiver object) + * @param target the target method being called + */ + public InvokeNode(int bci, int opcode, CiKind result, ValueNode[] args, RiMethod target, RiType returnType, Graph graph) { + super(result, graph); + arguments = new NodeInputList(this, args.length); + this.opcode = opcode; + this.target = target; + this.returnType = returnType; + this.bci = bci; + + this.argumentCount = args.length; + for (int i = 0; i < args.length; i++) { + arguments().set(i, args[i]); + } + } + + /** + * Gets the opcode of this invoke instruction. + * @return the opcode + */ + public int opcode() { + return opcode; + } + + /** + * Checks whether this is an invocation of a static method. + * @return {@code true} if the invocation is a static invocation + */ + public boolean isStatic() { + return opcode == Bytecodes.INVOKESTATIC; + } + + @Override + public RiType declaredType() { + return returnType; + } + + /** + * Gets the instruction that produces the receiver object for this invocation, if any. + * @return the instruction that produces the receiver object for this invocation if any, {@code null} if this + * invocation does not take a receiver object + */ + public ValueNode receiver() { + assert !isStatic(); + return arguments().get(0); + } + + /** + * Gets the target method for this invocation instruction. + * @return the target method + */ + public RiMethod target() { + return target; + } + + /** + * Checks whether this invocation has a receiver object. + * @return {@code true} if this invocation has a receiver object; {@code false} otherwise, if this is a + * static call + */ + public boolean hasReceiver() { + return !isStatic(); + } + + @Override + public void accept(ValueVisitor v) { + v.visitInvoke(this); + } + + @Override + public String toString() { + return super.toString() + target; + } + + @Override + public Map getDebugProperties() { + Map properties = super.getDebugProperties(); + properties.put("opcode", Bytecodes.nameOf(opcode)); + properties.put("target", CiUtil.format("%H.%n(%p):%r", target, false)); + properties.put("bci", bci); + return properties; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/LocalNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/LocalNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2009, 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.nodes; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.calc.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; +import com.sun.cri.ri.*; + +/** + * The {@code Local} instruction is a placeholder for an incoming argument + * to a function call. + */ +public final class LocalNode extends FloatingNode { + + @Input private StartNode start; + + public StartNode start() { + return start; + } + + public void setStart(StartNode x) { + updateUsages(start, x); + start = x; + } + + private final int index; + private RiType declaredType; + + public LocalNode(CiKind kind, int javaIndex, Graph graph) { + super(kind, graph); + this.index = javaIndex; + setStart(graph.start()); + } + + /** + * Gets the index of this local. + * @return the index + */ + public int index() { + return index; + } + + /** + * Sets the declared type of this local, e.g. derived from the signature of the method. + * @param declaredType the declared type of the local variable + */ + public void setDeclaredType(RiType declaredType) { + this.declaredType = declaredType; + } + + /** + * Computes the declared type of the result of this instruction, if possible. + * @return the declared type of the result of this instruction, if it is known; {@code null} otherwise + */ + @Override + public RiType declaredType() { + return declaredType; + } + + @Override + public void accept(ValueVisitor v) { + v.visitLocal(this); + } + + @Override + public Map getDebugProperties() { + Map properties = super.getDebugProperties(); + properties.put("index", index()); + return properties; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/LoopBeginNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/LoopBeginNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,146 @@ +/* + * 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.nodes; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.loop.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + +public class LoopBeginNode extends MergeNode { + + private double loopFrequency; + + public LoopBeginNode(Graph graph) { + super(graph); + loopFrequency = 1; + } + + public double loopFrequency() { + return loopFrequency; + } + + public void setLoopFrequency(double loopFrequency) { + this.loopFrequency = loopFrequency; + } + + public LoopEndNode loopEnd() { + for (Node usage : usages()) { + if (usage instanceof LoopEndNode) { + LoopEndNode end = (LoopEndNode) usage; + if (end.loopBegin() == this) { + return end; + } + } + } + return null; + } + + @Override + public void accept(ValueVisitor v) { + v.visitLoopBegin(this); + } + + @Override + public int phiPredecessorCount() { + return 2; + } + + @Override + public int phiPredecessorIndex(Node pred) { + if (pred == forwardEdge()) { + return 0; + } else if (pred == this.loopEnd()) { + return 1; + } + throw ValueUtil.shouldNotReachHere("unknown pred : " + pred + "(sp=" + forwardEdge() + ", le=" + this.loopEnd() + ")"); + } + + @Override + public Node phiPredecessorAt(int index) { + if (index == 0) { + return forwardEdge(); + } else if (index == 1) { + return loopEnd(); + } + throw ValueUtil.shouldNotReachHere(); + } + + public Collection inductionVariables() { + return ValueUtil.filter(this.usages(), InductionVariableNode.class); + } + + @Override + public Iterable phiPredecessors() { + return Arrays.asList(new Node[]{this.forwardEdge(), this.loopEnd()}); + } + + public EndNode forwardEdge() { + return this.endAt(0); + } + + public LoopCounterNode loopCounter() { + return loopCounter(CiKind.Long); + } + + public LoopCounterNode loopCounter(CiKind kind) { + for (Node usage : usages()) { + if (usage instanceof LoopCounterNode && ((LoopCounterNode) usage).kind == kind) { + return (LoopCounterNode) usage; + } + } + return new LoopCounterNode(kind, this, graph()); + } + + @Override + public boolean verify() { + assertTrue(loopEnd() != null); + assertTrue(forwardEdge() != null); + return true; + } + + @Override + public String toString() { + return "LoopBegin: " + super.toString(); + } + + @Override + public Iterable< ? extends Node> dataUsages() { + final Iterator< ? extends Node> dataUsages = super.dataUsages().iterator(); + return new Iterable() { + @Override + public Iterator iterator() { + return new StateSplit.FilteringIterator(dataUsages, LoopEndNode.class); + } + }; + } + + @Override + public Map getDebugProperties() { + Map properties = super.getDebugProperties(); + properties.put("loopFrequency", String.format("%7.1f", loopFrequency)); + return properties; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/LoopEndNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/LoopEndNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,58 @@ +/* + * 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.nodes; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + + +public class LoopEndNode extends FixedNode { + + @Input private LoopBeginNode loopBegin; + + public LoopBeginNode loopBegin() { + return loopBegin; + } + + public void setLoopBegin(LoopBeginNode x) { + updateUsages(this.loopBegin, x); + this.loopBegin = x; + } + + public LoopEndNode(Graph graph) { + super(CiKind.Illegal, graph); + } + + @Override + public void accept(ValueVisitor v) { + v.visitLoopEnd(this); + } + + @Override + public Iterable< ? extends Node> dataInputs() { + return Collections.emptyList(); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/MaterializeNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/MaterializeNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2009, 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.nodes; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.calc.*; + +public final class MaterializeNode extends ConditionalNode { + public MaterializeNode(BooleanNode value, Graph graph) { + super(value, ConstantNode.forInt(1, graph), ConstantNode.forInt(0, graph), graph); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/MergeNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/MergeNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,183 @@ +/* + * Copyright (c) 2009, 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.nodes; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + +/** + * Denotes the beginning of a basic block, and holds information + * about the basic block, including the successor and + * predecessor blocks, exception handlers, liveness information, etc. + */ +public class MergeNode extends StateSplit { + + @Input private final NodeInputList ends = new NodeInputList(this); + + public MergeNode(Graph graph) { + super(CiKind.Illegal, graph); + } + + @Override + public boolean needsStateAfter() { + return false; + } + + @Override + public void accept(ValueVisitor v) { + v.visitMerge(this); + } + + public int endIndex(EndNode end) { + return ends.indexOf(end); + } + + public void addEnd(EndNode end) { + ends.add(end); + } + + public int endCount() { + return ends.size(); + } + + public EndNode endAt(int index) { + return ends.get(index); + } + + public Iterable phiPredecessors() { + return ends; + } + + @Override + public Iterable cfgPredecessors() { + return ends; + } + + @Override + public Iterable< ? extends Node> dataInputs() { + return Collections.emptyList(); + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("merge #"); + builder.append(id()); + builder.append(" ["); + + builder.append("]"); + + builder.append(" -> "); + boolean hasSucc = false; + for (Node s : this.successors()) { + if (hasSucc) { + builder.append(", "); + } + builder.append("#"); + if (s != null) { + builder.append(s.id()); + } else { + builder.append("null"); + } + hasSucc = true; + } + return builder.toString(); + } + + /** + * Determines if a given instruction is a phi whose {@linkplain PhiNode#merge() join block} is a given block. + * + * @param value the instruction to test + * @param block the block that may be the join block of {@code value} if {@code value} is a phi + * @return {@code true} if {@code value} is a phi and its join block is {@code block} + */ + private boolean isPhiAtBlock(ValueNode value) { + return value instanceof PhiNode && ((PhiNode) value).merge() == this; + } + + + /** + * Formats a given instruction as a value in a {@linkplain FrameState frame state}. If the instruction is a phi defined at a given + * block, its {@linkplain PhiNode#valueCount() inputs} are appended to the returned string. + * + * @param index the index of the value in the frame state + * @param value the frame state value + * @param block if {@code value} is a phi, then its inputs are formatted if {@code block} is its + * {@linkplain PhiNode#merge() join point} + * @return the instruction representation as a string + */ + public String stateString(int index, ValueNode value) { + StringBuilder sb = new StringBuilder(30); + sb.append(String.format("%2d %s", index, ValueUtil.valueString(value))); + if (value instanceof PhiNode) { + PhiNode phi = (PhiNode) value; + // print phi operands + if (phi.merge() == this) { + sb.append(" ["); + for (int j = 0; j < phi.valueCount(); j++) { + sb.append(' '); + ValueNode operand = phi.valueAt(j); + if (operand != null) { + sb.append(ValueUtil.valueString(operand)); + } else { + sb.append("NULL"); + } + } + sb.append("] "); + } + } + return sb.toString(); + } + + public void removeEnd(EndNode pred) { + int predIndex = ends.indexOf(pred); + assert predIndex != -1; + ends.remove(predIndex); + + for (Node usage : usages()) { + if (usage instanceof PhiNode) { + ((PhiNode) usage).removeInput(predIndex); + } + } + } + + public int phiPredecessorCount() { + return endCount(); + } + + public int phiPredecessorIndex(Node pred) { + EndNode end = (EndNode) pred; + return endIndex(end); + } + + public Node phiPredecessorAt(int index) { + return endAt(index); + } + + public Collection phis() { + return ValueUtil.filter(this.usages(), PhiNode.class); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/PhiNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/PhiNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2009, 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.nodes; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.StateSplit.FilteringIterator; +import com.oracle.max.graal.nodes.calc.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + +/** + * The {@code Phi} instruction represents the merging of dataflow in the instruction graph. It refers to a join block + * and a variable. + */ +public final class PhiNode extends FloatingNode implements Canonicalizable { + + @Input private MergeNode merge; + + @Input private final NodeInputList values = new NodeInputList(this); + + public MergeNode merge() { + return merge; + } + + public void setMerge(MergeNode x) { + updateUsages(merge, x); + merge = x; + } + + public static enum PhiType { + Value, // normal value phis + Memory, // memory phis + Virtual // phis used for VirtualObjectField merges + } + + private final PhiType type; + + public PhiNode(CiKind kind, MergeNode merge, PhiType type, Graph graph) { + super(kind, graph); + this.type = type; + setMerge(merge); + } + + private PhiNode(CiKind kind, PhiType type, Graph graph) { + super(kind, graph); + this.type = type; + } + + public PhiType type() { + return type; + } + + @Override + public boolean verify() { + assertTrue(merge() != null); + assertTrue(merge().phiPredecessorCount() == valueCount(), merge().phiPredecessorCount() + "==" + valueCount()); + return true; + } + + /** + * Get the instruction that produces the value associated with the i'th predecessor of the join block. + * + * @param i the index of the predecessor + * @return the instruction that produced the value in the i'th predecessor + */ + public ValueNode valueAt(int i) { + return values.get(i); + } + + public void setValueAt(int i, ValueNode x) { + values.set(i, x); + } + + /** + * Get the number of inputs to this phi (i.e. the number of predecessors to the join block). + * + * @return the number of inputs in this phi + */ + public int valueCount() { + return values.size(); + } + + @Override + public void accept(ValueVisitor v) { + v.visitPhi(this); + } + + @Override + public String shortName() { + StringBuilder str = new StringBuilder(); + for (int i = 0; i < valueCount(); ++i) { + if (i != 0) { + str.append(' '); + } + str.append(valueAt(i) == null ? "-" : valueAt(i).id()); + } + if (type == PhiType.Value) { + return "Phi: (" + str + ")"; + } else { + return type + "Phi: (" + str + ")"; + } + } + + public void addInput(ValueNode x) { + values.add(x); + } + + public void removeInput(int index) { + values.remove(index); + } + + @Override + public Iterable< ? extends Node> dataInputs() { + final Iterator< ? extends Node> input = super.dataInputs().iterator(); + return new Iterable() { + + @Override + public Iterator iterator() { + return new FilteringIterator(input, MergeNode.class); + } + }; + } + + @Override + public Node canonical(NotifyReProcess reProcess) { + if (valueCount() != 2 || merge().endCount() != 2) { + return this; + } + if (merge().phis().size() > 1) { // XXX (gd) disable canonicalization of multiple conditional while we are not able to fuse them and the potentially leftover If in the backend + return this; + } + Node end0 = merge().endAt(0); + Node end1 = merge().endAt(1); + Node endPred0 = end0.predecessor(); + Node endPred1 = end1.predecessor(); + if (endPred0 != endPred1 || !(endPred0 instanceof IfNode)) { + return this; + } + IfNode ifNode = (IfNode) endPred0; + boolean inverted = ifNode.trueSuccessor() == end1; + ValueNode trueValue = valueAt(inverted ? 1 : 0); + ValueNode falseValue = valueAt(inverted ? 0 : 1); + if ((trueValue.kind != CiKind.Int && trueValue.kind != CiKind.Long) || (falseValue.kind != CiKind.Int && falseValue.kind != CiKind.Long)) { + return this; + } + if ((!(trueValue instanceof ConstantNode) && trueValue.usages().size() == 1) || (!(falseValue instanceof ConstantNode) && falseValue.usages().size() == 1)) { + return this; + } + BooleanNode compare = ifNode.compare(); + while (compare instanceof NegateBooleanNode) { + compare = ((NegateBooleanNode) compare).value(); + } + if (!(compare instanceof CompareNode || compare instanceof IsNonNullNode || compare instanceof NegateBooleanNode || compare instanceof ConstantNode)) { + return this; + } + reProcess.reProccess(ifNode); + return new ConditionalNode(ifNode.compare(), trueValue, falseValue, graph()); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/PlaceholderNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/PlaceholderNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,40 @@ +/* + * 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.nodes; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + + +public class PlaceholderNode extends StateSplit { + + public PlaceholderNode(Graph graph) { + super(CiKind.Void, graph); + } + + @Override + public void accept(ValueVisitor v) { + //assert false; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/ReturnNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/ReturnNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2009, 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.nodes; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + +/** + * The {@code Return} class definition. + */ +public final class ReturnNode extends FixedNode { + + @Input private ValueNode result; + + public ValueNode result() { + return result; + } + + public void setResult(ValueNode x) { + updateUsages(this.result, x); + this.result = x; + } + + /** + * Constructs a new Return instruction. + * @param result the instruction producing the result for this return; {@code null} if this + * is a void return + * @param graph + */ + public ReturnNode(ValueNode result, Graph graph) { + super(result == null ? CiKind.Void : result.kind, graph); + setResult(result); + } + + // for copying + private ReturnNode(CiKind kind, Graph graph) { + super(kind, graph); + } + + @Override + public void accept(ValueVisitor v) { + v.visitReturn(this); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/StateSplit.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/StateSplit.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2009, 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.nodes; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.sun.cri.ci.*; + +/** + * The {@code StateSplit} class is the abstract base class of all instructions + * that store an immutable copy of the frame state. + */ +public abstract class StateSplit extends FixedWithNextNode { + + @Input private FrameState stateAfter; + + public FrameState stateAfter() { + return stateAfter; + } + + public void setStateAfter(FrameState x) { + updateUsages(stateAfter, x); + stateAfter = x; + } + + /** + * Creates a new state split with the specified value type. + * @param kind the type of the value that this instruction produces + * @param graph + */ + public StateSplit(CiKind kind, Graph graph) { + super(kind, graph); + } + + public boolean needsStateAfter() { + return true; + } + + @Override + public void delete() { + FrameState stateAfter = stateAfter(); + super.delete(); + if (stateAfter != null) { + if (stateAfter.usages().isEmpty()) { + stateAfter.delete(); + } + } + } + + @Override + public Iterable< ? extends Node> dataInputs() { + final Iterator< ? extends Node> dataInputs = super.dataInputs().iterator(); + return new Iterable() { + @Override + public Iterator iterator() { + return new FilteringIterator(dataInputs, FrameState.class); + } + }; + } + + public static final class FilteringIterator implements Iterator { + + private final Iterator< ? extends Node> input; + private Node next; + private Class< ? > clazz; + + public FilteringIterator(Iterator< ? extends Node> input, Class clazz) { + this.input = input; + this.clazz = clazz; + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + + @Override + public Node next() { + forward(); + if (!hasNext()) { + throw new NoSuchElementException(); + } + Node res = next; + next = null; + return res; + } + + @Override + public boolean hasNext() { + forward(); + return next != null; + } + + private void forward() { + while (next == null && input.hasNext()) { + next = input.next(); + if (clazz.isInstance(next)) { + next = null; + } + } + } + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/UnwindNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/UnwindNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,55 @@ +/* + * 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.nodes; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + +/** + * Unwind takes an exception object, destroys the current stack frame and passes the exception object to the system's exception dispatch code. + */ +public final class UnwindNode extends FixedNode { + + @Input private ValueNode exception; + + public ValueNode exception() { + return exception; + } + + public void setException(ValueNode x) { + assert x == null || x.kind == CiKind.Object; + updateUsages(this.exception, x); + this.exception = x; + } + + public UnwindNode(ValueNode exception, Graph graph) { + super(CiKind.Object, graph); + setException(exception); + } + + @Override + public void accept(ValueVisitor v) { + v.visitUnwind(this); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/ValueNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/ValueNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,190 @@ +/* + * Copyright (c) 2009, 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.nodes; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.spi.*; +import com.oracle.max.graal.nodes.virtual.*; +import com.sun.cri.ci.*; +import com.sun.cri.ri.*; + +/** + * This class represents a value within the HIR graph, including local variables, phis, and + * all other instructions. + */ +public abstract class ValueNode extends Node { + + /** + * The kind of this value. This is {@link CiKind#Void} for instructions that produce no value. + * This kind is guaranteed to be a {@linkplain CiKind#stackKind() stack kind}. + */ + @Data public final CiKind kind; + + protected CiValue operand = CiValue.IllegalValue; + + /** + * Creates a new value with the specified kind. + * @param kind the type of this value + * @param inputCount + * @param successorCount + * @param graph + */ + public ValueNode(CiKind kind, Graph graph) { + super(graph); + assert kind != null && kind == kind.stackKind() : kind + " != " + kind.stackKind(); + this.kind = kind; + } + + /** + * Checks whether this value is a constant (i.e. it is of type {@link ConstantNode}. + * @return {@code true} if this value is a constant + */ + public final boolean isConstant() { + return this instanceof ConstantNode; + } + + /** + * Checks whether this value represents the null constant. + * @return {@code true} if this value represents the null constant + */ + public final boolean isNullConstant() { + return this instanceof ConstantNode && ((ConstantNode) this).value.isNull(); + } + + /** + * Convert this value to a constant if it is a constant, otherwise return null. + * @return the {@link CiConstant} represented by this value if it is a constant; {@code null} + * otherwise + */ + public final CiConstant asConstant() { + if (this instanceof ConstantNode) { + return ((ConstantNode) this).value; + } + return null; + } + + /** + * Gets the LIR operand associated with this instruction. + * @return the LIR operand for this instruction + */ + public final CiValue operand() { + return operand; + } + + /** + * Sets the LIR operand associated with this instruction. + * @param operand the operand to associate with this instruction + */ + public final void setOperand(CiValue operand) { + assert this.operand.isIllegal() : "operand cannot be set twice"; + assert operand != null && operand.isLegal() : "operand must be legal"; + assert operand.kind.stackKind() == this.kind; + assert !(this instanceof VirtualObjectNode); + this.operand = operand; + } + + /** + * Clears the LIR operand associated with this instruction. + */ + public final void clearOperand() { + this.operand = CiValue.IllegalValue; + } + + /** + * Computes the exact type of the result of this instruction, if possible. + * @return the exact type of the result of this instruction, if it is known; {@code null} otherwise + */ + public RiType exactType() { + return null; // default: unknown exact type + } + + /** + * Computes the declared type of the result of this instruction, if possible. + * @return the declared type of the result of this instruction, if it is known; {@code null} otherwise + */ + public RiType declaredType() { + return null; // default: unknown declared type + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("#"); + builder.append(id()); + builder.append(' '); + if (id() < 10) { + builder.append(' '); + } + builder.append(getClass().getSimpleName()); + builder.append(" [").append(flagsToString()).append("]"); + return builder.toString(); + } + + public String flagsToString() { + StringBuilder sb = new StringBuilder(); + return sb.toString(); + } + + /** + * This method supports the visitor pattern by accepting a visitor and calling the + * appropriate {@code visit()} method. + * + * @param v the visitor to accept + */ + public void accept(ValueVisitor v) { + throw new IllegalStateException("No visit method for this node (" + this.getClass().getSimpleName() + ")"); + } + + public static final LoweringOp DELEGATE_TO_RUNTIME = new LoweringOp() { + @Override + public void lower(Node n, CiLoweringTool tool) { + tool.getRuntime().lower(n, tool); + } + }; + + public static final LIRGeneratorOp DELEGATE_TO_VALUE_VISITOR = new LIRGeneratorOp() { + @Override + public void generate(Node n, LIRGeneratorTool generator) { + ((ValueNode) n).accept(generator); + } + }; + + @SuppressWarnings("unchecked") + @Override + public T lookup(Class clazz) { + if (clazz == LIRGeneratorOp.class) { + return (T) DELEGATE_TO_VALUE_VISITOR; + } + return super.lookup(clazz); + } + + @Override + public Map getDebugProperties() { + Map properties = super.getDebugProperties(); + properties.put("kind", kind.toString()); + properties.put("operand", operand == null ? "null" : operand.toString()); + return properties; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/ValueUtil.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/ValueUtil.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,116 @@ +/* + * 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.nodes; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.sun.cri.ci.*; + + +public class ValueUtil { + + public static ValueNode assertKind(CiKind kind, ValueNode x) { + assert x != null && (x.kind == kind) : "kind=" + kind + ", value=" + x + ((x == null) ? "" : ", value.kind=" + x.kind); + return x; + } + + public static RuntimeException shouldNotReachHere(String msg) { + throw new InternalError("should not reach here: " + msg); + } + + public static RuntimeException shouldNotReachHere() { + throw new InternalError("should not reach here"); + } + + public static ValueNode assertLong(ValueNode x) { + assert x != null && (x.kind == CiKind.Long); + return x; + } + + public static ValueNode assertJsr(ValueNode x) { + assert x != null && (x.kind == CiKind.Jsr); + return x; + } + + public static ValueNode assertInt(ValueNode x) { + assert x != null && (x.kind == CiKind.Int); + return x; + } + + public static ValueNode assertFloat(ValueNode x) { + assert x != null && (x.kind == CiKind.Float); + return x; + } + + public static ValueNode assertObject(ValueNode x) { + assert x != null && (x.kind == CiKind.Object); + return x; + } + + public static ValueNode assertWord(ValueNode x) { + assert x != null && (x.kind == CiKind.Word); + return x; + } + + public static ValueNode assertDouble(ValueNode x) { + assert x != null && (x.kind == CiKind.Double); + return x; + } + + public static void assertHigh(ValueNode x) { + assert x == null; + } + + public static boolean typeMismatch(ValueNode x, ValueNode y) { + return y == null || x.kind != y.kind; + } + + public static boolean isDoubleWord(ValueNode x) { + return x != null && x.kind.isDoubleWord(); + } + + + @SuppressWarnings("unchecked") + public static Collection filter(Iterable nodes, Class clazz) { + ArrayList phis = new ArrayList(); + for (Node node : nodes) { + if (clazz.isInstance(node)) { + phis.add((T) node); + } + } + return phis; + } + + /** + * Converts a given instruction to a value string. The representation of an instruction as + * a value is formed by concatenating the {@linkplain com.sun.cri.ci.CiKind#typeChar character} denoting its + * {@linkplain ValueNode#kind kind} and its {@linkplain ValueNode#id()}. For example, {@code "i13"}. + * + * @param value the instruction to convert to a value string. If {@code value == null}, then "-" is returned. + * @return the instruction representation as a string + */ + public static String valueString(ValueNode value) { + return (value == null) ? "-" : ("" + value.kind.typeChar + value.id()); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/AndNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/AndNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,75 @@ +/* + * 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.nodes.calc; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.bytecode.*; +import com.sun.cri.ci.*; + +@NodeInfo(shortName = "&") +public final class AndNode extends LogicNode implements Canonicalizable { + + public AndNode(CiKind kind, ValueNode x, ValueNode y, Graph graph) { + super(kind, kind == CiKind.Int ? Bytecodes.IAND : Bytecodes.LAND, x, y, graph); + } + + @Override + public Node canonical(NotifyReProcess reProcess) { + if (x() == y()) { + return x(); + } + if (x().isConstant() && !y().isConstant()) { + swapOperands(); + } + if (x().isConstant()) { + if (kind == CiKind.Int) { + return ConstantNode.forInt(x().asConstant().asInt() & y().asConstant().asInt(), graph()); + } else { + assert kind == CiKind.Long; + return ConstantNode.forLong(x().asConstant().asLong() & y().asConstant().asLong(), graph()); + } + } else if (y().isConstant()) { + if (kind == CiKind.Int) { + int c = y().asConstant().asInt(); + if (c == -1) { + return x(); + } + if (c == 0) { + return ConstantNode.forInt(0, graph()); + } + } else { + assert kind == CiKind.Long; + long c = y().asConstant().asLong(); + if (c == -1) { + return x(); + } + if (c == 0) { + return ConstantNode.forLong(0, graph()); + } + } + } + return this; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/ArithmeticNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/ArithmeticNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2009, 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.nodes.calc; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.bytecode.*; +import com.sun.cri.ci.*; + +/** + * The {@code ArithmeticOp} class represents arithmetic operations such as addition, subtraction, etc. + */ +public abstract class ArithmeticNode extends BinaryNode { + + private final boolean isStrictFP; + + /** + * Creates a new arithmetic operation. + * @param opcode the bytecode opcode + * @param kind the result kind of the operation + * @param x the first input instruction + * @param y the second input instruction + * @param isStrictFP indicates this operation has strict rounding semantics + */ + public ArithmeticNode(CiKind kind, int opcode, ValueNode x, ValueNode y, boolean isStrictFP, Graph graph) { + super(kind, opcode, x, y, graph); + this.isStrictFP = isStrictFP; + } + + /** + * Checks whether this instruction has strict fp semantics. + * @return {@code true} if this instruction has strict fp semantics + */ + public boolean isStrictFP() { + return isStrictFP; + } + + @Override + public void accept(ValueVisitor v) { + v.visitArithmetic(this); + } + + public boolean isCommutative() { + return Bytecodes.isCommutative(opcode); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/BinaryNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/BinaryNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2009, 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.nodes.calc; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.sun.cri.bytecode.*; +import com.sun.cri.ci.*; + +/** + * The {@code Op2} class is the base of arithmetic and logic operations with two inputs. + */ +public abstract class BinaryNode extends FloatingNode { + + @Input private ValueNode x; + @Input private ValueNode y; + @Data public final int opcode; + + public ValueNode x() { + return x; + } + + public void setX(ValueNode x) { + updateUsages(this.x, x); + this.x = x; + } + + public ValueNode y() { + return y; + } + + public void setY(ValueNode x) { + updateUsages(y, x); + this.y = x; + } + + /** + * Creates a new Op2 instance. + * @param kind the result type of this instruction + * @param opcode the bytecode opcode + * @param x the first input instruction + * @param y the second input instruction + */ + public BinaryNode(CiKind kind, int opcode, ValueNode x, ValueNode y, Graph graph) { + super(kind, graph); + this.opcode = opcode; + setX(x); + setY(y); + } + + /** + * Swaps the operands of this instruction. This is only legal for commutative operations. + */ + public void swapOperands() { + assert Bytecodes.isCommutative(opcode); + ValueNode t = x(); + setX(y()); + setY(t); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/CompareNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/CompareNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,210 @@ +/* + * Copyright (c) 2011, 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.nodes.calc; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + +/* (tw/gd) For high-level optimization purpose the compare node should be a boolean *value* (it is currently only a helper node) + * But in the back-end the comparison should not always be materialized (for example in x86 the comparison result will not be in a register but in a flag) + * + * Compare should probably be made a value (so that it can be canonicalized for example) and in later stages some Compare usage should be transformed + * into variants that do not materialize the value (CompareIf, CompareGuard...) + * + */ +public final class CompareNode extends BooleanNode implements Canonicalizable { + + @Input private ValueNode x; + @Input private ValueNode y; + + @Data private Condition condition; + @Data private boolean unorderedIsTrue; + + public ValueNode x() { + return x; + } + + public void setX(ValueNode x) { + updateUsages(this.x, x); + this.x = x; + } + + public ValueNode y() { + return y; + } + + public void setY(ValueNode x) { + updateUsages(y, x); + this.y = x; + } + + /** + * Constructs a new Compare instruction. + * + * @param x the instruction producing the first input to the instruction + * @param condition the condition (comparison operation) + * @param y the instruction that produces the second input to this instruction + * @param graph + */ + public CompareNode(ValueNode x, Condition condition, ValueNode y, Graph graph) { + super(CiKind.Illegal, graph); + assert (x == null && y == null) || x.kind == y.kind; + this.condition = condition; + setX(x); + setY(y); + } + + /** + * Gets the condition (comparison operation) for this instruction. + * + * @return the condition + */ + public Condition condition() { + return condition; + } + + /** + * Checks whether unordered inputs mean true or false. + * + * @return {@code true} if unordered inputs produce true + */ + public boolean unorderedIsTrue() { + return unorderedIsTrue; + } + + public void setUnorderedIsTrue(boolean unorderedIsTrue) { + this.unorderedIsTrue = unorderedIsTrue; + } + + /** + * Swaps the operands to this if and mirrors the condition (e.g. > becomes <). + * + * @see Condition#mirror() + */ + public void swapOperands() { + condition = condition.mirror(); + ValueNode t = x(); + setX(y()); + setY(t); + } + + public void negate() { + condition = condition.negate(); + unorderedIsTrue = !unorderedIsTrue; + } + + @Override + public void accept(ValueVisitor v) { + } + + @Override + public String shortName() { + return "Comp " + condition.operator; + } + + @Override + public Map getDebugProperties() { + Map properties = super.getDebugProperties(); + properties.put("unorderedIsTrue", unorderedIsTrue()); + return properties; + } + + private Node optimizeMaterialize(CiConstant constant, MaterializeNode materializeNode) { + if (constant.kind == CiKind.Int) { + boolean isFalseCheck = (constant.asInt() == 0); + if (condition == Condition.EQ || condition == Condition.NE) { + if (condition == Condition.NE) { + isFalseCheck = !isFalseCheck; + } + BooleanNode result = materializeNode.condition(); + if (isFalseCheck) { + result = new NegateBooleanNode(result, graph()); + } + return result; + } + } + return this; + } + + private Node optimizeNormalizeCmp(CiConstant constant, NormalizeCompareNode normalizeNode) { + if (constant.kind == CiKind.Int && constant.asInt() == 0) { + Condition condition = condition(); + if (normalizeNode == y()) { + condition = condition.mirror(); + } + CompareNode result = new CompareNode(normalizeNode.x(), condition, normalizeNode.y(), graph()); + boolean isLess = condition == Condition.LE || condition == Condition.LT || condition == Condition.BE || condition == Condition.BT; + result.unorderedIsTrue = condition != Condition.EQ && (condition == Condition.NE || !(isLess ^ normalizeNode.isUnorderedLess())); + return result; + } + return this; + } + + @Override + public Node canonical(NotifyReProcess reProcess) { + if (x().isConstant() && !y().isConstant()) { // move constants to the left (y) + swapOperands(); + } else if (x().isConstant() && y().isConstant()) { + CiConstant constX = x().asConstant(); + CiConstant constY = y().asConstant(); + Boolean result = condition().foldCondition(constX, constY, ((CompilerGraph) graph()).runtime(), unorderedIsTrue()); + if (result != null) { + return ConstantNode.forBoolean(result, graph()); + } + } + + if (y().isConstant()) { + if (x() instanceof MaterializeNode) { + return optimizeMaterialize(y().asConstant(), (MaterializeNode) x()); + } else if (x() instanceof NormalizeCompareNode) { + return optimizeNormalizeCmp(y().asConstant(), (NormalizeCompareNode) x()); + } + } + + if (x() == y() && x().kind != CiKind.Float && x().kind != CiKind.Double) { + return ConstantNode.forBoolean(condition().check(1, 1), graph()); + } + if ((condition == Condition.NE || condition == Condition.EQ) && x().kind == CiKind.Object) { + ValueNode object = null; + if (x().isNullConstant()) { + object = y(); + } else if (y().isNullConstant()) { + object = x(); + } + if (object != null) { + IsNonNullNode nonNull = new IsNonNullNode(object, graph()); + if (condition == Condition.NE) { + return nonNull; + } else { + assert condition == Condition.EQ; + return new NegateBooleanNode(nonNull, graph()); + } + } + } + return this; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/Condition.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/Condition.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,262 @@ +/* + * Copyright (c) 2009, 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.nodes.calc; + +import com.sun.cri.ci.*; +import com.sun.cri.ri.*; + +/** + * Condition codes used in conditionals. + */ +public enum Condition { + /** + * Equal. + */ + EQ("=="), + + /** + * Not equal. + */ + NE("!="), + + /** + * Signed less than. + */ + LT("<"), + + /** + * Signed less than or equal. + */ + LE("<="), + + /** + * Signed greater than. + */ + GT(">"), + + /** + * Signed greater than or equal. + */ + GE(">="), + + /** + * Unsigned greater than or equal ("above than or equal"). + */ + AE("|>=|"), + + /** + * Unsigned less than or equal ("below than or equal"). + */ + BE("|<=|"), + + /** + * Unsigned greater than ("above than"). + */ + AT("|>|"), + + /** + * Unsigned less than ("below than"). + */ + BT("|<|"), + + /** + * Operation produced an overflow. + */ + OF("overflow"), + + /** + * Operation did not produce an overflow. + */ + NOF("noOverflow"), + + TRUE("TRUE"); + + public final String operator; + + private Condition(String operator) { + this.operator = operator; + } + + public boolean check(int left, int right) { + switch (this) { + case EQ: return left == right; + case NE: return left != right; + case LT: return left < right; + case LE: return left <= right; + case GT: return left > right; + case GE: return left >= right; + case BT: return (left & 0xffffffffL) < (right & 0xffffffffL); + case BE: return (left & 0xffffffffL) <= (right & 0xffffffffL); + case AT: return (left & 0xffffffffL) > (right & 0xffffffffL); + case AE: return (left & 0xffffffffL) >= (right & 0xffffffffL); + } + throw new IllegalArgumentException(); + } + + /** + * Negate this conditional. + * @return the condition that represents the negation + */ + public final Condition negate() { + switch (this) { + case EQ: return NE; + case NE: return EQ; + case LT: return GE; + case LE: return GT; + case GT: return LE; + case GE: return LT; + case BT: return AE; + case BE: return AT; + case AT: return BE; + case AE: return BT; + case OF: return NOF; + case NOF: return OF; + } + throw new IllegalArgumentException(this.toString()); + } + + /** + * Mirror this conditional (i.e. commute "a op b" to "b op' a") + * @return the condition representing the equivalent commuted operation + */ + public final Condition mirror() { + switch (this) { + case EQ: return EQ; + case NE: return NE; + case LT: return GT; + case LE: return GE; + case GT: return LT; + case GE: return LE; + case BT: return AT; + case BE: return AE; + case AT: return BT; + case AE: return BE; + } + throw new IllegalArgumentException(); + } + + /** + * Checks if this conditional operation is commutative. + * @return {@code true} if this operation is commutative + */ + public final boolean isCommutative() { + return this == EQ || this == NE; + } + + /** + * Attempts to fold a comparison between two constants and return the result. + * @param lt the constant on the left side of the comparison + * @param rt the constant on the right side of the comparison + * @param runtime the RiRuntime (might be needed to compare runtime-specific types) + * @return {@link Boolean#TRUE} if the comparison is known to be true, + * {@link Boolean#FALSE} if the comparison is known to be false, {@code null} otherwise. + */ + public Boolean foldCondition(CiConstant lt, CiConstant rt, RiRuntime runtime, boolean unorderedIsTrue) { + switch (lt.kind) { + case Boolean: + case Int: { + int x = lt.asInt(); + int y = rt.asInt(); + switch (this) { + case EQ: return x == y; + case NE: return x != y; + case LT: return x < y; + case LE: return x <= y; + case GT: return x > y; + case GE: return x >= y; + case AE: return toUnsigned(x) >= toUnsigned(y); + case BE: return toUnsigned(x) <= toUnsigned(y); + case AT: return toUnsigned(x) > toUnsigned(y); + case BT: return toUnsigned(x) < toUnsigned(y); + } + break; + } + case Long: { + long x = lt.asLong(); + long y = rt.asLong(); + switch (this) { + case EQ: return x == y; + case NE: return x != y; + case LT: return x < y; + case LE: return x <= y; + case GT: return x > y; + case GE: return x >= y; + } + break; + } + case Object: { + switch (this) { + case EQ: return runtime.areConstantObjectsEqual(lt, rt); + case NE: return !runtime.areConstantObjectsEqual(lt, rt); + } + break; + } + case Float: { + float x = lt.asFloat(); + float y = rt.asFloat(); + if (Float.isNaN(x) || Float.isNaN(y)) { + return unorderedIsTrue; + } + switch (this) { + case EQ: return x == y; + case NE: return x != y; + case BT: + case LT: return x < y; + case BE: + case LE: return x <= y; + case AT: + case GT: return x > y; + case AE: + case GE: return x >= y; + } + } + case Double: { + double x = lt.asDouble(); + double y = rt.asDouble(); + if (Double.isNaN(x) || Double.isNaN(y)) { + return unorderedIsTrue; + } + switch (this) { + case EQ: return x == y; + case NE: return x != y; + case BT: + case LT: return x < y; + case BE: + case LE: return x <= y; + case AT: + case GT: return x > y; + case AE: + case GE: return x >= y; + } + } + } + return null; + } + + private long toUnsigned(int x) { + if (x < 0) { + return ((long) (x & 0x7FFFFFFF)) + ((long) Integer.MAX_VALUE) + 1; + } + return x; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/ConditionalNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/ConditionalNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2009, 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.nodes.calc; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.PhiNode.PhiType; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.bytecode.*; +import com.sun.cri.ci.*; + +/** + * The {@code Conditional} class represents a comparison that yields one of two values. Note that these nodes are not + * built directly from the bytecode but are introduced by conditional expression elimination. + */ +public class ConditionalNode extends BinaryNode implements Canonicalizable { + + @Input private BooleanNode condition; + + public BooleanNode condition() { + return condition; + } + + public void setCondition(BooleanNode n) { + updateUsages(condition, n); + condition = n; + } + + /** + * Constructs a new IfOp. + * + * @param x the instruction producing the first value to be compared + * @param condition the condition of the comparison + * @param y the instruction producing the second value to be compared + * @param trueValue the value produced if the condition is true + * @param falseValue the value produced if the condition is false + */ + public ConditionalNode(BooleanNode condition, ValueNode trueValue, ValueNode falseValue, Graph graph) { + // TODO: return the appropriate bytecode IF_ICMPEQ, etc + super(trueValue.kind.meet(falseValue.kind), Bytecodes.ILLEGAL, trueValue, falseValue, graph); + setCondition(condition); + } + + // for copying + private ConditionalNode(CiKind kind, Graph graph) { + super(kind, Bytecodes.ILLEGAL, null, null, graph); + } + + public ValueNode trueValue() { + return x(); + } + + public ValueNode falseValue() { + return y(); + } + + public void setTrueValue(ValueNode value) { + setX(value); + } + + public void setFalseValue(ValueNode value) { + setY(value); + } + + @SuppressWarnings("unchecked") + @Override + public T lookup(Class clazz) { + if (clazz == LIRGeneratorOp.class) { + return (T) LIRGEN; + } + return super.lookup(clazz); + } + + public static class ConditionalStructure { + + public final IfNode ifNode; + public final PhiNode phi; + public final MergeNode merge; + + public ConditionalStructure(IfNode ifNode, PhiNode phi, MergeNode merge) { + this.ifNode = ifNode; + this.phi = phi; + this.merge = merge; + } + } + + public static ConditionalStructure createConditionalStructure(BooleanNode condition, ValueNode trueValue, ValueNode falseValue) { + return createConditionalStructure(condition, trueValue, falseValue, 0.5); + } + + public static ConditionalStructure createConditionalStructure(BooleanNode condition, ValueNode trueValue, ValueNode falseValue, double trueProbability) { + Graph graph = condition.graph(); + CiKind kind = trueValue.kind.meet(falseValue.kind); + IfNode ifNode = new IfNode(condition, trueProbability, graph); + EndNode trueEnd = new EndNode(graph); + EndNode falseEnd = new EndNode(graph); + ifNode.setTrueSuccessor(trueEnd); + ifNode.setFalseSuccessor(falseEnd); + MergeNode merge = new MergeNode(graph); + merge.addEnd(trueEnd); + merge.addEnd(falseEnd); + PhiNode phi = new PhiNode(kind, merge, PhiType.Value, graph); + phi.addInput(trueValue); + phi.addInput(falseValue); + return new ConditionalStructure(ifNode, phi, merge); + } + + private static final LIRGeneratorOp LIRGEN = new LIRGeneratorOp() { + + @Override + public void generate(Node n, LIRGeneratorTool generator) { + generator.visitConditional((ConditionalNode) n); + } + }; + + @Override + public Node canonical(NotifyReProcess reProcess) { + if (condition instanceof ConstantNode) { + ConstantNode c = (ConstantNode) condition; + if (c.asConstant().asBoolean()) { + return trueValue(); + } else { + return falseValue(); + } + } + if (trueValue() == falseValue()) { + return trueValue(); + } + if (!(this instanceof MaterializeNode) && trueValue() instanceof ConstantNode && falseValue() instanceof ConstantNode && trueValue().kind == CiKind.Int && falseValue().kind == CiKind.Int) { + int trueInt = trueValue().asConstant().asInt(); + int falseInt = falseValue().asConstant().asInt(); + if (trueInt == 0 && falseInt == 1) { + reProcess.reProccess(condition); // because we negate it + return new MaterializeNode(new NegateBooleanNode(condition, graph()), graph()); + } else if (trueInt == 1 && falseInt == 0) { + return new MaterializeNode(condition, graph()); + } + } else if (falseValue() instanceof ConstantNode && !(trueValue() instanceof ConstantNode)) { + ValueNode temp = trueValue(); + setTrueValue(falseValue()); + setFalseValue(temp); + condition = new NegateBooleanNode(condition, graph()); + setCondition(condition); + } + return this; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/ConvertNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/ConvertNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2009, 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.nodes.calc; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + +/** + * The {@code Convert} class represents a conversion between primitive types. + */ +public final class ConvertNode extends FloatingNode { + @Input private ValueNode value; + + @Data public final int opcode; + + public ValueNode value() { + return value; + } + + public void setValue(ValueNode x) { + updateUsages(value, x); + value = x; + } + + /** + * Constructs a new Convert instance. + * @param opcode the bytecode representing the operation + * @param value the instruction producing the input value + * @param kind the result type of this instruction + * @param graph + */ + public ConvertNode(int opcode, ValueNode value, CiKind kind, Graph graph) { + super(kind, graph); + this.opcode = opcode; + setValue(value); + } + + @Override + public void accept(ValueVisitor v) { + v.visitConvert(this); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/FloatAddNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/FloatAddNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,66 @@ +/* + * 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.nodes.calc; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.bytecode.*; +import com.sun.cri.ci.*; + +@NodeInfo(shortName = "+") +public final class FloatAddNode extends FloatArithmeticNode implements Canonicalizable { + + public FloatAddNode(CiKind kind, ValueNode x, ValueNode y, boolean isStrictFP, Graph graph) { + super(kind, kind == CiKind.Double ? Bytecodes.DADD : Bytecodes.FADD, x, y, isStrictFP, graph); + } + + @Override + public Node canonical(NotifyReProcess reProcess) { + if (x().isConstant() && !y().isConstant()) { + swapOperands(); + } + if (x().isConstant()) { + if (kind == CiKind.Float) { + return ConstantNode.forFloat(x().asConstant().asFloat() + y().asConstant().asFloat(), graph()); + } else { + assert kind == CiKind.Double; + return ConstantNode.forDouble(x().asConstant().asDouble() + y().asConstant().asDouble(), graph()); + } + } else if (y().isConstant()) { + if (kind == CiKind.Float) { + float c = y().asConstant().asFloat(); + if (c == 0.0f) { + return x(); + } + } else { + assert kind == CiKind.Double; + double c = y().asConstant().asDouble(); + if (c == 0.0) { + return x(); + } + } + } + return this; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/FloatArithmeticNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/FloatArithmeticNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,35 @@ +/* + * 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.nodes.calc; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.sun.cri.ci.*; + +public abstract class FloatArithmeticNode extends ArithmeticNode { + + public FloatArithmeticNode(CiKind kind, int opcode, ValueNode x, ValueNode y, boolean isStrictFP, Graph graph) { + super(kind, opcode, x, y, isStrictFP, graph); + } + +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/FloatDivNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/FloatDivNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,50 @@ +/* + * 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.nodes.calc; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.bytecode.*; +import com.sun.cri.ci.*; + +@NodeInfo(shortName = "/") +public final class FloatDivNode extends FloatArithmeticNode implements Canonicalizable { + + public FloatDivNode(CiKind kind, ValueNode x, ValueNode y, boolean isStrictFP, Graph graph) { + super(kind, kind == CiKind.Double ? Bytecodes.DDIV : Bytecodes.FDIV, x, y, isStrictFP, graph); + } + + @Override + public Node canonical(NotifyReProcess reProcess) { + if (x().isConstant() && y().isConstant()) { + if (kind == CiKind.Float) { + return ConstantNode.forFloat(x().asConstant().asFloat() / y().asConstant().asFloat(), graph()); + } else { + assert kind == CiKind.Double; + return ConstantNode.forDouble(x().asConstant().asDouble() / y().asConstant().asDouble(), graph()); + } + } + return this; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/FloatMulNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/FloatMulNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,66 @@ +/* + * 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.nodes.calc; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.bytecode.*; +import com.sun.cri.ci.*; + +@NodeInfo(shortName = "*") +public final class FloatMulNode extends FloatArithmeticNode implements Canonicalizable { + + public FloatMulNode(CiKind kind, ValueNode x, ValueNode y, boolean isStrictFP, Graph graph) { + super(kind, kind == CiKind.Double ? Bytecodes.DMUL : Bytecodes.FMUL, x, y, isStrictFP, graph); + } + + @Override + public Node canonical(NotifyReProcess reProcess) { + if (x().isConstant() && !y().isConstant()) { + swapOperands(); + } + if (x().isConstant()) { + if (kind == CiKind.Float) { + return ConstantNode.forFloat(x().asConstant().asFloat() * y().asConstant().asFloat(), graph()); + } else { + assert kind == CiKind.Double; + return ConstantNode.forDouble(x().asConstant().asDouble() * y().asConstant().asDouble(), graph()); + } + } else if (y().isConstant()) { + if (kind == CiKind.Float) { + float c = y().asConstant().asFloat(); + if (c == 0.0f) { + return ConstantNode.forFloat(0.0f, graph()); + } + } else { + assert kind == CiKind.Double; + double c = y().asConstant().asDouble(); + if (c == 0.0) { + return ConstantNode.forDouble(0.0, graph()); + } + } + } + return this; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/FloatRemNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/FloatRemNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,50 @@ +/* + * 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.nodes.calc; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.bytecode.*; +import com.sun.cri.ci.*; + +@NodeInfo(shortName = "%") +public final class FloatRemNode extends FloatArithmeticNode implements Canonicalizable { + + public FloatRemNode(CiKind kind, ValueNode x, ValueNode y, boolean isStrictFP, Graph graph) { + super(kind, kind == CiKind.Double ? Bytecodes.DREM : Bytecodes.FREM, x, y, isStrictFP, graph); + } + + @Override + public Node canonical(NotifyReProcess reProcess) { + if (x().isConstant() && y().isConstant()) { + if (kind == CiKind.Float) { + return ConstantNode.forFloat(x().asConstant().asFloat() % y().asConstant().asFloat(), graph()); + } else { + assert kind == CiKind.Double; + return ConstantNode.forDouble(x().asConstant().asDouble() % y().asConstant().asDouble(), graph()); + } + } + return this; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/FloatSubNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/FloatSubNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,73 @@ +/* + * 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.nodes.calc; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.bytecode.*; +import com.sun.cri.ci.*; + +@NodeInfo(shortName = "-") +public final class FloatSubNode extends FloatArithmeticNode implements Canonicalizable { + + public FloatSubNode(CiKind kind, ValueNode x, ValueNode y, boolean isStrictFP, Graph graph) { + super(kind, kind == CiKind.Double ? Bytecodes.DSUB : Bytecodes.FSUB, x, y, isStrictFP, graph); + } + + @Override + public Node canonical(NotifyReProcess reProcess) { + if (x() == y()) { + if (kind == CiKind.Float) { + return ConstantNode.forFloat(0.0f, graph()); + } else { + assert kind == CiKind.Double; + return ConstantNode.forDouble(0.0, graph()); + } + } + if (x().isConstant() && y().isConstant()) { + if (kind == CiKind.Float) { + return ConstantNode.forFloat(x().asConstant().asFloat() - y().asConstant().asFloat(), graph()); + } else { + assert kind == CiKind.Double; + return ConstantNode.forDouble(x().asConstant().asDouble() - y().asConstant().asDouble(), graph()); + } + } else if (y().isConstant()) { + if (kind == CiKind.Float) { + float c = y().asConstant().asFloat(); + if (c == 0.0f) { + return x(); + } + return new FloatAddNode(kind, x(), ConstantNode.forFloat(-c, graph()), isStrictFP(), graph()); + } else { + assert kind == CiKind.Double; + double c = y().asConstant().asDouble(); + if (c == 0.0) { + return x(); + } + return new FloatAddNode(kind, x(), ConstantNode.forDouble(-c, graph()), isStrictFP(), graph()); + } + } + return this; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/FloatingNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/FloatingNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,33 @@ +/* + * 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.nodes.calc; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.sun.cri.ci.*; + +public abstract class FloatingNode extends ValueNode implements Node.ValueNumberable { + public FloatingNode(CiKind kind, Graph graph) { + super(kind, graph); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/IntegerAddNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/IntegerAddNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2011, 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.nodes.calc; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.bytecode.*; +import com.sun.cri.ci.*; + +@NodeInfo(shortName = "+") +public final class IntegerAddNode extends IntegerArithmeticNode implements Canonicalizable { + + public IntegerAddNode(CiKind kind, ValueNode x, ValueNode y, Graph graph) { + super(kind, kind == CiKind.Int ? Bytecodes.IADD : Bytecodes.LADD, x, y, graph); + } + + @Override + public Node canonical(NotifyReProcess reProcess) { + if (x().isConstant() && !y().isConstant()) { + swapOperands(); + } + if (x().isConstant()) { + if (kind == CiKind.Int) { + return ConstantNode.forInt(x().asConstant().asInt() + y().asConstant().asInt(), graph()); + } else { + assert kind == CiKind.Long; + return ConstantNode.forLong(x().asConstant().asLong() + y().asConstant().asLong(), graph()); + } + } else if (y().isConstant()) { + if (kind == CiKind.Int) { + int c = y().asConstant().asInt(); + if (c == 0) { + return x(); + } + } else { + assert kind == CiKind.Long; + long c = y().asConstant().asLong(); + if (c == 0) { + return x(); + } + } + } + return this; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/IntegerAddVectorNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/IntegerAddVectorNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,63 @@ +/* + * 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.nodes.calc; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.extended.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + + +public final class IntegerAddVectorNode extends AbstractVectorNode { + @Input private ValueNode value; + + public ValueNode value() { + return value; + } + + public void setValue(ValueNode x) { + updateUsages(value, x); + value = x; + } + + public IntegerAddVectorNode(AbstractVectorNode vector, ValueNode value, Graph graph) { + super(CiKind.Illegal, vector, graph); + setValue(value); + } + + @Override + public T lookup(Class clazz) { + if (clazz == LIRGeneratorOp.class) { + return null; + } + return super.lookup(clazz); + } + + @Override + public void addToLoop(LoopBeginNode loop, IdentityHashMap nodes) { + nodes.put(this, new IntegerAddNode(CiKind.Int, nodes.get(vector()), value(), graph())); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/IntegerArithmeticNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/IntegerArithmeticNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2011, 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.nodes.calc; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.sun.cri.ci.*; + + +public abstract class IntegerArithmeticNode extends ArithmeticNode { + + public IntegerArithmeticNode(CiKind kind, int opcode, ValueNode x, ValueNode y, Graph graph) { + super(kind, opcode, x, y, false, graph); + assert kind == CiKind.Int || kind == CiKind.Long; + } + + public static IntegerArithmeticNode add(ValueNode v1, ValueNode v2) { + assert v1.kind == v2.kind && v1.graph() == v2.graph(); + Graph graph = v1.graph(); + //TODO (gd) handle conversions here instead of strong assert ? + switch(v1.kind) { + case Int: + return new IntegerAddNode(CiKind.Int, v1, v2, graph); + case Long: + return new IntegerAddNode(CiKind.Long, v1, v2, graph); + default: + throw ValueUtil.shouldNotReachHere(); + } + } + + public static IntegerArithmeticNode mul(ValueNode v1, ValueNode v2) { + assert v1.kind == v2.kind && v1.graph() == v2.graph(); + Graph graph = v1.graph(); + //TODO (gd) handle conversions here instead of strong assert ? + switch(v1.kind) { + case Int: + return new IntegerMulNode(CiKind.Int, v1, v2, graph); + case Long: + return new IntegerMulNode(CiKind.Long, v1, v2, graph); + default: + throw ValueUtil.shouldNotReachHere(); + } + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/IntegerDivNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/IntegerDivNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,59 @@ +/* + * 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.nodes.calc; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.bytecode.*; +import com.sun.cri.ci.*; + +@NodeInfo(shortName = "/") +public final class IntegerDivNode extends IntegerArithmeticNode implements Canonicalizable { + + public IntegerDivNode(CiKind kind, ValueNode x, ValueNode y, Graph graph) { + super(kind, kind == CiKind.Int ? Bytecodes.IDIV : Bytecodes.LDIV, x, y, graph); + } + + @Override + public Node canonical(NotifyReProcess reProcess) { + if (x().isConstant() && y().isConstant()) { + long yConst = y().asConstant().asLong(); + if (yConst == 0) { + return this; // this will trap, can not canonicalize + } + if (kind == CiKind.Int) { + return ConstantNode.forInt(x().asConstant().asInt() / (int) yConst, graph()); + } else { + assert kind == CiKind.Long; + return ConstantNode.forLong(x().asConstant().asLong() / yConst, graph()); + } + } else if (y().isConstant()) { + long c = y().asConstant().asLong(); + if (c == 1) { + return x(); + } + } + return this; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/IntegerMulNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/IntegerMulNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,64 @@ +/* + * 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.nodes.calc; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.bytecode.*; +import com.sun.cri.ci.*; + +@NodeInfo(shortName = "*") +public final class IntegerMulNode extends IntegerArithmeticNode implements Canonicalizable { + + public IntegerMulNode(CiKind kind, ValueNode x, ValueNode y, Graph graph) { + super(kind, kind == CiKind.Int ? Bytecodes.IMUL : Bytecodes.LMUL, x, y, graph); + } + + @Override + public Node canonical(NotifyReProcess reProcess) { + if (x().isConstant() && !y().isConstant()) { + swapOperands(); + } + if (x().isConstant()) { + if (kind == CiKind.Int) { + return ConstantNode.forInt(x().asConstant().asInt() * y().asConstant().asInt(), graph()); + } else { + assert kind == CiKind.Long; + return ConstantNode.forLong(x().asConstant().asLong() * y().asConstant().asLong(), graph()); + } + } else if (y().isConstant()) { + long c = y().asConstant().asLong(); + if (c == 1) { + return x(); + } + if (c == 0) { + return ConstantNode.forInt(0, graph()); + } + if (c > 0 && CiUtil.isPowerOf2(c)) { + return new LeftShiftNode(kind, x(), ConstantNode.forInt(CiUtil.log2(c), graph()), graph()); + } + } + return this; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/IntegerRemNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/IntegerRemNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,64 @@ +/* + * 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.nodes.calc; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.bytecode.*; +import com.sun.cri.ci.*; + +@NodeInfo(shortName = "%") +public final class IntegerRemNode extends IntegerArithmeticNode implements Canonicalizable { + + public IntegerRemNode(CiKind kind, ValueNode x, ValueNode y, Graph graph) { + super(kind, kind == CiKind.Int ? Bytecodes.IREM : Bytecodes.LREM, x, y, graph); + } + + @Override + public Node canonical(NotifyReProcess reProcess) { + if (x().isConstant() && y().isConstant()) { + long yConst = y().asConstant().asLong(); + if (yConst == 0) { + return this; // this will trap, can not canonicalize + } + if (kind == CiKind.Int) { + return ConstantNode.forInt(x().asConstant().asInt() % (int) yConst, graph()); + } else { + assert kind == CiKind.Long; + return ConstantNode.forLong(x().asConstant().asLong() % yConst, graph()); + } + } else if (y().isConstant()) { + long c = y().asConstant().asLong(); + if (c == 1 || c == -1) { + if (kind == CiKind.Int) { + return ConstantNode.forInt(0, graph()); + } else { + assert kind == CiKind.Long; + return ConstantNode.forLong(0, graph()); + } + } + } + return this; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/IntegerSubNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/IntegerSubNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,74 @@ +/* + * 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.nodes.calc; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.bytecode.*; +import com.sun.cri.ci.*; + +@NodeInfo(shortName = "-") +public final class IntegerSubNode extends IntegerArithmeticNode implements Canonicalizable { + + public IntegerSubNode(CiKind kind, ValueNode x, ValueNode y, Graph graph) { + super(kind, kind == CiKind.Int ? Bytecodes.ISUB : Bytecodes.LSUB, x, y, graph); + } + + @Override + public Node canonical(NotifyReProcess reProcess) { + if (x() == y()) { + if (kind == CiKind.Int) { + return ConstantNode.forInt(0, graph()); + } else { + assert kind == CiKind.Long; + return ConstantNode.forLong(0, graph()); + } + } + if (x().isConstant() && y().isConstant()) { + if (kind == CiKind.Int) { + return ConstantNode.forInt(x().asConstant().asInt() - y().asConstant().asInt(), graph()); + } else { + assert kind == CiKind.Long; + return ConstantNode.forLong(x().asConstant().asLong() - y().asConstant().asLong(), graph()); + } + } else if (y().isConstant()) { + long c = y().asConstant().asLong(); + if (c == 0) { + return x(); + } + if (kind == CiKind.Int) { + return new IntegerAddNode(kind, x(), ConstantNode.forInt((int) -c, graph()), graph()); + } else { + assert kind == CiKind.Long; + return new IntegerAddNode(kind, x(), ConstantNode.forLong(-c, graph()), graph()); + } + } else if (x().isConstant()) { + long c = x().asConstant().asLong(); + if (c == 0) { + return new NegateNode(y(), graph()); + } + } + return this; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/IsNonNullNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/IsNonNullNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2009, 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.nodes.calc; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.java.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; +import com.sun.cri.ri.*; + +/** + * The {@code NullCheck} class represents an explicit null check instruction. + */ +public final class IsNonNullNode extends BooleanNode implements Canonicalizable { + + @Input private ValueNode object; + + public ValueNode object() { + return object; + } + + public void setObject(ValueNode x) { + updateUsages(object, x); + object = x; + } + + /** + * Constructs a new NullCheck instruction. + * + * @param object the instruction producing the object to check against null + * @param graph + */ + public IsNonNullNode(ValueNode object, Graph graph) { + super(CiKind.Object, graph); + assert object == null || object.kind == CiKind.Object : object; + setObject(object); + } + + @Override + public void accept(ValueVisitor v) { + // Nothing to do. + } + + @Override + public RiType declaredType() { + // null check does not alter the type of the object + return object().declaredType(); + } + + @Override + public RiType exactType() { + // null check does not alter the type of the object + return object().exactType(); + } + + @Override + public Node canonical(NotifyReProcess reProcess) { + if (object() instanceof NewInstanceNode || object() instanceof NewArrayNode) { + return ConstantNode.forBoolean(true, graph()); + } + CiConstant constant = object().asConstant(); + if (constant != null) { + assert constant.kind == CiKind.Object; + return ConstantNode.forBoolean(constant.isNonNull(), graph()); + } + return this; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/LeftShiftNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/LeftShiftNode.java Wed Aug 10 01:12:36 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.nodes.calc; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.bytecode.*; +import com.sun.cri.ci.*; + +@NodeInfo(shortName = "<<") +public final class LeftShiftNode extends ShiftNode implements Canonicalizable { + + public LeftShiftNode(CiKind kind, ValueNode x, ValueNode y, Graph graph) { + super(kind, kind == CiKind.Int ? Bytecodes.ISHL : Bytecodes.LSHL, x, y, graph); + } + + @Override + public Node canonical(NotifyReProcess reProcess) { + if (y().isConstant()) { + int amount = y().asConstant().asInt(); + int originalAmout = amount; + int mask; + if (kind == CiKind.Int) { + mask = 0x1f; + } else { + assert kind == CiKind.Long; + mask = 0x3f; + } + amount &= mask; + if (x().isConstant()) { + if (kind == CiKind.Int) { + return ConstantNode.forInt(x().asConstant().asInt() << amount, graph()); + } else { + assert kind == CiKind.Long; + return ConstantNode.forLong(x().asConstant().asLong() << amount, graph()); + } + } + if (amount == 0) { + return x(); + } + if (x() instanceof ShiftNode) { + ShiftNode other = (ShiftNode) x(); + if (other.y().isConstant()) { + int otherAmount = other.y().asConstant().asInt() & mask; + if (other instanceof LeftShiftNode) { + int total = amount + otherAmount; + if (total != (total & mask)) { + return ConstantNode.forInt(0, graph()); + } + return new LeftShiftNode(kind, other.x(), ConstantNode.forInt(total, graph()), graph()); + } else if ((other instanceof RightShiftNode || other instanceof UnsignedRightShiftNode) && otherAmount == amount) { + if (kind == CiKind.Long) { + return new AndNode(kind, other.x(), ConstantNode.forLong(-1L << amount, graph()), graph()); + } else { + assert kind == CiKind.Int; + return new AndNode(kind, other.x(), ConstantNode.forInt(-1 << amount, graph()), graph()); + } + } + } + } + if (originalAmout != amount) { + return new LeftShiftNode(kind, x(), ConstantNode.forInt(amount, graph()), graph()); + } + } + return this; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/LogicNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/LogicNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2009, 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.nodes.calc; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + +/** + * The {@code LogicOp} class definition. + */ +public abstract class LogicNode extends BinaryNode { + + /** + * Constructs a new logic operation instruction. + * @param opcode the opcode of the logic operation + * @param x the first input into this instruction + * @param y the second input into this instruction + */ + public LogicNode(CiKind kind, int opcode, ValueNode x, ValueNode y, Graph graph) { + super(kind, opcode, x, y, graph); + } + + @Override + public void accept(ValueVisitor v) { + v.visitLogic(this); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/NegateBooleanNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/NegateBooleanNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2009, 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.nodes.calc; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + +public final class NegateBooleanNode extends BooleanNode implements Canonicalizable { + + @Input private BooleanNode value; + + public BooleanNode value() { + return value; + } + + public void setValue(BooleanNode x) { + updateUsages(value, x); + value = x; + } + + public NegateBooleanNode(BooleanNode value, Graph graph) { + super(CiKind.Int, graph); + setValue(value); + } + + @Override + public void accept(ValueVisitor v) { + } + + @Override + public Node canonical(NotifyReProcess reProcess) { + if (value() instanceof NegateBooleanNode) { + return ((NegateBooleanNode) value()).value(); + } else if (value() instanceof ConstantNode) { + return ConstantNode.forBoolean(!value().asConstant().asBoolean(), graph()); + } + return this; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/NegateNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/NegateNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2009, 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.nodes.calc; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + +/** + * The {@code NegateOp} instruction negates its operand. + */ +public final class NegateNode extends FloatingNode implements Canonicalizable { + + @Input + private ValueNode x; + + public ValueNode x() { + return x; + } + + public void setX(ValueNode x) { + updateUsages(this.x, x); + this.x = x; + } + + /** + * Creates new NegateOp instance. + * + * @param x the instruction producing the value that is input to this instruction + */ + public NegateNode(ValueNode x, Graph graph) { + super(x.kind, graph); + setX(x); + } + + // for copying + private NegateNode(CiKind kind, Graph graph) { + super(kind, graph); + } + + @Override + public void accept(ValueVisitor v) { + v.visitNegate(this); + } + + @Override + public Node canonical(NotifyReProcess reProcess) { + if (x().isConstant()) { + switch (x().kind) { + case Int: + return ConstantNode.forInt(-x().asConstant().asInt(), graph()); + case Long: + return ConstantNode.forLong(-x().asConstant().asLong(), graph()); + case Float: + return ConstantNode.forFloat(-x().asConstant().asFloat(), graph()); + case Double: + return ConstantNode.forDouble(-x().asConstant().asDouble(), graph()); + } + } + if (x() instanceof NegateNode) { + return ((NegateNode) x()).x(); + } + return this; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/NormalizeCompareNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/NormalizeCompareNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2009, 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.nodes.calc; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.bytecode.*; +import com.sun.cri.ci.*; + +/** + * Returns -1, 0, or 1 if either x > y, x == y, or x < y. + */ +public final class NormalizeCompareNode extends BinaryNode { + + /** + * Creates a new compare operation. + * @param opcode the bytecode opcode + * @param kind the result kind + * @param x the first input + * @param y the second input + */ + public NormalizeCompareNode(int opcode, CiKind kind, ValueNode x, ValueNode y, Graph graph) { + super(kind, opcode, x, y, graph); + } + + @Override + public void accept(ValueVisitor v) { + v.visitNormalizeCompare(this); + } + + @Override + public Map getDebugProperties() { + Map properties = super.getDebugProperties(); + properties.put("isUnorderedLess", isUnorderedLess()); + return properties; + } + + public boolean isUnorderedLess() { + return this.opcode == Bytecodes.FCMPL || this.opcode == Bytecodes.DCMPL; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/OrNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/OrNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,75 @@ +/* + * 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.nodes.calc; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.bytecode.*; +import com.sun.cri.ci.*; + +@NodeInfo(shortName = "|") +public final class OrNode extends LogicNode implements Canonicalizable { + + public OrNode(CiKind kind, ValueNode x, ValueNode y, Graph graph) { + super(kind, kind == CiKind.Int ? Bytecodes.IOR : Bytecodes.LOR, x, y, graph); + } + + @Override + public Node canonical(NotifyReProcess reProcess) { + if (x() == y()) { + return x(); + } + if (x().isConstant() && !y().isConstant()) { + swapOperands(); + } + if (x().isConstant()) { + if (kind == CiKind.Int) { + return ConstantNode.forInt(x().asConstant().asInt() | y().asConstant().asInt(), graph()); + } else { + assert kind == CiKind.Long; + return ConstantNode.forLong(x().asConstant().asLong() | y().asConstant().asLong(), graph()); + } + } else if (y().isConstant()) { + if (kind == CiKind.Int) { + int c = y().asConstant().asInt(); + if (c == -1) { + return ConstantNode.forInt(-1, graph()); + } + if (c == 0) { + return x(); + } + } else { + assert kind == CiKind.Long; + long c = y().asConstant().asLong(); + if (c == -1) { + return ConstantNode.forLong(-1, graph()); + } + if (c == 0) { + return x(); + } + } + } + return this; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/RightShiftNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/RightShiftNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,81 @@ +/* + * 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.nodes.calc; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.bytecode.*; +import com.sun.cri.ci.*; + +@NodeInfo(shortName = ">>") +public final class RightShiftNode extends ShiftNode implements Canonicalizable { + + public RightShiftNode(CiKind kind, ValueNode x, ValueNode y, Graph graph) { + super(kind, kind == CiKind.Int ? Bytecodes.ISHR : Bytecodes.LSHR, x, y, graph); + } + + @Override + public Node canonical(NotifyReProcess reProcess) { + if (y().isConstant()) { + int amount = y().asConstant().asInt(); + int originalAmout = amount; + int mask; + if (kind == CiKind.Int) { + mask = 0x1f; + } else { + assert kind == CiKind.Long; + mask = 0x3f; + } + amount &= mask; + if (x().isConstant()) { + if (kind == CiKind.Int) { + return ConstantNode.forInt(x().asConstant().asInt() >> amount, graph()); + } else { + assert kind == CiKind.Long; + return ConstantNode.forLong(x().asConstant().asLong() >> amount, graph()); + } + } + if (amount == 0) { + return x(); + } + if (x() instanceof ShiftNode) { + ShiftNode other = (ShiftNode) x(); + if (other.y().isConstant()) { + int otherAmount = other.y().asConstant().asInt() & mask; + if (other instanceof RightShiftNode) { + int total = amount + otherAmount; + if (total != (total & mask)) { + return ConstantNode.forInt(0, graph()); + } + return new RightShiftNode(kind, other.x(), ConstantNode.forInt(total, graph()), graph()); + } + } + } + if (originalAmout != amount) { + return new RightShiftNode(kind, x(), ConstantNode.forInt(amount, graph()), graph()); + } + } + return this; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/ShiftNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/ShiftNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2009, 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.nodes.calc; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + +/** + * The {@code ShiftOp} class represents shift operations. + */ +public abstract class ShiftNode extends BinaryNode { + + /** + * Creates a new shift operation. + * @param opcode the opcode of the shift + * @param x the first input value + * @param s the second input value + */ + public ShiftNode(CiKind kind, int opcode, ValueNode x, ValueNode s, Graph graph) { + super(kind, opcode, x, s, graph); + assert x == null || x.kind == kind; + } + + @Override + public void accept(ValueVisitor v) { + v.visitShift(this); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/UnsignedRightShiftNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/UnsignedRightShiftNode.java Wed Aug 10 01:12:36 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.nodes.calc; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.bytecode.*; +import com.sun.cri.ci.*; + +@NodeInfo(shortName = ">>>") +public final class UnsignedRightShiftNode extends ShiftNode implements Canonicalizable { + + public UnsignedRightShiftNode(CiKind kind, ValueNode x, ValueNode y, Graph graph) { + super(kind, kind == CiKind.Int ? Bytecodes.IUSHR : Bytecodes.LUSHR, x, y, graph); + } + + @Override + public Node canonical(NotifyReProcess reProcess) { + if (y().isConstant()) { + int amount = y().asConstant().asInt(); + int originalAmout = amount; + int mask; + if (kind == CiKind.Int) { + mask = 0x1f; + } else { + assert kind == CiKind.Long; + mask = 0x3f; + } + amount &= mask; + if (x().isConstant()) { + if (kind == CiKind.Int) { + return ConstantNode.forInt(x().asConstant().asInt() >>> amount, graph()); + } else { + assert kind == CiKind.Long; + return ConstantNode.forLong(x().asConstant().asLong() >>> amount, graph()); + } + } + if (amount == 0) { + return x(); + } + if (x() instanceof ShiftNode) { + ShiftNode other = (ShiftNode) x(); + if (other.y().isConstant()) { + int otherAmount = other.y().asConstant().asInt() & mask; + if (other instanceof UnsignedRightShiftNode) { + int total = amount + otherAmount; + if (total != (total & mask)) { + return ConstantNode.forInt(0, graph()); + } + return new UnsignedRightShiftNode(kind, other.x(), ConstantNode.forInt(total, graph()), graph()); + } else if (other instanceof LeftShiftNode && otherAmount == amount) { + if (kind == CiKind.Long) { + return new AndNode(kind, other.x(), ConstantNode.forLong(-1L >>> amount, graph()), graph()); + } else { + assert kind == CiKind.Int; + return new AndNode(kind, other.x(), ConstantNode.forInt(-1 >>> amount, graph()), graph()); + } + } + } + } + if (originalAmout != amount) { + return new UnsignedRightShiftNode(kind, x(), ConstantNode.forInt(amount, graph()), graph()); + } + } + return this; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/XorNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/XorNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,74 @@ +/* + * 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.nodes.calc; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.bytecode.*; +import com.sun.cri.ci.*; + +@NodeInfo(shortName = "^") +public final class XorNode extends LogicNode implements Canonicalizable { + + public XorNode(CiKind kind, ValueNode x, ValueNode y, Graph graph) { + super(kind, kind == CiKind.Int ? Bytecodes.IXOR : Bytecodes.LXOR, x, y, graph); + } + + @Override + public Node canonical(NotifyReProcess reProcess) { + if (x() == y()) { + if (kind == CiKind.Int) { + return ConstantNode.forInt(0, graph()); + } else { + assert kind == CiKind.Long; + return ConstantNode.forLong(0L, graph()); + } + } + if (x().isConstant() && !y().isConstant()) { + swapOperands(); + } + if (x().isConstant()) { + if (kind == CiKind.Int) { + return ConstantNode.forInt(x().asConstant().asInt() ^ y().asConstant().asInt(), graph()); + } else { + assert kind == CiKind.Long; + return ConstantNode.forLong(x().asConstant().asLong() ^ y().asConstant().asLong(), graph()); + } + } else if (y().isConstant()) { + if (kind == CiKind.Int) { + int c = y().asConstant().asInt(); + if (c == 0) { + return x(); + } + } else { + assert kind == CiKind.Long; + long c = y().asConstant().asLong(); + if (c == 0) { + return x(); + } + } + } + return this; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/AbstractMemoryCheckpointNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/AbstractMemoryCheckpointNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,57 @@ +/* + * 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.nodes.extended; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.sun.cri.ci.*; + + +public abstract class AbstractMemoryCheckpointNode extends StateSplit { + + @Input private final NodeInputList mergedNodes = new NodeInputList(this); + + private static final int SUCCESSOR_COUNT = 0; + private static final int INPUT_COUNT = 0; + + public AbstractMemoryCheckpointNode(Graph graph) { + this(CiKind.Illegal, graph); + } + + public AbstractMemoryCheckpointNode(CiKind result, Graph graph) { + super(result, graph); + } + + @Override + public Map getDebugProperties() { + Map debugProperties = super.getDebugProperties(); + debugProperties.put("memoryCheckpoint", "true"); + return debugProperties; + } + + public NodeInputList mergedNodes() { + return mergedNodes; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/AbstractVectorNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/AbstractVectorNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,83 @@ +/* + * 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.nodes.extended; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.sun.cri.ci.*; + + +public abstract class AbstractVectorNode extends StateSplit { + @Input private AbstractVectorNode vector; + + public AbstractVectorNode vector() { + return vector; + } + + public void setVector(AbstractVectorNode x) { + updateUsages(vector, x); + vector = x; + } + + public AbstractVectorNode(CiKind kind, AbstractVectorNode vector, Graph graph) { + super(kind, graph); + setVector(vector); + } + + protected static AbstractVectorNode findCommonNode(AbstractVectorNode left, AbstractVectorNode right, List leftList, List rightList) { + Set occured = new HashSet(); + AbstractVectorNode common = null; + AbstractVectorNode cur = left; + while (cur != null) { + occured.add(cur); + cur = cur.vector(); + } + + cur = right; + while (cur != null) { + if (occured.contains(cur)) { + common = cur; + break; + } + cur = cur.vector(); + } + + fillUntil(left, cur, leftList); + fillUntil(right, cur, rightList); + return common; + } + + private static void fillUntil(AbstractVectorNode left, AbstractVectorNode until, List leftList) { + AbstractVectorNode cur = left; + while (cur != null && cur != until) { + leftList.add(cur); + cur = cur.vector(); + } + } + + public void addToLoop(LoopBeginNode loop, IdentityHashMap nodes) { + throw new IllegalStateException("unimplemented"); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/AccessNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/AccessNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,76 @@ +/* + * 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.nodes.extended; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.sun.cri.ci.*; + + +public abstract class AccessNode extends AbstractMemoryCheckpointNode { + @Input private ValueNode object; + @Input private GuardNode guard; + @Input private LocationNode location; + @Input private final NodeInputList dependencies = new NodeInputList(this); + + public ValueNode object() { + return object; + } + + public void setObject(ValueNode x) { + updateUsages(object, x); + object = x; + } + + public GuardNode guard() { + return guard; + } + + public void setGuard(GuardNode x) { + updateUsages(guard, x); + guard = x; + } + + public LocationNode location() { + return location; + } + + public void setLocation(LocationNode x) { + updateUsages(location, x); + location = x; + } + + public AccessNode(CiKind kind, ValueNode object, LocationNode location, Graph graph) { + super(kind, graph); + setLocation(location); + setObject(object); + } + + public void addDependency(Node x) { + dependencies.add(x); + } + + public NodeInputList dependencies() { + return dependencies; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/AccessVectorNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/AccessVectorNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,58 @@ +/* + * 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.nodes.extended; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.sun.cri.ci.*; + + +public abstract class AccessVectorNode extends AbstractVectorNode { + @Input private ValueNode object; + @Input private LocationNode location; + @Input private final NodeInputList dependencies = new NodeInputList(this); + + public ValueNode object() { + return object; + } + + public void setObject(ValueNode x) { + updateUsages(object, x); + object = x; + } + + public LocationNode location() { + return location; + } + + public void setLocation(LocationNode x) { + updateUsages(location, x); + location = x; + } + + public AccessVectorNode(CiKind kind, AbstractVectorNode vector, ValueNode object, LocationNode location, Graph graph) { + super(kind, vector, graph); + setObject(object); + setLocation(location); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/CreateVectorNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/CreateVectorNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,154 @@ +/* + * 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.nodes.extended; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.PhiNode.PhiType; +import com.oracle.max.graal.nodes.calc.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + + +public final class CreateVectorNode extends AbstractVectorNode { + @Input private ValueNode length; + + public ValueNode length() { + return length; + } + + public void setLength(ValueNode x) { + updateUsages(length, x); + length = x; + } + + private boolean reversed; + + public boolean reversed() { + return reversed; + } + + public void setReversed(boolean r) { + reversed = r; + } + + public CreateVectorNode(boolean reversed, ValueNode length, Graph graph) { + super(CiKind.Illegal, null, graph); + setLength(length); + setReversed(reversed); + } + + @Override + public Map getDebugProperties() { + Map debugProperties = super.getDebugProperties(); + debugProperties.put("reversed", reversed); + return debugProperties; + } + + @SuppressWarnings("unchecked") + @Override + public T lookup(Class clazz) { + if (clazz == LIRGeneratorOp.class) { + return null; + } else if (clazz == LoweringOp.class) { + return (T) LOWERING_OP; + } + return super.lookup(clazz); + } + + private LoopBeginNode createLoop(Map map) { + EndNode end = new EndNode(graph()); + LoopBeginNode loopBegin = new LoopBeginNode(graph()); + loopBegin.addEnd(end); + PhiNode loopVariable = new PhiNode(CiKind.Int, loopBegin, PhiType.Value, graph()); + + if (reversed) { + IntegerSubNode add = new IntegerSubNode(CiKind.Int, loopVariable, ConstantNode.forInt(1, graph()), graph()); + loopVariable.addInput(new IntegerSubNode(CiKind.Int, length(), ConstantNode.forInt(1, graph()), graph())); + loopVariable.addInput(add); + } else { + IntegerAddNode add = new IntegerAddNode(CiKind.Int, loopVariable, ConstantNode.forInt(1, graph()), graph()); + loopVariable.addInput(ConstantNode.forInt(0, graph())); + loopVariable.addInput(add); + } + + LoopEndNode loopEnd = new LoopEndNode(graph()); + loopEnd.setLoopBegin(loopBegin); + loopBegin.setStateAfter(stateAfter()); + CompareNode condition; + if (reversed) { + condition = new CompareNode(loopVariable, Condition.GE, ConstantNode.forInt(0, graph()), graph()); + } else { + condition = new CompareNode(loopVariable, Condition.LT, length(), graph()); + } + int expectedLength = 100; // TODO: it may be possible to get a more accurate estimate...? + if (length().isConstant()) { + expectedLength = length().asConstant().asInt(); + } + IfNode ifNode = new IfNode(condition, 1.0 / expectedLength, graph()); + loopBegin.setNext(ifNode); + ifNode.setTrueSuccessor(loopEnd); + this.replaceAtPredecessors(end); + ifNode.setFalseSuccessor(this); + map.put(this, loopVariable); + return loopBegin; + } + + private static final LoweringOp LOWERING_OP = new LoweringOp() { + @Override + public void lower(Node n, CiLoweringTool tool) { + CreateVectorNode vectorNode = (CreateVectorNode) n; + + IdentityHashMap nodes = new IdentityHashMap(); + LoopBeginNode begin = vectorNode.createLoop(nodes); + for (Node use : vectorNode.usages()) { + processUse(begin, use, nodes); + } + } + + private void processUse(LoopBeginNode loop, Node use, IdentityHashMap nodes) { + AbstractVectorNode vectorNode = (AbstractVectorNode) use; + if (nodes.containsKey(vectorNode)) { + return; + } + nodes.put(vectorNode, null); + + // Make sure inputs are evaluated. + for (Node input : use.inputs()) { + if (input instanceof AbstractVectorNode) { + AbstractVectorNode abstractVectorNodeInput = (AbstractVectorNode) input; + processUse(loop, abstractVectorNodeInput, nodes); + } + } + + vectorNode.addToLoop(loop, nodes); + + // Go on to usages. + for (Node usage : use.usages()) { + processUse(loop, usage, nodes); + } + } + }; +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/LocationNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/LocationNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,114 @@ +/* + * 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.nodes.extended; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.calc.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; +import com.sun.cri.ci.CiAddress.Scale; + + +public final class LocationNode extends FloatingNode { + @Input private ValueNode index; + + @Data private int displacement; + @Data private boolean indexScalingEnabled = true; + @Data private CiKind valueKind; + @Data private Object locationIdentity; + + public ValueNode index() { + return index; + } + + public void setIndex(ValueNode x) { + updateUsages(index, x); + index = x; + } + + public static final Object UNSAFE_ACCESS_LOCATION = new Object(); + public static final Object FINAL_LOCATION = new Object(); + + public static Object getArrayLocation(CiKind elementKind) { + return elementKind; + } + + public int displacement() { + return displacement; + } + + /** + * @return whether scaling of the index by the value kind's size is enabled (the default) or disabled. + */ + public boolean indexScalingEnabled() { + return indexScalingEnabled; + } + + /** + * Enables or disables scaling of the index by the value kind's size. Has no effect if the index input is not used. + */ + public void setIndexScalingEnabled(boolean enable) { + this.indexScalingEnabled = enable; + } + + public static LocationNode create(Object identity, CiKind kind, int displacement, Graph graph) { + LocationNode result = new LocationNode(identity, kind, displacement, graph); + return graph.value(result); + } + + private LocationNode(Object identity, CiKind kind, int displacement, Graph graph) { + super(CiKind.Illegal, graph); + this.displacement = displacement; + this.valueKind = kind; + this.locationIdentity = identity; + } + + @Override + public T lookup(Class clazz) { + if (clazz == LIRGeneratorOp.class) { + return null; + } + return super.lookup(clazz); + } + + public CiKind getValueKind() { + return valueKind; + } + + public CiAddress createAddress(LIRGeneratorTool lirGenerator, ValueNode object) { + CiValue indexValue = CiValue.IllegalValue; + Scale indexScale = Scale.Times1; + if (this.index() != null) { + indexValue = lirGenerator.load(this.index()); + if (indexScalingEnabled) { + indexScale = Scale.fromInt(valueKind.sizeInBytes(lirGenerator.target().wordSize)); + } + } + return new CiAddress(valueKind, lirGenerator.load(object), indexValue, indexScale, displacement); + } + + public Object locationIdentity() { + return locationIdentity; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/LookupSwitchNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/LookupSwitchNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2009, 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.nodes.extended; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; + +/** + * The {@code LookupSwitch} instruction represents a lookup switch bytecode, which has a sorted + * array of key values. + */ +public final class LookupSwitchNode extends SwitchNode { + + private static final int INPUT_COUNT = 0; + private static final int SUCCESSOR_COUNT = 0; + + final int[] keys; + + /** + * Constructs a new LookupSwitch instruction. + * @param value the instruction producing the value being switched on + * @param successors the list of successors + * @param keys the list of keys, sorted + * @param stateAfter the state after the switch + * @param graph + */ + public LookupSwitchNode(ValueNode value, List successors, int[] keys, double[] probability, Graph graph) { + super(value, successors, probability, INPUT_COUNT, SUCCESSOR_COUNT, graph); + this.keys = keys; + } + + /** + * Gets the key at the specified index. + * @param i the index + * @return the key at that index + */ + public int keyAt(int i) { + return keys[i]; + } + + public int keysLength() { + return keys.length; + } + + @Override + public void accept(ValueVisitor v) { + v.visitLookupSwitch(this); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/ReadNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/ReadNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,41 @@ +/* + * 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.nodes.extended; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + + +public final class ReadNode extends AccessNode implements Node.ValueNumberable { + + public ReadNode(CiKind kind, ValueNode object, LocationNode location, Graph graph) { + super(kind, object, location, graph); + } + + @Override + public void accept(ValueVisitor v) { + v.visitMemoryRead(this); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/ReadVectorNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/ReadVectorNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,58 @@ +/* + * 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.nodes.extended; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + + +public final class ReadVectorNode extends AccessVectorNode { + + public ReadVectorNode(AbstractVectorNode vector, ValueNode object, LocationNode location, Graph graph) { + super(CiKind.Illegal, vector, object, location, graph); + } + + @Override + public T lookup(Class clazz) { + if (clazz == LIRGeneratorOp.class) { + return null; + } + return super.lookup(clazz); + } + + @Override + public void addToLoop(LoopBeginNode loop, IdentityHashMap nodes) { + LocationNode newLocation = LocationNode.create(LocationNode.getArrayLocation(location().getValueKind()), location().getValueKind(), location().displacement(), graph()); + ValueNode index = nodes.get(vector()); + assert index != null; + newLocation.setIndex(index); + ReadNode readNode = new ReadNode(location().getValueKind().stackKind(), object(), newLocation, graph()); + loop.loopEnd().replaceAtPredecessors(readNode); + readNode.setNext(loop.loopEnd()); + nodes.put(this, readNode); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/SwitchNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/SwitchNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2009, 2010, 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.nodes.extended; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.sun.cri.ci.*; + +/** + * The {@code Switch} class is the base of both lookup and table switches. + */ +public abstract class SwitchNode extends ControlSplitNode { + + @Input private ValueNode value; + + public ValueNode value() { + return value; + } + + public void setValue(ValueNode x) { + updateUsages(value, x); + value = x; + } + + /** + * Constructs a new Switch. + * @param value the instruction that provides the value to be switched over + * @param successors the list of successors of this switch + * @param stateAfter the state after the switch + * @param graph + */ + public SwitchNode(ValueNode value, List successors, double[] probability, int inputCount, int successorCount, Graph graph) { + super(CiKind.Illegal, successors, probability, graph); + setValue(value); + } + + /** + * Gets the number of cases that this switch covers (excluding the default case). + * @return the number of cases + */ + public int numberOfCases() { + return blockSuccessorCount() - 1; + } + +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/TableSwitchNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/TableSwitchNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2009, 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.nodes.extended; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; + +/** + * The {@code TableSwitch} instruction represents a table switch. + */ +public final class TableSwitchNode extends SwitchNode { + + private static final int INPUT_COUNT = 0; + private static final int SUCCESSOR_COUNT = 0; + + final int lowKey; + + /** + * Constructs a new TableSwitch instruction. + * @param value the instruction producing the value being switched on + * @param successors the list of successors + * @param lowKey the lowest integer key in the table + * @param stateAfter the state after the switch + * @param graph + */ + public TableSwitchNode(ValueNode value, List successors, int lowKey, double[] probability, Graph graph) { + super(value, successors, probability, INPUT_COUNT, SUCCESSOR_COUNT, graph); + this.lowKey = lowKey; + } + + /** + * Gets the lowest key in the table switch (inclusive). + * @return the low key + */ + public int lowKey() { + return lowKey; + } + + /** + * Gets the highest key in the table switch (exclusive). + * @return the high key + */ + public int highKey() { + return lowKey + numberOfCases(); + } + + @Override + public void accept(ValueVisitor v) { + v.visitTableSwitch(this); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/ValueAnchorNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/ValueAnchorNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,54 @@ +/* + * 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.nodes.extended; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + +/** + * The ValueAnchor instruction keeps non-CFG nodes above a certain point in the graph. + */ +public final class ValueAnchorNode extends FixedWithNextNode { + @Input private ValueNode object; + + public ValueNode object() { + return object; + } + + public void setObject(ValueNode x) { + updateUsages(object, x); + object = x; + } + + public ValueAnchorNode(ValueNode object, Graph graph) { + super(CiKind.Illegal, graph); + setObject(object); + } + + @Override + public void accept(ValueVisitor v) { + v.visitValueAnchor(this); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/WriteMemoryCheckpointNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/WriteMemoryCheckpointNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,47 @@ +/* + * 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.nodes.extended; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + + +public final class WriteMemoryCheckpointNode extends AbstractMemoryCheckpointNode { + + public WriteMemoryCheckpointNode(Graph graph) { + this(CiKind.Illegal, graph); + } + + public WriteMemoryCheckpointNode(CiKind result, Graph graph) { + super(result, graph); + } + + @Override + public T lookup(Class clazz) { + if (clazz == LIRGeneratorOp.class) { + return null; + } + return super.lookup(clazz); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/WriteNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/WriteNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,52 @@ +/* + * 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.nodes.extended; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + + +public final class WriteNode extends AccessNode { + @Input private ValueNode value; + + public ValueNode value() { + return value; + } + + public void setValue(ValueNode x) { + updateUsages(value, x); + value = x; + } + + public WriteNode(CiKind kind, ValueNode object, ValueNode value, LocationNode location, Graph graph) { + super(kind, object, location, graph); + setValue(value); + } + + @Override + public void accept(ValueVisitor v) { + v.visitMemoryWrite(this); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/WriteVectorNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/WriteVectorNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,70 @@ +/* + * 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.nodes.extended; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + + +public final class WriteVectorNode extends AccessVectorNode { + @Input private AbstractVectorNode values; + + public AbstractVectorNode values() { + return values; + } + + public void setValues(AbstractVectorNode x) { + updateUsages(values, x); + values = x; + } + + public WriteVectorNode(AbstractVectorNode vector, ValueNode object, LocationNode location, AbstractVectorNode values, Graph graph) { + super(CiKind.Illegal, vector, object, location, graph); + setValues(values); + } + + @Override + public T lookup(Class clazz) { + if (clazz == LIRGeneratorOp.class) { + return null; + } + return super.lookup(clazz); + } + + @Override + public void addToLoop(LoopBeginNode loop, IdentityHashMap nodes) { + LocationNode newLocation = LocationNode.create(LocationNode.getArrayLocation(location().getValueKind()), location().getValueKind(), location().displacement(), graph()); + ValueNode index = nodes.get(vector()); + ValueNode value = nodes.get(values()); + assert index != null; + assert value != null; + newLocation.setIndex(index); + WriteNode writeNode = new WriteNode(location().getValueKind().stackKind(), object(), value, newLocation, graph()); + loop.loopEnd().replaceAtPredecessors(writeNode); + writeNode.setNext(loop.loopEnd()); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/AccessArrayNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/AccessArrayNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2009, 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.nodes.java; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.sun.cri.ci.*; + +/** + * This the base class of all array operations. + */ +public abstract class AccessArrayNode extends StateSplit { + + @Input private ValueNode array; + + public ValueNode array() { + return array; + } + + public void setArray(ValueNode x) { + updateUsages(array, x); + array = x; + } + + /** + * Creates a new AccessArray instruction. + * @param kind the type of the result of this instruction + * @param array the instruction that produces the array object value + * @param graph + */ + public AccessArrayNode(CiKind kind, ValueNode array, Graph graph) { + super(kind, graph); + setArray(array); + } + +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/AccessFieldNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/AccessFieldNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2009, 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.nodes.java; + +import java.lang.reflect.*; +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.sun.cri.ci.*; +import com.sun.cri.ri.*; + +/** + * The base class of all instructions that access fields. + */ +public abstract class AccessFieldNode extends StateSplit { + + @Input private ValueNode object; + + public ValueNode object() { + return object; + } + + public void setObject(ValueNode x) { + updateUsages(object, x); + object = x; + } + + protected final RiField field; + + /** + * Constructs a new access field object. + * @param kind the result kind of the access + * @param object the instruction producing the receiver object + * @param field the compiler interface representation of the field + * @param graph + */ + public AccessFieldNode(CiKind kind, ValueNode object, RiField field, Graph graph) { + super(kind, graph); + this.field = field; + setObject(object); + assert field.isResolved(); + assert field.holder().isInitialized(); + } + + /** + * Gets the compiler interface field for this field access. + * @return the compiler interface field for this field access + */ + public RiField field() { + return field; + } + + /** + * Checks whether this field access is an access to a static field. + * @return {@code true} if this field access is to a static field + */ + public boolean isStatic() { + return Modifier.isStatic(field.accessFlags()); + } + + /** + * Checks whether this field is declared volatile. + * @return {@code true} if the field is resolved and declared volatile + */ + public boolean isVolatile() { + return Modifier.isVolatile(field.accessFlags()); + } + + @Override + public Map getDebugProperties() { + Map properties = super.getDebugProperties(); + properties.put("field", field); + return properties; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/AccessIndexedNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/AccessIndexedNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2009, 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.nodes.java; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.sun.cri.ci.*; + +/** + * The {@code AccessIndexed} class is the base class of instructions that read or write + * elements of an array. + */ +public abstract class AccessIndexedNode extends AccessArrayNode { + + @Input private ValueNode index; + + @Input private ValueNode length; + + public ValueNode index() { + return index; + } + + public void setIndex(ValueNode x) { + updateUsages(index, x); + index = x; + } + + public ValueNode length() { + return length; + } + + public void setLength(ValueNode x) { + updateUsages(length, x); + length = x; + } + + private final CiKind elementType; + + /** + * Create an new AccessIndexed instruction. + * @param kind the result kind of the access + * @param array the instruction producing the array + * @param index the instruction producing the index + * @param length the instruction producing the length (used in bounds check elimination?) + * @param elementKind the type of the elements of the array + * @param graph + */ + protected AccessIndexedNode(CiKind kind, ValueNode array, ValueNode index, ValueNode length, CiKind elementKind, Graph graph) { + super(kind, array, graph); + setIndex(index); + setLength(length); + this.elementType = elementKind; + } + + /** + * Gets the element type of the array. + * @return the element type + */ + public CiKind elementKind() { + return elementType; + } + +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/AccessMonitorNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/AccessMonitorNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2009, 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.nodes.java; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.extended.*; +import com.sun.cri.ci.*; + +/** + * The {@code AccessMonitor} instruction is the base class of both monitor acquisition and release. + */ +public abstract class AccessMonitorNode extends AbstractMemoryCheckpointNode { + + @Input private ValueNode object; + @Input private ValueNode lockAddress; + + public ValueNode object() { + return object; + } + + public void setObject(ValueNode x) { + updateUsages(object, x); + object = x; + } + + public ValueNode lockAddress() { + return lockAddress; + } + + public void setLockAddress(ValueNode x) { + updateUsages(lockAddress, x); + lockAddress = x; + } + + /** + * The lock number of this monitor access. + */ + public final int lockNumber; + + /** + * Creates a new AccessMonitor instruction. + * + * @param object the instruction producing the object + * @param lockAddress the address of the on-stack lock object or {@code null} if the runtime does not place locks on the stack + * @param lockNumber the number of the lock being acquired + * @param graph + */ + public AccessMonitorNode(ValueNode object, ValueNode lockAddress, int lockNumber, Graph graph) { + super(CiKind.Illegal, graph); + this.lockNumber = lockNumber; + setObject(object); + setLockAddress(lockAddress); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/ArrayLengthNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/ArrayLengthNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2009, 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.nodes.java; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.calc.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; +import com.sun.cri.ri.*; + +/** + * The {@code ArrayLength} instruction gets the length of an array. + */ +public final class ArrayLengthNode extends FloatingNode implements Canonicalizable { + + @Input private ValueNode array; + + public ValueNode array() { + return array; + } + + public void setArray(ValueNode x) { + updateUsages(array, x); + array = x; + } + + /** + * Constructs a new ArrayLength instruction. + * + * @param array the instruction producing the array + * @param newFrameState the state after executing this instruction + */ + public ArrayLengthNode(ValueNode array, Graph graph) { + super(CiKind.Int, graph); + setArray(array); + } + + @Override + public void accept(ValueVisitor v) { + v.visitArrayLength(this); + } + + @Override + public Node canonical(NotifyReProcess reProcess) { + if (array() instanceof NewArrayNode) { + ValueNode length = ((NewArrayNode) array()).dimension(0); + assert length != null; + return length; + } + CiConstant constantValue = null; + if (array().isConstant()) { + constantValue = array().asConstant(); + if (constantValue != null && constantValue.isNonNull()) { + if (graph() instanceof CompilerGraph) { + RiRuntime runtime = ((CompilerGraph) graph()).runtime(); + return ConstantNode.forInt(runtime.getArrayLength(constantValue), graph()); + } + } + } + return this; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/CheckCastNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/CheckCastNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2009, 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.nodes.java; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.bytecode.*; +import com.sun.cri.ci.*; +import com.sun.cri.ri.*; + +/** + * The {@code CheckCast} instruction represents a {@link Bytecodes#CHECKCAST}. + */ +public final class CheckCastNode extends TypeCheckNode implements Canonicalizable { + + /** + * Creates a new CheckCast instruction. + * + * @param targetClass the class being cast to + * @param object the instruction producing the object + * @param graph + */ + public CheckCastNode(ValueNode targetClassInstruction, ValueNode object, Graph graph) { + super(targetClassInstruction, object, CiKind.Object, graph); + } + + /** + * Gets the declared type of the result of this instruction. + * + * @return the declared type of the result + */ + @Override + public RiType declaredType() { + return targetClass(); + } + + /** + * Gets the exact type of the result of this instruction. + * + * @return the exact type of the result + */ + @Override + public RiType exactType() { + return targetClass().isResolved() ? targetClass().exactType() : null; + } + + @Override + public void accept(ValueVisitor v) { + v.visitCheckCast(this); + } + + @Override + public Node canonical(NotifyReProcess reProcess) { + if (object().exactType() != null) { + return object(); + } + CiConstant constant = object().asConstant(); + if (constant != null) { + assert constant.kind == CiKind.Object; + if (constant.isNull()) { + return object(); + } else { + // this should never happen - non-null constants are always expected to provide an exactType + assert false; + } + } + return this; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/ExceptionObjectNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/ExceptionObjectNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2009, 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.nodes.java; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + +/** + * The {@code ExceptionObject} instruction represents the incoming exception object to an exception handler. + */ +public final class ExceptionObjectNode extends StateSplit { + + /** + * Constructs a new ExceptionObject instruction. + * @param graph + */ + public ExceptionObjectNode(Graph graph) { + super(CiKind.Object, graph); + } + + @Override + public void accept(ValueVisitor v) { + v.visitExceptionObject(this); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/InstanceOfNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/InstanceOfNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2009, 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.nodes.java; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + +/** + * The {@code InstanceOf} instruction represents an instanceof test. + */ +public final class InstanceOfNode extends TypeCheckNode implements Canonicalizable { + + /** + * Constructs a new InstanceOf instruction. + * + * @param targetClass the target class of the instanceof check + * @param object the instruction producing the object input to this instruction + * @param graph + */ + public InstanceOfNode(ConstantNode targetClassInstruction, ValueNode object, boolean nullIsTrue, Graph graph) { + super(targetClassInstruction, object, CiKind.Illegal, graph); + } + + @Override + public void accept(ValueVisitor v) { + } + + @Override + public Node canonical(NotifyReProcess reProcess) { + if (object().exactType() != null) { + return ConstantNode.forBoolean(object().exactType().isSubtypeOf(targetClass()), graph()); + } + CiConstant constant = object().asConstant(); + if (constant != null) { + assert constant.kind == CiKind.Object; + if (constant.isNull()) { + return ConstantNode.forBoolean(false, graph()); + } else { + // this should never happen - non-null constants are always expected to provide an exactType + assert false; + } + } + return this; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/IsTypeNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/IsTypeNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2009, 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.nodes.java; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; +import com.sun.cri.ri.*; + +/** + * The {@code TypeCheck} class represents an explicit type check instruction. + */ +public final class IsTypeNode extends BooleanNode implements Canonicalizable { + + @Input private ValueNode object; + + public ValueNode object() { + return object; + } + + public void setObject(ValueNode x) { + updateUsages(object, x); + object = x; + } + + private final RiType type; + + /** + * Constructs a new IsType instruction. + * + * @param object the instruction producing the object to check against the given type + * @param graph + */ + public IsTypeNode(ValueNode object, RiType type, Graph graph) { + super(CiKind.Object, graph); + assert type.isResolved(); + assert object == null || object.kind == CiKind.Object; + this.type = type; + setObject(object); + } + + public RiType type() { + return type; + } + + @Override + public void accept(ValueVisitor v) { + // Nothing to do. + } + + @Override + public RiType declaredType() { + // type check does not alter the type of the object + return object().declaredType(); + } + + @Override + public RiType exactType() { + return type; + } + + @Override + public Map getDebugProperties() { + Map properties = super.getDebugProperties(); + properties.put("type", type); + return properties; + } + + @Override + public Node canonical(NotifyReProcess reProcess) { + if (object().exactType() != null) { + return ConstantNode.forBoolean(object().exactType() == type(), graph()); + } + // constants return the correct exactType, so they are handled by the code above + return this; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/LoadFieldNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/LoadFieldNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2009, 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.nodes.java; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; +import com.sun.cri.ri.*; + +/** + * The {@code LoadField} instruction represents a read of a static or instance field. + */ +public final class LoadFieldNode extends AccessFieldNode implements Canonicalizable { + + /** + * Creates a new LoadField instance. + * + * @param object the receiver object + * @param field the compiler interface field + * @param isStatic indicates if the field is static + * @param stateAfter the state after the field access + * @param graph + * @param isLoaded indicates if the class is loaded + */ + public LoadFieldNode(ValueNode object, RiField field, Graph graph) { + super(field.kind().stackKind(), object, field, graph); + } + + /** + * Gets the declared type of the field being accessed. + * + * @return the declared type of the field being accessed. + */ + @Override + public RiType declaredType() { + return field().type(); + } + + /** + * Gets the exact type of the field being accessed. If the field type is a primitive array or an instance class and + * the class is loaded and final, then the exact type is the same as the declared type. Otherwise it is {@code null} + * + * @return the exact type of the field if known; {@code null} otherwise + */ + @Override + public RiType exactType() { + RiType declared = declaredType(); + return declared != null && declared.isResolved() ? declared.exactType() : null; + } + + @Override + public void accept(ValueVisitor v) { + v.visitLoadField(this); + } + + @Override + public boolean needsStateAfter() { + return false; + } + + /** + * Gets a constant value to which this load can be reduced. + * + * @return {@code null} if this load cannot be reduced to a constant + */ + private CiConstant constantValue() { + if (isStatic()) { + return field.constantValue(null); + } else if (object().isConstant()) { + return field.constantValue(object().asConstant()); + } + return null; + } + + @Override + public Node canonical(NotifyReProcess reProcess) { + CiConstant constant = null; + if (isStatic()) { + constant = field().constantValue(null); + } else if (object().isConstant()) { + constant = field().constantValue(object().asConstant()); + } + if (constant != null) { + return new ConstantNode(constant, graph()); + } + return this; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/LoadIndexedNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/LoadIndexedNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2009, 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.nodes.java; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; +import com.sun.cri.ri.*; + +/** + * The {@code LoadIndexed} instruction represents a read from an element of an array. + */ +public final class LoadIndexedNode extends AccessIndexedNode { + + /** + * Creates a new LoadIndexed instruction. + * @param array the instruction producing the array + * @param index the instruction producing the index + * @param length the instruction producing the length + * @param elementKind the element type + * @param graph + */ + public LoadIndexedNode(ValueNode array, ValueNode index, ValueNode length, CiKind elementKind, Graph graph) { + super(elementKind.stackKind(), array, index, length, elementKind, graph); + } + + /** + * Gets the declared type of this instruction's result. + * @return the declared type + */ + @Override + public RiType declaredType() { + RiType arrayType = array().declaredType(); + if (arrayType == null) { + return null; + } + return arrayType.componentType(); + } + + /** + * Gets the exact type of this instruction's result. + * @return the exact type + */ + @Override + public RiType exactType() { + RiType declared = declaredType(); + return declared != null && declared.isResolved() ? declared.exactType() : null; + } + + @Override + public void accept(ValueVisitor v) { + v.visitLoadIndexed(this); + } + + @Override + public boolean needsStateAfter() { + return false; + } + + @SuppressWarnings("unchecked") + @Override + public T lookup(Class clazz) { + if (clazz == LoweringOp.class) { + return (T) DELEGATE_TO_RUNTIME; + } + return super.lookup(clazz); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/MathIntrinsicNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/MathIntrinsicNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,62 @@ +/* + * 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.nodes.java; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.calc.*; +import com.oracle.max.graal.nodes.spi.*; + +public class MathIntrinsicNode extends FloatingNode { + + @Input private ValueNode x; + @Data private final Operation operation; + + public enum Operation { + ABS, SQRT, + } + + public ValueNode x() { + return x; + } + + private void setX(ValueNode x) { + updateUsages(this.x, x); + this.x = x; + } + + public Operation operation() { + return operation; + } + + public MathIntrinsicNode(ValueNode x, Operation op, Graph graph) { + super(x.kind, graph); + setX(x); + this.operation = op; + } + + @Override + public void accept(ValueVisitor v) { + v.visitMathIntrinsic(this); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/MonitorAddressNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/MonitorAddressNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2010, 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.nodes.java; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + +/** + * Instruction that is used to refer to the address of an on-stack monitor. + */ +public final class MonitorAddressNode extends ValueNode { + + private int monitorIndex; + + public MonitorAddressNode(int monitorIndex, Graph graph) { + super(CiKind.Word, graph); + this.monitorIndex = monitorIndex; + } + + @Override + public void accept(ValueVisitor v) { + v.visitMonitorAddress(this); + } + + public int monitorIndex() { + return monitorIndex; + } + + public void setMonitorIndex(int monitorIndex) { + this.monitorIndex = monitorIndex; + } + + @Override + public Map getDebugProperties() { + Map properties = super.getDebugProperties(); + properties.put("monitorIndex", monitorIndex); + return properties; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/MonitorEnterNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/MonitorEnterNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2009, 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.nodes.java; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; + +/** + * The {@code MonitorEnter} instruction represents the acquisition of a monitor. + */ +public final class MonitorEnterNode extends AccessMonitorNode { + + /** + * Creates a new MonitorEnter instruction. + * + * @param object the instruction producing the object + * @param lockAddress the address of the on-stack lock object or {@code null} if the runtime does not place locks on the stack + * @param lockNumber the number of the lock + * @param graph + */ + public MonitorEnterNode(ValueNode object, ValueNode lockAddress, int lockNumber, Graph graph) { + super(object, lockAddress, lockNumber, graph); + } + + @Override + public void accept(ValueVisitor v) { + v.visitMonitorEnter(this); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/MonitorExitNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/MonitorExitNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2009, 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.nodes.java; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; + +/** + * The {@code MonitorExit} instruction represents a monitor release. + */ +public final class MonitorExitNode extends AccessMonitorNode { + + /** + * Creates a new MonitorExit instruction. + * + * @param object the instruction produces the object value + * @param lockAddress the address of the on-stack lock object or {@code null} if the runtime does not place locks on the stack + * @param lockNumber the number of the lock + * @param graph + */ + public MonitorExitNode(ValueNode object, ValueNode lockAddress, int lockNumber, Graph graph) { + super(object, lockAddress, lockNumber, graph); + } + + @Override + public void accept(ValueVisitor v) { + v.visitMonitorExit(this); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/NewArrayNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/NewArrayNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2009, 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.nodes.java; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.oracle.max.graal.nodes.virtual.*; +import com.sun.cri.ci.*; + +/** + * The {@code NewArray} class is the base of all instructions that allocate arrays. + */ +public abstract class NewArrayNode extends FixedWithNextNode { + + @Input private ValueNode length; + + public static final int MaximumEscapeAnalysisArrayLength = 32; + + public ValueNode length() { + return length; + } + + public void setLength(ValueNode x) { + updateUsages(this.length, x); + this.length = x; + } + + /** + * Constructs a new NewArray instruction. + * @param length the instruction that produces the length for this allocation + * @param graph + */ + protected NewArrayNode(ValueNode length, Graph graph) { + super(CiKind.Object, graph); + setLength(length); + } + + /** + * The list of instructions which produce input for this instruction. + */ + public ValueNode dimension(int index) { + assert index == 0; + return length(); + } + + /** + * The rank of the array allocated by this instruction, i.e. how many array dimensions. + */ + public int dimensionCount() { + return 1; + } + + public abstract CiKind elementKind(); + + @Override + public Map getDebugProperties() { + Map properties = super.getDebugProperties(); + properties.put("exactType", exactType()); + return properties; + } + + @SuppressWarnings("unchecked") + @Override + public T lookup(Class clazz) { + if (clazz == EscapeOp.class) { + return (T) ESCAPE; + } + return super.lookup(clazz); + } + + private static final EscapeOp ESCAPE = new EscapeOp() { + + @Override + public boolean canAnalyze(Node node) { + NewArrayNode x = (NewArrayNode) node; + CiConstant length = x.dimension(0).asConstant(); + return length != null && length.asInt() >= 0 && length.asInt() < MaximumEscapeAnalysisArrayLength; + } + + @Override + public boolean escape(Node node, Node usage) { + if (usage instanceof LoadIndexedNode) { + LoadIndexedNode x = (LoadIndexedNode) usage; + assert x.array() == node; + CiConstant index = x.index().asConstant(); + CiConstant length = ((NewArrayNode) node).dimension(0).asConstant(); + if (index == null || length == null || index.asInt() < 0 || index.asInt() >= length.asInt()) { + return true; + } + return false; + } else if (usage instanceof StoreFieldNode) { + StoreFieldNode x = (StoreFieldNode) usage; + assert x.value() == node; + return true; + } else if (usage instanceof StoreIndexedNode) { + StoreIndexedNode x = (StoreIndexedNode) usage; + CiConstant index = x.index().asConstant(); + CiConstant length = ((NewArrayNode) node).dimension(0).asConstant(); + if (index == null || length == null || index.asInt() < 0 || index.asInt() >= length.asInt()) { + return true; + } + return x.value() == node && x.array() != node; + } else if (usage instanceof ArrayLengthNode) { + ArrayLengthNode x = (ArrayLengthNode) usage; + assert x.array() == node; + return false; + } else if (usage instanceof VirtualObjectFieldNode) { + return false; + } else { + return super.escape(node, usage); + } + } + + @Override + public EscapeField[] fields(Node node) { + NewArrayNode x = (NewArrayNode) node; + int length = x.dimension(0).asConstant().asInt(); + EscapeField[] fields = new EscapeField[length]; + for (int i = 0; i < length; i++) { + Integer representation = i; + fields[i] = new EscapeField("[" + i + "]", representation, ((NewArrayNode) node).elementKind()); + } + return fields; + } + + @Override + public void beforeUpdate(Node node, Node usage) { + if (usage instanceof ArrayLengthNode) { + ArrayLengthNode x = (ArrayLengthNode) usage; + x.replaceAndDelete(((NewArrayNode) node).dimension(0)); + } else { + super.beforeUpdate(node, usage); + } + } + + @Override + public int updateState(Node node, Node current, Map fieldIndex, ValueNode[] fieldState) { + if (current instanceof AccessIndexedNode) { + AccessIndexedNode x = (AccessIndexedNode) current; + if (x.array() == node) { + int index = ((AccessIndexedNode) current).index().asConstant().asInt(); + if (current instanceof LoadIndexedNode) { + x.replaceAtUsages(fieldState[index]); + assert x.usages().size() == 0; + x.replaceAndDelete(x.next()); + } else if (current instanceof StoreIndexedNode) { + fieldState[index] = ((StoreIndexedNode) x).value(); + assert x.usages().size() == 0; + x.replaceAndDelete(x.next()); + return index; + } + } + } + return -1; + } + }; +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/NewInstanceNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/NewInstanceNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2009, 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.nodes.java; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.oracle.max.graal.nodes.virtual.*; +import com.sun.cri.ci.*; +import com.sun.cri.ri.*; + +/** + * The {@code NewInstance} instruction represents the allocation of an instance class object. + */ +public final class NewInstanceNode extends FixedWithNextNode { + + final RiType instanceClass; + public final int cpi; + public final RiConstantPool constantPool; + + /** + * Constructs a NewInstance instruction. + * @param type the class being allocated + * @param cpi the constant pool index + * @param graph + */ + public NewInstanceNode(RiType type, int cpi, RiConstantPool constantPool, Graph graph) { + super(CiKind.Object, graph); + this.instanceClass = type; + this.cpi = cpi; + this.constantPool = constantPool; + } + + /** + * Gets the instance class being allocated by this instruction. + * @return the instance class allocated + */ + public RiType instanceClass() { + return instanceClass; + } + + /** + * Gets the exact type produced by this instruction. For allocations of instance classes, this is + * always the class allocated. + * @return the exact type produced by this instruction + */ + @Override + public RiType exactType() { + return instanceClass; + } + + @Override + public void accept(ValueVisitor v) { + v.visitNewInstance(this); + } + + @Override + public Map getDebugProperties() { + Map properties = super.getDebugProperties(); + properties.put("instanceClass", instanceClass); + properties.put("cpi", cpi); + return properties; + } + + @SuppressWarnings("unchecked") + @Override + public T lookup(Class clazz) { + if (clazz == EscapeOp.class) { + return (T) ESCAPE; + } + return super.lookup(clazz); + } + + private static final EscapeOp ESCAPE = new EscapeOp() { + + @Override + public boolean canAnalyze(Node node) { + return ((NewInstanceNode) node).instanceClass().isResolved(); + } + + @Override + public boolean escape(Node node, Node usage) { + if (usage instanceof LoadFieldNode) { + LoadFieldNode x = (LoadFieldNode) usage; + assert x.object() == node; + return x.field().isResolved() == false; + } else if (usage instanceof StoreFieldNode) { + StoreFieldNode x = (StoreFieldNode) usage; + return x.value() == node && x.object() != node; + } else if (usage instanceof StoreIndexedNode) { + StoreIndexedNode x = (StoreIndexedNode) usage; + assert x.value() == node; + return true; + } else if (usage instanceof VirtualObjectFieldNode) { + return false; + } else if (usage instanceof RegisterFinalizerNode) { + RegisterFinalizerNode x = (RegisterFinalizerNode) usage; + assert x.object() == node; + return false; + } else { + return super.escape(node, usage); + } + } + + @Override + public EscapeField[] fields(Node node) { + NewInstanceNode x = (NewInstanceNode) node; + RiField[] riFields = x.instanceClass().fields(); + EscapeField[] fields = new EscapeField[riFields.length]; + for (int i = 0; i < riFields.length; i++) { + RiField field = riFields[i]; + fields[i] = new EscapeField(field.name(), field, field.kind().stackKind()); + } + return fields; + } + + @Override + public void beforeUpdate(Node node, Node usage) { + if (usage instanceof RegisterFinalizerNode) { + RegisterFinalizerNode x = (RegisterFinalizerNode) usage; + x.replaceAndDelete(x.next()); + } else { + super.beforeUpdate(node, usage); + } + } + + @Override + public int updateState(Node node, Node current, Map fieldIndex, ValueNode[] fieldState) { + if (current instanceof AccessFieldNode) { + AccessFieldNode x = (AccessFieldNode) current; + if (x.object() == node) { + int field = fieldIndex.get(((AccessFieldNode) current).field()); + if (current instanceof LoadFieldNode) { + assert fieldState[field] != null : field + ", " + ((AccessFieldNode) current).field(); + x.replaceAtUsages(fieldState[field]); + assert x.usages().size() == 0; + x.replaceAndDelete(x.next()); + } else if (current instanceof StoreFieldNode) { + fieldState[field] = ((StoreFieldNode) x).value(); + assert x.usages().size() == 0; + x.replaceAndDelete(x.next()); + return field; + } + } + } + return -1; + } + }; +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/NewMultiArrayNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/NewMultiArrayNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2009, 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.nodes.java; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; +import com.sun.cri.ri.*; + +/** + * The {@code NewMultiArray} instruction represents an allocation of a multi-dimensional object + * array. + */ +public final class NewMultiArrayNode extends NewArrayNode { + + @Input private final NodeInputList dimensions; + + @Override + public ValueNode dimension(int index) { + return dimensions.get(index); + } + + public void setDimension(int index, ValueNode x) { + dimensions.set(index, x); + } + + /** + * The rank of the array allocated by this instruction, i.e. how many array dimensions. + */ + @Override + public int dimensionCount() { + return dimensions.size(); + } + + public final RiType elementType; + public final int cpi; + public final RiConstantPool constantPool; + + /** + * Constructs a new NewMultiArray instruction. + * @param elementType the element type of the array + * @param dimensions the instructions which produce the dimensions for this array + * @param cpi the constant pool index for resolution + * @param riConstantPool the constant pool for resolution + * @param graph + */ + public NewMultiArrayNode(RiType elementType, ValueNode[] dimensions, int cpi, RiConstantPool riConstantPool, Graph graph) { + super(null, graph); + this.constantPool = riConstantPool; + this.elementType = elementType; + this.cpi = cpi; + + this.dimensions = new NodeInputList(this, dimensions.length); + for (int i = 0; i < dimensions.length; i++) { + setDimension(i, dimensions[i]); + } + } + + @Override + public void accept(ValueVisitor v) { + v.visitNewMultiArray(this); + } + + /** + * Gets the element type of the array. + * @return the element type of the array + */ + public RiType elementType() { + return elementType; + } + + @Override + public CiKind elementKind() { + return elementType.kind(); + } + + @Override + public RiType exactType() { + return elementType.arrayOf(); + } + + @Override + public RiType declaredType() { + return exactType(); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/NewObjectArrayNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/NewObjectArrayNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2009, 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.nodes.java; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; +import com.sun.cri.ri.*; + +/** + * The {@code NewObjectArray} instruction represents an allocation of an object array. + */ +public final class NewObjectArrayNode extends NewArrayNode { + + final RiType elementClass; + + /** + * Constructs a new NewObjectArray instruction. + * @param elementClass the class of elements in this array + * @param length the instruction producing the length of the array + * @param graph + */ + public NewObjectArrayNode(RiType elementClass, ValueNode length, Graph graph) { + super(length, graph); + this.elementClass = elementClass; + } + + /** + * Gets the type of the elements of the array. + * @return the element type of the array + */ + public RiType elementType() { + return elementClass; + } + + @Override + public CiKind elementKind() { + return elementClass.kind(); + } + + @Override + public RiType exactType() { + return elementClass.arrayOf(); + } + + @Override + public RiType declaredType() { + return exactType(); + } + + @Override + public void accept(ValueVisitor v) { + v.visitNewObjectArray(this); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/NewTypeArrayNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/NewTypeArrayNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2009, 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.nodes.java; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; +import com.sun.cri.ri.*; + +/** + * The {@code NewTypeArray} class definition. + */ +public final class NewTypeArrayNode extends NewArrayNode { + + final RiType elementType; + + public NewTypeArrayNode(ValueNode length, RiType elementType, Graph graph) { + super(length, graph); + this.elementType = elementType; + } + + @Override + public CiKind elementKind() { + return elementType.kind(); + } + + @Override + public RiType declaredType() { + return elementType.arrayOf(); + } + + @Override + public RiType exactType() { + return elementType.arrayOf(); + } + + @Override + public void accept(ValueVisitor v) { + v.visitNewTypeArray(this); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/RegisterFinalizerNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/RegisterFinalizerNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2011, 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.nodes.java; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; +import com.sun.cri.ri.*; + +/** + * This instruction is used to perform the finalizer registration at the end of the java.lang.Object constructor. + */ +public final class RegisterFinalizerNode extends StateSplit implements Canonicalizable { + + @Input private ValueNode object; + + public ValueNode object() { + return object; + } + + public void setObject(ValueNode x) { + updateUsages(object, x); + object = x; + } + + public RegisterFinalizerNode(ValueNode object, Graph graph) { + super(CiKind.Void, graph); + setObject(object); + } + + @Override + public void accept(ValueVisitor v) { + v.visitRegisterFinalizer(this); + } + + @Override + public Node canonical(NotifyReProcess reProcess) { + RiType declaredType = object.declaredType(); + RiType exactType = object.exactType(); + if (exactType == null && declaredType != null) { + exactType = declaredType.exactType(); + } + + boolean needsCheck = true; + if (exactType != null) { + // we have an exact type + needsCheck = exactType.hasFinalizer(); + } else { + // if either the declared type of receiver or the holder can be assumed to have no finalizers + if (declaredType != null && !declaredType.hasFinalizableSubclass()) { + if (((CompilerGraph) graph()).assumptions().recordNoFinalizableSubclassAssumption(declaredType)) { + needsCheck = false; + } + } + } + + if (!needsCheck) { + return next(); + } + + return this; + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/StoreFieldNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/StoreFieldNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2009, 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.nodes.java; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; +import com.sun.cri.ri.*; + +/** + * The {@code StoreField} instruction represents a write to a static or instance field. + */ +public final class StoreFieldNode extends AccessFieldNode { + + @Input private ValueNode value; + + public ValueNode value() { + return value; + } + + public void setValue(ValueNode x) { + updateUsages(value, x); + value = x; + } + + /** + * Creates a new LoadField instance. + * @param object the receiver object + * @param field the compiler interface field + * @param value the instruction representing the value to store to the field + * @param stateAfter the state after the field access + * @param graph + */ + public StoreFieldNode(ValueNode object, RiField field, ValueNode value, Graph graph) { + super(CiKind.Void, object, field, graph); + setValue(value); + } + + @Override + public void accept(ValueVisitor v) { + v.visitStoreField(this); + } + + @SuppressWarnings("unchecked") + @Override + public T lookup(java.lang.Class clazz) { + if (clazz == LoweringOp.class) { + return (T) DELEGATE_TO_RUNTIME; + } + return super.lookup(clazz); + }; +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/StoreIndexedNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/StoreIndexedNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2009, 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.nodes.java; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + +/** + * The {@code StoreIndexed} instruction represents a write to an array element. + */ +public final class StoreIndexedNode extends AccessIndexedNode { + + @Input private ValueNode value; + + public ValueNode value() { + return value; + } + + public void setValue(ValueNode x) { + updateUsages(value, x); + value = x; + } + + /** + * Creates a new StoreIndexed instruction. + * @param array the instruction producing the array + * @param index the instruction producing the index + * @param length the instruction producing the length + * @param elementKind the element type + * @param value the value to store into the array + * @param stateAfter the state after executing this instruction + * @param graph + */ + public StoreIndexedNode(ValueNode array, ValueNode index, ValueNode length, CiKind elementKind, ValueNode value, Graph graph) { + super(CiKind.Void, array, index, length, elementKind, graph); + setValue(value); + } + + @Override + public void accept(ValueVisitor v) { + v.visitStoreIndexed(this); + } + + @SuppressWarnings("unchecked") + @Override + public T lookup(Class clazz) { + if (clazz == LoweringOp.class) { + return (T) DELEGATE_TO_RUNTIME; + } + return super.lookup(clazz); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/TypeCheckNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/TypeCheckNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2009, 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.nodes.java; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.sun.cri.ci.*; +import com.sun.cri.ri.*; + +/** + * The {@code TypeCheck} instruction is the base class of casts and instanceof tests. + */ +public abstract class TypeCheckNode extends BooleanNode { + @Input private ValueNode object; + @Input private ValueNode targetClassInstruction; + + public ValueNode object() { + return object; + } + + public void setObject(ValueNode x) { + updateUsages(object, x); + object = x; + } + + public ValueNode targetClassInstruction() { + return targetClassInstruction; + } + + public void setTargetClassInstruction(ValueNode x) { + updateUsages(targetClassInstruction, x); + targetClassInstruction = x; + } + + /** + * Gets the target class, i.e. the class being cast to, or the class being tested against. + * @return the target class + */ + public RiType targetClass() { + return targetClassInstruction() instanceof ConstantNode ? (RiType) targetClassInstruction().asConstant().asObject() : null; + } + + /** + * Creates a new TypeCheck instruction. + * @param targetClass the class which is being casted to or checked against + * @param object the instruction which produces the object + * @param kind the result type of this instruction + * @param graph + */ + public TypeCheckNode(ValueNode targetClassInstruction, ValueNode object, CiKind kind, Graph graph) { + super(kind, graph); + setObject(object); + setTargetClassInstruction(targetClassInstruction); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/loop/BasicInductionVariableNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/loop/BasicInductionVariableNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,125 @@ +/* + * 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.nodes.loop; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.PhiNode.PhiType; +import com.oracle.max.graal.nodes.calc.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + + +/** + * LinearInductionVariable that is computed in the loops thanks to Phi(init, this + stride). + * This will keep at least one register busy in the whole loop body + */ +public class BasicInductionVariableNode extends LinearInductionVariableNode implements Canonicalizable{ + public static final BIVLoweringOp LOWERING = new BIVLoweringOp(); + @Input private LoopCounterNode loopCounter; + + public BasicInductionVariableNode(CiKind kind, ValueNode init, ValueNode stride, LoopCounterNode counter, Graph graph) { + super(kind, init, stride, graph); + setLoopCounter(counter); + } + + public LoopCounterNode loopCounter() { + return loopCounter; + } + + public void setLoopCounter(LoopCounterNode loopCounter) { + updateUsages(this.loopCounter, loopCounter); + this.loopCounter = loopCounter; + } + + public ValueNode init() { + return a(); + } + + public void setInit(ValueNode init) { + setA(init); + } + + public ValueNode stride() { + return b(); + } + + public void setStride(ValueNode stride) { + setB(stride); + } + + @Override + public LoopBeginNode loopBegin() { + return loopCounter().loopBegin(); + } + + @Override + public void peelOneIteration() { + this.setInit(IntegerArithmeticNode.add(init(), stride())); + } + + /** + * Will lessen the register pressure but augment the code complexity with a multiplication. + * @return the new DerivedInductionVariable + */ + public DerivedInductionVariableNode toDerivedInductionVariable() { + DerivedInductionVariableNode newDIV = new DerivedInductionVariableNode(kind, init(), stride(), loopCounter(), graph()); + this.replaceAndDelete(newDIV); + return newDIV; + } + + @Override + public Node canonical(NotifyReProcess reProcess) { + if (this.init().isConstant() && this.init().asConstant().asLong() == 0 + && this.stride().isConstant() && this.stride().asConstant().asLong() == 1) { + return this.loopCounter(); + } + return this; + } + + @SuppressWarnings("unchecked") + @Override + public T lookup(Class clazz) { + if (clazz == LoweringOp.class) { + return (T) LOWERING; + } + return super.lookup(clazz); + } + + public static class BIVLoweringOp implements LoweringOp { + @Override + public void lower(Node n, CiLoweringTool tool) { + BasicInductionVariableNode biv = (BasicInductionVariableNode) n; + PhiNode phi = this.ivToPhi(biv.loopBegin(), biv.init(), biv.stride(), biv.kind); + biv.replaceAtNonIVUsages(phi); + } + + public PhiNode ivToPhi(LoopBeginNode loopBegin, ValueNode init, ValueNode stride, CiKind kind) { + PhiNode phi = new PhiNode(kind, loopBegin, PhiType.Value, loopBegin.graph()); + IntegerArithmeticNode after = IntegerArithmeticNode.add(phi, stride); + phi.addInput(init); + phi.addInput(after); + return phi; + } + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/loop/DerivedInductionVariableNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/loop/DerivedInductionVariableNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,125 @@ +/* + * 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.nodes.loop; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.calc.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + + +/** + * LinearInductionVariable that is computed in the loops with offset + scale * base. + * This is computed in the loop only when necessary, puts less pressure on registers. + */ +public class DerivedInductionVariableNode extends LinearInductionVariableNode { + @Input private InductionVariableNode base; + + public DerivedInductionVariableNode(CiKind kind, ValueNode offset, ValueNode scale, InductionVariableNode base, Graph graph) { + super(kind, offset, scale, graph); + setBase(base); + } + + public InductionVariableNode base() { + return base; + } + + public void setBase(InductionVariableNode base) { + updateUsages(this.base, base); + this.base = base; + } + + public ValueNode offset() { + return a(); + } + + public void setOffset(ValueNode offset) { + setA(offset); + } + + public ValueNode scale() { + return b(); + } + + public void setScale(ValueNode scale) { + setB(scale); + } + + @Override + public LoopBeginNode loopBegin() { + return base().loopBegin(); + } + + @Override + public void peelOneIteration() { + // nop + } + + /** + * This will apply strength reduction to this induction variable but will augment register pressure in the loop. + * @return the new BasicInductionVariable + */ + public BasicInductionVariableNode toBasicInductionVariable() { + InductionVariableNode base = base(); + if (base instanceof DerivedInductionVariableNode) { + base = ((DerivedInductionVariableNode) base).toBasicInductionVariable(); + } + ValueNode init; + ValueNode stride; + LoopCounterNode counter; + if (base instanceof BasicInductionVariableNode) { + BasicInductionVariableNode basic = (BasicInductionVariableNode) base; + // let the canonicalizer do its job with this + init = IntegerArithmeticNode.add(offset(), IntegerArithmeticNode.mul(scale(), basic.init())); + stride = IntegerArithmeticNode.mul(scale(), basic.stride()); + counter = basic.loopCounter(); + } else { + assert base instanceof LoopCounterNode; + init = offset(); + stride = scale(); + counter = (LoopCounterNode) base; + } + BasicInductionVariableNode newBIV = new BasicInductionVariableNode(kind, init, stride, counter, graph()); + this.replaceAndDelete(newBIV); + return newBIV; + } + + @SuppressWarnings("unchecked") + @Override + public T lookup(Class clazz) { + if (clazz == LoweringOp.class) { + return (T) LOWERING; + } + return super.lookup(clazz); + } + + private static final LoweringOp LOWERING = new LoweringOp() { + @Override + public void lower(Node n, CiLoweringTool tool) { + DerivedInductionVariableNode div = (DerivedInductionVariableNode) n; + IntegerArithmeticNode computed = IntegerArithmeticNode.add(div.offset(), IntegerArithmeticNode.mul(div.scale(), div.base())); + div.replaceAtNonIVUsages(computed); + } + }; +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/loop/InductionVariableNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/loop/InductionVariableNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,54 @@ +/* + * 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.nodes.loop; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.calc.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + +public abstract class InductionVariableNode extends FloatingNode { + + public InductionVariableNode(CiKind kind, Graph graph) { + super(kind, graph); + assert kind.isInt() || kind.isLong(); + } + + public abstract LoopBeginNode loopBegin(); + + public abstract void peelOneIteration(); + + public void replaceAtNonIVUsages(Node other) { + for (Node usage : this.usages().snapshot()) { + if (!(usage instanceof InductionVariableNode)) { + usage.replaceFirstInput(this, other); + } + } + } + + @Override + public void accept(ValueVisitor v) { + // nop + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/loop/LinearInductionVariableNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/loop/LinearInductionVariableNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,64 @@ +/* + * 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.nodes.loop; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.sun.cri.ci.*; + +/** + * InductionVariable of the form a+b*x. + */ +public abstract class LinearInductionVariableNode extends InductionVariableNode { + @Input private ValueNode a; + @Input private ValueNode b; + + public LinearInductionVariableNode(CiKind kind, ValueNode a, ValueNode b, Graph graph) { + super(kind, graph); + setA(a); + setB(b); + } + + protected ValueNode a() { + return a; + } + + protected ValueNode b() { + return b; + } + + protected void setA(ValueNode a) { + updateUsages(this.a, a); + this.a = a; + } + + + protected void setB(ValueNode b) { + updateUsages(this.b, b); + this.b = b; + } + + public boolean isLinearInductionVariableInput(Node n) { + return n == a() || n == b(); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/loop/LoopCounterNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/loop/LoopCounterNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,89 @@ +/* + * 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.nodes.loop; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + +/** + * Counts loop iterations from 0 to Niter. + * If used directly (and not just by BasicInductionVariables) computed with Phi(0, this + 1) + */ +public final class LoopCounterNode extends InductionVariableNode { + @Input private LoopBeginNode loopBegin; + + @Override + public LoopBeginNode loopBegin() { + return loopBegin; + } + + public void setLoopBegin(LoopBeginNode x) { + updateUsages(loopBegin, x); + loopBegin = x; + } + + public LoopCounterNode(CiKind kind, LoopBeginNode loop, Graph graph) { + super(kind, graph); + setLoopBegin(loop); + } + + @Override + public void peelOneIteration() { + BasicInductionVariableNode biv = null; + for (Node usage : usages()) { + if (!(usage instanceof InductionVariableNode && ((InductionVariableNode) usage).loopBegin() == this.loopBegin())) { + if (biv == null) { + biv = createBasicInductionVariable(); + biv.peelOneIteration(); + } + usage.inputs().replace(this, biv); + } + } + } + + @SuppressWarnings("unchecked") + @Override + public T lookup(Class clazz) { + if (clazz == LoweringOp.class) { + return (T) LOWERING; + } + return super.lookup(clazz); + } + + private BasicInductionVariableNode createBasicInductionVariable() { + Graph graph = graph(); + return new BasicInductionVariableNode(kind, ConstantNode.forInt(0, graph), ConstantNode.forInt(1, graph), this, graph); + } + + private static final LoweringOp LOWERING = new LoweringOp() { + @Override + public void lower(Node n, CiLoweringTool tool) { + LoopCounterNode loopCounter = (LoopCounterNode) n; + Graph graph = n.graph(); + PhiNode phi = BasicInductionVariableNode.LOWERING.ivToPhi(loopCounter.loopBegin(), ConstantNode.forInt(0, graph), ConstantNode.forInt(1, graph), loopCounter.kind); + loopCounter.replaceAtNonIVUsages(phi); + } + }; +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/spi/Canonicalizable.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/spi/Canonicalizable.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,30 @@ +/* + * 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.nodes.spi; + +import com.oracle.max.graal.graph.*; + + +public interface Canonicalizable { + Node canonical(NotifyReProcess reProcess); +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/spi/EscapeField.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/spi/EscapeField.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,55 @@ +/* + * 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.nodes.spi; + +import com.sun.cri.ci.*; + +public class EscapeField { + + private String name; + private Object representation; + private CiKind kind; + + public EscapeField(String name, Object representation, CiKind kind) { + this.name = name; + this.representation = representation; + this.kind = kind; + } + + public String name() { + return name; + } + + public Object representation() { + return representation; + } + + public CiKind kind() { + return kind; + } + + @Override + public String toString() { + return name(); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/spi/EscapeOp.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/spi/EscapeOp.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,79 @@ +/* + * 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.nodes.spi; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.calc.*; +import com.oracle.max.graal.nodes.java.*; + + +public abstract class EscapeOp implements Op { + + public abstract boolean canAnalyze(Node node); + + public boolean escape(Node node, Node usage) { + if (usage instanceof IsNonNullNode) { + IsNonNullNode x = (IsNonNullNode) usage; + assert x.object() == node; + return false; + } else if (usage instanceof IsTypeNode) { + IsTypeNode x = (IsTypeNode) usage; + assert x.object() == node; + return false; + } else if (usage instanceof FrameState) { + FrameState x = (FrameState) usage; + assert x.inputContains(node); + return true; + } else if (usage instanceof AccessMonitorNode) { + AccessMonitorNode x = (AccessMonitorNode) usage; + assert x.object() == node; + return false; + } else { + return true; + } + } + + public abstract EscapeField[] fields(Node node); + + public void beforeUpdate(Node node, Node usage) { + if (usage instanceof IsNonNullNode) { + IsNonNullNode x = (IsNonNullNode) usage; + // TODO (ls) not sure about this... + x.replaceAndDelete(ConstantNode.forBoolean(true, node.graph())); + } else if (usage instanceof IsTypeNode) { + IsTypeNode x = (IsTypeNode) usage; + assert x.type() == ((ValueNode) node).exactType(); + // TODO (ls) not sure about this... + x.replaceAndDelete(ConstantNode.forBoolean(true, node.graph())); + } else if (usage instanceof AccessMonitorNode) { + AccessMonitorNode x = (AccessMonitorNode) usage; + x.replaceAndDelete(x.next()); + } + } + + public abstract int updateState(Node node, Node current, Map fieldIndex, ValueNode[] fieldState); + +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/spi/ExceptionExit.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/spi/ExceptionExit.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,30 @@ +/* + * 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.nodes.spi; + +import com.oracle.max.graal.nodes.*; + + +public interface ExceptionExit { + FixedNode exceptionEdge(); +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/spi/FrameStateAccess.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/spi/FrameStateAccess.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,55 @@ +/* + * 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.nodes.spi; + +import com.oracle.max.graal.nodes.*; + +public interface FrameStateAccess { + + FrameState duplicate(int newBci); + + int localsSize(); + + int stackSize(); + + int locksSize(); + + boolean rethrowException(); + + ValueNode valueAt(int i); + + ValueNode localAt(int i); + + ValueNode lockAt(int i); + + ValueNode stackAt(int i); + + void setValueAt(int j, ValueNode v); + + void setRethrowException(boolean b); + + ValueNode outerFrameState(); + + FrameState duplicateWithException(int bci, ValueNode exceptionObject); + +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/spi/LIRGeneratorOp.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/spi/LIRGeneratorOp.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,29 @@ +/* + * 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.nodes.spi; + +import com.oracle.max.graal.graph.*; + +public interface LIRGeneratorOp extends Op { + void generate(Node n, LIRGeneratorTool generator); +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/spi/LIRGeneratorTool.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/spi/LIRGeneratorTool.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,42 @@ +/* + * 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.nodes.spi; + +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.calc.*; +import com.sun.cri.ci.*; + +public abstract class LIRGeneratorTool extends ValueVisitor { + public abstract CiValue load(ValueNode value); + public abstract CiVariable createResultVariable(ValueNode conv); + public abstract CiValue forceToSpill(CiValue value, CiKind kind, boolean b); + public abstract void emitMove(CiValue tmp, CiValue reg); + public abstract void integerAdd(ValueNode result, ValueNode x, ValueNode y); + public abstract void deoptimizeOn(Condition of); + public abstract CiVariable newVariable(CiKind kind); + public abstract CiTarget target(); + public abstract void emitLea(CiAddress address, CiVariable dest); + public abstract CiValue makeOperand(ValueNode object); + public abstract void emitUnsignedShiftRight(CiValue value, CiValue count, CiValue dst, CiValue tmp); + public abstract void emitAdd(CiValue a, CiValue b, CiValue dest); +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/spi/LoweringOp.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/spi/LoweringOp.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,31 @@ +/* + * 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.nodes.spi; + +import com.oracle.max.graal.graph.*; +import com.sun.cri.ci.*; + + +public interface LoweringOp extends Op { + void lower(Node n, CiLoweringTool tool); +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/spi/NotifyReProcess.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/spi/NotifyReProcess.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,30 @@ +/* + * 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.nodes.spi; + +import com.oracle.max.graal.graph.*; + + +public interface NotifyReProcess { + void reProccess(Node n); +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/spi/ValueVisitor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/spi/ValueVisitor.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2009, 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.nodes.spi; + +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.calc.*; +import com.oracle.max.graal.nodes.extended.*; +import com.oracle.max.graal.nodes.java.*; + +/** + * The {@link ValueVisitor} implements one half of the visitor + * pattern for {@linkplain ValueNode IR values}, allowing clients to implement functionality + * depending on the type of an value without doing type tests. + */ +public abstract class ValueVisitor { + // Checkstyle: stop + public abstract void visitArithmetic(ArithmeticNode i); + public abstract void visitArrayLength(ArrayLengthNode i); + public abstract void visitMerge(MergeNode i); + public abstract void visitCheckCast(CheckCastNode i); + public abstract void visitNormalizeCompare(NormalizeCompareNode i); + public abstract void visitConstant(ConstantNode i); + public abstract void visitConvert(ConvertNode i); + public abstract void visitConditional(ConditionalNode i); + public abstract void visitExceptionObject(ExceptionObjectNode i); + public abstract void visitEndNode(EndNode i); + public abstract void visitFrameState(FrameState i); + public abstract void visitAnchor(AnchorNode i); + public abstract void visitIf(IfNode i); + public abstract void visitInvoke(InvokeNode i); + public abstract void visitLoadField(LoadFieldNode i); + public abstract void visitLoadIndexed(LoadIndexedNode i); + public abstract void visitLocal(LocalNode i); + public abstract void visitLogic(LogicNode i); + public abstract void visitLookupSwitch(LookupSwitchNode i); + public abstract void visitMemoryRead(ReadNode i); + public abstract void visitMemoryWrite(WriteNode i); + public abstract void visitMonitorAddress(MonitorAddressNode monitorAddress); + public abstract void visitMonitorEnter(MonitorEnterNode i); + public abstract void visitMonitorExit(MonitorExitNode i); + public abstract void visitNegate(NegateNode i); + public abstract void visitNewInstance(NewInstanceNode i); + public abstract void visitNewMultiArray(NewMultiArrayNode i); + public abstract void visitNewObjectArray(NewObjectArrayNode i); + public abstract void visitNewTypeArray(NewTypeArrayNode i); + public abstract void visitFixedGuard(FixedGuardNode fixedGuard); + public abstract void visitPhi(PhiNode i); + public abstract void visitRegisterFinalizer(RegisterFinalizerNode i); + public abstract void visitReturn(ReturnNode i); + public abstract void visitShift(ShiftNode i); + public abstract void visitStoreField(StoreFieldNode i); + public abstract void visitStoreIndexed(StoreIndexedNode i); + public abstract void visitTableSwitch(TableSwitchNode i); + public abstract void visitDeoptimize(DeoptimizeNode deoptimize); + public abstract void visitUnwind(UnwindNode unwind); + public abstract void visitLoopBegin(LoopBeginNode loopBegin); + public abstract void visitLoopEnd(LoopEndNode loopEnd); + public abstract void visitValueAnchor(ValueAnchorNode valueAnchor); + public abstract void visitGuardNode(GuardNode guardNode); + public abstract void visitMathIntrinsic(MathIntrinsicNode node); +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/virtual/VirtualObjectFieldNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/virtual/VirtualObjectFieldNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,102 @@ +/* + * 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.nodes.virtual; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.*; +import com.oracle.max.graal.nodes.calc.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; + + +public class VirtualObjectFieldNode extends FloatingNode { + + @Input private VirtualObjectNode object; + @Input private FloatingNode lastState; + @Input private ValueNode input; + + public VirtualObjectNode object() { + return object; + } + + public void setObject(VirtualObjectNode x) { + updateUsages(object, x); + object = x; + } + + public FloatingNode lastState() { + return lastState; + } + + public void setLastState(FloatingNode x) { + updateUsages(lastState, x); + lastState = x; + } + + public ValueNode input() { + return input; + } + + public void setInput(ValueNode x) { + updateUsages(input, x); + input = x; + } + + private int index; + + /** + * Constructs a new ArrayLength instruction. + * @param array the instruction producing the array + * @param newFrameState the state after executing this instruction + */ + public VirtualObjectFieldNode(VirtualObjectNode object, FloatingNode lastState, ValueNode input, int index, Graph graph) { + super(CiKind.Int, graph); + this.index = index; + setObject(object); + setLastState(lastState); + setInput(input); + } + + public int index() { + return index; + } + + @Override + public void accept(ValueVisitor v) { + // nothing to do... + } + + @Override + public Map getDebugProperties() { + Map properties = super.getDebugProperties(); + properties.put("index", index); + return properties; + } + + @Override + public String shortName() { + return "VirtualObjectField " + object().fields()[index].name(); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/virtual/VirtualObjectNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/virtual/VirtualObjectNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -0,0 +1,71 @@ +/* + * 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.nodes.virtual; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.nodes.calc.*; +import com.oracle.max.graal.nodes.spi.*; +import com.sun.cri.ci.*; +import com.sun.cri.ri.*; + + +public class VirtualObjectNode extends FloatingNode { + + + + private EscapeField[] fields; + private RiType type; + + public VirtualObjectNode(RiType type, EscapeField[] fields, Graph graph) { + super(CiKind.Int, graph); + this.type = type; + this.fields = fields; + } + + public RiType type() { + return type; + } + + public EscapeField[] fields() { + return fields; + } + + @Override + public void accept(ValueVisitor v) { + // nothing to do... + } + + @Override + public Map getDebugProperties() { + Map properties = super.getDebugProperties(); + properties.put("type", type); + return properties; + } + + @Override + public String shortName() { + return "VirtualObject " + type.name(); + } +} diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.runtime/.classpath --- a/graal/com.oracle.max.graal.runtime/.classpath Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.runtime/.classpath Wed Aug 10 01:12:36 2011 +0200 @@ -8,5 +8,6 @@ + diff -r da773e1b6d9f -r dc4268828826 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 Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/HotSpotRuntime.java Wed Aug 10 01:12:36 2011 +0200 @@ -27,11 +27,10 @@ import java.util.*; import com.oracle.max.graal.compiler.*; -import com.oracle.max.graal.compiler.graph.*; import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; import com.oracle.max.graal.nodes.calc.*; -import com.oracle.max.graal.nodes.calc.ConditionalNode.*; +import com.oracle.max.graal.nodes.calc.ConditionalNode.ConditionalStructure; import com.oracle.max.graal.nodes.extended.*; import com.oracle.max.graal.nodes.java.*; import com.oracle.max.graal.runtime.nodes.*; diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/nodes/ArrayWriteBarrier.java --- a/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/nodes/ArrayWriteBarrier.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/nodes/ArrayWriteBarrier.java Wed Aug 10 01:12:36 2011 +0200 @@ -23,7 +23,7 @@ package com.oracle.max.graal.runtime.nodes; import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; import com.oracle.max.graal.nodes.extended.*; import com.oracle.max.graal.nodes.spi.*; import com.sun.cri.ci.*; diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/nodes/FPConversionNode.java --- a/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/nodes/FPConversionNode.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/nodes/FPConversionNode.java Wed Aug 10 01:12:36 2011 +0200 @@ -23,7 +23,7 @@ package com.oracle.max.graal.runtime.nodes; import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; import com.oracle.max.graal.nodes.calc.*; import com.oracle.max.graal.nodes.spi.*; import com.sun.cri.ci.*; diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/nodes/FieldWriteBarrier.java --- a/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/nodes/FieldWriteBarrier.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/nodes/FieldWriteBarrier.java Wed Aug 10 01:12:36 2011 +0200 @@ -23,7 +23,7 @@ package com.oracle.max.graal.runtime.nodes; import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; import com.oracle.max.graal.nodes.spi.*; import com.sun.cri.ci.*; diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/nodes/UnsafeLoad.java --- a/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/nodes/UnsafeLoad.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/nodes/UnsafeLoad.java Wed Aug 10 01:12:36 2011 +0200 @@ -23,7 +23,7 @@ package com.oracle.max.graal.runtime.nodes; import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; import com.oracle.max.graal.nodes.spi.*; import com.sun.cri.ci.*; diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/nodes/UnsafeStore.java --- a/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/nodes/UnsafeStore.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/nodes/UnsafeStore.java Wed Aug 10 01:12:36 2011 +0200 @@ -23,7 +23,7 @@ package com.oracle.max.graal.runtime.nodes; import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; import com.oracle.max.graal.nodes.spi.*; import com.sun.cri.ci.*; diff -r da773e1b6d9f -r dc4268828826 graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/nodes/WriteBarrier.java --- a/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/nodes/WriteBarrier.java Wed Aug 10 00:47:53 2011 +0200 +++ b/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/nodes/WriteBarrier.java Wed Aug 10 01:12:36 2011 +0200 @@ -23,7 +23,7 @@ package com.oracle.max.graal.runtime.nodes; import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.base.*; +import com.oracle.max.graal.nodes.*; import com.oracle.max.graal.nodes.spi.*; import com.oracle.max.graal.runtime.*; import com.sun.cri.ci.*;