1 /* |
1 /* |
2 * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
42 */ |
42 */ |
43 @NodeInfo(nameTemplate = "Write#{p#location/s}") |
43 @NodeInfo(nameTemplate = "Write#{p#location/s}") |
44 public class WriteNode extends AbstractWriteNode implements LIRLowerableAccess, Canonicalizable { |
44 public class WriteNode extends AbstractWriteNode implements LIRLowerableAccess, Canonicalizable { |
45 |
45 |
46 public static final NodeClass<WriteNode> TYPE = NodeClass.create(WriteNode.class); |
46 public static final NodeClass<WriteNode> TYPE = NodeClass.create(WriteNode.class); |
|
47 private final boolean volatileAccess; |
47 |
48 |
48 public WriteNode(AddressNode address, LocationIdentity location, ValueNode value, BarrierType barrierType) { |
49 public WriteNode(AddressNode address, LocationIdentity location, ValueNode value, BarrierType barrierType, boolean volatileAccess) { |
49 super(TYPE, address, location, value, barrierType); |
50 super(TYPE, address, location, value, barrierType); |
|
51 this.volatileAccess = volatileAccess; |
50 } |
52 } |
51 |
53 |
52 protected WriteNode(NodeClass<? extends WriteNode> c, AddressNode address, LocationIdentity location, ValueNode value, BarrierType barrierType) { |
54 protected WriteNode(NodeClass<? extends WriteNode> c, AddressNode address, LocationIdentity location, ValueNode value, BarrierType barrierType) { |
53 super(c, address, location, value, barrierType); |
55 super(c, address, location, value, barrierType); |
|
56 this.volatileAccess = false; |
54 } |
57 } |
55 |
58 |
56 @Override |
59 @Override |
57 public void generate(NodeLIRBuilderTool gen) { |
60 public void generate(NodeLIRBuilderTool gen) { |
58 LIRKind writeKind = gen.getLIRGeneratorTool().getLIRKind(value().stamp(NodeView.DEFAULT)); |
61 LIRKind writeKind = gen.getLIRGeneratorTool().getLIRKind(value().stamp(NodeView.DEFAULT)); |
59 gen.getLIRGeneratorTool().getArithmetic().emitStore(writeKind, gen.operand(address), gen.operand(value()), gen.state(this)); |
62 gen.getLIRGeneratorTool().getArithmetic().emitStore(writeKind, gen.operand(address), gen.operand(value()), gen.state(this)); |
60 } |
63 } |
61 |
64 |
62 @Override |
65 @Override |
63 public boolean canNullCheck() { |
66 public boolean canNullCheck() { |
64 return true; |
67 return !isVolatile(); |
65 } |
68 } |
66 |
69 |
67 @Override |
70 @Override |
68 public Stamp getAccessStamp() { |
71 public Stamp getAccessStamp() { |
69 return value().stamp(NodeView.DEFAULT); |
72 return value().stamp(NodeView.DEFAULT); |
71 |
74 |
72 @Override |
75 @Override |
73 public Node canonical(CanonicalizerTool tool) { |
76 public Node canonical(CanonicalizerTool tool) { |
74 if (tool.canonicalizeReads() && hasExactlyOneUsage() && next() instanceof WriteNode) { |
77 if (tool.canonicalizeReads() && hasExactlyOneUsage() && next() instanceof WriteNode) { |
75 WriteNode write = (WriteNode) next(); |
78 WriteNode write = (WriteNode) next(); |
76 if (write.lastLocationAccess == this && write.getAddress() == getAddress() && getAccessStamp().isCompatible(write.getAccessStamp())) { |
79 if (write.lastLocationAccess == this && write.getAddress() == getAddress() && getAccessStamp().isCompatible(write.getAccessStamp()) && !isVolatile()) { |
77 write.setLastLocationAccess(getLastLocationAccess()); |
80 write.setLastLocationAccess(getLastLocationAccess()); |
78 return write; |
81 return write; |
79 } |
82 } |
80 } |
83 } |
81 return this; |
84 return this; |
82 } |
85 } |
|
86 |
|
87 @Override |
|
88 public LocationIdentity getKilledLocationIdentity() { |
|
89 if (isVolatile()) { |
|
90 return LocationIdentity.any(); |
|
91 } |
|
92 return getLocationIdentity(); |
|
93 } |
|
94 |
|
95 public boolean isVolatile() { |
|
96 return volatileAccess; |
|
97 } |
83 } |
98 } |