# HG changeset patch # User Gilles Duboscq # Date 1354191848 -3600 # Node ID 05ce1defa4f917a845962d5d38e29188a1da8f97 # Parent af30115c9d0eb02e402280cb8882d6452df1cf20 Common out some parts of UnsafeLoad/Store in UnsafeAccess diff -r af30115c9d0e -r 05ce1defa4f9 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Wed Nov 28 20:39:43 2012 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Thu Nov 29 13:24:08 2012 +0100 @@ -518,14 +518,14 @@ } else if (n instanceof UnsafeLoadNode) { UnsafeLoadNode load = (UnsafeLoadNode) n; assert load.kind() != Kind.Illegal; - IndexedLocationNode location = IndexedLocationNode.create(LocationNode.ANY_LOCATION, load.loadKind(), load.displacement(), load.offset(), graph, false); + IndexedLocationNode location = IndexedLocationNode.create(LocationNode.ANY_LOCATION, load.accessKind(), load.displacement(), load.offset(), graph, false); ReadNode memoryRead = graph.add(new ReadNode(load.object(), location, load.stamp())); // An unsafe read must not floating outside its block as may float above an explicit null check on its object. memoryRead.dependencies().add(BeginNode.prevBegin(load)); graph.replaceFixedWithFixed(load, memoryRead); } else if (n instanceof UnsafeStoreNode) { UnsafeStoreNode store = (UnsafeStoreNode) n; - IndexedLocationNode location = IndexedLocationNode.create(LocationNode.ANY_LOCATION, store.storeKind(), store.displacement(), store.offset(), graph, false); + IndexedLocationNode location = IndexedLocationNode.create(LocationNode.ANY_LOCATION, store.accessKind(), store.displacement(), store.offset(), graph, false); ValueNode object = store.object(); WriteNode write = graph.add(new WriteNode(object, store.value(), location)); write.setStateAfter(store.stateAfter()); diff -r af30115c9d0e -r 05ce1defa4f9 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeAccessNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeAccessNode.java Thu Nov 29 13:24:08 2012 +0100 @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2012, 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.api.meta.*; +import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.type.*; + + +public abstract class UnsafeAccessNode extends FixedWithNextNode { + @Input private ValueNode object; + @Input private ValueNode offset; + private final int displacement; + private final Kind accessKind; + + public UnsafeAccessNode(Stamp stamp, ValueNode object, int displacement, ValueNode offset, Kind accessKind) { + super(stamp); + assert accessKind != null; + this.object = object; + this.displacement = displacement; + this.offset = offset; + this.accessKind = accessKind; + } + + public ValueNode object() { + return object; + } + + public int displacement() { + return displacement; + } + + public ValueNode offset() { + return offset; + } + + public Kind accessKind() { + return accessKind; + } +} diff -r af30115c9d0e -r 05ce1defa4f9 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeLoadNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeLoadNode.java Wed Nov 28 20:39:43 2012 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeLoadNode.java Thu Nov 29 13:24:08 2012 +0100 @@ -32,43 +32,18 @@ * Load of a value from a location specified as an offset relative to an object. * No null check is performed before the load. */ -public class UnsafeLoadNode extends FixedWithNextNode implements Lowerable, Virtualizable { - - @Input private ValueNode object; - @Input private ValueNode offset; - private final int displacement; - private final Kind loadKind; +public class UnsafeLoadNode extends UnsafeAccessNode implements Lowerable, Virtualizable { - public ValueNode object() { - return object; - } - - public int displacement() { - return displacement; - } - - public ValueNode offset() { - return offset; + public UnsafeLoadNode(ValueNode object, int displacement, ValueNode offset, boolean nonNull) { + this(nonNull ? StampFactory.objectNonNull() : StampFactory.object(), object, displacement, offset, Kind.Object); } - public UnsafeLoadNode(ValueNode object, int displacement, ValueNode offset, boolean nonNull) { - super(nonNull ? StampFactory.objectNonNull() : StampFactory.object()); - this.object = object; - this.displacement = displacement; - this.offset = offset; - this.loadKind = Kind.Object; + public UnsafeLoadNode(ValueNode object, int displacement, ValueNode offset, Kind accessKind) { + this(StampFactory.forKind(accessKind.getStackKind()), object, displacement, offset, accessKind); } - public UnsafeLoadNode(ValueNode object, int displacement, ValueNode offset, Kind kind) { - super(StampFactory.forKind(kind.getStackKind())); - this.object = object; - this.displacement = displacement; - this.offset = offset; - this.loadKind = kind; - } - - public Kind loadKind() { - return loadKind; + public UnsafeLoadNode(Stamp stamp, ValueNode object, int displacement, ValueNode offset, Kind accessKind) { + super(stamp, object, displacement, offset, accessKind); } @Override diff -r af30115c9d0e -r 05ce1defa4f9 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeStoreNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeStoreNode.java Wed Nov 28 20:39:43 2012 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeStoreNode.java Thu Nov 29 13:24:08 2012 +0100 @@ -32,14 +32,20 @@ * Store of a value at a location specified as an offset relative to an object. * No null check is performed before the store. */ -public class UnsafeStoreNode extends FixedWithNextNode implements StateSplit, Lowerable, Virtualizable { +public class UnsafeStoreNode extends UnsafeAccessNode implements StateSplit, Lowerable, Virtualizable { + + @Input private ValueNode value; + @Input(notDataflow = true) private FrameState stateAfter; - @Input private ValueNode object; - @Input private ValueNode offset; - @Input private ValueNode value; - private final int displacement; - private final Kind storeKind; - @Input(notDataflow = true) private FrameState stateAfter; + public UnsafeStoreNode(ValueNode object, int displacement, ValueNode offset, ValueNode value, Kind accessKind) { + this(StampFactory.forVoid(), object, displacement, offset, value, accessKind); + } + + public UnsafeStoreNode(Stamp stamp, ValueNode object, int displacement, ValueNode offset, ValueNode value, Kind accessKind) { + super(stamp, object, displacement, offset, accessKind); + assert accessKind != Kind.Void && accessKind != Kind.Illegal; + this.value = value; + } public FrameState stateAfter() { return stateAfter; @@ -55,43 +61,10 @@ return true; } - public UnsafeStoreNode(ValueNode object, int displacement, ValueNode offset, ValueNode value, Kind kind) { - super(StampFactory.forVoid()); - assert kind != Kind.Void && kind != Kind.Illegal; - this.object = object; - this.displacement = displacement; - this.offset = offset; - this.value = value; - this.storeKind = kind; - } - - public ValueNode object() { - return object; - } - - public int displacement() { - return displacement; - } - - public ValueNode offset() { - return offset; - } - public ValueNode value() { return value; } - public Kind storeKind() { - return storeKind; - } - - @Override - public boolean verify() { - assertTrue(storeKind != null, "UnsafeStoreNode must have a store kind"); - assertTrue(object != null, "UnsafeStoreNode should have an object"); - return super.verify(); - } - @Override public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool);