annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewArrayNode.java @ 15261:882f4cb7cfcf

Move Stamps to graal.compiler.common.
author Josef Eisl <josef.eisl@jku.at>
date Tue, 22 Apr 2014 11:51:34 +0200
parents 61363577a184
children bca2ed3b97fd
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
13554
83fd2094ff66 rework of monitorenter/exit (use MonitorIdNode)
Lukas Stadler <lukas.stadler@jku.at>
parents: 13122
diff changeset
25 import java.util.*;
83fd2094ff66 rework of monitorenter/exit (use MonitorIdNode)
Lukas Stadler <lukas.stadler@jku.at>
parents: 13122
diff changeset
26
5507
dc71b06d09f8 Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5504
diff changeset
27 import com.oracle.graal.api.meta.*;
15261
882f4cb7cfcf Move Stamps to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15260
diff changeset
28 import com.oracle.graal.compiler.common.type.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
29 import com.oracle.graal.nodes.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
30 import com.oracle.graal.nodes.spi.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
31 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
32 import com.oracle.graal.nodes.virtual.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
33
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34 /**
10589
17c5cc84560b Factor out common code of NewArrayNode and DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 9880
diff changeset
35 * The {@code NewArrayNode} is used for all array allocations where the element type is know at
17c5cc84560b Factor out common code of NewArrayNode and DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 9880
diff changeset
36 * compile time.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
37 */
10589
17c5cc84560b Factor out common code of NewArrayNode and DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 9880
diff changeset
38 public class NewArrayNode extends AbstractNewArrayNode implements VirtualizableAllocation {
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 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
41 * Constructs a new NewArrayNode.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7394
diff changeset
42 *
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7394
diff changeset
43 * @param elementType the the type of the elements of the newly created array (not the type of
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7394
diff changeset
44 * the array itself).
6511
0b62a9d44c21 add infrastructure for creating locked objects
Lukas Stadler <lukas.stadler@jku.at>
parents: 6399
diff changeset
45 * @param length the node that produces the length for this allocation.
0b62a9d44c21 add infrastructure for creating locked objects
Lukas Stadler <lukas.stadler@jku.at>
parents: 6399
diff changeset
46 * @param fillContents determines whether the array elements should be initialized to 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 NewArrayNode(ResolvedJavaType elementType, ValueNode length, boolean fillContents) {
10589
17c5cc84560b Factor out common code of NewArrayNode and DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 9880
diff changeset
49 super(StampFactory.exactNonNull(elementType.getArrayClass()), length, fillContents);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
50 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
51
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
52 /**
5814
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5811
diff changeset
53 * Gets the element type of the array.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7394
diff changeset
54 *
5814
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5811
diff changeset
55 * @return the element type of the array
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5811
diff changeset
56 */
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5811
diff changeset
57 public ResolvedJavaType elementType() {
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 13554
diff changeset
58 return StampTool.typeOrNull(this).getComponentType();
5814
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5811
diff changeset
59 }
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5811
diff changeset
60
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
61 @Override
7394
94f032472c28 changed PEA interface:
Lukas Stadler <lukas.stadler@jku.at>
parents: 7007
diff changeset
62 public void virtualize(VirtualizerTool tool) {
6399
6ad5bf2efb5e cleanups, merge EscapeRecord and VirtualObjectNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 6393
diff changeset
63 if (length().asConstant() != null) {
6ad5bf2efb5e cleanups, merge EscapeRecord and VirtualObjectNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 6393
diff changeset
64 final int constantLength = length().asConstant().asInt();
7394
94f032472c28 changed PEA interface:
Lukas Stadler <lukas.stadler@jku.at>
parents: 7007
diff changeset
65 if (constantLength >= 0 && constantLength < tool.getMaximumEntryCount()) {
7006
51b6e594b0cd refactor EscapeAnalyzeable (remove EscapeOp)
Lukas Stadler <lukas.stadler@jku.at>
parents: 6666
diff changeset
66 ValueNode[] state = new ValueNode[constantLength];
13122
c6ab6ae1b360 Allow subclasses of NewInstanceNode and NewArrayNode to provide the default values used by escape analysis
Christian Wimmer <christian.wimmer@oracle.com>
parents: 10589
diff changeset
67 ConstantNode defaultForKind = constantLength == 0 ? null : defaultElementValue();
7006
51b6e594b0cd refactor EscapeAnalyzeable (remove EscapeOp)
Lukas Stadler <lukas.stadler@jku.at>
parents: 6666
diff changeset
68 for (int i = 0; i < constantLength; i++) {
51b6e594b0cd refactor EscapeAnalyzeable (remove EscapeOp)
Lukas Stadler <lukas.stadler@jku.at>
parents: 6666
diff changeset
69 state[i] = defaultForKind;
51b6e594b0cd refactor EscapeAnalyzeable (remove EscapeOp)
Lukas Stadler <lukas.stadler@jku.at>
parents: 6666
diff changeset
70 }
13122
c6ab6ae1b360 Allow subclasses of NewInstanceNode and NewArrayNode to provide the default values used by escape analysis
Christian Wimmer <christian.wimmer@oracle.com>
parents: 10589
diff changeset
71 VirtualObjectNode virtualObject = new VirtualArrayNode(elementType(), constantLength);
13554
83fd2094ff66 rework of monitorenter/exit (use MonitorIdNode)
Lukas Stadler <lukas.stadler@jku.at>
parents: 13122
diff changeset
72 tool.createVirtualObject(virtualObject, state, Collections.<MonitorIdNode> emptyList());
7394
94f032472c28 changed PEA interface:
Lukas Stadler <lukas.stadler@jku.at>
parents: 7007
diff changeset
73 tool.replaceWithVirtual(virtualObject);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
74 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
75 }
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
76 }
13122
c6ab6ae1b360 Allow subclasses of NewInstanceNode and NewArrayNode to provide the default values used by escape analysis
Christian Wimmer <christian.wimmer@oracle.com>
parents: 10589
diff changeset
77
c6ab6ae1b360 Allow subclasses of NewInstanceNode and NewArrayNode to provide the default values used by escape analysis
Christian Wimmer <christian.wimmer@oracle.com>
parents: 10589
diff changeset
78 /* Factored out in a separate method so that subclasses can override it. */
c6ab6ae1b360 Allow subclasses of NewInstanceNode and NewArrayNode to provide the default values used by escape analysis
Christian Wimmer <christian.wimmer@oracle.com>
parents: 10589
diff changeset
79 protected ConstantNode defaultElementValue() {
c6ab6ae1b360 Allow subclasses of NewInstanceNode and NewArrayNode to provide the default values used by escape analysis
Christian Wimmer <christian.wimmer@oracle.com>
parents: 10589
diff changeset
80 return ConstantNode.defaultForKind(elementType().getKind(), graph());
c6ab6ae1b360 Allow subclasses of NewInstanceNode and NewArrayNode to provide the default values used by escape analysis
Christian Wimmer <christian.wimmer@oracle.com>
parents: 10589
diff changeset
81 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
82 }