1 /* 2 * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. 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 */ 23 package org.graalvm.compiler.hotspot.nodes; 24 25 import static org.graalvm.compiler.hotspot.HotSpotBackend.FETCH_UNROLL_INFO; 26 import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_UNKNOWN; 27 import static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_UNKNOWN; 28 29 import org.graalvm.compiler.core.common.LocationIdentity; 30 import org.graalvm.compiler.core.common.spi.ForeignCallsProvider; 31 import org.graalvm.compiler.core.common.type.StampFactory; 32 import org.graalvm.compiler.graph.NodeClass; 33 import org.graalvm.compiler.hotspot.HotSpotLIRGenerator; 34 import org.graalvm.compiler.lir.StandardOp.SaveRegistersOp; 35 import org.graalvm.compiler.nodeinfo.InputType; 36 import org.graalvm.compiler.nodeinfo.NodeInfo; 37 import org.graalvm.compiler.nodes.FixedWithNextNode; 38 import org.graalvm.compiler.nodes.ValueNode; 39 import org.graalvm.compiler.nodes.memory.MemoryCheckpoint; 40 import org.graalvm.compiler.nodes.spi.LIRLowerable; 41 import org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool; 42 import org.graalvm.compiler.word.Word; 43 44 import jdk.vm.ci.meta.JavaKind; 45 import jdk.vm.ci.meta.Value; 46 47 /** 48 * A call to the runtime code {@code Deoptimization::fetch_unroll_info}. 49 */ 50 @NodeInfo(allowedUsageTypes = {InputType.Memory}, cycles = CYCLES_UNKNOWN, size = SIZE_UNKNOWN) 51 public final class DeoptimizationFetchUnrollInfoCallNode extends FixedWithNextNode implements LIRLowerable, MemoryCheckpoint.Single { 52 53 public static final NodeClass<DeoptimizationFetchUnrollInfoCallNode> TYPE = NodeClass.create(DeoptimizationFetchUnrollInfoCallNode.class); 54 @Input SaveAllRegistersNode registerSaver; 55 @Input ValueNode mode; 56 protected final ForeignCallsProvider foreignCalls; 57 58 public DeoptimizationFetchUnrollInfoCallNode(@InjectedNodeParameter ForeignCallsProvider foreignCalls, ValueNode registerSaver, ValueNode mode) { 59 super(TYPE, StampFactory.forKind(JavaKind.fromJavaClass(FETCH_UNROLL_INFO.getResultType()))); 60 this.registerSaver = (SaveAllRegistersNode) registerSaver; 61 this.mode = mode; 62 this.foreignCalls = foreignCalls; 63 } 64 65 @Override 66 public LocationIdentity getLocationIdentity() { 67 return LocationIdentity.any(); 68 } 69 70 public SaveRegistersOp getSaveRegistersOp() { 71 return registerSaver.getSaveRegistersOp(); 72 } 73 74 /** 75 * Returns the node representing the exec_mode/unpack_kind used during this fetch_unroll_info 76 * call. 77 */ 78 public ValueNode getMode() { 79 return mode; 80 } 81 82 @Override 83 public void generate(NodeLIRBuilderTool gen) { 84 Value result = ((HotSpotLIRGenerator) gen.getLIRGeneratorTool()).emitDeoptimizationFetchUnrollInfoCall(gen.operand(getMode()), getSaveRegistersOp()); 85 gen.setResult(this, result); 86 } 87 88 @NodeIntrinsic 89 public static native Word fetchUnrollInfo(long registerSaver, int mode); 90 }