Mercurial > hg > truffle
annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnboxNode.java @ 7660:0b646334c5f7
keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Fri, 01 Feb 2013 17:32:59 +0100 |
parents | 5e3d1a68664e |
children | 653110156f8a |
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 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
|
33 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
34 @Input private ValueNode source; |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
35 private Kind destinationKind; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
36 |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
37 public UnboxNode(Kind kind, ValueNode source) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
38 super(StampFactory.forKind(kind)); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
39 this.source = source; |
4579
854145ec9866
Fix boxing elimination for boxed constants.
Andreas Woess <andreas.woess@jku.at>
parents:
4549
diff
changeset
|
40 this.destinationKind = kind; |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
41 assert kind != Kind.Object : "can only unbox to primitive"; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
42 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
|
43 } |
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 public ValueNode source() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
46 return source; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
47 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
48 |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
49 public Kind destinationKind() { |
4579
854145ec9866
Fix boxing elimination for boxed constants.
Andreas Woess <andreas.woess@jku.at>
parents:
4549
diff
changeset
|
50 return destinationKind; |
3733
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
53 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
|
54 ResolvedJavaField field = pool.getBoxField(kind()); |
7660
0b646334c5f7
keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
55 LoadFieldNode loadField = graph().add(new LoadFieldNode(source, field)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
56 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
|
57 ((StructuredGraph) graph()).replaceFixedWithFixed(this, loadField); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
58 } |
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 @Override |
4309
4a609a685fa4
changes to Node structures:
Lukas Stadler <lukas.stadler@jku.at>
parents:
4305
diff
changeset
|
61 public ValueNode canonical(CanonicalizerTool tool) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
62 if (source.isConstant()) { |
5538
e18ba36bfebc
Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5507
diff
changeset
|
63 Constant constant = source.asConstant(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
64 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
|
65 if (o != null) { |
4579
854145ec9866
Fix boxing elimination for boxed constants.
Andreas Woess <andreas.woess@jku.at>
parents:
4549
diff
changeset
|
66 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
|
67 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
|
68 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
|
69 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
|
70 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
|
71 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
|
72 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
|
73 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
|
74 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
|
75 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
|
76 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
|
77 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
|
78 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
|
79 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
|
80 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
|
81 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
|
82 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
|
83 default: |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
84 ValueNodeUtil.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
|
85 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
86 } |
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 return this; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
89 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
90 } |