1 /* 2 * Copyright (c) 2011, 2018, 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 24 25 package org.graalvm.compiler.nodes; 26 27 import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_IGNORED; 28 import static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_IGNORED; 29 30 import org.graalvm.compiler.core.common.type.StampFactory; 31 import org.graalvm.compiler.graph.NodeClass; 32 import org.graalvm.compiler.graph.NodeInputList; 33 import org.graalvm.compiler.nodeinfo.NodeInfo; 34 import org.graalvm.compiler.nodes.spi.LIRLowerable; 35 import org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool; 36 37 /** 38 * A node that results in a platform dependent breakpoint instruction being emitted. A number of 39 * arguments can be associated with such a node for placing values of interest in the Java ABI 40 * specified parameter locations corresponding to the kinds of the values. That is, the arguments 41 * are set up as if the breakpoint instruction was a call to a compiled Java method. 42 * <p> 43 * A breakpoint is usually place by defining a node intrinsic method as follows: 44 * 45 * <pre> 46 * {@literal @}NodeIntrinsic(BreakpointNode.class) 47 * static void breakpoint(Object object, Word mark, Word value) { 48 * throw new GraalError(""); 49 * } 50 * </pre> 51 * 52 * Note that the signature is arbitrary. It's sole purpose is to capture values you may want to 53 * inspect in the native debugger when the breakpoint is hit. 54 */ 55 @NodeInfo(cycles = CYCLES_IGNORED, size = SIZE_IGNORED) 56 public final class BreakpointNode extends FixedWithNextNode implements LIRLowerable { 57 58 public static final NodeClass<BreakpointNode> TYPE = NodeClass.create(BreakpointNode.class); 59 @Input NodeInputList<ValueNode> arguments; 60 BreakpointNode(ValueNode... arguments)61 public BreakpointNode(ValueNode... arguments) { 62 super(TYPE, StampFactory.forVoid()); 63 this.arguments = new NodeInputList<>(this, arguments); 64 } 65 66 @Override generate(NodeLIRBuilderTool gen)67 public void generate(NodeLIRBuilderTool gen) { 68 gen.visitBreakpointNode(this); 69 } 70 arguments()71 public NodeInputList<ValueNode> arguments() { 72 return arguments; 73 } 74 75 @NodeIntrinsic breakpoint()76 public static native void breakpoint(); 77 } 78