# HG changeset patch # User Gilles Duboscq # Date 1309272348 -7200 # Node ID 25b5ec0568e61ac73c35878971e05b7c0d7e7bce # Parent d5218b2465548cad75e7d06f2389aa02c25901e4# Parent 46fe56f202a4db5b9dc2a7c2096d66259c4987e9 Merge diff -r d5218b246554 -r 25b5ec0568e6 .hgignore --- a/.hgignore Tue Jun 28 16:13:32 2011 +0200 +++ b/.hgignore Tue Jun 28 16:45:48 2011 +0200 @@ -17,6 +17,10 @@ \.orig$ output\.txt$ output\.cfg$ +^Test.java$ +^diff1.txt$ +^diff2.txt$ +^test.xml$ java\.hprof\.txt$ /nbproject/private/ ^graal/hotspot/java$ diff -r d5218b246554 -r 25b5ec0568e6 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 Tue Jun 28 16:13:32 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java Tue Jun 28 16:45:48 2011 +0200 @@ -102,6 +102,7 @@ public static boolean TraceInlining = ____; public static boolean TraceDeadCodeElimination = ____; public static boolean TraceMemoryMaps = ____; + public static boolean TraceReadElimination = ____; public static int TraceBytecodeParserLevel = 0; public static boolean QuietBailout = ____; diff -r d5218b246554 -r 25b5ec0568e6 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 Tue Jun 28 16:13:32 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/IR.java Tue Jun 28 16:45:48 2011 +0200 @@ -109,6 +109,7 @@ if (GraalOptions.Lower) { new LoweringPhase(compilation.runtime).apply(graph); new MemoryPhase().apply(graph); + new ReadEliminationPhase().apply(graph); } IdentifyBlocksPhase schedule = new IdentifyBlocksPhase(true); diff -r d5218b246554 -r 25b5ec0568e6 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/AbstractMemoryCheckpointNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/AbstractMemoryCheckpointNode.java Tue Jun 28 16:45:48 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.compiler.ir; + +import java.util.*; + +import com.oracle.max.graal.graph.*; +import com.sun.cri.ci.*; + + +public abstract class AbstractMemoryCheckpointNode extends StateSplit { + + private static final int SUCCESSOR_COUNT = 0; + private static final int INPUT_COUNT = 0; + + public AbstractMemoryCheckpointNode(Graph graph) { + this(CiKind.Illegal, 0, 0, graph); + } + + public AbstractMemoryCheckpointNode(CiKind result, int inputCount, int successorCount, Graph graph) { + super(result, inputCount + INPUT_COUNT, successorCount + SUCCESSOR_COUNT, graph); + } + + @Override + public Map getDebugProperties() { + Map debugProperties = super.getDebugProperties(); + debugProperties.put("memoryCheckpoint", "true"); + return debugProperties; + } + + public List mergedNodes() { + return inputs().variablePart(); + } +} diff -r d5218b246554 -r 25b5ec0568e6 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/AbstractMemoryMergeNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/AbstractMemoryMergeNode.java Tue Jun 28 16:13:32 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.compiler.ir; - -import java.util.*; - -import com.oracle.max.graal.graph.*; -import com.sun.cri.ci.*; - - -public abstract class AbstractMemoryMergeNode extends StateSplit { - - private static final int SUCCESSOR_COUNT = 0; - private static final int INPUT_COUNT = 0; - - public AbstractMemoryMergeNode(Graph graph) { - this(CiKind.Illegal, 0, 0, graph); - } - - public AbstractMemoryMergeNode(CiKind result, int inputCount, int successorCount, Graph graph) { - super(result, inputCount + INPUT_COUNT, successorCount + SUCCESSOR_COUNT, graph); - } - - public List mergedNodes() { - return inputs().variablePart(); - } -} diff -r d5218b246554 -r 25b5ec0568e6 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/AccessMonitor.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/AccessMonitor.java Tue Jun 28 16:13:32 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/AccessMonitor.java Tue Jun 28 16:45:48 2011 +0200 @@ -28,7 +28,7 @@ /** * The {@code AccessMonitor} instruction is the base class of both monitor acquisition and release. */ -public abstract class AccessMonitor extends AbstractMemoryMergeNode { +public abstract class AccessMonitor extends AbstractMemoryCheckpointNode { private static final int INPUT_COUNT = 2; private static final int INPUT_OBJECT = 0; diff -r d5218b246554 -r 25b5ec0568e6 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/AccessNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/AccessNode.java Tue Jun 28 16:13:32 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/AccessNode.java Tue Jun 28 16:45:48 2011 +0200 @@ -27,10 +27,11 @@ import com.sun.cri.ci.*; -public abstract class AccessNode extends StateSplit { - private static final int INPUT_COUNT = 2; +public abstract class AccessNode extends AbstractMemoryCheckpointNode { + private static final int INPUT_COUNT = 3; private static final int INPUT_NODE = 0; - private static final int INPUT_GUARD = 1; + private static final int INPUT_LOCATION = 1; + private static final int INPUT_GUARD = 2; private static final int SUCCESSOR_COUNT = 0; @@ -58,12 +59,16 @@ } public LocationNode location() { - return location; + return (LocationNode) inputs().get(super.inputCount() + INPUT_LOCATION); + } + + public void setLocation(LocationNode n) { + inputs().set(super.inputCount() + INPUT_LOCATION, n); } public AccessNode(CiKind kind, Value object, LocationNode location, int inputCount, int successorCount, Graph graph) { super(kind, INPUT_COUNT + inputCount, SUCCESSOR_COUNT + successorCount, graph); - this.location = location; + setLocation(location); setObject(object); } diff -r d5218b246554 -r 25b5ec0568e6 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Invoke.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Invoke.java Tue Jun 28 16:13:32 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Invoke.java Tue Jun 28 16:45:48 2011 +0200 @@ -34,7 +34,7 @@ /** * The {@code Invoke} instruction represents all kinds of method calls. */ -public final class Invoke extends AbstractMemoryMergeNode implements ExceptionEdgeInstruction { +public final class Invoke extends AbstractMemoryCheckpointNode implements ExceptionEdgeInstruction { private final int argumentCount; diff -r d5218b246554 -r 25b5ec0568e6 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/LocationNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/LocationNode.java Tue Jun 28 16:13:32 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/LocationNode.java Tue Jun 28 16:45:48 2011 +0200 @@ -34,13 +34,13 @@ private int displacement; private CiKind valueKind; - private Object identity; + private Object locationIdentity; public LocationNode(Object identity, CiKind kind, int displacement, Graph graph) { super(CiKind.Illegal, INPUT_COUNT, SUCCESSOR_COUNT, graph); this.displacement = displacement; this.valueKind = kind; - this.identity = identity; + this.locationIdentity = identity; } @Override @@ -62,10 +62,18 @@ @Override public Node copy(Graph into) { - return new LocationNode(identity, valueKind, displacement, into); + return new LocationNode(locationIdentity, valueKind, displacement, into); } public CiValue createAddress(LIRGenerator lirGenerator, Value object) { return new CiAddress(valueKind, lirGenerator.load(object), displacement); } + + public Object locationIdentity() { + return locationIdentity; + } + + public boolean same(LocationNode location) { + return valueKind == location.valueKind && displacement == location.displacement; + } } diff -r d5218b246554 -r 25b5ec0568e6 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/MemoryMergeNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/MemoryMergeNode.java Tue Jun 28 16:13:32 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.ir; - -import com.oracle.max.graal.compiler.gen.*; -import com.oracle.max.graal.graph.*; -import com.sun.cri.ci.*; - - -public final class MemoryMergeNode extends AbstractMemoryMergeNode { - - private static final int SUCCESSOR_COUNT = 0; - private static final int INPUT_COUNT = 0; - - public MemoryMergeNode(Graph graph) { - this(CiKind.Illegal, 0, 0, graph); - } - - public MemoryMergeNode(CiKind result, int inputCount, int successorCount, Graph graph) { - super(result, inputCount + INPUT_COUNT, successorCount + SUCCESSOR_COUNT, graph); - } - - @Override - public T lookup(Class clazz) { - if (clazz == LIRGenerator.LIRGeneratorOp.class) { - return null; - } - return super.lookup(clazz); - } - - @Override - public Node copy(Graph into) { - return new MemoryMergeNode(into); - } -} diff -r d5218b246554 -r 25b5ec0568e6 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Value.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Value.java Tue Jun 28 16:13:32 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Value.java Tue Jun 28 16:45:48 2011 +0200 @@ -26,7 +26,6 @@ import com.oracle.max.graal.compiler.debug.*; import com.oracle.max.graal.compiler.gen.*; -import com.oracle.max.graal.compiler.value.*; import com.oracle.max.graal.graph.*; import com.sun.cri.ci.*; import com.sun.cri.ri.*; diff -r d5218b246554 -r 25b5ec0568e6 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/WriteMemoryCheckpointNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/WriteMemoryCheckpointNode.java Tue Jun 28 16:45:48 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.compiler.ir; + +import com.oracle.max.graal.compiler.gen.*; +import com.oracle.max.graal.graph.*; +import com.sun.cri.ci.*; + + +public final class WriteMemoryCheckpointNode extends AbstractMemoryCheckpointNode { + + private static final int SUCCESSOR_COUNT = 0; + private static final int INPUT_COUNT = 0; + + public WriteMemoryCheckpointNode(Graph graph) { + this(CiKind.Illegal, 0, 0, graph); + } + + public WriteMemoryCheckpointNode(CiKind result, int inputCount, int successorCount, Graph graph) { + super(result, inputCount + INPUT_COUNT, successorCount + SUCCESSOR_COUNT, graph); + } + + @Override + public T lookup(Class clazz) { + if (clazz == LIRGenerator.LIRGeneratorOp.class) { + return null; + } + return super.lookup(clazz); + } + + @Override + public Node copy(Graph into) { + return new WriteMemoryCheckpointNode(into); + } +} diff -r d5218b246554 -r 25b5ec0568e6 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/FrameMap.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/FrameMap.java Tue Jun 28 16:13:32 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/FrameMap.java Tue Jun 28 16:45:48 2011 +0200 @@ -33,7 +33,6 @@ import com.sun.cri.ci.*; import com.sun.cri.ci.CiCallingConvention.*; import com.sun.cri.ri.*; -import com.sun.cri.util.*; /** * This class is used to build the stack frame layout for a compiled method. @@ -130,7 +129,7 @@ incomingArguments = new CiCallingConvention(new CiValue[0], 0); } else { CiKind receiver = !isStatic(method.accessFlags()) ? method.holder().kind() : null; - incomingArguments = getCallingConvention(CRIUtil.signatureToKinds(method.signature(), receiver), JavaCallee); + incomingArguments = getCallingConvention(CiUtil.signatureToKinds(method.signature(), receiver), JavaCallee); } } @@ -142,7 +141,7 @@ * @return a {@link CiCallingConvention} instance describing the location of parameters and the return value */ public CiCallingConvention getCallingConvention(CiKind[] signature, Type type) { - CiCallingConvention cc = compilation.registerConfig.getCallingConvention(type, signature, compilation.target); + CiCallingConvention cc = compilation.registerConfig.getCallingConvention(type, signature, compilation.target, false); if (type == RuntimeCall) { assert cc.stackSize == 0 : "runtime call should not have stack arguments"; } else if (type.out) { @@ -189,7 +188,7 @@ this.spillSlotCount = spillSlotCount; int frameSize = offsetToStackBlocksEnd(); - frameSize += compilation.registerConfig.getCalleeSaveArea().size; + frameSize += compilation.registerConfig.getCalleeSaveLayout().size; this.frameSize = compilation.target.alignFrameSize(frameSize); } @@ -364,7 +363,7 @@ } public int offsetToCalleeSaveAreaStart() { - return offsetToCalleeSaveAreaEnd() - compilation.registerConfig.getCalleeSaveArea().size; + return offsetToCalleeSaveAreaEnd() - compilation.registerConfig.getCalleeSaveLayout().size; } public int offsetToCalleeSaveAreaEnd() { diff -r d5218b246554 -r 25b5ec0568e6 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 Tue Jun 28 16:13:32 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/MemoryPhase.java Tue Jun 28 16:45:48 2011 +0200 @@ -30,85 +30,224 @@ import com.oracle.max.graal.compiler.ir.*; import com.oracle.max.graal.compiler.schedule.*; import com.oracle.max.graal.graph.*; +import com.sun.cri.ci.*; public class MemoryPhase extends Phase { public static class MemoryMap { private final Block block; - private HashMap locationToWrite; - private HashMap> locationToReads; + private HashMap locationForWrite; + private HashMap locationForRead; + private Node mergeForWrite; + private Node mergeForRead; + private int mergeOperationCount; + private Node loopCheckPoint; + private MemoryMap loopEntryMap; public MemoryMap(Block b, MemoryMap memoryMap) { this(b); + if (b.firstNode() instanceof LoopBegin) { + loopCheckPoint = new WriteMemoryCheckpointNode(b.firstNode().graph()); + mergeForWrite = loopCheckPoint; + mergeForRead = loopCheckPoint; + this.loopEntryMap = memoryMap; + } else { + memoryMap.locationForWrite.putAll(memoryMap.locationForWrite); + memoryMap.locationForRead.putAll(memoryMap.locationForRead); + mergeForWrite = memoryMap.mergeForWrite; + mergeForRead = memoryMap.mergeForRead; + } } public MemoryMap(Block b) { - block = b; - locationToWrite = new HashMap(); - locationToReads = new HashMap>(); if (GraalOptions.TraceMemoryMaps) { TTY.println("Creating new memory map for block B" + b.blockID()); } + + block = b; + locationForWrite = new HashMap(); + locationForRead = new HashMap(); + StartNode startNode = b.firstNode().graph().start(); + if (b.firstNode() == startNode) { + WriteMemoryCheckpointNode checkpoint = new WriteMemoryCheckpointNode(startNode.graph()); + checkpoint.setNext((FixedNode) startNode.start()); + startNode.setStart(checkpoint); + mergeForWrite = checkpoint; + mergeForRead = checkpoint; + } } - public void mergeWith(MemoryMap memoryMap) { + public Node getLoopCheckPoint() { + return loopCheckPoint; + } + + public MemoryMap getLoopEntryMap() { + return loopEntryMap; + } + + public void resetMergeOperationCount() { + mergeOperationCount = 0; + } + + public void mergeWith(MemoryMap memoryMap, Block block) { if (GraalOptions.TraceMemoryMaps) { TTY.println("Merging with memory map of block B" + memoryMap.block.blockID()); } + mergeForWrite = mergeNodes(mergeForWrite, memoryMap.mergeForWrite, locationForWrite, memoryMap.locationForWrite, block); + mergeForRead = mergeNodes(mergeForRead, memoryMap.mergeForRead, locationForRead, memoryMap.locationForRead, block); + mergeOperationCount++; } - public void createMemoryMerge(AbstractMemoryMergeNode memMerge) { + private Node mergeNodes(Node mergeLeft, Node mergeRight, HashMap locationLeft, HashMap locationRight, Block block) { if (GraalOptions.TraceMemoryMaps) { - TTY.println("Creating memory merge at node " + memMerge.id()); + TTY.println("Merging main merge nodes: " + mergeLeft.id() + " and " + mergeRight.id()); + } + + for (Entry e : locationRight.entrySet()) { + if (!locationLeft.containsKey(e.getKey())) { + // Only available in right map => create correct node for left map. + if (GraalOptions.TraceMemoryMaps) { + TTY.println("Only right map " + e.getKey()); + } + Node leftNode = mergeLeft; + if (leftNode instanceof Phi && ((Phi) leftNode).merge() == block.firstNode()) { + leftNode = leftNode.copyWithEdges(); + } + locationLeft.put(e.getKey(), leftNode); + } + } + + for (Entry e : locationLeft.entrySet()) { + if (locationRight.containsKey(e.getKey())) { + // Available in both maps. + if (GraalOptions.TraceMemoryMaps) { + TTY.println("Merging entries for location " + e.getKey()); + } + locationLeft.put(e.getKey(), mergeNodes(e.getValue(), locationRight.get(e.getKey()), block)); + } else { + // Only available in left map. + if (GraalOptions.TraceMemoryMaps) { + TTY.println("Only available in left map " + e.getKey()); + } + locationLeft.put(e.getKey(), mergeNodes(e.getValue(), mergeRight, block)); + } } - for (Entry writeEntry : locationToWrite.entrySet()) { + return mergeNodes(mergeLeft, mergeRight, block); + } + + private Node mergeNodes(Node original, Node newValue, Block block) { + if (original == newValue) { + // Nothing to merge. + if (GraalOptions.TraceMemoryMaps) { + TTY.println("Nothing to merge both nodes are " + original.id()); + } + return original; + } + Merge m = (Merge) block.firstNode(); + if (original instanceof Phi && ((Phi) original).merge() == m) { + Phi phi = (Phi) original; + phi.addInput(newValue); + if (GraalOptions.TraceMemoryMaps) { + TTY.println("Add new input to phi " + original.id()); + } + assert phi.valueCount() <= phi.merge().endCount(); + return original; + } else { + Phi phi = new Phi(CiKind.Illegal, m, m.graph()); + phi.makeDead(); // Phi does not produce a value, it is only a memory phi. + for (int i = 0; i < mergeOperationCount + 1; ++i) { + phi.addInput(original); + } + phi.addInput(newValue); + if (GraalOptions.TraceMemoryMaps) { + TTY.println("Creating new phi " + phi.id()); + } + assert phi.valueCount() <= phi.merge().endCount() + ((phi.merge() instanceof LoopBegin) ? 1 : 0) : phi.merge() + "/" + phi.valueCount() + "/" + phi.merge().endCount() + "/" + mergeOperationCount; + return phi; + } + } + + public void createWriteMemoryMerge(AbstractMemoryCheckpointNode memMerge) { + if (GraalOptions.TraceMemoryMaps) { + TTY.println("Creating write memory checkpoint at node " + memMerge.id()); + } + + // Merge in all writes. + for (Entry writeEntry : locationForWrite.entrySet()) { memMerge.mergedNodes().add(writeEntry.getValue()); } - - for (Entry> readEntry : locationToReads.entrySet()) { - memMerge.mergedNodes().addAll(readEntry.getValue()); - } - - locationToReads.clear(); - locationToWrite.clear(); + locationForWrite.clear(); + mergeForWrite = memMerge; } - public void registerWrite(Object location, Node node) { + public void createReadWriteMemoryCheckpoint(AbstractMemoryCheckpointNode memMerge) { + if (GraalOptions.TraceMemoryMaps) { + TTY.println("Creating readwrite memory checkpoint at node " + memMerge.id()); + } + createWriteMemoryMerge(memMerge); + locationForRead.clear(); + mergeForRead = memMerge; + } + + public void registerWrite(WriteNode node) { + Object location = node.location().locationIdentity(); if (GraalOptions.TraceMemoryMaps) { TTY.println("Register write to " + location + " at node " + node.id()); } - if (locationToWrite.containsKey(location)) { - Node prevWrite = locationToWrite.get(location); - node.inputs().add(prevWrite); + // Create dependency on previous write to same location. + node.inputs().variablePart().add(getLocationForWrite(node)); + + locationForWrite.put(location, node); + locationForRead.put(location, node); + } + + public Node getLocationForWrite(WriteNode node) { + Object location = node.location().locationIdentity(); + if (locationForWrite.containsKey(location)) { + Node prevWrite = locationForWrite.get(location); + return prevWrite; + } else { + return mergeForWrite; + } + } + + public void registerRead(ReadNode node) { + if (GraalOptions.TraceMemoryMaps) { + TTY.println("Register read to node " + node.id()); } - if (locationToReads.containsKey(location)) { - for (Node prevRead : locationToReads.get(location)) { - node.inputs().add(prevRead); - } - } - locationToWrite.put(location, node); - locationToReads.remove(location); + // Create dependency on previous node that creates the memory state for this location. + node.inputs().variablePart().add(getLocationForRead(node)); } - public void registerRead(Object location, Node node) { - if (GraalOptions.TraceMemoryMaps) { - TTY.println("Register read to " + location + " at node " + node.id()); + public Node getLocationForRead(ReadNode node) { + Object location = node.location().locationIdentity(); + if (locationForRead.containsKey(location)) { + return locationForRead.get(location); } + return mergeForRead; + } - if (locationToWrite.containsKey(location)) { - Node prevWrite = locationToWrite.get(location); - node.inputs().add(prevWrite); + public void replaceCheckPoint(Node loopCheckPoint) { + List usages = new ArrayList(loopCheckPoint.usages()); + for (Node n : usages) { + replaceCheckPoint(loopCheckPoint, n); } + } - if (!locationToReads.containsKey(location)) { - locationToReads.put(location, new ArrayList()); + private void replaceCheckPoint(Node loopCheckPoint, Node n) { + if (n instanceof ReadNode) { + n.inputs().replace(loopCheckPoint, getLocationForRead((ReadNode) n)); + } else if (n instanceof WriteNode) { + n.inputs().replace(loopCheckPoint, getLocationForWrite((WriteNode) n)); + } else if (n instanceof WriteMemoryCheckpointNode) { + n.inputs().replace(loopCheckPoint, mergeForWrite); + } else { + n.inputs().replace(loopCheckPoint, mergeForRead); } - locationToReads.get(location).add(node); - TTY.println("entrySet size" + locationToReads.entrySet()); } } @@ -120,11 +259,11 @@ List blocks = s.getBlocks(); MemoryMap[] memoryMaps = new MemoryMap[blocks.size()]; for (final Block b : blocks) { - process(b, memoryMaps); + process(b, memoryMaps, s.getNodeToBlock()); } } - private void process(final Block b, MemoryMap[] memoryMaps) { + private void process(final Block b, MemoryMap[] memoryMaps, NodeMap nodeMap) { // Visit every block at most once. if (memoryMaps[b.blockID()] != null) { return; @@ -132,7 +271,7 @@ // Process predecessors before this block. for (Block pred : b.getPredecessors()) { - process(pred, memoryMaps); + process(pred, memoryMaps, nodeMap); } // Create initial memory map for the block. @@ -142,24 +281,44 @@ } else { map = new MemoryMap(b, memoryMaps[b.getPredecessors().get(0).blockID()]); for (int i = 1; i < b.getPredecessors().size(); ++i) { - map.mergeWith(memoryMaps[b.getPredecessors().get(0).blockID()]); + assert b.firstNode() instanceof Merge : b.firstNode(); + Block block = b.getPredecessors().get(i); + map.mergeWith(memoryMaps[block.blockID()], b); } } - // Lower the instructions of this block. + // Create the floating memory checkpoint instructions. for (final Node n : b.getInstructions()) { - // This memory merge node is not lowered => create a memory merge nevertheless. - if (n instanceof AbstractMemoryMergeNode) { - map.createMemoryMerge((AbstractMemoryMergeNode) n); - } else if (n instanceof ReadNode) { + if (n instanceof ReadNode) { ReadNode readNode = (ReadNode) n; - + readNode.replaceAtPredecessors(readNode.next()); + readNode.setNext(null); + map.registerRead(readNode); } else if (n instanceof WriteNode) { WriteNode writeNode = (WriteNode) n; - + WriteMemoryCheckpointNode checkpoint = new WriteMemoryCheckpointNode(writeNode.graph()); + checkpoint.setStateAfter(writeNode.stateAfter()); + writeNode.setStateAfter(null); + checkpoint.setNext(writeNode.next()); + writeNode.setNext(null); + writeNode.replaceAtPredecessors(checkpoint); + map.registerWrite(writeNode); + map.createWriteMemoryMerge(checkpoint); + } else if (n instanceof AbstractMemoryCheckpointNode) { + map.createReadWriteMemoryCheckpoint((AbstractMemoryCheckpointNode) n); } } memoryMaps[b.blockID()] = map; + if (b.lastNode() instanceof LoopEnd) { + LoopEnd end = (LoopEnd) b.lastNode(); + LoopBegin begin = end.loopBegin(); + Block beginBlock = nodeMap.get(begin); + MemoryMap memoryMap = memoryMaps[beginBlock.blockID()]; + memoryMap.getLoopEntryMap().resetMergeOperationCount(); + memoryMap.getLoopEntryMap().mergeWith(map, beginBlock); + Node loopCheckPoint = memoryMap.getLoopCheckPoint(); + memoryMap.getLoopEntryMap().replaceCheckPoint(loopCheckPoint); + } } } diff -r d5218b246554 -r 25b5ec0568e6 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/ReadEliminationPhase.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/ReadEliminationPhase.java Tue Jun 28 16:45:48 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.compiler.phases; + +import com.oracle.max.graal.compiler.*; +import com.oracle.max.graal.compiler.debug.*; +import com.oracle.max.graal.compiler.ir.*; +import com.oracle.max.graal.graph.*; + +/** + * Duplicates every node in the graph to test the implementation of the {@link com.oracle.max.graal.graph.Node#copy()} method in node subclasses. + */ +public class ReadEliminationPhase extends Phase { + + @Override + protected void run(Graph graph) { + for (ReadNode n : graph.getNodes(ReadNode.class)) { + Node memoryInput = n.inputs().variablePart().get(0); + if (memoryInput instanceof WriteNode) { + WriteNode other = (WriteNode) memoryInput; + if (other.object() == n.object() && other.location().same(n.location())) { + if (GraalOptions.TraceReadElimination) { + TTY.println("Eliminated memory read " + n + "and replaced with node " + other.value()); + } + n.replaceAndDelete(other.value()); + } + } + } + } +} diff -r d5218b246554 -r 25b5ec0568e6 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 Tue Jun 28 16:13:32 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/Block.java Tue Jun 28 16:45:48 2011 +0200 @@ -171,6 +171,10 @@ return "B" + blockID; } + public boolean isLoopHeader() { + return firstNode instanceof LoopBegin; + } + public Block dominator() { return dominator; } diff -r d5218b246554 -r 25b5ec0568e6 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 Tue Jun 28 16:13:32 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/IdentifyBlocksPhase.java Tue Jun 28 16:45:48 2011 +0200 @@ -74,10 +74,9 @@ if (b.lastNode() == null) { b.setFirstNode(n); b.setLastNode(n); + b.getInstructions().add(n); } else { - if (b.firstNode() != b.lastNode()) { - b.getInstructions().add(0, b.firstNode()); - } + b.getInstructions().add(0, n); b.setFirstNode(n); } @@ -321,15 +320,15 @@ List sortedInstructions = new ArrayList(instructions.size() + 2); assert !map.isMarked(b.firstNode()) && nodeToBlock.get(b.firstNode()) == b; - assert !instructions.contains(b.firstNode()); - assert !instructions.contains(b.lastNode()); +// assert !instructions.contains(b.firstNode()); +// assert !instructions.contains(b.lastNode()); assert !map.isMarked(b.lastNode()) && nodeToBlock.get(b.lastNode()) == b; - addToSorting(b, b.firstNode(), sortedInstructions, map); + //addToSorting(b, b.firstNode(), sortedInstructions, map); for (Node i : instructions) { addToSorting(b, i, sortedInstructions, map); } - addToSorting(b, b.lastNode(), sortedInstructions, map); + //addToSorting(b, b.lastNode(), sortedInstructions, map); // Make sure that last node gets really last (i.e. when a frame state successor hangs off it). Node lastSorted = sortedInstructions.get(sortedInstructions.size() - 1); @@ -351,6 +350,11 @@ } } b.setInstructions(sortedInstructions); +// TTY.println(); +// TTY.println("B" + b.blockID()); +// for (Node n : sortedInstructions) { +// TTY.println("n=" + n); +// } } private void addToSorting(Block b, Node i, List sortedInstructions, NodeBitMap map) { @@ -358,9 +362,19 @@ return; } + if (i instanceof WriteNode) { + // Make sure every ReadNode that is connected to the same memory state is executed before every write node. + WriteNode wn = (WriteNode) i; + // TODO: Iterate over variablePart. + wn.inputs().variablePart(); + } + FrameState state = null; + WriteNode writeNode = null; for (Node input : i.inputs()) { - if (input instanceof FrameState) { + if (input instanceof WriteNode && !map.isMarked(input) && nodeToBlock.get(input) == b) { + writeNode = (WriteNode) input; + } else if (input instanceof FrameState) { state = (FrameState) input; } else { addToSorting(b, input, sortedInstructions, map); @@ -373,20 +387,12 @@ map.mark(i); - for (Node succ : i.successors()) { - if (succ instanceof FrameState) { - addToSorting(b, succ, sortedInstructions, map); - } - } - - if (state != null) { - addToSorting(b, state, sortedInstructions, map); - } + addToSorting(b, state, sortedInstructions, map); + assert writeNode == null || !map.isMarked(writeNode); + addToSorting(b, writeNode, sortedInstructions, map); // Now predecessors and inputs are scheduled => we can add this node. - if (!(i instanceof FrameState)) { - sortedInstructions.add(i); - } + sortedInstructions.add(i); } private void computeDominators() { diff -r d5218b246554 -r 25b5ec0568e6 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64GlobalStubEmitter.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64GlobalStubEmitter.java Tue Jun 28 16:13:32 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64GlobalStubEmitter.java Tue Jun 28 16:45:48 2011 +0200 @@ -98,7 +98,7 @@ emitStandardForward(null, runtimeCall); String name = "stub-" + runtimeCall; CiTargetMethod targetMethod = tasm.finishTargetMethod(name, runtime, registerRestoreEpilogueOffset, true); - Object stubObject = runtime.registerGlobalStub(targetMethod, name); + Object stubObject = runtime.registerCompilerStub(targetMethod, name); return new GlobalStub(null, runtimeCall.resultKind, stubObject, argsSize, argOffsets, resultOffset); } @@ -128,7 +128,7 @@ String name = "stub-" + stub; CiTargetMethod targetMethod = tasm.finishTargetMethod(name, runtime, registerRestoreEpilogueOffset, true); - Object stubObject = runtime.registerGlobalStub(targetMethod, name); + Object stubObject = runtime.registerCompilerStub(targetMethod, name); return new GlobalStub(stub, stub.resultKind, stubObject, argsSize, argOffsets, resultOffset); } @@ -238,7 +238,7 @@ assembler.emitXirInstructions(null, template.fastPath, labels, operands, null); epilogue(); CiTargetMethod targetMethod = tasm.finishTargetMethod(template.name, runtime, registerRestoreEpilogueOffset, true); - Object stubObject = runtime.registerGlobalStub(targetMethod, template.name); + Object stubObject = runtime.registerCompilerStub(targetMethod, template.name); return new GlobalStub(null, template.resultOperand.kind, stubObject, argsSize, argOffsets, resultOffset); } @@ -377,7 +377,7 @@ } private void completeSavePrologue() { - CiCalleeSaveArea csa = compiler.globalStubRegisterConfig.getCalleeSaveArea(); + CiCalleeSaveLayout csa = compiler.globalStubRegisterConfig.getCalleeSaveLayout(); this.saveSize = csa.size; int entryCodeOffset = runtime.codeOffset(); if (entryCodeOffset != 0) { @@ -396,7 +396,7 @@ registerRestoreEpilogueOffset = asm.codeBuffer.position(); if (savedAllRegisters) { - CiCalleeSaveArea csa = compiler.globalStubRegisterConfig.getCalleeSaveArea(); + CiCalleeSaveLayout csa = compiler.globalStubRegisterConfig.getCalleeSaveLayout(); int frameToCSA = 0; asm.restore(csa, frameToCSA); } else { @@ -419,7 +419,7 @@ private void forwardRuntimeCall(CiRuntimeCall call) { // Load arguments - CiCallingConvention cc = compiler.globalStubRegisterConfig.getCallingConvention(RuntimeCall, call.arguments, target); + CiCallingConvention cc = compiler.globalStubRegisterConfig.getCallingConvention(RuntimeCall, call.arguments, target, false); for (int i = 0; i < cc.locations.length; ++i) { CiValue location = cc.locations[i]; loadArgument(i, location.asRegister()); diff -r d5218b246554 -r 25b5ec0568e6 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRAssembler.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRAssembler.java Tue Jun 28 16:13:32 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRAssembler.java Tue Jun 28 16:45:48 2011 +0200 @@ -1965,7 +1965,7 @@ masm.movl(new CiAddress(CiKind.Int, AMD64.rsp.asValue(), i * intSize), 0xC1C1C1C1); } } - CiCalleeSaveArea csa = compilation.registerConfig.getCalleeSaveArea(); + CiCalleeSaveLayout csa = compilation.registerConfig.getCalleeSaveLayout(); if (csa.size != 0) { int frameToCSA = frameMap.offsetToCalleeSaveAreaStart(); assert frameToCSA >= 0; @@ -1976,7 +1976,7 @@ case PopFrame: { int frameSize = initialFrameSizeInBytes(); - CiCalleeSaveArea csa = compilation.registerConfig.getCalleeSaveArea(); + CiCalleeSaveLayout csa = compilation.registerConfig.getCalleeSaveLayout(); if (csa.size != 0) { registerRestoreEpilogueOffset = masm.codeBuffer.position(); // saved all registers, restore all registers diff -r d5218b246554 -r 25b5ec0568e6 graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/HotSpotRegisterConfig.java --- a/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/HotSpotRegisterConfig.java Tue Jun 28 16:13:32 2011 +0200 +++ b/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/HotSpotRegisterConfig.java Tue Jun 28 16:45:48 2011 +0200 @@ -72,7 +72,7 @@ xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15 }; - private final CiCalleeSaveArea registerSaveArea; + private final CiCalleeSaveLayout registerSaveArea; public HotSpotRegisterConfig(HotSpotVMConfig config, boolean globalStubConfig) { @@ -83,9 +83,9 @@ } if (globalStubConfig) { - registerSaveArea = new CiCalleeSaveArea(-1, 8, rsaRegs); + registerSaveArea = new CiCalleeSaveLayout(0, -1, 8, rsaRegs); } else { - registerSaveArea = CiCalleeSaveArea.EMPTY; + registerSaveArea = new CiCalleeSaveLayout(0, 0, 0, new CiRegister[0]); } attributesMap = RiRegisterAttributes.createMap(this, AMD64.allRegisters); @@ -104,18 +104,18 @@ } @Override - public CiCallingConvention getCallingConvention(Type type, CiKind[] parameters, CiTarget target) { + public CiCallingConvention getCallingConvention(Type type, CiKind[] parameters, CiTarget target, boolean stackOnly) { if (type == Type.NativeCall) { throw new UnsupportedOperationException(); } - return callingConvention(parameters, type, target); + return callingConvention(parameters, type, target, stackOnly); } public CiRegister[] getCallingConventionRegisters(Type type, RegisterFlag flag) { return allParameterRegisters; } - private CiCallingConvention callingConvention(CiKind[] types, Type type, CiTarget target) { + private CiCallingConvention callingConvention(CiKind[] types, Type type, CiTarget target, boolean stackOnly) { CiValue[] locations = new CiValue[types.length]; int currentGeneral = 0; @@ -134,14 +134,14 @@ case Long: case Word: case Object: - if (currentGeneral < generalParameterRegisters.length) { + if (!stackOnly && currentGeneral < generalParameterRegisters.length) { CiRegister register = generalParameterRegisters[currentGeneral++]; locations[i] = register.asValue(kind); } break; case Float: case Double: - if (currentXMM < xmmParameterRegisters.length) { + if (!stackOnly && currentXMM < xmmParameterRegisters.length) { CiRegister register = xmmParameterRegisters[currentXMM++]; locations[i] = register.asValue(kind); } @@ -193,7 +193,7 @@ return rsp; } - public CiCalleeSaveArea getCalleeSaveArea() { + public CiCalleeSaveLayout getCalleeSaveLayout() { return registerSaveArea; } @@ -202,7 +202,7 @@ String res = String.format( "Allocatable: " + Arrays.toString(getAllocatableRegisters()) + "%n" + "CallerSave: " + Arrays.toString(getCallerSaveRegisters()) + "%n" + - "CalleeSave: " + getCalleeSaveArea() + "%n" + + "CalleeSave: " + getCalleeSaveLayout() + "%n" + "Scratch: " + getScratchRegister() + "%n"); return res; } diff -r d5218b246554 -r 25b5ec0568e6 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 Tue Jun 28 16:13:32 2011 +0200 +++ b/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/HotSpotRuntime.java Tue Jun 28 16:45:48 2011 +0200 @@ -82,8 +82,8 @@ return "{" + call.runtimeCall.name() + "}"; } else if (call.symbol != null) { return "{" + call.symbol + "}"; - } else if (call.globalStubID != null) { - return "{" + call.globalStubID + "}"; + } else if (call.stubID != null) { + return "{" + call.stubID + "}"; } else { return "{" + call.method + "}"; } @@ -178,7 +178,7 @@ } @Override - public Object registerGlobalStub(CiTargetMethod targetMethod, String name) { + public Object registerCompilerStub(CiTargetMethod targetMethod, String name) { return HotSpotTargetMethod.installStub(compiler, targetMethod, name); } @@ -266,10 +266,6 @@ memoryWrite.setGuard((GuardNode) tool.createGuard(new IsNonNull(field.object(), graph))); memoryWrite.setStateAfter(field.stateAfter()); memoryWrite.setNext(field.next()); - - //MemoryMergeNode memoryMergeNode = new MemoryMergeNode(graph); - //memoryMergeNode.setStateAfter(field.stateAfter()); - //tool.createMemoryMerge(memoryMergeNode); if (field.field().kind() == CiKind.Object && !field.value().isNullConstant()) { FieldWriteBarrier writeBarrier = new FieldWriteBarrier(field.object(), graph); memoryWrite.setNext(writeBarrier); diff -r d5218b246554 -r 25b5ec0568e6 graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/HotSpotXirGenerator.java --- a/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/HotSpotXirGenerator.java Tue Jun 28 16:13:32 2011 +0200 +++ b/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/HotSpotXirGenerator.java Tue Jun 28 16:45:48 2011 +0200 @@ -96,7 +96,7 @@ XirOperand temp = asm.createRegisterTemp("temp (r10)", CiKind.Word, AMD64.r10); XirOperand cache = asm.createRegisterTemp("cache (rax)", CiKind.Word, AMD64.rax); - CiCallingConvention conventions = registerConfig.getCallingConvention(JavaCallee, new CiKind[] {CiKind.Object}, target); + CiCallingConvention conventions = registerConfig.getCallingConvention(JavaCallee, new CiKind[] {CiKind.Object}, target, false); XirOperand receiver = asm.createRegisterTemp("receiver", CiKind.Word, conventions.locations[0].asRegister()); asm.pload(CiKind.Word, temp, receiver, asm.i(config.hubOffset), false); diff -r d5218b246554 -r 25b5ec0568e6 src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/GraalColoringFilter.java diff -r d5218b246554 -r 25b5ec0568e6 src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/GraalEdgeColorFilter.java --- a/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/GraalEdgeColorFilter.java Tue Jun 28 16:13:32 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/GraalEdgeColorFilter.java Tue Jun 28 16:45:48 2011 +0200 @@ -28,6 +28,7 @@ import com.sun.hotspot.igv.graph.Connection; import com.sun.hotspot.igv.graph.Diagram; import com.sun.hotspot.igv.graph.Figure; +import com.sun.hotspot.igv.graph.InputSlot; import com.sun.hotspot.igv.graph.OutputSlot; import java.awt.Color; import java.util.List; @@ -39,8 +40,9 @@ */ public class GraalEdgeColorFilter extends AbstractFilter { - private Color successorColor = Color.ORANGE; + private Color successorColor = Color.BLUE; private Color usageColor = Color.RED; + private Color memoryColor = Color.GREEN; public GraalEdgeColorFilter() { } @@ -53,7 +55,6 @@ List
figures = d.getFigures(); for (Figure f : figures) { Properties p = f.getProperties(); - int succCount = Integer.parseInt(p.get("successorCount")); for (OutputSlot os : f.getOutputSlots()) { Color color; @@ -69,6 +70,22 @@ } } } + for (Figure f : figures) { + Properties p = f.getProperties(); + int predCount = Integer.parseInt(p.get("predecessorCount")); + int inputCount = Integer.parseInt(p.get("inputCount")); + int variableInputCount = Integer.parseInt(p.get("variableInputCount")); + if (p.get("memoryCheckpoint") != null) { + for (InputSlot is : f.getInputSlots()) { + if (is.getPosition() > predCount + inputCount - variableInputCount) { + is.setColor(memoryColor); + for (Connection c : is.getConnections()) { + c.setColor(memoryColor); + } + } + } + } + } } public Color getUsageColor() { @@ -78,7 +95,15 @@ public void setUsageColor(Color usageColor) { this.usageColor = usageColor; } + + public void setMemoryColor(Color memoryColor) { + this.memoryColor = memoryColor; + } + public Color getMemoryColor() { + return memoryColor; + } + public Color getSuccessorColor() { return successorColor; } diff -r d5218b246554 -r 25b5ec0568e6 src/share/tools/IdealGraphVisualizer/Text Editor/build/classes/at/ssw/visualizer/texteditor/Bundle.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Text Editor/build/classes/at/ssw/visualizer/texteditor/Bundle.properties Tue Jun 28 16:45:48 2011 +0200 @@ -0,0 +1,1 @@ +OpenIDE-Module-Name=Text Editor diff -r d5218b246554 -r 25b5ec0568e6 src/share/tools/IdealGraphVisualizer/Text Editor/build/classes/at/ssw/visualizer/texteditor/layer.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Text Editor/build/classes/at/ssw/visualizer/texteditor/layer.xml Tue Jun 28 16:45:48 2011 +0200 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -r d5218b246554 -r 25b5ec0568e6 src/share/tools/IdealGraphVisualizer/Text Editor/build/classes/at/ssw/visualizer/texteditor/preferences.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Text Editor/build/classes/at/ssw/visualizer/texteditor/preferences.xml Tue Jun 28 16:45:48 2011 +0200 @@ -0,0 +1,6 @@ + + + + + + diff -r d5218b246554 -r 25b5ec0568e6 src/share/tools/IdealGraphVisualizer/Text Editor/build/depcache/dependencies.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Text Editor/build/depcache/dependencies.txt Tue Jun 28 16:45:48 2011 +0200 @@ -0,0 +1,282 @@ +||:at.ssw.visualizer.texteditor.Editor +at.ssw.visualizer.core.selection.SelectionManager +at.ssw.visualizer.core.selection.SelectionProvider +org.openide.text.CloneableEditor +javax.swing.JEditorPane +at.ssw.visualizer.texteditor.Editor$2 +at.ssw.visualizer.texteditor.Editor$1 +at.ssw.visualizer.core.selection.Selection +at.ssw.visualizer.texteditor.Editor +at.ssw.visualizer.texteditor.EditorSupport +||:at.ssw.visualizer.texteditor.EditorSupport +java.lang.StringBuilder +java.lang.UnsupportedOperationException +org.openide.windows.CloneableOpenSupport$Env +org.openide.text.CloneableEditorSupport +at.ssw.visualizer.texteditor.EditorSupport$Env +javax.swing.text.StyledDocument +org.openide.windows.CloneableOpenSupport +at.ssw.visualizer.texteditor.model.Text +org.openide.cookies.EditorCookie$Observable +com.sun.hotspot.igv.data.InputGraph +org.openide.cookies.EditCookie +org.openide.cookies.EditorCookie +org.openide.text.CloneableEditorSupport$Env +at.ssw.visualizer.texteditor.EditorSupport +com.sun.hotspot.igv.data.Group +||:at.ssw.visualizer.texteditor.fold.FoldManager$SideBarFactory +java.lang.Object +at.ssw.visualizer.texteditor.fold.FoldManager$SideBarFactory +org.netbeans.editor.SideBarFactory +at.ssw.visualizer.texteditor.fold.FoldManager +org.netbeans.editor.CodeFoldingSideBar +||:at.ssw.visualizer.texteditor.model.FoldingRegion +at.ssw.visualizer.texteditor.model.FoldingRegion +at.ssw.visualizer.texteditor.model.TextRegion +||:at.ssw.visualizer.texteditor.tooltip.StyledToolTip +java.awt.Color +javax.swing.border.LineBorder +java.awt.BorderLayout +java.lang.StringBuilder +java.awt.Dimension +at.ssw.visualizer.texteditor.tooltip.StyledToolTip +javax.swing.JEditorPane +javax.swing.JPanel +||:at.ssw.visualizer.texteditor.model.TextRegion +java.lang.Object +at.ssw.visualizer.texteditor.model.TextRegion +||:at.ssw.visualizer.texteditor.view.AbstractTextViewTopComponent$1 +java.lang.Object +at.ssw.visualizer.texteditor.view.AbstractTextViewTopComponent +at.ssw.visualizer.texteditor.view.AbstractTextViewTopComponent$1 +javax.swing.event.ChangeListener +||:at.ssw.visualizer.texteditor.model.TextBuilder +java.lang.StringBuilder +com.sun.hotspot.igv.data.InputBlock +java.util.HashSet +java.util.Set +java.util.List +java.util.ArrayList +at.ssw.visualizer.texteditor.model.Text +at.ssw.visualizer.texteditor.model.TextBuilder +java.util.Iterator +java.util.HashMap +java.util.Map +[Lat.ssw.visualizer.texteditor.model.FoldingRegion; +at.ssw.visualizer.texteditor.model.FoldingRegion +java.lang.Object +java.lang.String +||:at.ssw.visualizer.texteditor.view.AbstractTextViewTopComponent +at.ssw.visualizer.texteditor.view.AbstractTextViewTopComponent +javax.swing.JScrollPane +at.ssw.visualizer.core.selection.SelectionManager +javax.swing.JEditorPane +javax.swing.BorderFactory +java.awt.BorderLayout +com.sun.hotspot.igv.data.InputGraph +[Lcom.sun.hotspot.igv.data.InputBlock; +at.ssw.visualizer.core.selection.Selection +org.openide.windows.TopComponent +at.ssw.visualizer.texteditor.view.AbstractTextViewTopComponent$1 +java.util.Arrays +||:at.ssw.visualizer.texteditor.tooltip.ToolTipAction +at.ssw.visualizer.texteditor.model.Scanner +org.netbeans.editor.PopupManager +org.netbeans.editor.Utilities +org.netbeans.editor.TokenID +org.netbeans.editor.PopupManager$HorizontalBounds +org.netbeans.modules.editor.NbEditorKit$NbBuildToolTipAction +org.netbeans.editor.BaseDocument +org.netbeans.editor.EditorUI +at.ssw.visualizer.texteditor.model.Text +javax.swing.plaf.TextUI +java.awt.event.MouseEvent +org.netbeans.modules.editor.NbEditorKit +org.netbeans.editor.ext.ToolTipSupport +at.ssw.visualizer.texteditor.tooltip.ToolTipAction +javax.swing.text.JTextComponent +at.ssw.visualizer.texteditor.tooltip.StyledToolTip +org.netbeans.editor.PopupManager$Placement +||:at.ssw.visualizer.texteditor.fold.FoldManager$FoldManagerFactory +java.lang.Object +org.netbeans.spi.editor.fold.FoldManagerFactory +at.ssw.visualizer.texteditor.fold.FoldManager$FoldManagerFactory +at.ssw.visualizer.texteditor.fold.FoldManager +||:at.ssw.visualizer.core.selection.Selection +[Ljavax.swing.event.ChangeListener; +at.ssw.visualizer.core.selection.Selection$1 +javax.swing.event.ChangeListener +java.util.List +java.util.ArrayList +at.ssw.visualizer.core.selection.SelectionManager +java.lang.Class +java.util.HashMap +java.util.Map +javax.swing.event.ChangeEvent +at.ssw.visualizer.core.selection.Selection +java.lang.Object +javax.swing.Timer +||:at.ssw.visualizer.texteditor.model.BlockRegion +at.ssw.visualizer.texteditor.model.BlockRegion +at.ssw.visualizer.texteditor.model.TextRegion +||:at.ssw.visualizer.texteditor.highlight.HighlightsContainer$HighlightsLayerFactory +at.ssw.visualizer.texteditor.highlight.HighlightsContainer +at.ssw.visualizer.texteditor.model.Text +org.netbeans.spi.editor.highlighting.HighlightsLayerFactory +org.netbeans.spi.editor.highlighting.HighlightsLayer +java.lang.Object +javax.swing.text.Document +org.netbeans.spi.editor.highlighting.ZOrder +org.netbeans.spi.editor.highlighting.HighlightsLayerFactory$Context +at.ssw.visualizer.texteditor.highlight.HighlightsContainer$HighlightsLayerFactory +||:at.ssw.visualizer.texteditor.highlight.HighlightsContainer +javax.swing.text.JTextComponent +org.netbeans.spi.editor.highlighting.support.AbstractHighlightsContainer +org.netbeans.api.editor.mimelookup.MimeLookup +org.openide.util.WeakListeners +org.netbeans.api.editor.mimelookup.MimePath +javax.swing.text.SimpleAttributeSet +at.ssw.visualizer.texteditor.highlight.HighlightsContainer$HighlightsLayerFactory +org.openide.util.Lookup +javax.swing.event.CaretListener +at.ssw.visualizer.texteditor.highlight.HighlightsContainer +at.ssw.visualizer.texteditor.model.Text +at.ssw.visualizer.texteditor.model.Scanner +org.netbeans.api.editor.settings.FontColorSettings +at.ssw.visualizer.texteditor.highlight.HighlightsContainer$1 +javax.swing.text.Caret +org.netbeans.editor.TokenID +at.ssw.visualizer.texteditor.highlight.HighlightsContainer$RegionSequence +javax.swing.text.Document +||:at.ssw.visualizer.core.selection.Selection$1 +java.lang.Object +at.ssw.visualizer.core.selection.Selection +at.ssw.visualizer.core.selection.Selection$1 +java.awt.event.ActionListener +||:at.ssw.visualizer.texteditor.model.HoverParser +java.lang.Object +java.util.Iterator +java.lang.String +java.lang.StringBuilder +java.lang.UnsupportedOperationException +at.ssw.visualizer.texteditor.model.HoverParser +||:at.ssw.visualizer.texteditor.Editor$2 +at.ssw.visualizer.texteditor.Editor +java.util.ArrayList +javax.swing.event.CaretEvent +java.util.List +[Lcom.sun.hotspot.igv.data.InputBlock; +com.sun.hotspot.igv.data.InputBlock +java.util.Map +java.util.Collection +at.ssw.visualizer.core.selection.Selection +at.ssw.visualizer.texteditor.model.BlockRegion +java.util.Iterator +javax.swing.event.CaretListener +at.ssw.visualizer.texteditor.Editor$2 +at.ssw.visualizer.texteditor.model.Text +java.lang.Math +java.lang.Object +javax.swing.JEditorPane +javax.swing.text.Document +||:at.ssw.visualizer.texteditor.EditorSupport$Env +java.lang.UnsupportedOperationException +org.openide.text.CloneableEditorSupport +at.ssw.visualizer.texteditor.EditorSupport$Env +java.beans.VetoableChangeSupport +at.ssw.visualizer.texteditor.model.Text +java.io.ByteArrayInputStream +java.io.IOException +java.lang.Object +at.ssw.visualizer.texteditor.EditorSupport +org.openide.text.CloneableEditorSupport$Env +java.beans.PropertyChangeSupport +java.lang.String +||:at.ssw.visualizer.texteditor.Editor$1 +java.lang.Math +at.ssw.visualizer.texteditor.model.BlockRegion +javax.swing.event.ChangeListener +at.ssw.visualizer.texteditor.model.Text +javax.swing.JEditorPane +java.util.Map +[Lcom.sun.hotspot.igv.data.InputBlock; +at.ssw.visualizer.texteditor.Editor$1 +at.ssw.visualizer.core.selection.Selection +java.lang.Object +javax.swing.text.Document +at.ssw.visualizer.texteditor.Editor +java.util.Arrays +||:at.ssw.visualizer.texteditor.model.Text +java.lang.String +[Lat.ssw.visualizer.texteditor.model.TextRegion; +java.lang.Object +java.util.Iterator +java.util.Map +java.util.Set +at.ssw.visualizer.texteditor.model.Text +at.ssw.visualizer.texteditor.model.TextRegion +||:at.ssw.visualizer.core.selection.SelectionProvider +java.lang.Object +at.ssw.visualizer.core.selection.SelectionProvider +||:at.ssw.visualizer.texteditor.EditorKit +javax.swing.Action +at.ssw.visualizer.texteditor.tooltip.ToolTipAction +at.ssw.visualizer.texteditor.EditorKit +org.netbeans.modules.editor.NbEditorKit +javax.swing.text.TextAction +||:at.ssw.visualizer.core.selection.SelectionManager +at.ssw.visualizer.core.selection.Selection +java.lang.Object +at.ssw.visualizer.core.selection.SelectionManager +||:at.ssw.visualizer.texteditor.model.Scanner +at.ssw.visualizer.texteditor.model.Scanner +javax.swing.text.BadLocationException +java.lang.Math +java.util.Set +java.util.BitSet +java.lang.Class +java.util.logging.Level +java.util.logging.Logger +javax.swing.text.Document +java.lang.String +org.netbeans.editor.Syntax +||:at.ssw.visualizer.texteditor.fold.FoldManager +at.ssw.visualizer.texteditor.fold.FoldManager$FoldManagerFactory +javax.swing.text.BadLocationException +at.ssw.visualizer.texteditor.fold.FoldManager +org.netbeans.api.editor.fold.FoldType +at.ssw.visualizer.texteditor.fold.FoldManager$SideBarFactory +org.netbeans.spi.editor.fold.FoldManager +at.ssw.visualizer.texteditor.model.Text +java.lang.Class +java.util.logging.Level +java.util.logging.Logger +at.ssw.visualizer.texteditor.model.FoldingRegion +java.lang.Object +org.netbeans.api.editor.fold.FoldHierarchy +javax.swing.text.Document +javax.swing.text.JTextComponent +org.netbeans.spi.editor.fold.FoldOperation +||:at.ssw.visualizer.texteditor.highlight.HighlightsContainer$1 +java.lang.Object +javax.swing.event.CaretListener +at.ssw.visualizer.texteditor.highlight.HighlightsContainer +at.ssw.visualizer.texteditor.highlight.HighlightsContainer$1 +javax.swing.text.Document +||:at.ssw.visualizer.texteditor.hyperlink.HyperlinkProvider +at.ssw.visualizer.texteditor.model.Scanner +org.netbeans.editor.Utilities +at.ssw.visualizer.texteditor.hyperlink.HyperlinkProvider +org.netbeans.editor.TokenID +org.netbeans.lib.editor.hyperlink.spi.HyperlinkProvider +at.ssw.visualizer.texteditor.model.Text +java.lang.Object +javax.swing.text.Document +at.ssw.visualizer.texteditor.model.TextRegion +javax.swing.text.JTextComponent +||:at.ssw.visualizer.texteditor.highlight.HighlightsContainer$RegionSequence +java.lang.Object +org.netbeans.spi.editor.highlighting.HighlightsSequence +at.ssw.visualizer.texteditor.highlight.HighlightsContainer +at.ssw.visualizer.texteditor.highlight.HighlightsContainer$RegionSequence +at.ssw.visualizer.texteditor.model.TextRegion diff -r d5218b246554 -r 25b5ec0568e6 src/share/tools/IdealGraphVisualizer/Text Editor/build/no-license.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Text Editor/build/no-license.txt Tue Jun 28 16:45:48 2011 +0200 @@ -0,0 +1,1 @@ +[NO LICENSE SPECIFIED] \ No newline at end of file diff -r d5218b246554 -r 25b5ec0568e6 src/share/vm/graal/graalCodeInstaller.cpp --- a/src/share/vm/graal/graalCodeInstaller.cpp Tue Jun 28 16:13:32 2011 +0200 +++ b/src/share/vm/graal/graalCodeInstaller.cpp Tue Jun 28 16:45:48 2011 +0200 @@ -525,7 +525,7 @@ oop runtime_call = CiTargetMethod_Call::runtimeCall(site); oop hotspot_method = CiTargetMethod_Call::method(site); oop symbol = CiTargetMethod_Call::symbol(site); - oop global_stub = CiTargetMethod_Call::globalStubID(site); + oop global_stub = CiTargetMethod_Call::stubID(site); oop debug_info = CiTargetMethod_Call::debugInfo(site); diff -r d5218b246554 -r 25b5ec0568e6 src/share/vm/graal/graalJavaAccess.hpp --- a/src/share/vm/graal/graalJavaAccess.hpp Tue Jun 28 16:13:32 2011 +0200 +++ b/src/share/vm/graal/graalJavaAccess.hpp Tue Jun 28 16:45:48 2011 +0200 @@ -117,7 +117,7 @@ oop_field(CiTargetMethod_Call, runtimeCall, "Lcom/sun/cri/ci/CiRuntimeCall;") \ oop_field(CiTargetMethod_Call, method, "Lcom/sun/cri/ri/RiMethod;") \ oop_field(CiTargetMethod_Call, symbol, "Ljava/lang/String;") \ - oop_field(CiTargetMethod_Call, globalStubID, "Ljava/lang/Object;") \ + oop_field(CiTargetMethod_Call, stubID, "Ljava/lang/Object;") \ oop_field(CiTargetMethod_Call, debugInfo, "Lcom/sun/cri/ci/CiDebugInfo;") \ end_class \ start_class(CiTargetMethod_DataPatch) \