From 9531c85965e1632aa929f29cf550348a7127453f Mon Sep 17 00:00:00 2001 From: Tobias Hartmann Date: Wed, 14 Aug 2024 15:11:00 +0200 Subject: [PATCH] 8326605: [lworld] SplitIfSharedFastLockBehindCastPP performs synchronization on a value class --- .../loopopts/SplitIfSharedFastLockBehindCastPP.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/compiler/loopopts/SplitIfSharedFastLockBehindCastPP.java b/test/hotspot/jtreg/compiler/loopopts/SplitIfSharedFastLockBehindCastPP.java index 628a5a4cb75..84c155031f1 100644 --- a/test/hotspot/jtreg/compiler/loopopts/SplitIfSharedFastLockBehindCastPP.java +++ b/test/hotspot/jtreg/compiler/loopopts/SplitIfSharedFastLockBehindCastPP.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -70,6 +71,14 @@ private static void test1(boolean flag, Object obj) { } } + static class MyBox { + int val; + + public MyBox(int val) { + this.val = val; + } + } + private static Object test2(boolean flag) { int integer; if (flag) { @@ -80,7 +89,7 @@ private static Object test2(boolean flag) { integer = 2; } - Object obj = integer; + Object obj = new MyBox(integer); // This loop will be unswitched. The condition becomes candidate for split if for (int i = 0; i < 100; i++) {