Mercurial > hg > graal-compiler
changeset 23043:c00fc84509da
restructured monitorenter snippet for one test fewer on fast path and added marker node for that path
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 20 Nov 2015 06:42:41 +0100 |
parents | cbe35e56ae82 |
children | 17e704e362b5 |
files | graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/FastAcquireBiasedLockNode.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java |
diffstat | 2 files changed, 76 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/FastAcquireBiasedLockNode.java Fri Nov 20 06:42:41 2015 +0100 @@ -0,0 +1,58 @@ +/* + * Copyright (c) 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.hotspot.nodes; + +import com.oracle.graal.compiler.common.type.StampFactory; +import com.oracle.graal.graph.NodeClass; +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; + +/** + * Marks the control flow path where an object acquired a biased lock because the lock was already + * biased to the object on the current thread. + */ +@NodeInfo +public final class FastAcquireBiasedLockNode extends FixedWithNextNode implements LIRLowerable { + public static final NodeClass<FastAcquireBiasedLockNode> TYPE = NodeClass.create(FastAcquireBiasedLockNode.class); + + @Input ValueNode object; + + public FastAcquireBiasedLockNode(ValueNode object) { + super(TYPE, StampFactory.forVoid()); + this.object = object; + } + + public ValueNode object() { + return object; + } + + public void generate(NodeLIRBuilderTool generator) { + // This is just a marker node so it generates nothing + } + + @NodeIntrinsic + public static native void mark(Object object); +}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java Fri Nov 20 03:08:32 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java Fri Nov 20 06:42:41 2015 +0100 @@ -77,6 +77,7 @@ import com.oracle.graal.hotspot.meta.HotSpotRegistersProvider; import com.oracle.graal.hotspot.nodes.CurrentLockNode; import com.oracle.graal.hotspot.nodes.DirectCompareAndSwapNode; +import com.oracle.graal.hotspot.nodes.FastAcquireBiasedLockNode; import com.oracle.graal.hotspot.nodes.MonitorCounterNode; import com.oracle.graal.hotspot.word.KlassPointer; import com.oracle.graal.nodes.BreakpointNode; @@ -241,26 +242,27 @@ // pointers to allow age to be placed into low bits. final Word biasableLockBits = mark.and(biasedLockMaskInPlace()); - // First check to see whether biasing is enabled for this object + // Check whether the bias pattern is present in the object's mark word + // and the bias owner and the epoch are both still current. + final Word prototypeMarkWord = hub.readWord(prototypeMarkWordOffset(), PROTOTYPE_MARK_WORD_LOCATION); + final Word thread = registerAsWord(threadRegister); + final Word tmp = prototypeMarkWord.or(thread).xor(mark).and(~ageMaskInPlace()); + trace(trace, "prototypeMarkWord: 0x%016lx\n", prototypeMarkWord); + trace(trace, " thread: 0x%016lx\n", thread); + trace(trace, " tmp: 0x%016lx\n", tmp); + if (probability(FREQUENT_PROBABILITY, tmp.equal(0))) { + // Object is already biased to current thread -> done + traceObject(trace, "+lock{bias:existing}", object, true); + lockBiasExisting.inc(); + FastAcquireBiasedLockNode.mark(object); + return; + } + + // Now check to see whether biasing is enabled for this object if (probability(NOT_FREQUENT_PROBABILITY, biasableLockBits.notEqual(Word.unsigned(biasedLockPattern())))) { // Biasing not enabled -> fall through to lightweight locking unbiasable.inc(); } else { - // The bias pattern is present in the object's mark word. Need to check - // whether the bias owner and the epoch are both still current. - final Word prototypeMarkWord = hub.readWord(prototypeMarkWordOffset(), PROTOTYPE_MARK_WORD_LOCATION); - final Word thread = registerAsWord(threadRegister); - final Word tmp = prototypeMarkWord.or(thread).xor(mark).and(~ageMaskInPlace()); - trace(trace, "prototypeMarkWord: 0x%016lx\n", prototypeMarkWord); - trace(trace, " thread: 0x%016lx\n", thread); - trace(trace, " tmp: 0x%016lx\n", tmp); - if (probability(FREQUENT_PROBABILITY, tmp.equal(0))) { - // Object is already biased to current thread -> done - traceObject(trace, "+lock{bias:existing}", object, true); - lockBiasExisting.inc(); - return; - } - // At this point we know that the mark word has the bias pattern and // that we are not the bias owner in the current epoch. We need to // figure out more details about the state of the mark word in order to @@ -695,5 +697,4 @@ public static final SnippetCounter unlockCas = new SnippetCounter(unlockCounters, "unlock{cas}", "cas-unlocked an object"); public static final SnippetCounter unlockCasRecursive = new SnippetCounter(unlockCounters, "unlock{cas:recursive}", "cas-unlocked an object, recursive"); public static final SnippetCounter unlockStub = new SnippetCounter(unlockCounters, "unlock{stub}", "stub-unlocked an object"); - }