Mercurial > hg > graal-compiler
changeset 23024:f2f031d9f896
Add GraalDirectives.spillRegisters().
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Wed, 18 Nov 2015 15:53:20 +0100 |
parents | af3e38798eba |
children | aa7f30dc77e2 |
files | graal/com.oracle.graal.api.directives/src/com/oracle/graal/api/directives/GraalDirectives.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/debug/SpillRegistersNode.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StandardGraphBuilderPlugins.java |
diffstat | 4 files changed, 84 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.directives/src/com/oracle/graal/api/directives/GraalDirectives.java Thu Nov 19 14:56:27 2015 +0100 +++ b/graal/com.oracle.graal.api.directives/src/com/oracle/graal/api/directives/GraalDirectives.java Wed Nov 18 15:53:20 2015 +0100 @@ -179,6 +179,12 @@ } /** + * Spills all caller saved registers. + */ + public static void spillRegisters() { + } + + /** * Do nothing, but also make sure the compiler doesn't do any optimizations across this call. * * For example, the compiler will constant fold the expression 5 * 3, but the expression 5 *
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java Thu Nov 19 14:56:27 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java Wed Nov 18 15:53:20 2015 +0100 @@ -380,6 +380,25 @@ } } + @Opcode("SPILLREGISTERS") + public static final class SpillRegistersOp extends LIRInstruction { + public static final LIRInstructionClass<SpillRegistersOp> TYPE = LIRInstructionClass.create(SpillRegistersOp.class); + + public SpillRegistersOp() { + super(TYPE); + } + + @Override + public boolean destroysCallerSavedRegisters() { + return true; + } + + @Override + public void emitCode(CompilationResultBuilder crb) { + // do nothing, just keep value alive until at least here + } + } + public static final class StackMove extends LIRInstruction implements ValueMoveOp { public static final LIRInstructionClass<StackMove> TYPE = LIRInstructionClass.create(StackMove.class);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/debug/SpillRegistersNode.java Wed Nov 18 15:53:20 2015 +0100 @@ -0,0 +1,50 @@ +/* + * 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.spi.LIRLowerable; +import com.oracle.graal.nodes.spi.NodeLIRBuilderTool; + +@NodeInfo +public final class SpillRegistersNode extends FixedWithNextNode implements LIRLowerable { + + public static final NodeClass<SpillRegistersNode> TYPE = NodeClass.create(SpillRegistersNode.class); + + protected Object unique; + + public SpillRegistersNode() { + super(TYPE, StampFactory.forVoid()); + // prevent control-flow optimization + this.unique = new Object(); + } + + @Override + public void generate(NodeLIRBuilderTool gen) { + gen.getLIRGeneratorTool().append(new StandardOp.SpillRegistersOp()); + } +}
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StandardGraphBuilderPlugins.java Thu Nov 19 14:56:27 2015 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StandardGraphBuilderPlugins.java Wed Nov 18 15:53:20 2015 +0100 @@ -69,6 +69,7 @@ import com.oracle.graal.nodes.debug.BlackholeNode; import com.oracle.graal.nodes.debug.ControlFlowAnchorNode; import com.oracle.graal.nodes.debug.OpaqueNode; +import com.oracle.graal.nodes.debug.SpillRegistersNode; import com.oracle.graal.nodes.extended.BoxNode; import com.oracle.graal.nodes.extended.BranchProbabilityNode; import com.oracle.graal.nodes.extended.GetClassNode; @@ -681,6 +682,14 @@ } } + InvocationPlugin spillPlugin = new InvocationPlugin() { + public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) { + b.add(new SpillRegistersNode()); + return true; + } + }; + r.register0("spillRegisters", spillPlugin); + r.register1("guardingNonNull", Object.class, new InvocationPlugin() { public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) { ObjectStamp objectStamp = (ObjectStamp) value.stamp();