Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassGetSuperclassNode.java @ 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
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 15 Aug 2014 11:34:38 +0200 |
parents | 5d468add216f |
children | 06c15e88d383 |
rev | line source |
---|---|
10901
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 */ |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.hotspot.nodes; |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
11880
9a747d8e0d0f
broadened types in Canonicalizable interface so that it can be moved to the com.oracle.graal.graph project (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents:
11202
diff
changeset
|
25 import com.oracle.graal.graph.*; |
11881
da9db8331658
moved Canonicalizable and Simplifiable to the com.oracle.graal.graph project (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents:
11880
diff
changeset
|
26 import com.oracle.graal.graph.spi.*; |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
11959
diff
changeset
|
27 import com.oracle.graal.hotspot.meta.*; |
10902
4cda6853056e
added ClassGetComponentTypeNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
10901
diff
changeset
|
28 import com.oracle.graal.hotspot.replacements.*; |
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:
16811
diff
changeset
|
29 import com.oracle.graal.nodeinfo.*; |
10901
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.graal.nodes.*; |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
31 import com.oracle.graal.replacements.nodes.*; |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
32 |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
33 /** |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
34 * {@link MacroNode Macro node} for {@link Class#getSuperclass()}. |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
11959
diff
changeset
|
35 * |
10902
4cda6853056e
added ClassGetComponentTypeNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
10901
diff
changeset
|
36 * @see ClassSubstitutions#getSuperclass(Class) |
10901
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
37 */ |
16811
5d468add216f
added @NodeInfo annotations to all Node classes
Doug Simon <doug.simon@oracle.com>
parents:
16248
diff
changeset
|
38 @NodeInfo |
10904
4b8aa6386c12
removed redundant implements clause for Lowerable
Doug Simon <doug.simon@oracle.com>
parents:
10902
diff
changeset
|
39 public class ClassGetSuperclassNode extends MacroNode implements Canonicalizable { |
10901
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
40 |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
41 public ClassGetSuperclassNode(Invoke invoke) { |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
42 super(invoke); |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
43 } |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
44 |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
45 private ValueNode getJavaClass() { |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
46 return arguments.get(0); |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 } |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
48 |
11882
51059863da73
replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents:
11881
diff
changeset
|
49 @Override |
11880
9a747d8e0d0f
broadened types in Canonicalizable interface so that it can be moved to the com.oracle.graal.graph project (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents:
11202
diff
changeset
|
50 public Node canonical(CanonicalizerTool tool) { |
10901
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
51 ValueNode javaClass = getJavaClass(); |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
52 if (javaClass.isConstant()) { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
53 Class<?> c = (Class<?>) HotSpotObjectConstant.asObject(javaClass.asConstant()); |
11202
4c0f7b396be6
added receiver null check in canonicalization of java.lang.Class macro nodes
Doug Simon <doug.simon@oracle.com>
parents:
10904
diff
changeset
|
54 if (c != null) { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
55 Class<?> superclass = c.getSuperclass(); |
16248
c5b2a3c22318
refactor more Canonicalizable implementations to not add new nodes to the graph
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15040
diff
changeset
|
56 return ConstantNode.forConstant(HotSpotObjectConstant.forObject(superclass), tool.getMetaAccess()); |
11202
4c0f7b396be6
added receiver null check in canonicalization of java.lang.Class macro nodes
Doug Simon <doug.simon@oracle.com>
parents:
10904
diff
changeset
|
57 } |
10901
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
58 } |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
59 return this; |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
60 } |
2ed6b9c832be
added ClassGetSuperclassNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
61 } |