001/* 002 * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. 003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 004 * 005 * This code is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU General Public License version 2 only, as 007 * published by the Free Software Foundation. 008 * 009 * This code is distributed in the hope that it will be useful, but WITHOUT 010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 011 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 012 * version 2 for more details (a copy is included in the LICENSE file that 013 * accompanied this code). 014 * 015 * You should have received a copy of the GNU General Public License version 016 * 2 along with this work; if not, write to the Free Software Foundation, 017 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 018 * 019 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 020 * or visit www.oracle.com if you need additional information or have any 021 * questions. 022 */ 023package com.oracle.graal.nodes.java; 024 025import jdk.internal.jvmci.meta.*; 026 027import com.oracle.graal.compiler.common.type.*; 028import com.oracle.graal.graph.*; 029import com.oracle.graal.nodeinfo.*; 030import com.oracle.graal.nodes.*; 031import com.oracle.graal.nodes.extended.*; 032import com.oracle.graal.nodes.memory.*; 033import com.oracle.graal.nodes.spi.*; 034import com.oracle.graal.nodes.virtual.*; 035 036/** 037 * The {@code MonitorEnterNode} represents the acquisition of a monitor. The object needs already be 038 * non-null and the hub is an additional parameter to the node. 039 */ 040@NodeInfo 041public final class RawMonitorEnterNode extends AccessMonitorNode implements Virtualizable, Lowerable, IterableNodeType, MonitorEnter, MemoryCheckpoint.Single { 042 043 public static final NodeClass<RawMonitorEnterNode> TYPE = NodeClass.create(RawMonitorEnterNode.class); 044 045 @Input ValueNode hub; 046 047 public RawMonitorEnterNode(ValueNode object, ValueNode hub, MonitorIdNode monitorId) { 048 super(TYPE, object, monitorId); 049 assert ((ObjectStamp) object.stamp()).nonNull(); 050 this.hub = hub; 051 } 052 053 @Override 054 public LocationIdentity getLocationIdentity() { 055 return LocationIdentity.any(); 056 } 057 058 @Override 059 public void lower(LoweringTool tool) { 060 tool.getLowerer().lower(this, tool); 061 } 062 063 @Override 064 public void virtualize(VirtualizerTool tool) { 065 ValueNode alias = tool.getAlias(object()); 066 if (alias instanceof VirtualObjectNode) { 067 VirtualObjectNode virtual = (VirtualObjectNode) alias; 068 if (virtual.hasIdentity()) { 069 tool.addLock(virtual, getMonitorId()); 070 tool.delete(); 071 } 072 } 073 } 074 075 public ValueNode getHub() { 076 return hub; 077 } 078}