ResolveMethodAndLoadCountersStubCall.java revision 12651:6ef01bd40ce2
1156057Semax/* 2156057Semax * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. 3156057Semax * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4156057Semax * 5139749Simp * This code is free software; you can redistribute it and/or modify it 6137776Semax * under the terms of the GNU General Public License version 2 only, as 7137776Semax * published by the Free Software Foundation. 8137776Semax * 9137776Semax * This code is distributed in the hope that it will be useful, but WITHOUT 10137776Semax * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11137776Semax * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12137776Semax * version 2 for more details (a copy is included in the LICENSE file that 13137776Semax * accompanied this code). 14137776Semax * 15137776Semax * You should have received a copy of the GNU General Public License version 16137776Semax * 2 along with this work; if not, write to the Free Software Foundation, 17137776Semax * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18137776Semax * 19137776Semax * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20137776Semax * or visit www.oracle.com if you need additional information or have any 21137776Semax * questions. 22137776Semax */ 23137776Semaxpackage org.graalvm.compiler.hotspot.nodes.aot; 24137776Semax 25137776Semaximport jdk.vm.ci.meta.Constant; 26137776Semaximport jdk.vm.ci.meta.Value; 27137776Semax 28137776Semaximport static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_UNKNOWN; 29137776Semaximport static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_20; 30137776Semax 31137776Semaximport org.graalvm.compiler.graph.Node; 32137776Semaximport org.graalvm.compiler.graph.NodeClass; 33137776Semaximport org.graalvm.compiler.graph.spi.Canonicalizable; 34162711Sruimport org.graalvm.compiler.graph.spi.CanonicalizerTool; 35137776Semaximport org.graalvm.compiler.hotspot.HotSpotLIRGenerator; 36137776Semaximport org.graalvm.compiler.hotspot.nodes.DeoptimizingStubCall; 37137776Semaximport org.graalvm.compiler.hotspot.nodes.type.MethodCountersPointerStamp; 38137776Semaximport org.graalvm.compiler.hotspot.word.KlassPointer; 39139204Sphkimport org.graalvm.compiler.hotspot.word.MethodCountersPointer; 40137776Semaximport org.graalvm.compiler.hotspot.word.MethodPointer; 41137776Semaximport org.graalvm.compiler.lir.LIRFrameState; 42137776Semaximport org.graalvm.compiler.nodeinfo.NodeInfo; 43137776Semaximport org.graalvm.compiler.nodes.ValueNode; 44137776Semaximport org.graalvm.compiler.nodes.spi.LIRLowerable; 45137776Semaximport org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool; 46137776Semaximport org.graalvm.compiler.nodes.util.GraphUtil; 47137776Semax 48137776Semax/** 49137776Semax * A call to the VM via a regular stub. 50139204Sphk */ 51137776Semax@NodeInfo(cycles = CYCLES_UNKNOWN, size = SIZE_20) 52137776Semaxpublic class ResolveMethodAndLoadCountersStubCall extends DeoptimizingStubCall implements Canonicalizable, LIRLowerable { 53137776Semax public static final NodeClass<ResolveMethodAndLoadCountersStubCall> TYPE = NodeClass.create(ResolveMethodAndLoadCountersStubCall.class); 54137776Semax 55137776Semax @OptionalInput protected ValueNode method; 56137776Semax @Input protected ValueNode klassHint; 57137776Semax @Input protected ValueNode methodDescription; 58137776Semax protected Constant methodConstant; 59137776Semax 60137776Semax public ResolveMethodAndLoadCountersStubCall(ValueNode method, ValueNode klassHint, ValueNode methodDescription) { 61137776Semax super(TYPE, MethodCountersPointerStamp.methodCountersNonNull()); 62137776Semax this.klassHint = klassHint; 63137776Semax this.method = method; 64137776Semax this.methodDescription = methodDescription; 65137776Semax } 66137776Semax 67137776Semax @NodeIntrinsic 68137776Semax public static native MethodCountersPointer resolveMethodAndLoadCounters(MethodPointer method, KlassPointer klassHint, Object methodDescription); 69137776Semax 70156057Semax @Override 71156057Semax public Node canonical(CanonicalizerTool tool) { 72156057Semax if (method != null) { 73156057Semax methodConstant = GraphUtil.foldIfConstantAndRemove(this, method); 74156057Semax } 75156057Semax return this; 76156057Semax } 77137776Semax 78148246Semax @Override 79137776Semax public void generate(NodeLIRBuilderTool gen) { 80137776Semax assert methodConstant != null : "Expected method to fold: " + method; 81137776Semax 82137776Semax Value methodDescriptionValue = gen.operand(methodDescription); 83137776Semax Value klassHintValue = gen.operand(klassHint); 84137776Semax LIRFrameState fs = gen.state(this); 85156057Semax assert fs != null : "The stateAfter is null"; 86156057Semax 87156057Semax Value result = ((HotSpotLIRGenerator) gen.getLIRGeneratorTool()).emitResolveMethodAndLoadCounters(methodConstant, klassHintValue, methodDescriptionValue, fs); 88156057Semax 89156057Semax gen.setResult(this, result); 90156057Semax } 91156057Semax 92156057Semax} 93156057Semax