# HG changeset patch # User Doug Simon # Date 1334255592 -7200 # Node ID f9aae727d035c4072550e4e2706c31def5bd910e # Parent 15c857decc43ae0a689bad73ec2bb8ce00b5ec6b removed XIR safepoint operation diff -r 15c857decc43 -r f9aae727d035 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Thu Apr 12 17:27:04 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Thu Apr 12 20:33:12 2012 +0200 @@ -612,11 +612,11 @@ moveToPhi(end.merge(), end); } + /** + * Runtime specific classes can override this to insert a safepoint at the end of a loop. + */ @Override public void visitLoopEnd(LoopEndNode x) { - if (GraalOptions.GenLoopSafepoints && x.hasSafepointPolling()) { - emitSafepointPoll(x); - } } private ArrayList phiValues = new ArrayList<>(); @@ -662,14 +662,6 @@ } } - - public void emitSafepointPoll(FixedNode x) { - if (!lastState.method().noSafepointPolls()) { - XirSnippet snippet = xir.genSafepointPoll(site(x)); - emitXir(snippet, x, state(), false); - } - } - @Override public void emitIf(IfNode x) { assert x.defaultSuccessor() == x.falseSuccessor() : "wrong destination"; diff -r 15c857decc43 -r f9aae727d035 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotXirGenerator.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotXirGenerator.java Thu Apr 12 17:27:04 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotXirGenerator.java Thu Apr 12 20:33:12 2012 +0200 @@ -102,27 +102,6 @@ } } - private SimpleTemplates safepointTemplates = new SimpleTemplates() { - - @Override - protected XirTemplate create(CiXirAssembler asm, long flags) { - asm.restart(CiKind.Void); - - XirOperand temp = asm.createRegisterTemp("temp", target.wordKind, AMD64.r10); - if (config.isPollingPageFar) { - asm.mov(temp, wordConst(asm, config.safepointPollingAddress)); - asm.mark(MARK_POLL_FAR); - asm.pload(target.wordKind, temp, temp, true); - } else { - XirOperand rip = asm.createRegister("rip", target.wordKind, AMD64.rip); - asm.mark(MARK_POLL_NEAR); - asm.pload(target.wordKind, temp, rip, asm.i(0xEFBEADDE), true); - } - - return asm.finishTemplate("safepoint"); - } - }; - private SimpleTemplates exceptionObjectTemplates = new SimpleTemplates() { @Override @@ -864,11 +843,6 @@ }; @Override - public XirSnippet genSafepointPoll(XirSite site) { - return new XirSnippet(safepointTemplates.get(site)); - } - - @Override public XirSnippet genExceptionObject(XirSite site) { return new XirSnippet(exceptionObjectTemplates.get(site)); } diff -r 15c857decc43 -r f9aae727d035 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/AMD64SafepointOp.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/AMD64SafepointOp.java Thu Apr 12 20:33:12 2012 +0200 @@ -0,0 +1,70 @@ +/* + * 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.hotspot.ri.HotSpotXirGenerator.*; +import static com.oracle.max.asm.target.amd64.AMD64.*; + +import java.util.*; + +import com.oracle.graal.graph.*; +import com.oracle.graal.hotspot.*; +import com.oracle.graal.lir.*; +import com.oracle.graal.lir.amd64.*; +import com.oracle.graal.lir.asm.*; +import com.oracle.max.asm.target.amd64.*; +import com.oracle.max.cri.ci.*; + +/** + * Emits a safepoint poll. + */ +public class AMD64SafepointOp extends AMD64LIRInstruction { + + private final HotSpotVMConfig config; + + public AMD64SafepointOp(LIRDebugInfo info, HotSpotVMConfig config) { + super("SAFEPOINT", LIRInstruction.NO_OPERANDS, info, LIRInstruction.NO_OPERANDS, LIRInstruction.NO_OPERANDS, LIRInstruction.NO_OPERANDS); + this.config = config; + } + + @Override + public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler asm) { + CiRegister scratch = tasm.frameMap.registerConfig.getScratchRegister(); + int pos = asm.codeBuffer.position(); + if (config.isPollingPageFar) { + asm.movq(scratch, config.safepointPollingAddress); + tasm.recordMark(MARK_POLL_FAR); + tasm.recordSafepoint(pos, info); + asm.movq(scratch, new CiAddress(tasm.target.wordKind, scratch.asValue())); + } else { + tasm.recordMark(MARK_POLL_NEAR); + tasm.recordSafepoint(pos, info); + asm.movq(scratch, new CiAddress(tasm.target.wordKind, rip.asValue())); + } + } + + @Override + protected EnumSet flagsFor(OperandMode mode, int index) { + throw GraalInternalError.shouldNotReachHere(); + } +} diff -r 15c857decc43 -r f9aae727d035 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 Thu Apr 12 17:27:04 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/HotSpotAMD64Backend.java Thu Apr 12 20:33:12 2012 +0200 @@ -39,6 +39,7 @@ import com.oracle.graal.lir.*; import com.oracle.graal.lir.amd64.*; import com.oracle.graal.lir.asm.*; +import com.oracle.graal.nodes.*; import com.oracle.max.asm.*; import com.oracle.max.asm.target.amd64.*; import com.oracle.max.asm.target.amd64.AMD64Assembler.ConditionFlag; @@ -56,7 +57,17 @@ @Override public LIRGenerator newLIRGenerator(Graph graph, FrameMap frameMap, RiResolvedMethod method, LIR lir, RiXirGenerator xir) { - return new AMD64LIRGenerator(graph, runtime, target, frameMap, method, lir, xir); + return new AMD64LIRGenerator(graph, runtime, target, frameMap, method, lir, xir) { + @Override + public void visitLoopEnd(LoopEndNode x) { + if (GraalOptions.GenLoopSafepoints && x.hasSafepointPolling()) { + LIRDebugInfo info = state(); + if (!info.topFrame.method.noSafepointPolls()) { + append(new AMD64SafepointOp(info, ((HotSpotRuntime) runtime).config)); + } + } + } + }; } @Override diff -r 15c857decc43 -r f9aae727d035 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 Thu Apr 12 17:27:04 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java Thu Apr 12 20:33:12 2012 +0200 @@ -98,10 +98,6 @@ public abstract void visitEndNode(EndNode i); public abstract void visitLoopEnd(LoopEndNode i); - // The CompareAndSwapNode in its current form needs to be lowered to several Nodes before code generation to separate three parts: - // * The write barriers (and possibly read barriers) when accessing an object field - // * The distinction of returning a boolean value (semantic similar to a BooleanNode to be used as a condition?) or the old value being read - // * The actual compare-and-swap public abstract void visitCompareAndSwap(CompareAndSwapNode i); // Functionality that is currently implemented in XIR. diff -r 15c857decc43 -r f9aae727d035 graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/RiXirGenerator.java --- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/RiXirGenerator.java Thu Apr 12 17:27:04 2012 +0200 +++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/RiXirGenerator.java Thu Apr 12 20:33:12 2012 +0200 @@ -31,8 +31,6 @@ */ public interface RiXirGenerator { - XirSnippet genSafepointPoll(XirSite site); - XirSnippet genExceptionObject(XirSite site); XirSnippet genInvokeInterface(XirSite site, XirArgument receiver, RiMethod method);