43972
|
1 |
/*
|
58877
|
2 |
* Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
|
43972
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
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
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
20 |
* or visit www.oracle.com if you need additional information or have any
|
|
21 |
* questions.
|
|
22 |
*/
|
50858
|
23 |
|
|
24 |
|
43972
|
25 |
package org.graalvm.compiler.nodes.java;
|
|
26 |
|
46393
|
27 |
import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_64;
|
|
28 |
import static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_64;
|
43972
|
29 |
|
|
30 |
import org.graalvm.compiler.core.common.type.ObjectStamp;
|
|
31 |
import org.graalvm.compiler.graph.IterableNodeType;
|
|
32 |
import org.graalvm.compiler.graph.NodeClass;
|
|
33 |
import org.graalvm.compiler.nodeinfo.NodeInfo;
|
48190
|
34 |
import org.graalvm.compiler.nodes.NodeView;
|
43972
|
35 |
import org.graalvm.compiler.nodes.ValueNode;
|
|
36 |
import org.graalvm.compiler.nodes.extended.MonitorEnter;
|
|
37 |
import org.graalvm.compiler.nodes.memory.MemoryCheckpoint;
|
|
38 |
import org.graalvm.compiler.nodes.spi.Lowerable;
|
|
39 |
import org.graalvm.compiler.nodes.spi.LoweringTool;
|
|
40 |
import org.graalvm.compiler.nodes.spi.Virtualizable;
|
|
41 |
import org.graalvm.compiler.nodes.spi.VirtualizerTool;
|
|
42 |
import org.graalvm.compiler.nodes.virtual.VirtualObjectNode;
|
49873
|
43 |
import jdk.internal.vm.compiler.word.LocationIdentity;
|
43972
|
44 |
|
|
45 |
/**
|
|
46 |
* The {@code RawMonitorEnterNode} represents the acquisition of a monitor. The object needs to
|
|
47 |
* already be non-null and the hub is an additional parameter to the node.
|
|
48 |
*/
|
|
49 |
// @formatter:off
|
46393
|
50 |
@NodeInfo(cycles = CYCLES_64,
|
43972
|
51 |
cyclesRationale = "Rough estimation of the enter operation",
|
46393
|
52 |
size = SIZE_64)
|
43972
|
53 |
// @formatter:on
|
|
54 |
public final class RawMonitorEnterNode extends AccessMonitorNode implements Virtualizable, Lowerable, IterableNodeType, MonitorEnter, MemoryCheckpoint.Single {
|
|
55 |
|
|
56 |
public static final NodeClass<RawMonitorEnterNode> TYPE = NodeClass.create(RawMonitorEnterNode.class);
|
|
57 |
|
|
58 |
@Input ValueNode hub;
|
|
59 |
|
|
60 |
public RawMonitorEnterNode(ValueNode object, ValueNode hub, MonitorIdNode monitorId) {
|
|
61 |
super(TYPE, object, monitorId);
|
48190
|
62 |
assert ((ObjectStamp) object.stamp(NodeView.DEFAULT)).nonNull();
|
43972
|
63 |
this.hub = hub;
|
|
64 |
}
|
|
65 |
|
|
66 |
@Override
|
58877
|
67 |
public LocationIdentity getKilledLocationIdentity() {
|
43972
|
68 |
return LocationIdentity.any();
|
|
69 |
}
|
|
70 |
|
|
71 |
@Override
|
|
72 |
public void lower(LoweringTool tool) {
|
|
73 |
tool.getLowerer().lower(this, tool);
|
|
74 |
}
|
|
75 |
|
|
76 |
@Override
|
|
77 |
public void virtualize(VirtualizerTool tool) {
|
|
78 |
ValueNode alias = tool.getAlias(object());
|
|
79 |
if (alias instanceof VirtualObjectNode) {
|
|
80 |
VirtualObjectNode virtual = (VirtualObjectNode) alias;
|
|
81 |
if (virtual.hasIdentity()) {
|
|
82 |
tool.addLock(virtual, getMonitorId());
|
|
83 |
tool.delete();
|
|
84 |
}
|
|
85 |
}
|
|
86 |
}
|
|
87 |
|
|
88 |
public ValueNode getHub() {
|
|
89 |
return hub;
|
|
90 |
}
|
|
91 |
}
|