43972
|
1 |
/*
|
|
2 |
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
20 |
* or visit www.oracle.com if you need additional information or have any
|
|
21 |
* questions.
|
|
22 |
*/
|
|
23 |
package org.graalvm.compiler.nodes.virtual;
|
|
24 |
|
|
25 |
import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_0;
|
|
26 |
import static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_0;
|
|
27 |
|
48861
|
28 |
import org.graalvm.compiler.core.common.spi.ArrayOffsetProvider;
|
43972
|
29 |
import org.graalvm.compiler.core.common.type.StampFactory;
|
|
30 |
import org.graalvm.compiler.core.common.type.TypeReference;
|
|
31 |
import org.graalvm.compiler.graph.IterableNodeType;
|
|
32 |
import org.graalvm.compiler.graph.Node;
|
|
33 |
import org.graalvm.compiler.graph.NodeClass;
|
|
34 |
import org.graalvm.compiler.nodeinfo.NodeInfo;
|
|
35 |
import org.graalvm.compiler.nodes.FixedNode;
|
|
36 |
import org.graalvm.compiler.nodes.ValueNode;
|
|
37 |
import org.graalvm.compiler.nodes.spi.LIRLowerable;
|
|
38 |
import org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool;
|
|
39 |
|
|
40 |
import jdk.vm.ci.meta.JavaKind;
|
|
41 |
import jdk.vm.ci.meta.ResolvedJavaType;
|
|
42 |
|
|
43 |
@NodeInfo(cycles = CYCLES_0, size = SIZE_0)
|
|
44 |
public abstract class VirtualObjectNode extends ValueNode implements LIRLowerable, IterableNodeType {
|
|
45 |
|
|
46 |
public static final NodeClass<VirtualObjectNode> TYPE = NodeClass.create(VirtualObjectNode.class);
|
|
47 |
protected boolean hasIdentity;
|
|
48 |
private int objectId = -1;
|
|
49 |
|
|
50 |
protected VirtualObjectNode(NodeClass<? extends VirtualObjectNode> c, ResolvedJavaType type, boolean hasIdentity) {
|
|
51 |
super(c, StampFactory.objectNonNull(TypeReference.createExactTrusted(type)));
|
|
52 |
this.hasIdentity = hasIdentity;
|
|
53 |
}
|
|
54 |
|
|
55 |
public final int getObjectId() {
|
|
56 |
return objectId;
|
|
57 |
}
|
|
58 |
|
|
59 |
public final void resetObjectId() {
|
|
60 |
this.objectId = -1;
|
|
61 |
}
|
|
62 |
|
|
63 |
public final void setObjectId(int objectId) {
|
|
64 |
assert objectId != -1;
|
|
65 |
this.objectId = objectId;
|
|
66 |
}
|
|
67 |
|
|
68 |
@Override
|
|
69 |
protected void afterClone(Node other) {
|
|
70 |
super.afterClone(other);
|
|
71 |
resetObjectId();
|
|
72 |
}
|
|
73 |
|
|
74 |
/**
|
|
75 |
* The type of object described by this {@link VirtualObjectNode}. In case of arrays, this is
|
|
76 |
* the array type (and not the component type).
|
|
77 |
*/
|
|
78 |
public abstract ResolvedJavaType type();
|
|
79 |
|
|
80 |
/**
|
|
81 |
* The number of entries this virtual object has. Either the number of fields or the number of
|
|
82 |
* array elements.
|
|
83 |
*/
|
|
84 |
public abstract int entryCount();
|
|
85 |
|
|
86 |
/**
|
|
87 |
* Returns the name of the entry at the given index. Only used for debugging purposes.
|
|
88 |
*/
|
|
89 |
public abstract String entryName(int i);
|
|
90 |
|
|
91 |
/**
|
|
92 |
* If the given index denotes an entry in this virtual object, the index of this entry is
|
|
93 |
* returned. If no such entry can be found, this method returns -1.
|
|
94 |
*
|
|
95 |
* @param constantOffset offset, where the value is placed.
|
|
96 |
* @param expectedEntryKind Specifies which type is expected at this offset (Is important when
|
|
97 |
* doing implicit casts, especially on big endian systems.
|
|
98 |
*/
|
48861
|
99 |
public abstract int entryIndexForOffset(ArrayOffsetProvider arrayOffsetProvider, long constantOffset, JavaKind expectedEntryKind);
|
43972
|
100 |
|
|
101 |
/**
|
|
102 |
* Returns the {@link JavaKind} of the entry at the given index.
|
|
103 |
*/
|
|
104 |
public abstract JavaKind entryKind(int index);
|
|
105 |
|
|
106 |
/**
|
|
107 |
* Returns an exact duplicate of this virtual object node, which has not been added to the graph
|
|
108 |
* yet.
|
|
109 |
*/
|
|
110 |
public abstract VirtualObjectNode duplicate();
|
|
111 |
|
|
112 |
/**
|
|
113 |
* Specifies whether this virtual object has an object identity. If not, then the result of a
|
|
114 |
* comparison of two virtual objects is determined by comparing their contents.
|
|
115 |
*/
|
|
116 |
public boolean hasIdentity() {
|
|
117 |
return hasIdentity;
|
|
118 |
}
|
|
119 |
|
|
120 |
public void setIdentity(boolean identity) {
|
|
121 |
this.hasIdentity = identity;
|
|
122 |
}
|
|
123 |
|
|
124 |
/**
|
|
125 |
* Returns a node that can be used to materialize this virtual object. If this returns an
|
|
126 |
* {@link AllocatedObjectNode} then this node will be attached to a {@link CommitAllocationNode}
|
|
127 |
* , otherwise the node will just be added to the graph.
|
|
128 |
*/
|
|
129 |
public abstract ValueNode getMaterializedRepresentation(FixedNode fixed, ValueNode[] entries, LockState locks);
|
|
130 |
|
|
131 |
@Override
|
|
132 |
public void generate(NodeLIRBuilderTool gen) {
|
|
133 |
// nothing to do...
|
|
134 |
}
|
|
135 |
}
|