8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 25 package org.graalvm.compiler.hotspot.replacements; 26 27 import static jdk.vm.ci.code.MemoryBarriers.LOAD_STORE; 28 import static jdk.vm.ci.code.MemoryBarriers.STORE_STORE; 29 import static org.graalvm.compiler.hotspot.GraalHotSpotVMConfig.INJECTED_OPTIONVALUES; 30 import static org.graalvm.compiler.hotspot.GraalHotSpotVMConfig.INJECTED_VMCONFIG; 31 import static org.graalvm.compiler.hotspot.nodes.AcquiredCASLockNode.mark; 32 import static org.graalvm.compiler.hotspot.nodes.BeginLockScopeNode.beginLockScope; 33 import static org.graalvm.compiler.hotspot.nodes.EndLockScopeNode.endLockScope; 34 import static org.graalvm.compiler.hotspot.nodes.VMErrorNode.vmError; 35 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.DISPLACED_MARK_WORD_LOCATION; 36 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.MARK_WORD_LOCATION; 37 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.OBJECT_MONITOR_CXQ_LOCATION; 38 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.OBJECT_MONITOR_ENTRY_LIST_LOCATION; 39 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.OBJECT_MONITOR_OWNER_LOCATION; 40 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.OBJECT_MONITOR_RECURSION_LOCATION; 41 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.PROTOTYPE_MARK_WORD_LOCATION; 42 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.ageMaskInPlace; 43 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.biasedLockMaskInPlace; 44 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.biasedLockPattern; 45 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.epochMaskInPlace; 46 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.loadWordFromObject; 47 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.lockDisplacedMarkOffset; 48 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.markOffset; 49 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.monitorMask; 50 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.objectMonitorCxqOffset; 51 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.objectMonitorEntryListOffset; 52 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.objectMonitorOwnerOffset; 53 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.objectMonitorRecursionsOffset; 54 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.pageSize; 55 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.prototypeMarkWordOffset; 56 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.registerAsWord; 57 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.stackBias; 58 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.unlockedMask; 59 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.useBiasedLocking; 60 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.verifyOop; 61 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.wordSize; 62 import static org.graalvm.compiler.hotspot.replacements.HotspotSnippetsOptions.ProfileMonitors; 63 import static org.graalvm.compiler.hotspot.replacements.HotspotSnippetsOptions.SimpleFastInflatedLocking; 64 import static org.graalvm.compiler.hotspot.replacements.HotspotSnippetsOptions.TraceMonitorsMethodFilter; 65 import static org.graalvm.compiler.hotspot.replacements.HotspotSnippetsOptions.TraceMonitorsTypeFilter; 66 import static org.graalvm.compiler.hotspot.replacements.HotspotSnippetsOptions.VerifyBalancedMonitors; 67 import static org.graalvm.compiler.nodes.extended.BranchProbabilityNode.FAST_PATH_PROBABILITY; 68 import static org.graalvm.compiler.nodes.extended.BranchProbabilityNode.FREQUENT_PROBABILITY; 69 import static org.graalvm.compiler.nodes.extended.BranchProbabilityNode.NOT_FREQUENT_PROBABILITY; 70 import static org.graalvm.compiler.nodes.extended.BranchProbabilityNode.NOT_LIKELY_PROBABILITY; 71 import static org.graalvm.compiler.nodes.extended.BranchProbabilityNode.SLOW_PATH_PROBABILITY; 72 import static org.graalvm.compiler.nodes.extended.BranchProbabilityNode.VERY_FAST_PATH_PROBABILITY; 73 import static org.graalvm.compiler.nodes.extended.BranchProbabilityNode.probability; 557 int ownerOffset = objectMonitorOwnerOffset(INJECTED_VMCONFIG); 558 Word owner = monitor.readWord(ownerOffset, OBJECT_MONITOR_OWNER_LOCATION); 559 int recursionsOffset = objectMonitorRecursionsOffset(INJECTED_VMCONFIG); 560 Word recursions = monitor.readWord(recursionsOffset, OBJECT_MONITOR_RECURSION_LOCATION); 561 Word thread = registerAsWord(threadRegister); 562 if (probability(FAST_PATH_PROBABILITY, owner.xor(thread).or(recursions).equal(0))) { 563 // owner == thread && recursions == 0 564 int cxqOffset = objectMonitorCxqOffset(INJECTED_VMCONFIG); 565 Word cxq = monitor.readWord(cxqOffset, OBJECT_MONITOR_CXQ_LOCATION); 566 int entryListOffset = objectMonitorEntryListOffset(INJECTED_VMCONFIG); 567 Word entryList = monitor.readWord(entryListOffset, OBJECT_MONITOR_ENTRY_LIST_LOCATION); 568 if (probability(FREQUENT_PROBABILITY, cxq.or(entryList).equal(0))) { 569 // cxq == 0 && entryList == 0 570 // Nobody is waiting, success 571 // release_store 572 memoryBarrier(LOAD_STORE | STORE_STORE); 573 monitor.writeWord(ownerOffset, zero()); 574 traceObject(trace, "-lock{inflated:simple}", object, false); 575 counters.unlockInflatedSimple.inc(); 576 return true; 577 } 578 } 579 counters.unlockStubInflated.inc(); 580 traceObject(trace, "-lock{stub:inflated}", object, false); 581 monitorexitStubC(MONITOREXIT, object, lock); 582 return true; 583 } 584 return false; 585 } 586 587 /** 588 * Calls straight out to the monitorexit stub. 589 */ 590 @Snippet 591 public static void monitorexitStub(Object object, @ConstantParameter int lockDepth, @ConstantParameter boolean trace) { 592 verifyOop(object); 593 traceObject(trace, "-lock{stub}", object, false); 594 final Word lock = CurrentLockNode.currentLock(lockDepth); 595 monitorexitStubC(MONITOREXIT, object, lock); 596 endLockScope(); 675 public final SnippetCounter lockStubEpochExpired; 676 public final SnippetCounter lockStubRevoke; 677 public final SnippetCounter lockStubFailedCas; 678 public final SnippetCounter inflatedCas; 679 public final SnippetCounter inflatedFailedCas; 680 public final SnippetCounter inflatedOwned; 681 public final SnippetCounter unbiasable; 682 public final SnippetCounter revokeBias; 683 684 /** 685 * Counters for the various paths for releasing a lock. The counters whose names start with 686 * {@code "unlock"} are mutually exclusive. The other counters are for paths that may be 687 * shared. 688 */ 689 public final SnippetCounter unlockBias; 690 public final SnippetCounter unlockCas; 691 public final SnippetCounter unlockCasRecursive; 692 public final SnippetCounter unlockStub; 693 public final SnippetCounter unlockStubInflated; 694 public final SnippetCounter unlockInflatedSimple; 695 696 public Counters(SnippetCounter.Group.Factory factory) { 697 SnippetCounter.Group enter = factory.createSnippetCounterGroup("MonitorEnters"); 698 SnippetCounter.Group exit = factory.createSnippetCounterGroup("MonitorExits"); 699 lockBiasExisting = new SnippetCounter(enter, "lock{bias:existing}", "bias-locked previously biased object"); 700 lockBiasAcquired = new SnippetCounter(enter, "lock{bias:acquired}", "bias-locked newly biased object"); 701 lockBiasTransfer = new SnippetCounter(enter, "lock{bias:transfer}", "bias-locked, biased transferred"); 702 lockCas = new SnippetCounter(enter, "lock{cas}", "cas-locked an object"); 703 lockCasRecursive = new SnippetCounter(enter, "lock{cas:recursive}", "cas-locked, recursive"); 704 lockStubEpochExpired = new SnippetCounter(enter, "lock{stub:epoch-expired}", "stub-locked, epoch expired"); 705 lockStubRevoke = new SnippetCounter(enter, "lock{stub:revoke}", "stub-locked, biased revoked"); 706 lockStubFailedCas = new SnippetCounter(enter, "lock{stub:failed-cas/stack}", "stub-locked, failed cas and stack locking"); 707 inflatedCas = new SnippetCounter(enter, "lock{inflated:cas}", "heavyweight-locked, cas-locked"); 708 inflatedFailedCas = new SnippetCounter(enter, "lock{inflated:failed-cas}", "heavyweight-locked, failed cas"); 709 inflatedOwned = new SnippetCounter(enter, "lock{inflated:owned}", "heavyweight-locked, already owned"); 710 unbiasable = new SnippetCounter(enter, "unbiasable", "object with unbiasable type"); 711 revokeBias = new SnippetCounter(enter, "revokeBias", "object had bias revoked"); 712 713 unlockBias = new SnippetCounter(exit, "unlock{bias}", "bias-unlocked an object"); 714 unlockCas = new SnippetCounter(exit, "unlock{cas}", "cas-unlocked an object"); 715 unlockCasRecursive = new SnippetCounter(exit, "unlock{cas:recursive}", "cas-unlocked an object, recursive"); 716 unlockStub = new SnippetCounter(exit, "unlock{stub}", "stub-unlocked an object"); 717 unlockStubInflated = new SnippetCounter(exit, "unlock{stub:inflated}", "stub-unlocked an object with inflated monitor"); 718 unlockInflatedSimple = new SnippetCounter(exit, "unlock{inflated}", "unlocked an object monitor"); 719 } 720 } 721 722 public static class Templates extends AbstractTemplates { 723 724 private final SnippetInfo monitorenter = snippet(MonitorSnippets.class, "monitorenter"); 725 private final SnippetInfo monitorexit = snippet(MonitorSnippets.class, "monitorexit"); 726 private final SnippetInfo monitorenterStub = snippet(MonitorSnippets.class, "monitorenterStub"); 727 private final SnippetInfo monitorexitStub = snippet(MonitorSnippets.class, "monitorexitStub"); 728 private final SnippetInfo initCounter = snippet(MonitorSnippets.class, "initCounter"); 729 private final SnippetInfo checkCounter = snippet(MonitorSnippets.class, "checkCounter"); 730 731 private final boolean useFastLocking; 732 public final Counters counters; 733 734 public Templates(OptionValues options, Iterable<DebugHandlersFactory> factories, SnippetCounter.Group.Factory factory, HotSpotProviders providers, TargetDescription target, 735 boolean useFastLocking) { 736 super(options, factories, providers, providers.getSnippetReflection(), target); 737 this.useFastLocking = useFastLocking; 738 | 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 25 package org.graalvm.compiler.hotspot.replacements; 26 27 import static jdk.vm.ci.code.MemoryBarriers.LOAD_STORE; 28 import static jdk.vm.ci.code.MemoryBarriers.STORE_LOAD; 29 import static jdk.vm.ci.code.MemoryBarriers.STORE_STORE; 30 import static org.graalvm.compiler.hotspot.GraalHotSpotVMConfig.INJECTED_OPTIONVALUES; 31 import static org.graalvm.compiler.hotspot.GraalHotSpotVMConfig.INJECTED_VMCONFIG; 32 import static org.graalvm.compiler.hotspot.nodes.AcquiredCASLockNode.mark; 33 import static org.graalvm.compiler.hotspot.nodes.BeginLockScopeNode.beginLockScope; 34 import static org.graalvm.compiler.hotspot.nodes.EndLockScopeNode.endLockScope; 35 import static org.graalvm.compiler.hotspot.nodes.VMErrorNode.vmError; 36 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.DISPLACED_MARK_WORD_LOCATION; 37 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.MARK_WORD_LOCATION; 38 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.OBJECT_MONITOR_CXQ_LOCATION; 39 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.OBJECT_MONITOR_ENTRY_LIST_LOCATION; 40 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.OBJECT_MONITOR_OWNER_LOCATION; 41 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.OBJECT_MONITOR_RECURSION_LOCATION; 42 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.OBJECT_MONITOR_SUCC_LOCATION; 43 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.PROTOTYPE_MARK_WORD_LOCATION; 44 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.ageMaskInPlace; 45 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.biasedLockMaskInPlace; 46 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.biasedLockPattern; 47 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.epochMaskInPlace; 48 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.loadWordFromObject; 49 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.lockDisplacedMarkOffset; 50 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.markOffset; 51 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.monitorMask; 52 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.objectMonitorCxqOffset; 53 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.objectMonitorEntryListOffset; 54 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.objectMonitorOwnerOffset; 55 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.objectMonitorRecursionsOffset; 56 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.objectMonitorSuccOffset; 57 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.pageSize; 58 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.prototypeMarkWordOffset; 59 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.registerAsWord; 60 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.stackBias; 61 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.unlockedMask; 62 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.useBiasedLocking; 63 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.verifyOop; 64 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.wordSize; 65 import static org.graalvm.compiler.hotspot.replacements.HotspotSnippetsOptions.ProfileMonitors; 66 import static org.graalvm.compiler.hotspot.replacements.HotspotSnippetsOptions.SimpleFastInflatedLocking; 67 import static org.graalvm.compiler.hotspot.replacements.HotspotSnippetsOptions.TraceMonitorsMethodFilter; 68 import static org.graalvm.compiler.hotspot.replacements.HotspotSnippetsOptions.TraceMonitorsTypeFilter; 69 import static org.graalvm.compiler.hotspot.replacements.HotspotSnippetsOptions.VerifyBalancedMonitors; 70 import static org.graalvm.compiler.nodes.extended.BranchProbabilityNode.FAST_PATH_PROBABILITY; 71 import static org.graalvm.compiler.nodes.extended.BranchProbabilityNode.FREQUENT_PROBABILITY; 72 import static org.graalvm.compiler.nodes.extended.BranchProbabilityNode.NOT_FREQUENT_PROBABILITY; 73 import static org.graalvm.compiler.nodes.extended.BranchProbabilityNode.NOT_LIKELY_PROBABILITY; 74 import static org.graalvm.compiler.nodes.extended.BranchProbabilityNode.SLOW_PATH_PROBABILITY; 75 import static org.graalvm.compiler.nodes.extended.BranchProbabilityNode.VERY_FAST_PATH_PROBABILITY; 76 import static org.graalvm.compiler.nodes.extended.BranchProbabilityNode.probability; 560 int ownerOffset = objectMonitorOwnerOffset(INJECTED_VMCONFIG); 561 Word owner = monitor.readWord(ownerOffset, OBJECT_MONITOR_OWNER_LOCATION); 562 int recursionsOffset = objectMonitorRecursionsOffset(INJECTED_VMCONFIG); 563 Word recursions = monitor.readWord(recursionsOffset, OBJECT_MONITOR_RECURSION_LOCATION); 564 Word thread = registerAsWord(threadRegister); 565 if (probability(FAST_PATH_PROBABILITY, owner.xor(thread).or(recursions).equal(0))) { 566 // owner == thread && recursions == 0 567 int cxqOffset = objectMonitorCxqOffset(INJECTED_VMCONFIG); 568 Word cxq = monitor.readWord(cxqOffset, OBJECT_MONITOR_CXQ_LOCATION); 569 int entryListOffset = objectMonitorEntryListOffset(INJECTED_VMCONFIG); 570 Word entryList = monitor.readWord(entryListOffset, OBJECT_MONITOR_ENTRY_LIST_LOCATION); 571 if (probability(FREQUENT_PROBABILITY, cxq.or(entryList).equal(0))) { 572 // cxq == 0 && entryList == 0 573 // Nobody is waiting, success 574 // release_store 575 memoryBarrier(LOAD_STORE | STORE_STORE); 576 monitor.writeWord(ownerOffset, zero()); 577 traceObject(trace, "-lock{inflated:simple}", object, false); 578 counters.unlockInflatedSimple.inc(); 579 return true; 580 } else { 581 int succOffset = objectMonitorSuccOffset(INJECTED_VMCONFIG); 582 Word succ = monitor.readWord(succOffset, OBJECT_MONITOR_SUCC_LOCATION); 583 if (probability(FREQUENT_PROBABILITY, succ.isNonNull())) { 584 // There may be a thread spinning on this monitor. Temporarily setting 585 // the monitor owner to null, and hope that the other thread will grab it. 586 monitor.writeWord(ownerOffset, zero()); 587 memoryBarrier(STORE_STORE | STORE_LOAD); 588 succ = monitor.readWord(succOffset, OBJECT_MONITOR_SUCC_LOCATION); 589 if (probability(NOT_FREQUENT_PROBABILITY, succ.isNonNull())) { 590 // We manage to release the monitor before the other running thread even 591 // notices. 592 traceObject(trace, "-lock{inflated:transfer}", object, false); 593 counters.unlockInflatedTransfer.inc(); 594 return true; 595 } else { 596 // Either the monitor is grabbed by a spinning thread, or the spinning 597 // thread parks. Now we attempt to reset the owner of the monitor. 598 if (probability(FREQUENT_PROBABILITY, !monitor.logicCompareAndSwapWord(ownerOffset, zero(), thread, OBJECT_MONITOR_OWNER_LOCATION))) { 599 // The monitor is stolen. 600 traceObject(trace, "-lock{inflated:transfer}", object, false); 601 counters.unlockInflatedTransfer.inc(); 602 return true; 603 } 604 } 605 } 606 } 607 } 608 counters.unlockStubInflated.inc(); 609 traceObject(trace, "-lock{stub:inflated}", object, false); 610 monitorexitStubC(MONITOREXIT, object, lock); 611 return true; 612 } 613 return false; 614 } 615 616 /** 617 * Calls straight out to the monitorexit stub. 618 */ 619 @Snippet 620 public static void monitorexitStub(Object object, @ConstantParameter int lockDepth, @ConstantParameter boolean trace) { 621 verifyOop(object); 622 traceObject(trace, "-lock{stub}", object, false); 623 final Word lock = CurrentLockNode.currentLock(lockDepth); 624 monitorexitStubC(MONITOREXIT, object, lock); 625 endLockScope(); 704 public final SnippetCounter lockStubEpochExpired; 705 public final SnippetCounter lockStubRevoke; 706 public final SnippetCounter lockStubFailedCas; 707 public final SnippetCounter inflatedCas; 708 public final SnippetCounter inflatedFailedCas; 709 public final SnippetCounter inflatedOwned; 710 public final SnippetCounter unbiasable; 711 public final SnippetCounter revokeBias; 712 713 /** 714 * Counters for the various paths for releasing a lock. The counters whose names start with 715 * {@code "unlock"} are mutually exclusive. The other counters are for paths that may be 716 * shared. 717 */ 718 public final SnippetCounter unlockBias; 719 public final SnippetCounter unlockCas; 720 public final SnippetCounter unlockCasRecursive; 721 public final SnippetCounter unlockStub; 722 public final SnippetCounter unlockStubInflated; 723 public final SnippetCounter unlockInflatedSimple; 724 public final SnippetCounter unlockInflatedTransfer; 725 726 public Counters(SnippetCounter.Group.Factory factory) { 727 SnippetCounter.Group enter = factory.createSnippetCounterGroup("MonitorEnters"); 728 SnippetCounter.Group exit = factory.createSnippetCounterGroup("MonitorExits"); 729 lockBiasExisting = new SnippetCounter(enter, "lock{bias:existing}", "bias-locked previously biased object"); 730 lockBiasAcquired = new SnippetCounter(enter, "lock{bias:acquired}", "bias-locked newly biased object"); 731 lockBiasTransfer = new SnippetCounter(enter, "lock{bias:transfer}", "bias-locked, biased transferred"); 732 lockCas = new SnippetCounter(enter, "lock{cas}", "cas-locked an object"); 733 lockCasRecursive = new SnippetCounter(enter, "lock{cas:recursive}", "cas-locked, recursive"); 734 lockStubEpochExpired = new SnippetCounter(enter, "lock{stub:epoch-expired}", "stub-locked, epoch expired"); 735 lockStubRevoke = new SnippetCounter(enter, "lock{stub:revoke}", "stub-locked, biased revoked"); 736 lockStubFailedCas = new SnippetCounter(enter, "lock{stub:failed-cas/stack}", "stub-locked, failed cas and stack locking"); 737 inflatedCas = new SnippetCounter(enter, "lock{inflated:cas}", "heavyweight-locked, cas-locked"); 738 inflatedFailedCas = new SnippetCounter(enter, "lock{inflated:failed-cas}", "heavyweight-locked, failed cas"); 739 inflatedOwned = new SnippetCounter(enter, "lock{inflated:owned}", "heavyweight-locked, already owned"); 740 unbiasable = new SnippetCounter(enter, "unbiasable", "object with unbiasable type"); 741 revokeBias = new SnippetCounter(enter, "revokeBias", "object had bias revoked"); 742 743 unlockBias = new SnippetCounter(exit, "unlock{bias}", "bias-unlocked an object"); 744 unlockCas = new SnippetCounter(exit, "unlock{cas}", "cas-unlocked an object"); 745 unlockCasRecursive = new SnippetCounter(exit, "unlock{cas:recursive}", "cas-unlocked an object, recursive"); 746 unlockStub = new SnippetCounter(exit, "unlock{stub}", "stub-unlocked an object"); 747 unlockStubInflated = new SnippetCounter(exit, "unlock{stub:inflated}", "stub-unlocked an object with inflated monitor"); 748 unlockInflatedSimple = new SnippetCounter(exit, "unlock{inflated}", "unlocked an object monitor"); 749 unlockInflatedTransfer = new SnippetCounter(exit, "unlock{inflated:transfer}", "unlocked an object monitor in the presence of ObjectMonitor::_succ"); 750 } 751 } 752 753 public static class Templates extends AbstractTemplates { 754 755 private final SnippetInfo monitorenter = snippet(MonitorSnippets.class, "monitorenter"); 756 private final SnippetInfo monitorexit = snippet(MonitorSnippets.class, "monitorexit"); 757 private final SnippetInfo monitorenterStub = snippet(MonitorSnippets.class, "monitorenterStub"); 758 private final SnippetInfo monitorexitStub = snippet(MonitorSnippets.class, "monitorexitStub"); 759 private final SnippetInfo initCounter = snippet(MonitorSnippets.class, "initCounter"); 760 private final SnippetInfo checkCounter = snippet(MonitorSnippets.class, "checkCounter"); 761 762 private final boolean useFastLocking; 763 public final Counters counters; 764 765 public Templates(OptionValues options, Iterable<DebugHandlersFactory> factories, SnippetCounter.Group.Factory factory, HotSpotProviders providers, TargetDescription target, 766 boolean useFastLocking) { 767 super(options, factories, providers, providers.getSnippetReflection(), target); 768 this.useFastLocking = useFastLocking; 769 |