Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/WriteNode.java @ 14945:b14cb2d9253d
Make compression and uncompression explicit in the high level graph.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Wed, 02 Apr 2014 15:26:58 +0200 |
parents | f6630873316b |
children | d5a1206e1923 |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
4314
9ce8594bedaf
Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
2 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. |
3733
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 |
9298
9ee5f3bfa755
Restructure load/store/lea LIR instructions.
Roland Schatz <roland.schatz@oracle.com>
parents:
9203
diff
changeset
|
25 import com.oracle.graal.api.meta.*; |
14714
b602356a9cfc
additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
13520
diff
changeset
|
26 import com.oracle.graal.graph.spi.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
27 import com.oracle.graal.nodes.*; |
9545
7931508747f5
Fix parameters of node intrinsics to use more specific Location and LocationIdentity types.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9526
diff
changeset
|
28 import com.oracle.graal.nodes.extended.LocationNode.Location; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
29 import com.oracle.graal.nodes.spi.*; |
9875
2c55e8c4a591
make ReadNode and WriteNode virtualizable
Lukas Stadler <lukas.stadler@jku.at>
parents:
9850
diff
changeset
|
30 import com.oracle.graal.nodes.virtual.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
31 |
5823
f238fe91dc7f
partial (non XIR) support for inlining virtual dispatch at call sites - still needs fixing
Doug Simon <doug.simon@oracle.com>
parents:
5443
diff
changeset
|
32 /** |
13289
1734954cc73d
Rename AccessNode to FixedAccessNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13153
diff
changeset
|
33 * Writes a given {@linkplain #value() value} a {@linkplain FixedAccessNode memory location}. |
5823
f238fe91dc7f
partial (non XIR) support for inlining virtual dispatch at call sites - still needs fixing
Doug Simon <doug.simon@oracle.com>
parents:
5443
diff
changeset
|
34 */ |
14945
b14cb2d9253d
Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
14888
diff
changeset
|
35 public final class WriteNode extends AbstractWriteNode implements LIRLowerable, Simplifiable, Virtualizable { |
10758
e82c28e94f08
Don't add G1 prebarrier if the written location is uninitialized.
Roland Schatz <roland.schatz@oracle.com>
parents:
10090
diff
changeset
|
36 |
10828
b05e1ff3aac0
Rename WriteBarrierType to BarrierType
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10821
diff
changeset
|
37 public WriteNode(ValueNode object, ValueNode value, ValueNode location, BarrierType barrierType, boolean compressible) { |
14945
b14cb2d9253d
Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
14888
diff
changeset
|
38 super(object, value, location, barrierType, compressible); |
10758
e82c28e94f08
Don't add G1 prebarrier if the written location is uninitialized.
Roland Schatz <roland.schatz@oracle.com>
parents:
10090
diff
changeset
|
39 } |
e82c28e94f08
Don't add G1 prebarrier if the written location is uninitialized.
Roland Schatz <roland.schatz@oracle.com>
parents:
10090
diff
changeset
|
40 |
10833
079513fc609e
Rename isInitialized to isInitialization (inverting semantics!).
Roland Schatz <roland.schatz@oracle.com>
parents:
10828
diff
changeset
|
41 public WriteNode(ValueNode object, ValueNode value, ValueNode location, BarrierType barrierType, boolean compressible, boolean initialization) { |
14945
b14cb2d9253d
Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
14888
diff
changeset
|
42 super(object, value, location, barrierType, compressible, initialization); |
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 @Override |
14888
f6630873316b
Rename NodeLIRGenerator (and related classes and interfaces) to NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents:
14850
diff
changeset
|
46 public void generate(NodeLIRBuiderTool gen) { |
9298
9ee5f3bfa755
Restructure load/store/lea LIR instructions.
Roland Schatz <roland.schatz@oracle.com>
parents:
9203
diff
changeset
|
47 Value address = location().generateAddress(gen, gen.operand(object())); |
13520
fb7b39f07232
Embed compressed constants when possible and use more efficient patterns for encoding
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13289
diff
changeset
|
48 // It's possible a constant was forced for other usages so inspect the value directly and |
fb7b39f07232
Embed compressed constants when possible and use more efficient patterns for encoding
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13289
diff
changeset
|
49 // use a constant if it can be directly stored. |
fb7b39f07232
Embed compressed constants when possible and use more efficient patterns for encoding
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13289
diff
changeset
|
50 Value v; |
14841
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
14836
diff
changeset
|
51 if (value().isConstant() && gen.getLIRGeneratorTool().canStoreConstant(value().asConstant(), isCompressible())) { |
13520
fb7b39f07232
Embed compressed constants when possible and use more efficient patterns for encoding
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13289
diff
changeset
|
52 v = value().asConstant(); |
fb7b39f07232
Embed compressed constants when possible and use more efficient patterns for encoding
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13289
diff
changeset
|
53 } else { |
fb7b39f07232
Embed compressed constants when possible and use more efficient patterns for encoding
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13289
diff
changeset
|
54 v = gen.operand(value()); |
fb7b39f07232
Embed compressed constants when possible and use more efficient patterns for encoding
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13289
diff
changeset
|
55 } |
14945
b14cb2d9253d
Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
14888
diff
changeset
|
56 PlatformKind writeKind = gen.getLIRGeneratorTool().getPlatformKind(value().stamp()); |
b14cb2d9253d
Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
14888
diff
changeset
|
57 gen.getLIRGeneratorTool().emitStore(writeKind, address, v, this); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
58 } |
6290
01d274503562
canonicalize reads and writes on null objects to deopts
Lukas Stadler <lukas.stadler@jku.at>
parents:
5823
diff
changeset
|
59 |
14714
b602356a9cfc
additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
13520
diff
changeset
|
60 @Override |
b602356a9cfc
additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
13520
diff
changeset
|
61 public void simplify(SimplifierTool tool) { |
b602356a9cfc
additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
13520
diff
changeset
|
62 if (object() instanceof PiNode && ((PiNode) object()).getGuard() == getGuard()) { |
b602356a9cfc
additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
13520
diff
changeset
|
63 setObject(((PiNode) object()).getOriginalValue()); |
b602356a9cfc
additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
13520
diff
changeset
|
64 } |
b602356a9cfc
additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
13520
diff
changeset
|
65 } |
b602356a9cfc
additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
13520
diff
changeset
|
66 |
6406
33dab7b4b006
Add snippet factory methods
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6290
diff
changeset
|
67 @NodeIntrinsic |
10828
b05e1ff3aac0
Rename WriteBarrierType to BarrierType
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10821
diff
changeset
|
68 public static native void writeMemory(Object object, Object value, Location location, @ConstantNodeParameter BarrierType barrierType, @ConstantNodeParameter boolean compressible); |
7864
b66a826acf4b
add location identity to MemoryCheckpoint and let WriteNode implement MemoryCheckpoint
Lukas Stadler <lukas.stadler@jku.at>
parents:
7861
diff
changeset
|
69 |
b66a826acf4b
add location identity to MemoryCheckpoint and let WriteNode implement MemoryCheckpoint
Lukas Stadler <lukas.stadler@jku.at>
parents:
7861
diff
changeset
|
70 @Override |
9875
2c55e8c4a591
make ReadNode and WriteNode virtualizable
Lukas Stadler <lukas.stadler@jku.at>
parents:
9850
diff
changeset
|
71 public void virtualize(VirtualizerTool tool) { |
2c55e8c4a591
make ReadNode and WriteNode virtualizable
Lukas Stadler <lukas.stadler@jku.at>
parents:
9850
diff
changeset
|
72 if (location() instanceof ConstantLocationNode) { |
2c55e8c4a591
make ReadNode and WriteNode virtualizable
Lukas Stadler <lukas.stadler@jku.at>
parents:
9850
diff
changeset
|
73 ConstantLocationNode constantLocation = (ConstantLocationNode) location(); |
2c55e8c4a591
make ReadNode and WriteNode virtualizable
Lukas Stadler <lukas.stadler@jku.at>
parents:
9850
diff
changeset
|
74 State state = tool.getObjectState(object()); |
2c55e8c4a591
make ReadNode and WriteNode virtualizable
Lukas Stadler <lukas.stadler@jku.at>
parents:
9850
diff
changeset
|
75 if (state != null && state.getState() == EscapeState.Virtual) { |
2c55e8c4a591
make ReadNode and WriteNode virtualizable
Lukas Stadler <lukas.stadler@jku.at>
parents:
9850
diff
changeset
|
76 VirtualObjectNode virtual = state.getVirtualObject(); |
2c55e8c4a591
make ReadNode and WriteNode virtualizable
Lukas Stadler <lukas.stadler@jku.at>
parents:
9850
diff
changeset
|
77 int entryIndex = virtual.entryIndexForOffset(constantLocation.getDisplacement()); |
2c55e8c4a591
make ReadNode and WriteNode virtualizable
Lukas Stadler <lukas.stadler@jku.at>
parents:
9850
diff
changeset
|
78 if (entryIndex != -1 && virtual.entryKind(entryIndex) == constantLocation.getValueKind()) { |
12617
bca33c3135de
PEA: support for unsafe stores of mismatching sizes, cleanup, documentation
Lukas Stadler <lukas.stadler@jku.at>
parents:
11661
diff
changeset
|
79 tool.setVirtualEntry(state, entryIndex, value(), false); |
9875
2c55e8c4a591
make ReadNode and WriteNode virtualizable
Lukas Stadler <lukas.stadler@jku.at>
parents:
9850
diff
changeset
|
80 tool.delete(); |
2c55e8c4a591
make ReadNode and WriteNode virtualizable
Lukas Stadler <lukas.stadler@jku.at>
parents:
9850
diff
changeset
|
81 } |
2c55e8c4a591
make ReadNode and WriteNode virtualizable
Lukas Stadler <lukas.stadler@jku.at>
parents:
9850
diff
changeset
|
82 } |
2c55e8c4a591
make ReadNode and WriteNode virtualizable
Lukas Stadler <lukas.stadler@jku.at>
parents:
9850
diff
changeset
|
83 } |
2c55e8c4a591
make ReadNode and WriteNode virtualizable
Lukas Stadler <lukas.stadler@jku.at>
parents:
9850
diff
changeset
|
84 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
85 } |