# HG changeset patch # User Doug Simon # Date 1347898322 -7200 # Node ID 258d3e0b5a656b43f3cf7d8b835b496f36e5e42e # Parent de36df0fcfc6d80ccd50f80bf81cd86cc05aecdb added support for placing breakpoints in snippets diff -r de36df0fcfc6 -r 258d3e0b5a65 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRegisterConfig.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRegisterConfig.java Mon Sep 17 16:32:51 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRegisterConfig.java Mon Sep 17 18:12:02 2012 +0200 @@ -119,15 +119,15 @@ return allParameterRegisters; } - private CallingConvention callingConvention(Kind[] types, Type type, TargetDescription target, boolean stackOnly) { - Value[] locations = new Value[types.length]; + private CallingConvention callingConvention(Kind[] kinds, Type type, TargetDescription target, boolean stackOnly) { + Value[] locations = new Value[kinds.length]; int currentGeneral = 0; int currentXMM = 0; int currentStackOffset = 0; - for (int i = 0; i < types.length; i++) { - final Kind kind = types[i]; + for (int i = 0; i < kinds.length; i++) { + final Kind kind = kinds[i]; switch (kind) { case Byte: diff -r de36df0fcfc6 -r 258d3e0b5a65 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/AMD64BreakpointOp.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/AMD64BreakpointOp.java Mon Sep 17 18:12:02 2012 +0200 @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.target.amd64; + +import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.lir.LIRInstruction.Opcode; +import com.oracle.graal.lir.amd64.*; +import com.oracle.graal.lir.asm.*; +import com.oracle.max.asm.target.amd64.*; + +/** + * Emits a breakpoint. + */ +@Opcode("BREAKPOINT") +public class AMD64BreakpointOp extends AMD64LIRInstruction { + + /** + * A set of values loaded into the Java ABI parameter locations (for inspection by a debugger). + */ + @Use({REG, STACK}) protected Value[] parameters; + + public AMD64BreakpointOp(Value[] parameters) { + this.parameters = parameters; + } + + @Override + public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler asm) { + asm.int3(); + } +} diff -r de36df0fcfc6 -r 258d3e0b5a65 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/HotSpotAMD64Backend.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/HotSpotAMD64Backend.java Mon Sep 17 16:32:51 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/HotSpotAMD64Backend.java Mon Sep 17 18:12:02 2012 +0200 @@ -27,6 +27,7 @@ import static com.oracle.max.asm.target.amd64.AMD64.*; import java.lang.reflect.*; +import java.util.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; @@ -106,6 +107,20 @@ } @Override + public void visitBreakpointNode(BreakpointNode i) { + Kind[] sig = new Kind[i.arguments.size()]; + int pos = 0; + for (ValueNode arg : i.arguments) { + sig[pos++] = arg.kind(); + } + + CallingConvention cc = frameMap.registerConfig.getCallingConvention(CallingConvention.Type.JavaCall, sig, target(), false); + List argList = visitInvokeArguments(cc, i.arguments); + Value[] parameters = argList.toArray(new Value[argList.size()]); + append(new AMD64BreakpointOp(parameters)); + } + + @Override public void visitExceptionObject(ExceptionObjectNode x) { HotSpotVMConfig config = ((HotSpotRuntime) runtime).config; RegisterValue thread = config.threadRegister.asValue(); diff -r de36df0fcfc6 -r 258d3e0b5a65 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/BreakpointNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/BreakpointNode.java Mon Sep 17 18:12:02 2012 +0200 @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.nodes; + +import com.oracle.graal.graph.*; +import com.oracle.graal.nodes.spi.*; +import com.oracle.graal.nodes.type.*; + +/** + * A node that results in a platform dependent breakpoint instruction being emitted. + * A number of arguments can be associated with such a node for placing values of + * interest in the Java ABI specified parameter locations corresponding to the + * kinds of the values. That is, the arguments are set up as if the breakpoint instruction + * was a call to a compiled Java method. + */ +public final class BreakpointNode extends FixedWithNextNode implements LIRLowerable { + + @Input + public final NodeInputList arguments; + + public BreakpointNode(ValueNode... arguments) { + super(StampFactory.forVoid()); + this.arguments = new NodeInputList<>(this, arguments); + } + + @Override + public void generate(LIRGeneratorTool gen) { + gen.visitBreakpointNode(this); + } +} diff -r de36df0fcfc6 -r 258d3e0b5a65 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java Mon Sep 17 16:32:51 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java Mon Sep 17 18:12:02 2012 +0200 @@ -102,6 +102,7 @@ public abstract void visitEndNode(EndNode i); public abstract void visitLoopEnd(LoopEndNode i); public abstract void visitSafepointNode(SafepointNode i); + public abstract void visitBreakpointNode(BreakpointNode i); public abstract void visitCompareAndSwap(CompareAndSwapNode i);