# HG changeset patch # User Josef Eisl # Date 1447858264 -3600 # Node ID aa7f30dc77e27702623ddb10fc10c1a3dda28c2e # Parent f2f031d9f89645f5946d8daa7a53236664f0bd65 Add GraalDirectives.bindToRegister(). diff -r f2f031d9f896 -r aa7f30dc77e2 graal/com.oracle.graal.api.directives/src/com/oracle/graal/api/directives/GraalDirectives.java --- a/graal/com.oracle.graal.api.directives/src/com/oracle/graal/api/directives/GraalDirectives.java Wed Nov 18 15:53:20 2015 +0100 +++ b/graal/com.oracle.graal.api.directives/src/com/oracle/graal/api/directives/GraalDirectives.java Wed Nov 18 15:51:04 2015 +0100 @@ -179,6 +179,69 @@ } /** + * Forces a value to be kept in a register. + */ + @SuppressWarnings("unused") + public static void bindToRegister(boolean value) { + } + + /** + * Forces a value to be kept in a register. + */ + @SuppressWarnings("unused") + public static void bindToRegister(byte value) { + } + + /** + * Forces a value to be kept in a register. + */ + @SuppressWarnings("unused") + public static void bindToRegister(short value) { + } + + /** + * Forces a value to be kept in a register. + */ + @SuppressWarnings("unused") + public static void bindToRegister(char value) { + } + + /** + * Forces a value to be kept in a register. + */ + @SuppressWarnings("unused") + public static void bindToRegister(int value) { + } + + /** + * Forces a value to be kept in a register. + */ + @SuppressWarnings("unused") + public static void bindToRegister(long value) { + } + + /** + * Forces a value to be kept in a register. + */ + @SuppressWarnings("unused") + public static void bindToRegister(float value) { + } + + /** + * Forces a value to be kept in a register. + */ + @SuppressWarnings("unused") + public static void bindToRegister(double value) { + } + + /** + * Forces a value to be kept in a register. + */ + @SuppressWarnings("unused") + public static void bindToRegister(Object value) { + } + + /** * Spills all caller saved registers. */ public static void spillRegisters() { diff -r f2f031d9f896 -r aa7f30dc77e2 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java Wed Nov 18 15:53:20 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java Wed Nov 18 15:51:04 2015 +0100 @@ -380,6 +380,22 @@ } } + public static final class BindToRegisterOp extends LIRInstruction { + public static final LIRInstructionClass TYPE = LIRInstructionClass.create(BindToRegisterOp.class); + + @Use({REG}) private Value value; + + public BindToRegisterOp(Value value) { + super(TYPE); + this.value = value; + } + + @Override + public void emitCode(CompilationResultBuilder crb) { + // do nothing, just keep value alive until at least here + } + } + @Opcode("SPILLREGISTERS") public static final class SpillRegistersOp extends LIRInstruction { public static final LIRInstructionClass TYPE = LIRInstructionClass.create(SpillRegistersOp.class); diff -r f2f031d9f896 -r aa7f30dc77e2 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/debug/BindToRegisterNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/debug/BindToRegisterNode.java Wed Nov 18 15:51:04 2015 +0100 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2015, 2015, 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.debug; + +import com.oracle.graal.compiler.common.type.StampFactory; +import com.oracle.graal.graph.NodeClass; +import com.oracle.graal.lir.StandardOp; +import com.oracle.graal.nodeinfo.NodeInfo; +import com.oracle.graal.nodes.FixedWithNextNode; +import com.oracle.graal.nodes.ValueNode; +import com.oracle.graal.nodes.spi.LIRLowerable; +import com.oracle.graal.nodes.spi.NodeLIRBuilderTool; + +@NodeInfo +public final class BindToRegisterNode extends FixedWithNextNode implements LIRLowerable { + + public static final NodeClass TYPE = NodeClass.create(BindToRegisterNode.class); + @Input ValueNode value; + + public BindToRegisterNode(ValueNode value) { + super(TYPE, StampFactory.forVoid()); + this.value = value; + } + + @Override + public void generate(NodeLIRBuilderTool gen) { + gen.getLIRGeneratorTool().append(new StandardOp.BindToRegisterOp(gen.getLIRGeneratorTool().asAllocatable(gen.operand(value)))); + } +} diff -r f2f031d9f896 -r aa7f30dc77e2 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StandardGraphBuilderPlugins.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StandardGraphBuilderPlugins.java Wed Nov 18 15:53:20 2015 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StandardGraphBuilderPlugins.java Wed Nov 18 15:51:04 2015 +0100 @@ -66,6 +66,7 @@ import com.oracle.graal.nodes.calc.UnsignedDivNode; import com.oracle.graal.nodes.calc.UnsignedRemNode; import com.oracle.graal.nodes.calc.ZeroExtendNode; +import com.oracle.graal.nodes.debug.BindToRegisterNode; import com.oracle.graal.nodes.debug.BlackholeNode; import com.oracle.graal.nodes.debug.ControlFlowAnchorNode; import com.oracle.graal.nodes.debug.OpaqueNode; @@ -668,10 +669,17 @@ } }; + InvocationPlugin bindToRegisterPlugin = new InvocationPlugin() { + public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) { + b.add(new BindToRegisterNode(value)); + return true; + } + }; for (JavaKind kind : JavaKind.values()) { if ((kind.isPrimitive() && kind != JavaKind.Void) || kind == JavaKind.Object) { Class javaClass = kind == JavaKind.Object ? Object.class : kind.toJavaClass(); r.register1("blackhole", javaClass, blackholePlugin); + r.register1("bindToRegister", javaClass, bindToRegisterPlugin); r.register1("opaque", javaClass, new InvocationPlugin() { public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {