annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewInstanceNode.java @ 11496:b36028c30a81

Allow escape analysis to ignore object identity correctness for types marked via the CompilerDirectives.ValueType annotation.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Sun, 01 Sep 2013 19:46:15 +0200
parents 5bab3272bb82
children ae619d70bf4b
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) 2009, 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.java;
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: 5299
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.graph.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
27 import com.oracle.graal.nodes.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
28 import com.oracle.graal.nodes.spi.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
29 import com.oracle.graal.nodes.type.*;
6393
adf0879a41c1 more escape analysis infrastructure: change EscapeOp behavior, make MaterializeObjectNodes roots for escape analysis
Lukas Stadler <lukas.stadler@jku.at>
parents: 6356
diff changeset
30 import com.oracle.graal.nodes.virtual.*;
3733
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 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
33 * The {@code NewInstanceNode} represents the allocation of an instance class object.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34 */
5814
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
35 @NodeInfo(nameTemplate = "New {p#instanceClass/s}")
10670
5bab3272bb82 Make array allocations deoptimizing nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 9880
diff changeset
36 public final class NewInstanceNode extends DeoptimizingFixedWithNextNode implements Node.IterableNodeType, Canonicalizable, Lowerable, VirtualizableAllocation {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
37
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
38 private final ResolvedJavaType instanceClass;
6354
6a324c13cfff add fillContents property to New... nodes
Lukas Stadler <lukas.stadler@jku.at>
parents: 6286
diff changeset
39 private final boolean fillContents;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
40
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
41 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
42 * Constructs a NewInstanceNode.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7394
diff changeset
43 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
44 * @param type the class being allocated
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7394
diff changeset
45 * @param fillContents determines whether the new object's fields should be initialized to
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7394
diff changeset
46 * zero/null.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
47 */
9504
106f0a0acafa refactored monitor handling in EA: MonitorEnter/Exit is removed, not eliminated
Lukas Stadler <lukas.stadler@jku.at>
parents: 9497
diff changeset
48 public NewInstanceNode(ResolvedJavaType type, boolean fillContents) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
49 super(StampFactory.exactNonNull(type));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
50 this.instanceClass = type;
6354
6a324c13cfff add fillContents property to New... nodes
Lukas Stadler <lukas.stadler@jku.at>
parents: 6286
diff changeset
51 this.fillContents = fillContents;
3733
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
54 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
55 * Gets the instance class being allocated by this node.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7394
diff changeset
56 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
57 * @return the instance class allocated
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
58 */
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
59 public ResolvedJavaType instanceClass() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
60 return instanceClass;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
61 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
62
6511
0b62a9d44c21 add infrastructure for creating locked objects
Lukas Stadler <lukas.stadler@jku.at>
parents: 6462
diff changeset
63 /**
0b62a9d44c21 add infrastructure for creating locked objects
Lukas Stadler <lukas.stadler@jku.at>
parents: 6462
diff changeset
64 * @return <code>true</code> if the fields of the new object will be initialized.
0b62a9d44c21 add infrastructure for creating locked objects
Lukas Stadler <lukas.stadler@jku.at>
parents: 6462
diff changeset
65 */
6354
6a324c13cfff add fillContents property to New... nodes
Lukas Stadler <lukas.stadler@jku.at>
parents: 6286
diff changeset
66 public boolean fillContents() {
6a324c13cfff add fillContents property to New... nodes
Lukas Stadler <lukas.stadler@jku.at>
parents: 6286
diff changeset
67 return fillContents;
6a324c13cfff add fillContents property to New... nodes
Lukas Stadler <lukas.stadler@jku.at>
parents: 6286
diff changeset
68 }
6a324c13cfff add fillContents property to New... nodes
Lukas Stadler <lukas.stadler@jku.at>
parents: 6286
diff changeset
69
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
70 @Override
7575
e3e8090cb46a remove unused allocations during (full) canonicalization
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
71 public ValueNode canonical(CanonicalizerTool tool) {
e3e8090cb46a remove unused allocations during (full) canonicalization
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
72 if (usages().isEmpty()) {
e3e8090cb46a remove unused allocations during (full) canonicalization
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
73 return null;
e3e8090cb46a remove unused allocations during (full) canonicalization
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
74 } else {
e3e8090cb46a remove unused allocations during (full) canonicalization
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
75 return this;
e3e8090cb46a remove unused allocations during (full) canonicalization
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
76 }
e3e8090cb46a remove unused allocations during (full) canonicalization
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
77 }
e3e8090cb46a remove unused allocations during (full) canonicalization
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
78
e3e8090cb46a remove unused allocations during (full) canonicalization
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
79 @Override
9251
435bb9425124 added enum to Lowerable interface (before/after guard lowering)
Lukas Stadler <lukas.stadler@jku.at>
parents: 8398
diff changeset
80 public void lower(LoweringTool tool, LoweringType loweringType) {
9880
f7ec3ec8a03c HotSpotRuntime should decide when to lower which nodes, not the nodes themselves
Lukas Stadler <lukas.stadler@jku.at>
parents: 9504
diff changeset
81 tool.getRuntime().lower(this, tool);
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents: 5541
diff changeset
82 }
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents: 5541
diff changeset
83
6399
6ad5bf2efb5e cleanups, merge EscapeRecord and VirtualObjectNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 6393
diff changeset
84 @Override
7394
94f032472c28 changed PEA interface:
Lukas Stadler <lukas.stadler@jku.at>
parents: 7060
diff changeset
85 public void virtualize(VirtualizerTool tool) {
6399
6ad5bf2efb5e cleanups, merge EscapeRecord and VirtualObjectNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 6393
diff changeset
86 if (instanceClass != null) {
7060
06d5f450f32b rename: ResolvedJavaType.isArrayClass() -> ResolvedJavaType.isArray()
Doug Simon <doug.simon@oracle.com>
parents: 7013
diff changeset
87 assert !instanceClass().isArray();
11496
b36028c30a81 Allow escape analysis to ignore object identity correctness for types marked via the CompilerDirectives.ValueType annotation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10670
diff changeset
88 VirtualInstanceNode virtualObject = new VirtualInstanceNode(instanceClass(), true);
8398
2d1b0b20f89d small change VirtualInstanceNode constructor
Lukas Stadler <lukas.stadler@jku.at>
parents: 7728
diff changeset
89 ResolvedJavaField[] fields = virtualObject.getFields();
7006
51b6e594b0cd refactor EscapeAnalyzeable (remove EscapeOp)
Lukas Stadler <lukas.stadler@jku.at>
parents: 6666
diff changeset
90 ValueNode[] state = new ValueNode[fields.length];
51b6e594b0cd refactor EscapeAnalyzeable (remove EscapeOp)
Lukas Stadler <lukas.stadler@jku.at>
parents: 6666
diff changeset
91 for (int i = 0; i < state.length; i++) {
51b6e594b0cd refactor EscapeAnalyzeable (remove EscapeOp)
Lukas Stadler <lukas.stadler@jku.at>
parents: 6666
diff changeset
92 state[i] = ConstantNode.defaultForKind(fields[i].getType().getKind(), graph());
51b6e594b0cd refactor EscapeAnalyzeable (remove EscapeOp)
Lukas Stadler <lukas.stadler@jku.at>
parents: 6666
diff changeset
93 }
9504
106f0a0acafa refactored monitor handling in EA: MonitorEnter/Exit is removed, not eliminated
Lukas Stadler <lukas.stadler@jku.at>
parents: 9497
diff changeset
94 tool.createVirtualObject(virtualObject, state, null);
7394
94f032472c28 changed PEA interface:
Lukas Stadler <lukas.stadler@jku.at>
parents: 7060
diff changeset
95 tool.replaceWithVirtual(virtualObject);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
96 }
6393
adf0879a41c1 more escape analysis infrastructure: change EscapeOp behavior, make MaterializeObjectNodes roots for escape analysis
Lukas Stadler <lukas.stadler@jku.at>
parents: 6356
diff changeset
97 }
10670
5bab3272bb82 Make array allocations deoptimizing nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 9880
diff changeset
98
5bab3272bb82 Make array allocations deoptimizing nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 9880
diff changeset
99 @Override
5bab3272bb82 Make array allocations deoptimizing nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 9880
diff changeset
100 public boolean canDeoptimize() {
5bab3272bb82 Make array allocations deoptimizing nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 9880
diff changeset
101 return true;
5bab3272bb82 Make array allocations deoptimizing nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 9880
diff changeset
102 }
5bab3272bb82 Make array allocations deoptimizing nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 9880
diff changeset
103
5bab3272bb82 Make array allocations deoptimizing nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 9880
diff changeset
104 @Override
5bab3272bb82 Make array allocations deoptimizing nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 9880
diff changeset
105 public DeoptimizationReason getDeoptimizationReason() {
5bab3272bb82 Make array allocations deoptimizing nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 9880
diff changeset
106 return DeoptimizationReason.RuntimeConstraint;
5bab3272bb82 Make array allocations deoptimizing nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 9880
diff changeset
107 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
108 }