7 * published by the Free Software Foundation.
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 * @test
25 * @bug 8134918
26 * @modules java.base/jdk.internal.misc
27 * @run main/bootclasspath/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:TypeProfileLevel=222 -XX:+UseTypeSpeculation -Xbatch
28 * -XX:CompileCommand=dontinline,UnsafeAccess::test*
29 * UnsafeAccess
30 */
31 import jdk.internal.misc.Unsafe;
32
33 public class UnsafeAccess {
34 private static final Unsafe U = Unsafe.getUnsafe();
35
36 static Class cls = Object.class;
37 static long off = U.ARRAY_OBJECT_BASE_OFFSET;
38
39 static Object testUnsafeAccess(Object o, boolean isObjArray) {
40 if (o != null && cls.isInstance(o)) { // speculates "o" type to int[]
41 return helperUnsafeAccess(o, isObjArray);
42 }
43 return null;
44 }
45
46 static Object helperUnsafeAccess(Object o, boolean isObjArray) {
47 if (isObjArray) {
48 U.putObject(o, off, new Object());
49 }
50 return o;
|
7 * published by the Free Software Foundation.
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 * @test
25 * @bug 8134918
26 * @modules java.base/jdk.internal.misc
27 *
28 * @run main/bootclasspath/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:TypeProfileLevel=222 -XX:+UseTypeSpeculation -Xbatch
29 * -XX:CompileCommand=dontinline,compiler.profiling.UnsafeAccess::test*
30 * compiler.profiling.UnsafeAccess
31 */
32
33 package compiler.profiling;
34
35 import jdk.internal.misc.Unsafe;
36
37 public class UnsafeAccess {
38 private static final Unsafe U = Unsafe.getUnsafe();
39
40 static Class cls = Object.class;
41 static long off = U.ARRAY_OBJECT_BASE_OFFSET;
42
43 static Object testUnsafeAccess(Object o, boolean isObjArray) {
44 if (o != null && cls.isInstance(o)) { // speculates "o" type to int[]
45 return helperUnsafeAccess(o, isObjArray);
46 }
47 return null;
48 }
49
50 static Object helperUnsafeAccess(Object o, boolean isObjArray) {
51 if (isObjArray) {
52 U.putObject(o, off, new Object());
53 }
54 return o;
|