Mercurial > hg > truffle
annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnboxNode.java @ 5541:b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sat, 09 Jun 2012 16:52:12 +0200 |
parents | a891c53a295b |
children | b6617d13ea44 |
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) 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.extended; |
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:
5504
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.java.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
29 import com.oracle.graal.nodes.spi.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
30 import com.oracle.graal.nodes.type.*; |
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 public final class UnboxNode extends FixedWithNextNode implements Node.IterableNodeType, Canonicalizable { |
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 @Input private ValueNode source; |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
36 private Kind destinationKind; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
37 |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
38 public UnboxNode(Kind kind, ValueNode source) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
39 super(StampFactory.forKind(kind)); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
40 this.source = source; |
4579
854145ec9866
Fix boxing elimination for boxed constants.
Andreas Woess <andreas.woess@jku.at>
parents:
4549
diff
changeset
|
41 this.destinationKind = kind; |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
42 assert kind != Kind.Object : "can only unbox to primitive"; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
43 assert source.kind() == Kind.Object : "can only unbox objects"; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
44 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
45 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
46 public ValueNode source() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
47 return source; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
48 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
49 |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
50 public Kind destinationKind() { |
4579
854145ec9866
Fix boxing elimination for boxed constants.
Andreas Woess <andreas.woess@jku.at>
parents:
4549
diff
changeset
|
51 return destinationKind; |
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 public void expand(BoxingMethodPool pool) { |
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:
5540
diff
changeset
|
55 ResolvedJavaField field = pool.getBoxField(kind()); |
5312
f8fc624c07a7
add leafGraphId to AccessFieldNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
5299
diff
changeset
|
56 LoadFieldNode loadField = graph().add(new LoadFieldNode(source, field, StructuredGraph.INVALID_GRAPH_ID)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
57 loadField.setProbability(probability()); |
4305
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4199
diff
changeset
|
58 ((StructuredGraph) graph()).replaceFixedWithFixed(this, loadField); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
59 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
60 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
61 @Override |
4309
4a609a685fa4
changes to Node structures:
Lukas Stadler <lukas.stadler@jku.at>
parents:
4305
diff
changeset
|
62 public ValueNode canonical(CanonicalizerTool tool) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
63 if (source.isConstant()) { |
5538
e18ba36bfebc
Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5507
diff
changeset
|
64 Constant constant = source.asConstant(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
65 Object o = constant.asObject(); |
4549
2bab0e314b5c
Fixed a bug in the canonicalizer of the UnboxNode (brought up by Truffle).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4309
diff
changeset
|
66 if (o != null) { |
4579
854145ec9866
Fix boxing elimination for boxed constants.
Andreas Woess <andreas.woess@jku.at>
parents:
4549
diff
changeset
|
67 switch (destinationKind) { |
4549
2bab0e314b5c
Fixed a bug in the canonicalizer of the UnboxNode (brought up by Truffle).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4309
diff
changeset
|
68 case Boolean: |
2bab0e314b5c
Fixed a bug in the canonicalizer of the UnboxNode (brought up by Truffle).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4309
diff
changeset
|
69 return ConstantNode.forBoolean((Boolean) o, graph()); |
2bab0e314b5c
Fixed a bug in the canonicalizer of the UnboxNode (brought up by Truffle).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4309
diff
changeset
|
70 case Byte: |
2bab0e314b5c
Fixed a bug in the canonicalizer of the UnboxNode (brought up by Truffle).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4309
diff
changeset
|
71 return ConstantNode.forByte((Byte) o, graph()); |
2bab0e314b5c
Fixed a bug in the canonicalizer of the UnboxNode (brought up by Truffle).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4309
diff
changeset
|
72 case Char: |
2bab0e314b5c
Fixed a bug in the canonicalizer of the UnboxNode (brought up by Truffle).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4309
diff
changeset
|
73 return ConstantNode.forChar((Character) o, graph()); |
2bab0e314b5c
Fixed a bug in the canonicalizer of the UnboxNode (brought up by Truffle).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4309
diff
changeset
|
74 case Short: |
2bab0e314b5c
Fixed a bug in the canonicalizer of the UnboxNode (brought up by Truffle).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4309
diff
changeset
|
75 return ConstantNode.forShort((Short) o, graph()); |
2bab0e314b5c
Fixed a bug in the canonicalizer of the UnboxNode (brought up by Truffle).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4309
diff
changeset
|
76 case Int: |
2bab0e314b5c
Fixed a bug in the canonicalizer of the UnboxNode (brought up by Truffle).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4309
diff
changeset
|
77 return ConstantNode.forInt((Integer) o, graph()); |
2bab0e314b5c
Fixed a bug in the canonicalizer of the UnboxNode (brought up by Truffle).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4309
diff
changeset
|
78 case Long: |
2bab0e314b5c
Fixed a bug in the canonicalizer of the UnboxNode (brought up by Truffle).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4309
diff
changeset
|
79 return ConstantNode.forLong((Long) o, graph()); |
2bab0e314b5c
Fixed a bug in the canonicalizer of the UnboxNode (brought up by Truffle).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4309
diff
changeset
|
80 case Float: |
2bab0e314b5c
Fixed a bug in the canonicalizer of the UnboxNode (brought up by Truffle).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4309
diff
changeset
|
81 return ConstantNode.forFloat((Long) o, graph()); |
2bab0e314b5c
Fixed a bug in the canonicalizer of the UnboxNode (brought up by Truffle).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4309
diff
changeset
|
82 case Double: |
2bab0e314b5c
Fixed a bug in the canonicalizer of the UnboxNode (brought up by Truffle).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4309
diff
changeset
|
83 return ConstantNode.forDouble((Long) o, graph()); |
2bab0e314b5c
Fixed a bug in the canonicalizer of the UnboxNode (brought up by Truffle).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4309
diff
changeset
|
84 default: |
4579
854145ec9866
Fix boxing elimination for boxed constants.
Andreas Woess <andreas.woess@jku.at>
parents:
4549
diff
changeset
|
85 ValueUtil.shouldNotReachHere(); |
4549
2bab0e314b5c
Fixed a bug in the canonicalizer of the UnboxNode (brought up by Truffle).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4309
diff
changeset
|
86 } |
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 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
89 return this; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
90 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
91 } |