Mercurial > hg > truffle
annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewArrayNode.java @ 16957:27b40d2f8f8a
relaxed access control from package to protected for elements that need to be accessed in generated subclasses in disjoint packages
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 26 Aug 2014 23:44:31 +0200 |
parents | 0fe4732e5181 |
children | 1a02fc45776f |
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.*; |
16841
cbd42807a31f
moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
Doug Simon <doug.simon@oracle.com>
parents:
16822
diff
changeset
|
29 import com.oracle.graal.nodeinfo.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
30 import com.oracle.graal.nodes.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
31 import com.oracle.graal.nodes.spi.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
32 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
|
33 import com.oracle.graal.nodes.virtual.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
34 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
35 /** |
10589
17c5cc84560b
Factor out common code of NewArrayNode and DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
9880
diff
changeset
|
36 * 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
|
37 * compile time. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
38 */ |
16822
5d468add216f
added @NodeInfo annotations to all Node classes
Doug Simon <doug.simon@oracle.com>
parents:
16028
diff
changeset
|
39 @NodeInfo |
10589
17c5cc84560b
Factor out common code of NewArrayNode and DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
9880
diff
changeset
|
40 public class NewArrayNode extends AbstractNewArrayNode implements VirtualizableAllocation { |
3733
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 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
43 * Constructs a new NewArrayNode. |
16028
bca2ed3b97fd
skip initialization and use arraycopy for cloning arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15261
diff
changeset
|
44 * |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7394
diff
changeset
|
45 * @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
|
46 * the array itself). |
6511
0b62a9d44c21
add infrastructure for creating locked objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
6399
diff
changeset
|
47 * @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
|
48 * @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
|
49 */ |
16895
06c15e88d383
added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents:
16841
diff
changeset
|
50 public static NewArrayNode create(ResolvedJavaType elementType, ValueNode length, boolean fillContents) { |
16919
0fe4732e5181
made use of generated Node classes predicated on value of graal.useGeneratedNodes system property (default is false)
Doug Simon <doug.simon@oracle.com>
parents:
16895
diff
changeset
|
51 return USE_GENERATED_NODES ? new NewArrayNodeGen(elementType, length, fillContents) : new NewArrayNode(elementType, length, fillContents); |
16895
06c15e88d383
added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents:
16841
diff
changeset
|
52 } |
06c15e88d383
added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents:
16841
diff
changeset
|
53 |
16957
27b40d2f8f8a
relaxed access control from package to protected for elements that need to be accessed in generated subclasses in disjoint packages
Doug Simon <doug.simon@oracle.com>
parents:
16919
diff
changeset
|
54 protected 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
|
55 super(StampFactory.exactNonNull(elementType.getArrayClass()), length, fillContents); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
56 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
57 |
16028
bca2ed3b97fd
skip initialization and use arraycopy for cloning arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15261
diff
changeset
|
58 @NodeIntrinsic |
bca2ed3b97fd
skip initialization and use arraycopy for cloning arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15261
diff
changeset
|
59 static private native Object newArray(@ConstantNodeParameter Class<?> elementType, int length, @ConstantNodeParameter boolean fillContents); |
bca2ed3b97fd
skip initialization and use arraycopy for cloning arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15261
diff
changeset
|
60 |
bca2ed3b97fd
skip initialization and use arraycopy for cloning arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15261
diff
changeset
|
61 public static Object newUninitializedArray(Class<?> elementType, int length) { |
bca2ed3b97fd
skip initialization and use arraycopy for cloning arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15261
diff
changeset
|
62 return newArray(elementType, length, false); |
bca2ed3b97fd
skip initialization and use arraycopy for cloning arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15261
diff
changeset
|
63 } |
bca2ed3b97fd
skip initialization and use arraycopy for cloning arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15261
diff
changeset
|
64 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
65 /** |
5814
d241f8b2e6f9
Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5811
diff
changeset
|
66 * Gets the element type of the array. |
16028
bca2ed3b97fd
skip initialization and use arraycopy for cloning arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15261
diff
changeset
|
67 * |
5814
d241f8b2e6f9
Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5811
diff
changeset
|
68 * @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
|
69 */ |
d241f8b2e6f9
Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5811
diff
changeset
|
70 public ResolvedJavaType elementType() { |
15260
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
13554
diff
changeset
|
71 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
|
72 } |
d241f8b2e6f9
Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5811
diff
changeset
|
73 |
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
|
74 @Override |
7394
94f032472c28
changed PEA interface:
Lukas Stadler <lukas.stadler@jku.at>
parents:
7007
diff
changeset
|
75 public void virtualize(VirtualizerTool tool) { |
6399
6ad5bf2efb5e
cleanups, merge EscapeRecord and VirtualObjectNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
6393
diff
changeset
|
76 if (length().asConstant() != null) { |
6ad5bf2efb5e
cleanups, merge EscapeRecord and VirtualObjectNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
6393
diff
changeset
|
77 final int constantLength = length().asConstant().asInt(); |
7394
94f032472c28
changed PEA interface:
Lukas Stadler <lukas.stadler@jku.at>
parents:
7007
diff
changeset
|
78 if (constantLength >= 0 && constantLength < tool.getMaximumEntryCount()) { |
7006
51b6e594b0cd
refactor EscapeAnalyzeable (remove EscapeOp)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6666
diff
changeset
|
79 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
|
80 ConstantNode defaultForKind = constantLength == 0 ? null : defaultElementValue(); |
7006
51b6e594b0cd
refactor EscapeAnalyzeable (remove EscapeOp)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6666
diff
changeset
|
81 for (int i = 0; i < constantLength; i++) { |
51b6e594b0cd
refactor EscapeAnalyzeable (remove EscapeOp)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6666
diff
changeset
|
82 state[i] = defaultForKind; |
51b6e594b0cd
refactor EscapeAnalyzeable (remove EscapeOp)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6666
diff
changeset
|
83 } |
16895
06c15e88d383
added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents:
16841
diff
changeset
|
84 VirtualObjectNode virtualObject = VirtualArrayNode.create(elementType(), constantLength); |
13554
83fd2094ff66
rework of monitorenter/exit (use MonitorIdNode)
Lukas Stadler <lukas.stadler@jku.at>
parents:
13122
diff
changeset
|
85 tool.createVirtualObject(virtualObject, state, Collections.<MonitorIdNode> emptyList()); |
7394
94f032472c28
changed PEA interface:
Lukas Stadler <lukas.stadler@jku.at>
parents:
7007
diff
changeset
|
86 tool.replaceWithVirtual(virtualObject); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
87 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
88 } |
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
|
89 } |
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
|
90 |
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
|
91 /* 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
|
92 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
|
93 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
|
94 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
95 } |