Mercurial > hg > truffle
changeset 10437:1fb21605c0e1
Common base class for nodes that need array range barriers.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Thu, 20 Jun 2013 16:59:58 +0200 |
parents | 8c8285e345cc |
children | 6a847d44d4ef |
files | graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/WriteBarrierAdditionPhase.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GenericArrayRangeWriteBarrier.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ArrayRangeWriteNode.java |
diffstat | 3 files changed, 78 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/WriteBarrierAdditionPhase.java Thu Jun 20 16:59:56 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/WriteBarrierAdditionPhase.java Thu Jun 20 16:59:58 2013 +0200 @@ -41,8 +41,13 @@ for (CompareAndSwapNode node : graph.getNodes(CompareAndSwapNode.class)) { addCASBarriers(node, graph); } + for (ArrayRangeWriteNode node : graph.getNodes(ArrayRangeWriteNode.class)) { + if (node.isObjectArray()) { + addArrayRangeBarriers(node, graph); + } + } for (GenericArrayRangeWriteBarrier node : graph.getNodes(GenericArrayRangeWriteBarrier.class)) { - addArrayRangeBarriers(node, graph); + graph.removeFixed(node); } } @@ -69,9 +74,9 @@ } } - private static void addArrayRangeBarriers(GenericArrayRangeWriteBarrier node, StructuredGraph graph) { - SerialArrayRangeWriteBarrier serialArrayRangeWriteBarrier = graph.add(new SerialArrayRangeWriteBarrier(node.getDstObject(), node.getDstPos(), node.getLength())); - graph.replaceFixedWithFixed(node, serialArrayRangeWriteBarrier); + private static void addArrayRangeBarriers(ArrayRangeWriteNode node, StructuredGraph graph) { + SerialArrayRangeWriteBarrier serialArrayRangeWriteBarrier = graph.add(new SerialArrayRangeWriteBarrier(node.getArray(), node.getIndex(), node.getLength())); + graph.addAfterFixed(node, serialArrayRangeWriteBarrier); } }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GenericArrayRangeWriteBarrier.java Thu Jun 20 16:59:56 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GenericArrayRangeWriteBarrier.java Thu Jun 20 16:59:58 2013 +0200 @@ -23,26 +23,35 @@ package com.oracle.graal.nodes; import com.oracle.graal.graph.*; +import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.type.*; -public final class GenericArrayRangeWriteBarrier extends FixedWithNextNode implements Node.IterableNodeType { +public final class GenericArrayRangeWriteBarrier extends ArrayRangeWriteNode implements Node.IterableNodeType { @Input private ValueNode dstObject; @Input private ValueNode dstPos; @Input private ValueNode length; - public ValueNode getDstObject() { + @Override + public ValueNode getArray() { return dstObject; } - public ValueNode getDstPos() { + @Override + public ValueNode getIndex() { return dstPos; } + @Override public ValueNode getLength() { return length; } + @Override + public boolean isObjectArray() { + return true; + } + public GenericArrayRangeWriteBarrier(ValueNode dstObject, ValueNode dstPos, ValueNode length) { super(StampFactory.forVoid()); this.dstObject = dstObject;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ArrayRangeWriteNode.java Thu Jun 20 16:59:58 2013 +0200 @@ -0,0 +1,57 @@ +/* + * 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.extended; + +import com.oracle.graal.graph.*; +import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.type.*; + +/** + * Base class for nodes that modify a range of an array. + */ +public abstract class ArrayRangeWriteNode extends AbstractStateSplit implements Node.IterableNodeType { + + protected ArrayRangeWriteNode(Stamp stamp) { + super(stamp); + } + + /** + * The array that is written to. + */ + public abstract ValueNode getArray(); + + /** + * The first modified index. + */ + public abstract ValueNode getIndex(); + + /** + * The length of the modified range. + */ + public abstract ValueNode getLength(); + + /** + * Return true if the written array is an object array, false if it is a primitive array. + */ + public abstract boolean isObjectArray(); +}