Skip to content

Commit

Permalink
8327214: [lworld] Valhalla compiler testing move to classfile API
Browse files Browse the repository at this point in the history
Reviewed-by: dsimms
  • Loading branch information
liach authored and David Simms committed Feb 13, 2025
1 parent d94c589 commit 991ec92
Show file tree
Hide file tree
Showing 26 changed files with 25 additions and 6,403 deletions.
32 changes: 15 additions & 17 deletions test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestLWorld.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2025, 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
Expand All @@ -25,14 +25,12 @@

import compiler.lib.ir_framework.*;
import jdk.test.lib.Asserts;
import test.java.lang.invoke.lib.OldInstructionHelper;

import test.java.lang.invoke.lib.InstructionHelper;

import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.reflect.Method;
import jdk.experimental.bytecode.TypeTag;
import java.util.Arrays;
import java.util.Objects;

Expand All @@ -48,12 +46,12 @@
* @test
* @key randomness
* @summary Test inline types in LWorld.
* @library /test/lib /test/jdk/lib/testlibrary/bytecode /test/jdk/java/lang/invoke/common /
* @library /test/lib /test/jdk/java/lang/invoke/common /
* @requires (os.simpleArch == "x64" | os.simpleArch == "aarch64")
* @enablePreview
* @modules java.base/jdk.internal.value
* java.base/jdk.internal.vm.annotation
* @build jdk.experimental.bytecode.BasicClassBuilder test.java.lang.invoke.lib.OldInstructionHelper
* @build test.java.lang.invoke.lib.InstructionHelper
* @run main/othervm/timeout=450 compiler.valhalla.inlinetypes.TestLWorld
*/

Expand Down Expand Up @@ -1093,13 +1091,13 @@ public void test34_verifier() {

// Test writing constant null to a (flattened) inline type array

private static final MethodHandle setArrayElementNull = OldInstructionHelper.loadCode(MethodHandles.lookup(),
private static final MethodHandle setArrayElementNull = InstructionHelper.buildMethodHandle(MethodHandles.lookup(),
"setArrayElementNull",
MethodType.methodType(void.class, TestLWorld.class, MyValue1[].class, int.class),
CODE -> {
CODE.
aload_1().
iload_2().
aload(1).
iload(2).
aconst_null().
aastore().
return_();
Expand Down Expand Up @@ -1433,14 +1431,14 @@ public void test43_verifier(RunInfo info) {
}

// Tests writing an array element with a (statically known) incompatible type
private static final MethodHandle setArrayElementIncompatible = OldInstructionHelper.loadCode(MethodHandles.lookup(),
private static final MethodHandle setArrayElementIncompatible = InstructionHelper.buildMethodHandle(MethodHandles.lookup(),
"setArrayElementIncompatible",
MethodType.methodType(void.class, TestLWorld.class, MyValue1[].class, int.class, MyValue2.class),
CODE -> {
CODE.
aload_1().
iload_2().
aload_3().
aload(1).
iload(2).
aload(3).
aastore().
return_();
});
Expand Down Expand Up @@ -4060,14 +4058,14 @@ public void test144_verifier() {
}

// Tests writing an array element with a (statically known) incompatible type
private static final MethodHandle setArrayElementIncompatibleRef = OldInstructionHelper.loadCode(MethodHandles.lookup(),
private static final MethodHandle setArrayElementIncompatibleRef = InstructionHelper.buildMethodHandle(MethodHandles.lookup(),
"setArrayElementIncompatibleRef",
MethodType.methodType(void.class, TestLWorld.class, MyValue1[].class, int.class, MyValue2.class),
CODE -> {
CODE.
aload_1().
iload_2().
aload_3().
aload(1).
iload(2).
aload(3).
aastore().
return_();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2025, 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
Expand All @@ -25,8 +25,7 @@

import compiler.lib.ir_framework.*;
import jdk.test.lib.Asserts;
import jdk.experimental.bytecode.TypeTag;
import test.java.lang.invoke.lib.OldInstructionHelper;
import test.java.lang.invoke.lib.InstructionHelper;

import java.util.Objects;

Expand All @@ -47,12 +46,12 @@
* @test
* @key randomness
* @summary Test correct handling of nullable value classes.
* @library /test/lib /test/jdk/lib/testlibrary/bytecode /test/jdk/java/lang/invoke/common /
* @library /test/lib /test/jdk/java/lang/invoke/common /
* @requires (os.simpleArch == "x64" | os.simpleArch == "aarch64")
* @enablePreview
* @modules java.base/jdk.internal.value
* java.base/jdk.internal.vm.annotation
* @build jdk.experimental.bytecode.BasicClassBuilder test.java.lang.invoke.lib.OldInstructionHelper
* @build test.java.lang.invoke.lib.InstructionHelper
* @run main/othervm/timeout=300 compiler.valhalla.inlinetypes.TestNullableInlineTypes
*/

Expand Down Expand Up @@ -2578,14 +2577,14 @@ public void test92_verifier() {
Asserts.assertEQ(test92(), testValue1);
}

private static final MethodHandle refCheckCast = OldInstructionHelper.loadCode(MethodHandles.lookup(),
private static final MethodHandle refCheckCast = InstructionHelper.buildMethodHandle(MethodHandles.lookup(),
"refCheckCast",
MethodType.methodType(MyValue2.class, TestNullableInlineTypes.class, MyValue1.class),
CODE -> {
CODE.
aload_1().
checkcast(MyValue2.class).
return_(TypeTag.A);
aload(1).
checkcast(MyValue2.class.describeConstable().orElseThrow()).
areturn();
});

// Test checkcast that only passes with null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2025, 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
Expand All @@ -25,14 +25,12 @@

import compiler.lib.ir_framework.*;
import jdk.test.lib.Asserts;
import jdk.experimental.bytecode.TypeTag;

import java.lang.reflect.Method;

import static compiler.valhalla.inlinetypes.InlineTypeIRNode.*;
import static compiler.valhalla.inlinetypes.InlineTypes.*;

import jdk.internal.value.ValueClass;
import jdk.internal.vm.annotation.ImplicitlyConstructible;
import jdk.internal.vm.annotation.LooselyConsistentValue;
import jdk.internal.vm.annotation.NullRestricted;
Expand All @@ -41,7 +39,7 @@
* @test
* @key randomness
* @summary Test correct handling of value classes.
* @library /test/lib /test/jdk/lib/testlibrary/bytecode /test/jdk/java/lang/invoke/common /
* @library /test/lib /test/jdk/java/lang/invoke/common /
* @requires (os.simpleArch == "x64" | os.simpleArch == "aarch64")
* @enablePreview
* @modules java.base/jdk.internal.value
Expand Down
Loading

0 comments on commit 991ec92

Please sign in to comment.