# HG changeset patch # User Thomas Wuerthinger # Date 1396540058 -7200 # Node ID 809870c0203e15b96af3edd037b176b07ba91e39 # Parent 4062efea018b687f24637cd9f2016644cf44774e# Parent a6bd51a7c14c68cb8042695fabc7940602524719 Merge. diff -r 4062efea018b -r 809870c0203e .hgignore --- a/.hgignore Thu Apr 03 17:47:29 2014 +0200 +++ b/.hgignore Thu Apr 03 17:47:38 2014 +0200 @@ -70,6 +70,7 @@ .idea/ ^cscope.out ^tags +graal.src.zip$ syntax: glob *.bgv core.* diff -r 4062efea018b -r 809870c0203e graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Thu Apr 03 17:47:29 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Thu Apr 03 17:47:38 2014 +0200 @@ -189,7 +189,8 @@ @Override public Variable emitForeignCall(ForeignCallLinkage linkage, DeoptimizingNode info, Value... args) { - boolean destroysRegisters = linkage.destroysRegisters(); + HotSpotForeignCallLinkage hotspotLinkage = (HotSpotForeignCallLinkage) linkage; + boolean destroysRegisters = hotspotLinkage.destroysRegisters(); AMD64SaveRegistersOp save = null; StackSlot[] savedRegisterLocations = null; @@ -210,15 +211,20 @@ } Variable result; + DeoptimizingNode deoptInfo = null; + if (hotspotLinkage.canDeoptimize()) { + deoptInfo = info; + assert deoptInfo != null || getStub() != null; + assert hotspotLinkage.needsJavaFrameAnchor(); + } - if (linkage.canDeoptimize()) { - assert info != null || ((AMD64HotSpotLIRGenerationResult) getResult()).getStub() != null; + if (hotspotLinkage.needsJavaFrameAnchor()) { Register thread = getProviders().getRegisters().getThreadRegister(); append(new AMD64HotSpotCRuntimeCallPrologueOp(config.threadLastJavaSpOffset(), thread)); - result = super.emitForeignCall(linkage, info, args); + result = super.emitForeignCall(hotspotLinkage, deoptInfo, args); append(new AMD64HotSpotCRuntimeCallEpilogueOp(config.threadLastJavaSpOffset(), config.threadLastJavaFpOffset(), thread)); } else { - result = super.emitForeignCall(linkage, info, args); + result = super.emitForeignCall(hotspotLinkage, deoptInfo, args); } if (destroysRegisters) { diff -r 4062efea018b -r 809870c0203e graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java Thu Apr 03 17:47:29 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java Thu Apr 03 17:47:38 2014 +0200 @@ -80,18 +80,23 @@ @Override public Variable emitForeignCall(ForeignCallLinkage linkage, DeoptimizingNode info, Value... args) { + HotSpotForeignCallLinkage hotspotLinkage = (HotSpotForeignCallLinkage) linkage; Variable result; + DeoptimizingNode deoptInfo = null; + if (hotspotLinkage.canDeoptimize()) { + deoptInfo = info; + assert deoptInfo != null || getStub() != null; + } - if (linkage.canDeoptimize()) { - assert info != null || getStub() != null; + if (hotspotLinkage.needsJavaFrameAnchor()) { HotSpotRegistersProvider registers = getProviders().getRegisters(); Register thread = registers.getThreadRegister(); Register stackPointer = registers.getStackPointerRegister(); append(new SPARCHotSpotCRuntimeCallPrologueOp(config.threadLastJavaSpOffset(), thread, stackPointer)); - result = super.emitForeignCall(linkage, info, args); + result = super.emitForeignCall(hotspotLinkage, deoptInfo, args); append(new SPARCHotSpotCRuntimeCallEpilogueOp(config.threadLastJavaSpOffset(), config.threadLastJavaPcOffset(), config.threadJavaFrameAnchorFlagsOffset(), thread)); } else { - result = super.emitForeignCall(linkage, null, args); + result = super.emitForeignCall(hotspotLinkage, deoptInfo, args); } return result; diff -r 4062efea018b -r 809870c0203e graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotForeignCallLinkage.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotForeignCallLinkage.java Thu Apr 03 17:47:29 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotForeignCallLinkage.java Thu Apr 03 17:47:38 2014 +0200 @@ -58,6 +58,7 @@ public enum Transition { LEAF_NOFP, LEAF, + LEAF_SP, NOT_LEAF; } @@ -110,7 +111,7 @@ /** * Creates a {@link HotSpotForeignCallLinkage}. - * + * * @param descriptor the descriptor of the call * @param address the address of the code to call * @param effect specifies if the call destroys or preserves all registers (apart from @@ -264,4 +265,8 @@ public boolean mayContainFP() { return transition != Transition.LEAF_NOFP; } + + public boolean needsJavaFrameAnchor() { + return canDeoptimize() || transition == Transition.LEAF_SP; + } } diff -r 4062efea018b -r 809870c0203e graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotHostForeignCallsProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotHostForeignCallsProvider.java Thu Apr 03 17:47:29 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotHostForeignCallsProvider.java Thu Apr 03 17:47:38 2014 +0200 @@ -27,7 +27,6 @@ import static com.oracle.graal.hotspot.HotSpotBackend.*; import static com.oracle.graal.hotspot.HotSpotForeignCallLinkage.RegisterEffect.*; import static com.oracle.graal.hotspot.HotSpotForeignCallLinkage.Transition.*; -import static com.oracle.graal.hotspot.nodes.MonitorExitStubCall.*; import static com.oracle.graal.hotspot.nodes.NewArrayStubCall.*; import static com.oracle.graal.hotspot.nodes.NewInstanceStubCall.*; import static com.oracle.graal.hotspot.nodes.NewMultiArrayStubCall.*; @@ -131,7 +130,7 @@ linkForeignCall(providers, CREATE_NULL_POINTER_EXCEPTION, c.createNullPointerExceptionAddress, PREPEND_THREAD, NOT_LEAF, REEXECUTABLE, ANY_LOCATION); linkForeignCall(providers, CREATE_OUT_OF_BOUNDS_EXCEPTION, c.createOutOfBoundsExceptionAddress, PREPEND_THREAD, NOT_LEAF, REEXECUTABLE, ANY_LOCATION); linkForeignCall(providers, MONITORENTER, c.monitorenterAddress, PREPEND_THREAD, NOT_LEAF, NOT_REEXECUTABLE, ANY_LOCATION); - linkForeignCall(providers, MONITOREXIT, c.monitorexitAddress, PREPEND_THREAD, NOT_LEAF, NOT_REEXECUTABLE, ANY_LOCATION); + linkForeignCall(providers, MONITOREXIT, c.monitorexitAddress, PREPEND_THREAD, LEAF_SP, NOT_REEXECUTABLE, ANY_LOCATION); linkForeignCall(providers, NEW_MULTI_ARRAY, c.newMultiArrayAddress, PREPEND_THREAD, NOT_LEAF, REEXECUTABLE, INIT_LOCATION); linkForeignCall(providers, DYNAMIC_NEW_ARRAY, c.dynamicNewArrayAddress, PREPEND_THREAD, NOT_LEAF, REEXECUTABLE, INIT_LOCATION); linkForeignCall(providers, DYNAMIC_NEW_INSTANCE, c.dynamicNewInstanceAddress, PREPEND_THREAD, NOT_LEAF, REEXECUTABLE, INIT_LOCATION); diff -r 4062efea018b -r 809870c0203e graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorExitStubCall.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorExitStubCall.java Thu Apr 03 17:47:29 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -/* - * Copyright (c) 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.nodes; - -import com.oracle.graal.api.code.*; -import com.oracle.graal.api.meta.*; -import com.oracle.graal.compiler.gen.*; -import com.oracle.graal.compiler.target.*; -import com.oracle.graal.hotspot.*; -import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.type.*; -import com.oracle.graal.word.*; - -/** - * Node implementing a call to {@code GraalRuntime::monitorexit}. - */ -public class MonitorExitStubCall extends DeoptimizingStubCall implements LIRGenLowerable { - - @Input private ValueNode object; - private int lockDepth; - public static final ForeignCallDescriptor MONITOREXIT = new ForeignCallDescriptor("monitorexit", void.class, Object.class, Word.class); - - public MonitorExitStubCall(ValueNode object, int lockDepth) { - super(StampFactory.forVoid()); - this.object = object; - this.lockDepth = lockDepth; - } - - @Override - public void generate(NodeLIRBuilder gen) { - assert lockDepth != -1; - HotSpotLIRGenerator hsGen = (HotSpotLIRGenerator) gen.getLIRGeneratorTool(); - StackSlot slot = hsGen.getLockSlot(lockDepth); - ForeignCallLinkage linkage = gen.getLIRGeneratorTool().getForeignCalls().lookupForeignCall(MonitorExitStubCall.MONITOREXIT); - gen.getLIRGeneratorTool().emitForeignCall(linkage, this, gen.operand(object), gen.getLIRGeneratorTool().emitAddress(slot)); - } - - @NodeIntrinsic - public static native void call(Object object, @ConstantNodeParameter int lockDepth); -} diff -r 4062efea018b -r 809870c0203e graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java Thu Apr 03 17:47:29 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java Thu Apr 03 17:47:38 2014 +0200 @@ -59,7 +59,7 @@ /** * Snippets used for implementing the monitorenter and monitorexit instructions. - * + * * The locking algorithm used is described in the paper Eliminating synchronization-related * atomic operations with biased locking and bulk rebiasing by Kenneth Russell and David @@ -325,7 +325,7 @@ // The object's mark word was not pointing to the displaced header, // we do unlocking via runtime call. traceObject(trace, "-lock{stub}", object, false); - MonitorExitStubCall.call(object, lockDepth); + monitorexitStub(MONITOREXIT, object, lock); } else { traceObject(trace, "-lock{cas}", object, false); } @@ -341,7 +341,8 @@ public static void monitorexitStub(Object object, @ConstantParameter int lockDepth, @ConstantParameter boolean trace) { verifyOop(object); traceObject(trace, "-lock{stub}", object, false); - MonitorExitStubCall.call(object, lockDepth); + final Word lock = CurrentLockNode.currentLock(lockDepth); + monitorexitStub(MONITOREXIT, object, lock); endLockScope(); decCounter(); } @@ -528,8 +529,12 @@ } public static final ForeignCallDescriptor MONITORENTER = new ForeignCallDescriptor("monitorenter", void.class, Object.class, Word.class); + public static final ForeignCallDescriptor MONITOREXIT = new ForeignCallDescriptor("monitorexit", void.class, Object.class, Word.class); @NodeIntrinsic(ForeignCallNode.class) private static native void monitorenterStub(@ConstantNodeParameter ForeignCallDescriptor descriptor, Object object, Word lock); + @NodeIntrinsic(ForeignCallNode.class) + private static native void monitorexitStub(@ConstantNodeParameter ForeignCallDescriptor descriptor, Object object, Word lock); + }