# HG changeset patch # User Bernhard Urban # Date 1380571540 -7200 # Node ID f5faf49a86dd4bfd8e5ff6b9d6beedd280ea3f69 # Parent 41a2a20d49498ea72695fe7d4860ba24444cea0f remove MemoryState, make MemoryMap a node, add MemoryMap input to ReturnNode diff -r 41a2a20d4949 -r f5faf49a86dd graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MemoryMap.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MemoryMap.java Mon Sep 30 16:36:24 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2013, 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.graal.nodes; - -import com.oracle.graal.api.meta.*; - -public interface MemoryMap { - - T getLastLocationAccess(LocationIdentity locationIdentity); -} diff -r 41a2a20d4949 -r f5faf49a86dd graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MemoryMapNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MemoryMapNode.java Mon Sep 30 22:05:40 2013 +0200 @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2013, 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.graal.nodes; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.graph.*; +import com.oracle.graal.nodes.calc.*; +import com.oracle.graal.nodes.type.*; + +public abstract class MemoryMapNode extends FloatingNode { + + public MemoryMapNode() { + super(StampFactory.forVoid()); + } + + public abstract Node getLastLocationAccess(LocationIdentity locationIdentity); +} diff -r 41a2a20d4949 -r f5faf49a86dd graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MemoryState.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MemoryState.java Mon Sep 30 16:36:24 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2013, 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.graal.nodes; - -import com.oracle.graal.graph.*; - -public class MemoryState extends VirtualState { - - private MemoryMap memoryMap; - @Input private Node object; - - public MemoryState(MemoryMap memoryMap, FixedNode object) { - this.memoryMap = memoryMap; - this.object = object; - } - - public Node object() { - return object; - } - - public MemoryMap getMemoryMap() { - return memoryMap; - } - - @Override - public VirtualState duplicateWithVirtualState() { - throw new GraalInternalError("should not reach here"); - } - - @Override - public void applyToNonVirtual(NodeClosure closure) { - throw new GraalInternalError("should not reach here"); - } - - @Override - public void applyToVirtual(VirtualClosure closure) { - throw new GraalInternalError("should not reach here"); - } - - @Override - public boolean isPartOfThisState(VirtualState state) { - throw new GraalInternalError("should not reach here"); - } -} diff -r 41a2a20d4949 -r f5faf49a86dd graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ReturnNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ReturnNode.java Mon Sep 30 16:36:24 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ReturnNode.java Mon Sep 30 22:05:40 2013 +0200 @@ -28,6 +28,7 @@ public final class ReturnNode extends ControlSinkNode implements LIRLowerable { @Input private ValueNode result; + @Input private MemoryMapNode memoryMap; public ValueNode result() { return result; @@ -40,8 +41,13 @@ * void return */ public ReturnNode(ValueNode result) { + this(result, null); + } + + public ReturnNode(ValueNode result, MemoryMapNode memoryMap) { super(StampFactory.forVoid()); this.result = result; + this.memoryMap = memoryMap; } @Override @@ -53,4 +59,13 @@ public void generate(LIRGeneratorTool gen) { gen.visitReturn(this); } + + public void setMemoryMap(MemoryMapNode memoryMap) { + updateUsages(this.memoryMap, memoryMap); + this.memoryMap = memoryMap; + } + + public MemoryMapNode getMemoryMap() { + return memoryMap; + } } diff -r 41a2a20d4949 -r f5faf49a86dd graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java Mon Sep 30 16:36:24 2013 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java Mon Sep 30 22:05:40 2013 +0200 @@ -27,7 +27,6 @@ import java.util.*; import com.oracle.graal.api.meta.*; -import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.PhiNode.PhiType; import com.oracle.graal.nodes.extended.*; @@ -42,7 +41,7 @@ ANALYSIS_ONLY, CREATE_FLOATING_READS } - public static class MemoryMapImpl implements MemoryMap { + public static class MemoryMapImpl extends MemoryMapNode { private IdentityHashMap lastMemorySnapshot; @@ -74,11 +73,6 @@ } } - @Override - public String toString() { - return "Map=" + lastMemorySnapshot.toString(); - } - public boolean isEmpty() { if (lastMemorySnapshot.size() == 0) { return true; @@ -192,7 +186,7 @@ assert MemoryCheckpoint.TypeAssertion.correctType(node) : node; if (execmode == ExecutionMode.ANALYSIS_ONLY && node instanceof ReturnNode) { - node.graph().add(new MemoryState(new MemoryMapImpl(state), node)); + ((ReturnNode) node).setMemoryMap(node.graph().unique(new MemoryMapImpl(state))); } return state; } diff -r 41a2a20d4949 -r f5faf49a86dd graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/InstanceOfSnippetsTemplates.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/InstanceOfSnippetsTemplates.java Mon Sep 30 16:36:24 2013 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/InstanceOfSnippetsTemplates.java Mon Sep 30 22:05:40 2013 +0200 @@ -206,7 +206,7 @@ } @Override - public void replace(ValueNode oldNode, ValueNode newNode, MemoryMap mmap) { + public void replace(ValueNode oldNode, ValueNode newNode, MemoryMapNode mmap) { assert newNode instanceof PhiNode; assert oldNode == instanceOf; newNode.inferStamp(); @@ -238,7 +238,7 @@ } @Override - public void replace(ValueNode oldNode, ValueNode newNode, MemoryMap mmap) { + public void replace(ValueNode oldNode, ValueNode newNode, MemoryMapNode mmap) { assert newNode instanceof PhiNode; assert oldNode == instanceOf; newNode.inferStamp(); diff -r 41a2a20d4949 -r f5faf49a86dd graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Mon Sep 30 16:36:24 2013 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Mon Sep 30 22:05:40 2013 +0200 @@ -552,7 +552,7 @@ StartNode entryPointNode = snippet.start(); nodes = new ArrayList<>(snippet.getNodeCount()); boolean seenReturn = false; - boolean containsMemoryState = false; + boolean containsMemoryMap = false; for (Node node : snippet.getNodes()) { if (node == entryPointNode || node == entryPointNode.stateAfter()) { // Do nothing. @@ -560,20 +560,20 @@ nodes.add(node); if (node instanceof ReturnNode) { retNode = (ReturnNode) node; - NodeIterable memstates = retNode.usages().filter(MemoryState.class); + NodeIterable memstates = retNode.inputs().filter(MemoryMapNode.class); assert memstates.count() == 1; - MemoryState memstate = memstates.first(); - this.memoryMap = memstate.getMemoryMap(); - memstate.safeDelete(); + memoryMap = memstates.first(); + retNode.replaceFirstInput(memoryMap, null); + memoryMap.safeDelete(); assert !seenReturn : "can handle only one ReturnNode"; seenReturn = true; - } else if (node instanceof MemoryState) { - containsMemoryState = true; + } else if (node instanceof MemoryMapNode) { + containsMemoryMap = true; } } } - assert !containsMemoryState; + assert !containsMemoryMap; this.sideEffectNodes = curSideEffectNodes; this.deoptNodes = curDeoptNodes; @@ -659,7 +659,7 @@ /** * map of killing locations to memory checkpoints (nodes). */ - private MemoryMap memoryMap; + private MemoryMapNode memoryMap; /** * Gets the instantiation-time bindings to this template's parameters. @@ -753,7 +753,7 @@ /** * Replaces all usages of {@code oldNode} with direct or indirect usages of {@code newNode}. */ - void replace(ValueNode oldNode, ValueNode newNode, MemoryMap mmap); + void replace(ValueNode oldNode, ValueNode newNode, MemoryMapNode mmap); } /** @@ -763,7 +763,7 @@ public static final UsageReplacer DEFAULT_REPLACER = new UsageReplacer() { @Override - public void replace(ValueNode oldNode, ValueNode newNode, MemoryMap mmap) { + public void replace(ValueNode oldNode, ValueNode newNode, MemoryMapNode mmap) { oldNode.replaceAtUsages(newNode); if (mmap == null || newNode == null) { return; @@ -830,7 +830,7 @@ return true; } - private class DuplicateMapper implements MemoryMap { + private class DuplicateMapper extends MemoryMapNode { Map duplicates; StartNode replaceeStart; @@ -917,7 +917,7 @@ returnValue = (ValueNode) duplicates.get(returnNode.result()); } Node returnDuplicate = duplicates.get(returnNode); - MemoryMap mmap = new DuplicateMapper(duplicates, replaceeGraph.start()); + MemoryMapNode mmap = new DuplicateMapper(duplicates, replaceeGraph.start()); if (returnValue == null && replacee.usages().isNotEmpty() && replacee instanceof MemoryCheckpoint) { replacer.replace(replacee, (ValueNode) returnDuplicate.predecessor(), mmap); } else {