--- old/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java 2015-11-04 14:34:49.807376004 +0100 +++ new/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java 2015-11-04 14:34:49.450340419 +0100 @@ -39,6 +39,7 @@ import java.util.Collection; import java.util.Date; import java.util.concurrent.TimeUnit; +import jdk.internal.vm.annotation.ReservedStackAccess; /** * Provides a framework for implementing blocking locks and related @@ -886,6 +887,7 @@ * @param arg the acquire argument * @return {@code true} if interrupted while waiting */ + @ReservedStackAccess final boolean acquireQueued(final Node node, int arg) { try { boolean interrupted = false; @@ -1218,6 +1220,7 @@ * {@link #tryAcquire} but is otherwise uninterpreted and * can represent anything you like. */ + @ReservedStackAccess public final void acquire(int arg) { if (!tryAcquire(arg) && acquireQueued(addWaiter(Node.EXCLUSIVE), arg)) @@ -1281,6 +1284,7 @@ * can represent anything you like. * @return the value returned from {@link #tryRelease} */ + @ReservedStackAccess public final boolean release(int arg) { if (tryRelease(arg)) { Node h = head; @@ -1361,6 +1365,7 @@ * and can represent anything you like. * @return the value returned from {@link #tryReleaseShared} */ + @ReservedStackAccess public final boolean releaseShared(int arg) { if (tryReleaseShared(arg)) { doReleaseShared(); --- old/src/java.base/share/classes/java/util/concurrent/locks/ReentrantLock.java 2015-11-04 14:34:51.092504090 +0100 +++ new/src/java.base/share/classes/java/util/concurrent/locks/ReentrantLock.java 2015-11-04 14:34:50.745469502 +0100 @@ -37,6 +37,7 @@ import java.util.Collection; import java.util.concurrent.TimeUnit; +import jdk.internal.vm.annotation.ReservedStackAccess; /** * A reentrant mutual exclusion {@link Lock} with the same basic @@ -127,6 +128,7 @@ * Performs non-fair tryLock. tryAcquire is implemented in * subclasses, but both need nonfair try for trylock method. */ + @ReservedStackAccess final boolean nonfairTryAcquire(int acquires) { final Thread current = Thread.currentThread(); int c = getState(); @@ -146,6 +148,7 @@ return false; } + @ReservedStackAccess protected final boolean tryRelease(int releases) { int c = getState() - releases; if (Thread.currentThread() != getExclusiveOwnerThread()) @@ -203,6 +206,7 @@ * Performs lock. Try immediate barge, backing up to normal * acquire on failure. */ + @ReservedStackAccess final void lock() { if (compareAndSetState(0, 1)) setExclusiveOwnerThread(Thread.currentThread()); @@ -229,6 +233,7 @@ * Fair version of tryAcquire. Don't grant access unless * recursive call or no waiters or is first. */ + @ReservedStackAccess protected final boolean tryAcquire(int acquires) { final Thread current = Thread.currentThread(); int c = getState(); --- /dev/null 2015-09-01 10:30:13.517273143 +0200 +++ new/src/java.base/share/classes/jdk/internal/vm/annotation/ReservedStackAccess.java 2015-11-04 14:34:51.858580444 +0100 @@ -0,0 +1,53 @@ +/* + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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 jdk.internal.vm.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + *

An annotation expressing that a method is especially sensitive + * to stack overflows and asking the JVM to grant access to extra stack + * space when executing this code if such feature is supported by the JVM. + * The JVM is free to ignore this annotation. + * + * A possible way for the JVM to improve the execution context for methods + * with this annotation is to reserve part of the thread's execution stack + * for them. Access to this section of the stack would be denied by default + * but could be granted if the JVM detects a possible stack overflow and + * the thread's call stack includes at least one annotated method. Even if + * access to this reserved area has been granted, the JVM might decide to + * throw a delayed StackOverflowError when the thread exits the annotated + * method. + * + * @since 1.9 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD, ElementType.CONSTRUCTOR}) +public @interface ReservedStackAccess { } +