annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeLoadNode.java @ 7090:05ce1defa4f9

Common out some parts of UnsafeLoad/Store in UnsafeAccess
author Gilles Duboscq <duboscq@ssw.jku.at>
date Thu, 29 Nov 2012 13:24:08 +0100
parents ccade022ec83
children 08fe3a509cf1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
23 package com.oracle.graal.nodes.extended;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
5507
dc71b06d09f8 Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5504
diff changeset
25 import com.oracle.graal.api.meta.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
26 import com.oracle.graal.nodes.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
27 import com.oracle.graal.nodes.spi.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
28 import com.oracle.graal.nodes.type.*;
7049
ccade022ec83 virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents: 6716
diff changeset
29 import com.oracle.graal.nodes.virtual.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
30
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
31 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
32 * Load of a value from a location specified as an offset relative to an object.
6716
536dbb4dd212 removed null check from UnsafeLoadNode, UnsafeStoreNode, ReadNode and WriteNode as it violates the sun.misc.Unsafe API
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
33 * No null check is performed before the load.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34 */
7090
05ce1defa4f9 Common out some parts of UnsafeLoad/Store in UnsafeAccess
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7049
diff changeset
35 public class UnsafeLoadNode extends UnsafeAccessNode implements Lowerable, Virtualizable {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
36
7090
05ce1defa4f9 Common out some parts of UnsafeLoad/Store in UnsafeAccess
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7049
diff changeset
37 public UnsafeLoadNode(ValueNode object, int displacement, ValueNode offset, boolean nonNull) {
05ce1defa4f9 Common out some parts of UnsafeLoad/Store in UnsafeAccess
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7049
diff changeset
38 this(nonNull ? StampFactory.objectNonNull() : StampFactory.object(), object, displacement, offset, Kind.Object);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
39 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
40
7090
05ce1defa4f9 Common out some parts of UnsafeLoad/Store in UnsafeAccess
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7049
diff changeset
41 public UnsafeLoadNode(ValueNode object, int displacement, ValueNode offset, Kind accessKind) {
05ce1defa4f9 Common out some parts of UnsafeLoad/Store in UnsafeAccess
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7049
diff changeset
42 this(StampFactory.forKind(accessKind.getStackKind()), object, displacement, offset, accessKind);
5464
1d00c9a1f733 support @NodeIntrinsic based creation of a UnsafeLoadNode with a stamp indicating non-nullness
Doug Simon <doug.simon@oracle.com>
parents: 5362
diff changeset
43 }
1d00c9a1f733 support @NodeIntrinsic based creation of a UnsafeLoadNode with a stamp indicating non-nullness
Doug Simon <doug.simon@oracle.com>
parents: 5362
diff changeset
44
7090
05ce1defa4f9 Common out some parts of UnsafeLoad/Store in UnsafeAccess
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7049
diff changeset
45 public UnsafeLoadNode(Stamp stamp, ValueNode object, int displacement, ValueNode offset, Kind accessKind) {
05ce1defa4f9 Common out some parts of UnsafeLoad/Store in UnsafeAccess
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7049
diff changeset
46 super(stamp, object, displacement, offset, accessKind);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
47 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
48
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
49 @Override
5718
10341299528c renamings: ExtendedRiRuntime -> GraalCodeCacheProvider, CiLoweringTool -> LoweringTool, RiGraphCache -> GraphCache
Doug Simon <doug.simon@oracle.com>
parents: 5540
diff changeset
50 public void lower(LoweringTool tool) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
51 tool.getRuntime().lower(this, tool);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
52 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
53
7049
ccade022ec83 virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents: 6716
diff changeset
54 @Override
ccade022ec83 virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents: 6716
diff changeset
55 public void virtualize(VirtualizerTool tool) {
ccade022ec83 virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents: 6716
diff changeset
56 VirtualObjectNode virtual = tool.getVirtualState(object());
ccade022ec83 virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents: 6716
diff changeset
57 if (virtual != null) {
ccade022ec83 virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents: 6716
diff changeset
58 ValueNode indexValue = tool.getReplacedValue(offset());
ccade022ec83 virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents: 6716
diff changeset
59 if (indexValue.isConstant()) {
ccade022ec83 virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents: 6716
diff changeset
60 int fieldIndex = virtual.fieldIndexForOffset(indexValue.asConstant().asLong());
ccade022ec83 virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents: 6716
diff changeset
61 if (fieldIndex != -1) {
ccade022ec83 virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents: 6716
diff changeset
62 ValueNode result = tool.getVirtualEntry(virtual, fieldIndex);
ccade022ec83 virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents: 6716
diff changeset
63 VirtualObjectNode virtualResult = tool.getVirtualState(result);
ccade022ec83 virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents: 6716
diff changeset
64 if (virtualResult != null) {
ccade022ec83 virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents: 6716
diff changeset
65 tool.replaceWithVirtual(virtualResult);
ccade022ec83 virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents: 6716
diff changeset
66 } else {
ccade022ec83 virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents: 6716
diff changeset
67 tool.replaceWithValue(result);
ccade022ec83 virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents: 6716
diff changeset
68 }
ccade022ec83 virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents: 6716
diff changeset
69 }
ccade022ec83 virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents: 6716
diff changeset
70 }
ccade022ec83 virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents: 6716
diff changeset
71 }
ccade022ec83 virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents: 6716
diff changeset
72 }
ccade022ec83 virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents: 6716
diff changeset
73
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
74 @NodeIntrinsic
6458
fb66841a0994 made all @NodeIntrinsic annotated methods be native (this is a requirement now enforced during snippet intrinsification)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
75 public static native <T> T load(Object object, @ConstantNodeParameter int displacement, long offset, @ConstantNodeParameter Kind kind);
5464
1d00c9a1f733 support @NodeIntrinsic based creation of a UnsafeLoadNode with a stamp indicating non-nullness
Doug Simon <doug.simon@oracle.com>
parents: 5362
diff changeset
76
1d00c9a1f733 support @NodeIntrinsic based creation of a UnsafeLoadNode with a stamp indicating non-nullness
Doug Simon <doug.simon@oracle.com>
parents: 5362
diff changeset
77 @NodeIntrinsic
6458
fb66841a0994 made all @NodeIntrinsic annotated methods be native (this is a requirement now enforced during snippet intrinsification)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
78 public static native Object loadObject(Object object, @ConstantNodeParameter int displacement, long offset, @ConstantNodeParameter boolean nonNull);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
79 }