From cbfa496f00bf74780f3ab0889aec2eb5aefc38b9 Mon Sep 17 00:00:00 2001 From: Damon Fenacci Date: Thu, 15 Jan 2026 13:22:37 +0100 Subject: [PATCH] JDK-8374852: remove VerifyIntrinsicChecks and refactor opaque flag --- src/hotspot/share/opto/c2_globals.hpp | 3 --- src/hotspot/share/opto/library_call.cpp | 15 +++++++------ src/hotspot/share/opto/library_call.hpp | 3 +-- .../intrinsics/TestVerifyIntrinsicChecks.java | 9 ++++---- .../intrinsics/string/TestCountPositives.java | 21 ------------------- .../string/TestEncodeIntrinsics.java | 20 ------------------ .../intrinsics/string/TestHasNegatives.java | 21 ------------------- 7 files changed, 12 insertions(+), 80 deletions(-) diff --git a/src/hotspot/share/opto/c2_globals.hpp b/src/hotspot/share/opto/c2_globals.hpp index 7fa3ca638c2..f470049bf7e 100644 --- a/src/hotspot/share/opto/c2_globals.hpp +++ b/src/hotspot/share/opto/c2_globals.hpp @@ -675,9 +675,6 @@ product(bool, PrintIntrinsics, false, DIAGNOSTIC, \ "prints attempted and successful inlining of intrinsics") \ \ - develop(bool, VerifyIntrinsicChecks, false, \ - "Verify in intrinsic that Java level checks work as expected") \ - \ develop(bool, StressReflectiveCode, false, \ "Use inexact types at allocations, etc., to test reflection") \ \ diff --git a/src/hotspot/share/opto/library_call.cpp b/src/hotspot/share/opto/library_call.cpp index cc744e5befe..947449a33fe 100644 --- a/src/hotspot/share/opto/library_call.cpp +++ b/src/hotspot/share/opto/library_call.cpp @@ -951,8 +951,7 @@ void LibraryCallKit::generate_string_range_check(Node* array, Node* offset, Node* count, bool char_count, - bool halt_on_oob, - bool is_opaque) { + bool halt_on_oob) { if (stopped()) { return; // already stopped } @@ -964,10 +963,10 @@ void LibraryCallKit::generate_string_range_check(Node* array, } // Offset and count must not be negative - generate_negative_guard(offset, bailout, nullptr, is_opaque); - generate_negative_guard(count, bailout, nullptr, is_opaque); + generate_negative_guard(offset, bailout, nullptr, halt_on_oob); + generate_negative_guard(count, bailout, nullptr, halt_on_oob); // Offset + count must not exceed length of array - generate_limit_guard(offset, count, load_array_length(array), bailout, is_opaque); + generate_limit_guard(offset, count, load_array_length(array), bailout, halt_on_oob); if (bailout->req() > 1) { if (halt_on_oob) { @@ -1151,7 +1150,7 @@ bool LibraryCallKit::inline_countPositives() { Node* len = argument(2); ba = must_be_not_null(ba, true); - generate_string_range_check(ba, offset, len, false, true, !VerifyIntrinsicChecks); + generate_string_range_check(ba, offset, len, false, true); if (stopped()) { return true; } @@ -6226,8 +6225,8 @@ bool LibraryCallKit::inline_encodeISOArray(bool ascii) { } // Check source & target bounds - generate_string_range_check(src, src_offset, length, src_elem == T_BYTE, true, !VerifyIntrinsicChecks); - generate_string_range_check(dst, dst_offset, length, false, true, !VerifyIntrinsicChecks); + generate_string_range_check(src, src_offset, length, src_elem == T_BYTE, true); + generate_string_range_check(dst, dst_offset, length, false, true); if (stopped()) { return true; } diff --git a/src/hotspot/share/opto/library_call.hpp b/src/hotspot/share/opto/library_call.hpp index 6153484696d..73432663231 100644 --- a/src/hotspot/share/opto/library_call.hpp +++ b/src/hotspot/share/opto/library_call.hpp @@ -166,8 +166,7 @@ class LibraryCallKit : public GraphKit { bool is_opaque = false); void generate_string_range_check(Node* array, Node* offset, Node* length, bool char_count, - bool halt_on_oob = false, - bool is_opaque = false); + bool halt_on_oob = false); Node* current_thread_helper(Node* &tls_output, ByteSize handle_offset, bool is_immutable); Node* generate_current_thread(Node* &tls_output); diff --git a/test/hotspot/jtreg/compiler/intrinsics/TestVerifyIntrinsicChecks.java b/test/hotspot/jtreg/compiler/intrinsics/TestVerifyIntrinsicChecks.java index c482a73affd..de52ae92aab 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/TestVerifyIntrinsicChecks.java +++ b/test/hotspot/jtreg/compiler/intrinsics/TestVerifyIntrinsicChecks.java @@ -24,15 +24,15 @@ /* * @test * @bug 8361842 - * @summary Verify the effectiveness of the `VerifyIntrinsicChecks` VM flag - * through (bypassing `StringCoding::encodeAsciiArray`, and) feeding + * @summary Verify the effectiveness of intrinsics range and limit checks + * (bypassing `StringCoding::encodeAsciiArray`, and) feeding * invalid input to an intrinsified `StringCoding::encodeAsciiArray0` * (note the `0` suffix!). * @library /compiler/patches * @library /test/lib * @build java.base/java.lang.Helper - * @comment `vm.debug == true` is required since `VerifyIntrinsicChecks` is a - * development flag + * @comment `vm.debug == true` is required since redundant intrinsics checks + * are only added in debug builds * @requires vm.debug == true & vm.flavor == "server" & !vm.graal.enabled * @requires (os.arch != "riscv64" | (os.arch == "riscv64" & vm.cpu.features ~= ".*rvv.*")) * @run main/othervm compiler.intrinsics.TestVerifyIntrinsicChecks verify @@ -55,7 +55,6 @@ public final class TestVerifyIntrinsicChecks { "-Xcomp", "-XX:-TieredCompilation", "-XX:CompileCommand=inline,java.lang.StringCoding::encodeAsciiArray0", - "-XX:+VerifyIntrinsicChecks", "--patch-module", "java.base=%s/java.base".formatted(System.getProperty("test.patch.path")), "compiler.intrinsics.TestVerifyIntrinsicChecks", "crash"); diff --git a/test/hotspot/jtreg/compiler/intrinsics/string/TestCountPositives.java b/test/hotspot/jtreg/compiler/intrinsics/string/TestCountPositives.java index 1c20a49d281..6bfb98e9127 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/string/TestCountPositives.java +++ b/test/hotspot/jtreg/compiler/intrinsics/string/TestCountPositives.java @@ -48,27 +48,6 @@ * @run main/othervm/timeout=1200 -XX:UseAVX=3 -XX:+UnlockDiagnosticVMOptions -XX:AVX3Threshold=0 compiler.intrinsics.string.TestCountPositives */ -/* - * @test - * @bug 8281146 - * @summary Verify `StringCoding::countPositives` intrinsic Java wrapper checks - * by enabling the ones in the VM intrinsic using - * `-XX:+VerifyIntrinsicChecks` - * @comment This does not check out-of-range conditions. The - * `-XX:+VerifyIntrinsicChecks` version of this test simply ensures - * that the VM intrinsic will produce no spurious errors. - * @key randomness - * @library /compiler/patches - * @library /test/lib - * @comment `vm.debug == true` is required since `VerifyIntrinsicChecks` is a - * development flag - * @requires vm.debug == true - * @build java.base/java.lang.Helper - * @run main/othervm - * -XX:+VerifyIntrinsicChecks - * compiler.intrinsics.string.TestCountPositives - */ - package compiler.intrinsics.string; import java.lang.Helper; diff --git a/test/hotspot/jtreg/compiler/intrinsics/string/TestEncodeIntrinsics.java b/test/hotspot/jtreg/compiler/intrinsics/string/TestEncodeIntrinsics.java index bb343b246ff..35fed85e5c9 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/string/TestEncodeIntrinsics.java +++ b/test/hotspot/jtreg/compiler/intrinsics/string/TestEncodeIntrinsics.java @@ -31,26 +31,6 @@ * @run main/othervm/timeout=1200 --add-opens=java.base/sun.nio.cs=ALL-UNNAMED -Xbatch -Xmx256m compiler.intrinsics.string.TestEncodeIntrinsics */ -/* - * @test - * @bug 6896617 8274242 - * @summary Verify `sun.nio.cs.ISO_8859_1.Encoder::encodeISOArray` intrinsic - * Java wrapper checks by enabling the ones in the VM intrinsic using - * `-XX:+VerifyIntrinsicChecks` - * @comment This does not check out-of-range conditions. The - * `-XX:+VerifyIntrinsicChecks` version of this test simply ensures - * that the VM intrinsic will produce no spurious errors. - * @key randomness - * @library /test/lib - * @comment `vm.debug == true` is required since `VerifyIntrinsicChecks` is a - * development flag - * @requires vm.debug == true - * @run main/othervm/timeout=1200 - * -XX:+VerifyIntrinsicChecks - * --add-opens=java.base/sun.nio.cs=ALL-UNNAMED -Xbatch -Xmx256m - * compiler.intrinsics.string.TestEncodeIntrinsics - */ - package compiler.intrinsics.string; import jdk.test.lib.Utils; diff --git a/test/hotspot/jtreg/compiler/intrinsics/string/TestHasNegatives.java b/test/hotspot/jtreg/compiler/intrinsics/string/TestHasNegatives.java index a15f6aade2e..3e998cf139f 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/string/TestHasNegatives.java +++ b/test/hotspot/jtreg/compiler/intrinsics/string/TestHasNegatives.java @@ -47,27 +47,6 @@ * @run main/othervm/timeout=1200 -XX:UseAVX=3 -XX:+UnlockDiagnosticVMOptions -XX:AVX3Threshold=0 compiler.intrinsics.string.TestHasNegatives */ -/* - * @test - * @bug 8054307 - * @summary Verify `StringCoding::hasNegatives` intrinsic Java wrapper checks - * by enabling the ones in the VM intrinsic using - * `-XX:+VerifyIntrinsicChecks` - * @comment This does not check out-of-range conditions. The - * `-XX:+VerifyIntrinsicChecks` version of this test simply ensures - * that the VM intrinsic will produce no spurious errors. - * @key randomness - * @library /compiler/patches - * @library /test/lib - * @comment `vm.debug == true` is required since `VerifyIntrinsicChecks` is a - * development flag - * @requires vm.debug == true - * @build java.base/java.lang.Helper - * @run main/othervm - * -XX:+VerifyIntrinsicChecks - * compiler.intrinsics.string.TestHasNegatives - */ - package compiler.intrinsics.string; import java.lang.Helper;