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
26 /**
27 * @test
28 * @summary Basic tests for jdk.internal.vm.Continuation
29 * @requires vm.continuations
30 * @modules java.base/jdk.internal.vm
31 * @build java.base/java.lang.StackWalkerHelper
32 *
33 * @run testng/othervm -XX:+UnlockDiagnosticVMOptions -XX:+ShowHiddenFrames -Xint Basic
34 *
35 * @run testng/othervm -XX:+UnlockDiagnosticVMOptions -XX:+ShowHiddenFrames -Xcomp -XX:TieredStopAtLevel=3 -XX:CompileOnly=jdk.internal.vm.Continuation::*,Basic::* Basic
36 * @run testng/othervm -XX:+UnlockDiagnosticVMOptions -XX:+ShowHiddenFrames -Xcomp -XX:-TieredCompilation -XX:CompileOnly=jdk.internal.vm.Continuation::*,Basic::* Basic
37 * @run testng/othervm -XX:+UnlockDiagnosticVMOptions -XX:+ShowHiddenFrames -Xcomp -XX:-TieredCompilation -XX:CompileOnly=jdk.internal.vm.Continuation::*,Basic::* -XX:CompileCommand=exclude,Basic.manyArgsDriver Basic
38 * @run testng/othervm -XX:+UnlockDiagnosticVMOptions -XX:+ShowHiddenFrames -Xcomp -XX:-TieredCompilation -XX:CompileOnly=jdk.internal.vm.Continuation::*,Basic::* -XX:CompileCommand=exclude,jdk/internal/vm/Continuation.enter Basic
39 * @run testng/othervm -XX:+UnlockDiagnosticVMOptions -XX:+ShowHiddenFrames -Xcomp -XX:-TieredCompilation -XX:CompileOnly=jdk.internal.vm.Continuation::*,Basic::* -XX:CompileCommand=inline,jdk/internal/vm/Continuation.run Basic
40 */
41
42 /**
43 * @test
44 * @requires vm.continuations
45 * @requires vm.debug
46 * @modules java.base/jdk.internal.vm
47 * @build java.base/java.lang.StackWalkerHelper
48 *
49 * @run testng/othervm -XX:+UnlockDiagnosticVMOptions -XX:+ShowHiddenFrames -XX:+VerifyStack -Xint Basic
50 * @run testng/othervm -XX:+UnlockDiagnosticVMOptions -XX:+ShowHiddenFrames -XX:+VerifyStack -Xcomp -XX:TieredStopAtLevel=3 -XX:CompileOnly=jdk.internal.vm.Continuation::*,Basic::* Basic
51 * @run testng/othervm -XX:+UnlockDiagnosticVMOptions -XX:+ShowHiddenFrames -XX:+VerifyStack -Xcomp -XX:-TieredCompilation -XX:CompileOnly=jdk.internal.vm.Continuation::*,Basic::* Basic
52 */
53
54 import jdk.internal.vm.Continuation;
55 import jdk.internal.vm.ContinuationScope;
56
57 import java.util.ArrayList;
58 import java.util.Arrays;
59 import java.util.List;
60 import java.util.stream.Collectors;
61 import java.util.stream.IntStream;
62
63 import org.testng.annotations.Test;
64 import org.testng.annotations.DataProvider;
65 import static org.testng.Assert.*;
66
67 import java.util.concurrent.atomic.AtomicInteger;
68 import java.util.concurrent.atomic.AtomicReference;
69
70 public class Basic {
71 static final ContinuationScope FOO = new ContinuationScope() {};
72
73 @Test
74 public void test1() {
75 // Basic freeze and thaw
76 final AtomicInteger res = new AtomicInteger(0);
259 }
260
261 static String barMany(long b,
262 int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8, int x9, int x10, int x11, int x12,
263 int x13, int x14, int x15, int x16, int x17, int x18, int x19, int x20,
264 double f1, double f2, double f3, double f4, double f5, float f6, float f7, double f8, double f9, double f10,
265 double f11, double f12, double f13, float f14, float f15, float f16, double f17, double f18, double f19, double f20,
266 Object o1, Object o2, Object o3, Object o4, Object o5, Object o6, Object o7, Object o8, Object o9, Object o10,
267 Object o11, Object o12, Object o13, Object o14, Object o15, Object o16, Object o17, Object o18, Object o19, Object o20) {
268 double x = 9.99;
269 String s = "zzz";
270 for (int i=0; i<2; i++) {
271 Continuation.yield(FOO);
272 }
273 long r = b+1;
274 return "" + r;
275 }
276
277 @Test
278 public void testPinnedMonitor() {
279 // Test pinning due to held monitor
280 final AtomicReference<Continuation.Pinned> res = new AtomicReference<>();
281
282 Continuation cont = new Continuation(FOO, ()-> {
283 syncFoo(1);
284 }) {
285 @Override
286 protected void onPinned(Continuation.Pinned reason) {
287 assert Continuation.isPinned(FOO);
288 res.set(reason);
289 }
290 };
291
292 cont.run();
293 assertEquals(res.get(), Continuation.Pinned.MONITOR);
294 boolean isDone = cont.isDone();
295 assertEquals(isDone, true);
296 }
297
298 static double syncFoo(int a) {
|
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
26 /**
27 * @test
28 * @summary Basic tests for jdk.internal.vm.Continuation
29 * @requires vm.continuations
30 * @modules java.base/jdk.internal.vm
31 * @library /test/lib
32 * @build java.base/java.lang.StackWalkerHelper
33 *
34 * @run testng/othervm -XX:+UnlockDiagnosticVMOptions -XX:+ShowHiddenFrames -Xint Basic
35 *
36 * @run testng/othervm -XX:+UnlockDiagnosticVMOptions -XX:+ShowHiddenFrames -Xcomp -XX:TieredStopAtLevel=3 -XX:CompileOnly=jdk.internal.vm.Continuation::*,Basic::* Basic
37 * @run testng/othervm -XX:+UnlockDiagnosticVMOptions -XX:+ShowHiddenFrames -Xcomp -XX:-TieredCompilation -XX:CompileOnly=jdk.internal.vm.Continuation::*,Basic::* Basic
38 * @run testng/othervm -XX:+UnlockDiagnosticVMOptions -XX:+ShowHiddenFrames -Xcomp -XX:-TieredCompilation -XX:CompileOnly=jdk.internal.vm.Continuation::*,Basic::* -XX:CompileCommand=exclude,Basic.manyArgsDriver Basic
39 * @run testng/othervm -XX:+UnlockDiagnosticVMOptions -XX:+ShowHiddenFrames -Xcomp -XX:-TieredCompilation -XX:CompileOnly=jdk.internal.vm.Continuation::*,Basic::* -XX:CompileCommand=exclude,jdk/internal/vm/Continuation.enter Basic
40 * @run testng/othervm -XX:+UnlockDiagnosticVMOptions -XX:+ShowHiddenFrames -Xcomp -XX:-TieredCompilation -XX:CompileOnly=jdk.internal.vm.Continuation::*,Basic::* -XX:CompileCommand=inline,jdk/internal/vm/Continuation.run Basic
41 */
42
43 /**
44 * @test
45 * @requires vm.continuations
46 * @requires vm.debug
47 * @modules java.base/jdk.internal.vm
48 * @library /test/lib
49 * @build java.base/java.lang.StackWalkerHelper
50 *
51 * @run testng/othervm -XX:+UnlockDiagnosticVMOptions -XX:+ShowHiddenFrames -XX:+VerifyStack -Xint Basic
52 * @run testng/othervm -XX:+UnlockDiagnosticVMOptions -XX:+ShowHiddenFrames -XX:+VerifyStack -Xcomp -XX:TieredStopAtLevel=3 -XX:CompileOnly=jdk.internal.vm.Continuation::*,Basic::* Basic
53 * @run testng/othervm -XX:+UnlockDiagnosticVMOptions -XX:+ShowHiddenFrames -XX:+VerifyStack -Xcomp -XX:-TieredCompilation -XX:CompileOnly=jdk.internal.vm.Continuation::*,Basic::* Basic
54 */
55
56 import jdk.internal.vm.Continuation;
57 import jdk.internal.vm.ContinuationScope;
58
59 import jdk.test.lib.Platform;
60
61 import java.util.ArrayList;
62 import java.util.Arrays;
63 import java.util.List;
64 import java.util.stream.Collectors;
65 import java.util.stream.IntStream;
66
67 import org.testng.annotations.Test;
68 import org.testng.annotations.DataProvider;
69 import static org.testng.Assert.*;
70
71 import java.util.concurrent.atomic.AtomicInteger;
72 import java.util.concurrent.atomic.AtomicReference;
73
74 public class Basic {
75 static final ContinuationScope FOO = new ContinuationScope() {};
76
77 @Test
78 public void test1() {
79 // Basic freeze and thaw
80 final AtomicInteger res = new AtomicInteger(0);
263 }
264
265 static String barMany(long b,
266 int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8, int x9, int x10, int x11, int x12,
267 int x13, int x14, int x15, int x16, int x17, int x18, int x19, int x20,
268 double f1, double f2, double f3, double f4, double f5, float f6, float f7, double f8, double f9, double f10,
269 double f11, double f12, double f13, float f14, float f15, float f16, double f17, double f18, double f19, double f20,
270 Object o1, Object o2, Object o3, Object o4, Object o5, Object o6, Object o7, Object o8, Object o9, Object o10,
271 Object o11, Object o12, Object o13, Object o14, Object o15, Object o16, Object o17, Object o18, Object o19, Object o20) {
272 double x = 9.99;
273 String s = "zzz";
274 for (int i=0; i<2; i++) {
275 Continuation.yield(FOO);
276 }
277 long r = b+1;
278 return "" + r;
279 }
280
281 @Test
282 public void testPinnedMonitor() {
283 if (Platform.isX64() || Platform.isAArch64()) return;
284
285 // Test pinning due to held monitor
286 final AtomicReference<Continuation.Pinned> res = new AtomicReference<>();
287
288 Continuation cont = new Continuation(FOO, ()-> {
289 syncFoo(1);
290 }) {
291 @Override
292 protected void onPinned(Continuation.Pinned reason) {
293 assert Continuation.isPinned(FOO);
294 res.set(reason);
295 }
296 };
297
298 cont.run();
299 assertEquals(res.get(), Continuation.Pinned.MONITOR);
300 boolean isDone = cont.isDone();
301 assertEquals(isDone, true);
302 }
303
304 static double syncFoo(int a) {
|