Mercurial > hg > truffle
annotate graal/com.oracle.max.graal.nodes/src/com/oracle/graal/nodes/extended/UnboxNode.java @ 5059:ed559a528128
Perform renames on files.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Thu, 08 Mar 2012 17:57:30 +0100 |
parents | graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/UnboxNode.java@854145ec9866 |
children | 4ed4295ce15f |
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 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.max.graal.nodes.extended; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
4199
aaac4894175c
Renamed cri packages from sun to oracle.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
25 import com.oracle.max.cri.ci.*; |
aaac4894175c
Renamed cri packages from sun to oracle.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
26 import com.oracle.max.cri.ri.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
27 import com.oracle.max.graal.graph.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
28 import com.oracle.max.graal.nodes.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
29 import com.oracle.max.graal.nodes.java.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.max.graal.nodes.spi.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
31 import com.oracle.max.graal.nodes.type.*; |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
34 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
|
35 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
36 @Input private ValueNode source; |
4579
854145ec9866
Fix boxing elimination for boxed constants.
Andreas Woess <andreas.woess@jku.at>
parents:
4549
diff
changeset
|
37 @Data private CiKind destinationKind; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
38 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
39 public UnboxNode(CiKind kind, ValueNode source) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
40 super(StampFactory.forKind(kind)); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
41 this.source = source; |
4579
854145ec9866
Fix boxing elimination for boxed constants.
Andreas Woess <andreas.woess@jku.at>
parents:
4549
diff
changeset
|
42 this.destinationKind = kind; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
43 assert kind != CiKind.Object : "can only unbox to primitive"; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
44 assert source.kind() == CiKind.Object : "can only unbox objects"; |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
47 public ValueNode source() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
48 return source; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
49 } |
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 public CiKind destinationKind() { |
4579
854145ec9866
Fix boxing elimination for boxed constants.
Andreas Woess <andreas.woess@jku.at>
parents:
4549
diff
changeset
|
52 return destinationKind; |
3733
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
55 public void expand(BoxingMethodPool pool) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
56 RiResolvedField field = pool.getBoxField(kind()); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
57 LoadFieldNode loadField = graph().add(new LoadFieldNode(source, field)); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
58 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
|
59 ((StructuredGraph) graph()).replaceFixedWithFixed(this, loadField); |
3733
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
62 @Override |
4309
4a609a685fa4
changes to Node structures:
Lukas Stadler <lukas.stadler@jku.at>
parents:
4305
diff
changeset
|
63 public ValueNode canonical(CanonicalizerTool tool) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
64 if (source.isConstant()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
65 CiConstant constant = source.asConstant(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
66 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
|
67 if (o != null) { |
4579
854145ec9866
Fix boxing elimination for boxed constants.
Andreas Woess <andreas.woess@jku.at>
parents:
4549
diff
changeset
|
68 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
|
69 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
|
70 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
|
71 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
|
72 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
|
73 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
|
74 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
|
75 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
|
76 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
|
77 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
|
78 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
|
79 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
|
80 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
|
81 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
|
82 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
|
83 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
|
84 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
|
85 default: |
4579
854145ec9866
Fix boxing elimination for boxed constants.
Andreas Woess <andreas.woess@jku.at>
parents:
4549
diff
changeset
|
86 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
|
87 } |
3733
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 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
90 return this; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
91 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
92 } |