diff --git a/src/hotspot/share/gc/shared/genArguments.cpp b/src/hotspot/share/gc/shared/genArguments.cpp
index 76f9f6d4052..c94ca56722f 100644
--- a/src/hotspot/share/gc/shared/genArguments.cpp
+++ b/src/hotspot/share/gc/shared/genArguments.cpp
@@ -37,7 +37,11 @@ size_t MinNewSize = 0;
size_t MinOldSize = 0;
size_t MaxOldSize = 0;
-size_t OldSize = 0;
+// If InitialHeapSize or MinHeapSize is not set on cmdline, this variable,
+// together with NewSize, is used to derive them.
+// Using the same value when it was a configurable flag to avoid breakage.
+// See more in JDK-8346005
+size_t OldSize = ScaleForWordSize(4*M);
size_t GenAlignment = 0;
diff --git a/src/hotspot/share/oops/compressedKlass.hpp b/src/hotspot/share/oops/compressedKlass.hpp
index f0615283f33..dd54c8130eb 100644
--- a/src/hotspot/share/oops/compressedKlass.hpp
+++ b/src/hotspot/share/oops/compressedKlass.hpp
@@ -258,9 +258,15 @@ class CompressedKlassPointers : public AllStatic {
is_aligned(addr, klass_alignment_in_bytes());
}
- // Check that with the given base, shift and range, aarch64 an encode and decode the klass pointer.
- static bool check_klass_decode_mode(address base, int shift, const size_t range) NOT_AARCH64({ return true;});
- static bool set_klass_decode_mode() NOT_AARCH64({ return true;}); // can be called after initialization
+#if defined(AARCH64) && !defined(ZERO)
+ // Check that with the given base, shift and range, aarch64 code can encode and decode the klass pointer.
+ static bool check_klass_decode_mode(address base, int shift, const size_t range);
+ // Called after initialization.
+ static bool set_klass_decode_mode();
+#else
+ static bool check_klass_decode_mode(address base, int shift, const size_t range) { return true; }
+ static bool set_klass_decode_mode() { return true; }
+#endif
};
#endif // SHARE_OOPS_COMPRESSEDKLASS_HPP
diff --git a/src/hotspot/share/opto/vectorIntrinsics.cpp b/src/hotspot/share/opto/vectorIntrinsics.cpp
index 3d20b22a175..63bbc0443b6 100644
--- a/src/hotspot/share/opto/vectorIntrinsics.cpp
+++ b/src/hotspot/share/opto/vectorIntrinsics.cpp
@@ -1637,8 +1637,9 @@ bool LibraryCallKit::inline_vector_reduction() {
int opc = VectorSupport::vop2ideal(opr->get_con(), elem_bt);
int sopc = ReductionNode::opcode(opc, elem_bt);
+ // Ensure reduction operation for lanewise operation
// When using mask, mask use type needs to be VecMaskUseLoad.
- if (!arch_supports_vector(sopc, num_elem, elem_bt, is_masked_op ? VecMaskUseLoad : VecMaskNotUsed)) {
+ if (sopc == opc || !arch_supports_vector(sopc, num_elem, elem_bt, is_masked_op ? VecMaskUseLoad : VecMaskNotUsed)) {
log_if_needed(" ** not supported: arity=1 op=%d/reduce vlen=%d etype=%s is_masked_op=%d",
sopc, num_elem, type2name(elem_bt), is_masked_op ? 1 : 0);
return false;
diff --git a/src/java.base/share/classes/java/lang/classfile/CompoundElement.java b/src/java.base/share/classes/java/lang/classfile/CompoundElement.java
index 38d149623e1..d9f9fe1e5f9 100644
--- a/src/java.base/share/classes/java/lang/classfile/CompoundElement.java
+++ b/src/java.base/share/classes/java/lang/classfile/CompoundElement.java
@@ -34,6 +34,8 @@
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
+import jdk.internal.classfile.components.ClassPrinter;
+
/**
* A {@link ClassFileElement} that has complex structure defined in terms of
* other classfile elements, such as a method, field, method body, or entire
@@ -92,4 +94,14 @@ public void accept(E e) {
return Collections.unmodifiableList(list);
}
+ /**
+ * {@return a text representation of the compound element and its contents for debugging purposes}
+ *
+ * The format, structure and exact contents of the returned string are not specified and may change at any time in the future.
+ */
+ default String toDebugString() {
+ StringBuilder text = new StringBuilder();
+ ClassPrinter.toYaml(this, ClassPrinter.Verbosity.TRACE_ALL, text::append);
+ return text.toString();
+ }
}
diff --git a/src/java.base/share/classes/java/net/Socket.java b/src/java.base/share/classes/java/net/Socket.java
index 929e99b5303..8566367a62d 100644
--- a/src/java.base/share/classes/java/net/Socket.java
+++ b/src/java.base/share/classes/java/net/Socket.java
@@ -569,9 +569,8 @@ void setConnected() {
/**
* Connects this socket to the server.
*
- *
If the endpoint is an unresolved {@link InetSocketAddress}, or the
- * connection cannot be established, then the socket is closed, and an
- * {@link IOException} is thrown.
+ *
If the connection cannot be established, then the socket is closed,
+ * and an {@link IOException} is thrown.
*
*
This method is {@linkplain Thread#interrupt() interruptible} in the
* following circumstances:
@@ -591,8 +590,8 @@ void setConnected() {
* @param endpoint the {@code SocketAddress}
* @throws IOException if an error occurs during the connection, the socket
* is already connected or the socket is closed
- * @throws UnknownHostException if the endpoint is an unresolved
- * {@link InetSocketAddress}
+ * @throws UnknownHostException if the connection could not be established
+ * because the endpoint is an unresolved {@link InetSocketAddress}
* @throws java.nio.channels.IllegalBlockingModeException
* if this socket has an associated channel,
* and the channel is in non-blocking mode
@@ -609,9 +608,8 @@ public void connect(SocketAddress endpoint) throws IOException {
* A timeout of zero is interpreted as an infinite timeout. The connection
* will then block until established or an error occurs.
*
- *
If the endpoint is an unresolved {@link InetSocketAddress}, the
- * connection cannot be established, or the timeout expires before the
- * connection is established, then the socket is closed, and an
+ *
If the connection cannot be established, or the timeout expires
+ * before the connection is established, then the socket is closed, and an
* {@link IOException} is thrown.
*
*
This method is {@linkplain Thread#interrupt() interruptible} in the
@@ -634,8 +632,8 @@ public void connect(SocketAddress endpoint) throws IOException {
* @throws IOException if an error occurs during the connection, the socket
* is already connected or the socket is closed
* @throws SocketTimeoutException if timeout expires before connecting
- * @throws UnknownHostException if the endpoint is an unresolved
- * {@link InetSocketAddress}
+ * @throws UnknownHostException if the connection could not be established
+ * because the endpoint is an unresolved {@link InetSocketAddress}
* @throws java.nio.channels.IllegalBlockingModeException
* if this socket has an associated channel,
* and the channel is in non-blocking mode
@@ -660,12 +658,6 @@ public void connect(SocketAddress endpoint, int timeout) throws IOException {
if (!(endpoint instanceof InetSocketAddress epoint))
throw new IllegalArgumentException("Unsupported address type");
- if (epoint.isUnresolved()) {
- var uhe = new UnknownHostException(epoint.getHostName());
- closeSuppressingExceptions(uhe);
- throw uhe;
- }
-
InetAddress addr = epoint.getAddress();
checkAddress(addr, "connect");
diff --git a/src/java.base/share/classes/java/util/ResourceBundle.java b/src/java.base/share/classes/java/util/ResourceBundle.java
index 989cc09f388..4206dda6a3a 100644
--- a/src/java.base/share/classes/java/util/ResourceBundle.java
+++ b/src/java.base/share/classes/java/util/ResourceBundle.java
@@ -3654,8 +3654,7 @@ private static String toPackageName(String bundleName) {
}
- private static final boolean TRACE_ON = Boolean.getBoolean(
- System.getProperty("resource.bundle.debug", "false"));
+ private static final boolean TRACE_ON = Boolean.getBoolean("resource.bundle.debug");
private static void trace(String format, Object... params) {
if (TRACE_ON)
diff --git a/src/java.base/share/classes/module-info.java b/src/java.base/share/classes/module-info.java
index b9337902e7e..17c3c2ed3bb 100644
--- a/src/java.base/share/classes/module-info.java
+++ b/src/java.base/share/classes/module-info.java
@@ -155,7 +155,6 @@
exports jdk.internal.javac to
java.compiler,
java.desktop, // for ScopedValue
- java.se, // for ParticipatesInPreview
jdk.compiler,
jdk.incubator.vector, // participates in preview features
jdk.jartool, // participates in preview features
diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/PresentationDirection.java b/src/java.desktop/share/classes/javax/print/attribute/standard/PresentationDirection.java
index a9c971d82d6..d4ff8581a2d 100644
--- a/src/java.desktop/share/classes/javax/print/attribute/standard/PresentationDirection.java
+++ b/src/java.desktop/share/classes/javax/print/attribute/standard/PresentationDirection.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2024, 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
@@ -43,7 +43,7 @@
*
* IPP Compatibility: This attribute is not an IPP 1.1 attribute; it is
* an attribute in the Production Printing Extension
- * (
+ * (
* PDF) of IPP 1.1. The category name returned by {@code getName()} is the
* IPP attribute name. The enumeration's integer value is the IPP enum value.
* The {@code toString()} method returns the IPP string representation of the
diff --git a/src/java.se/share/classes/module-info.java b/src/java.se/share/classes/module-info.java
index 9a2704660b7..5dbf65830e3 100644
--- a/src/java.se/share/classes/module-info.java
+++ b/src/java.se/share/classes/module-info.java
@@ -23,8 +23,6 @@
* questions.
*/
-import jdk.internal.javac.ParticipatesInPreview;
-
/**
* Defines the API of the Java SE Platform.
*
@@ -40,7 +38,6 @@
* @moduleGraph
* @since 9
*/
-@ParticipatesInPreview
module java.se {
requires transitive java.base;
requires transitive java.compiler;
diff --git a/src/java.sql/share/classes/java/sql/SQLPermission.java b/src/java.sql/share/classes/java/sql/SQLPermission.java
index 863037502e5..84e41c51a33 100644
--- a/src/java.sql/share/classes/java/sql/SQLPermission.java
+++ b/src/java.sql/share/classes/java/sql/SQLPermission.java
@@ -32,7 +32,7 @@
* A {@code SQLPermission} object contains
* a name (also referred to as a "target name") but no actions
* list; there is either a named permission or there is not.
- * The target name is the name of the permission (see below). The
+ * The target name is the name of the permission. The
* naming convention follows the hierarchical property naming convention.
* In addition, an asterisk
* may appear at the end of the name, following a ".", or by itself, to
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Directive.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Directive.java
index cf942dab5cd..f41866ddb6a 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Directive.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Directive.java
@@ -76,7 +76,7 @@ public static int value(Set s) {
@Override
public String toString() {
- return String.format("ACC_%s (0x%04x", name(), value);
+ return String.format("ACC_%s (0x%04x)", name(), value);
}
}
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java
index c66e1758616..3879f72ff30 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java
@@ -150,7 +150,9 @@ public boolean participatesInPreview(Symtab syms, ModuleSymbol m) {
// s participates in the preview API
return syms.java_base.exports.stream()
.filter(ed -> ed.packge.fullname == names.jdk_internal_javac)
- .anyMatch(ed -> ed.modules.contains(m));
+ .anyMatch(ed -> ed.modules.contains(m)) ||
+ //the specification lists the java.se module as participating in preview:
+ m.name == names.java_se;
}
/**
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
index 62f7c15a95f..2c3a79650b4 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
@@ -2587,10 +2587,6 @@ public void visitApply(JCMethodInvocation tree) {
chk.checkRefType(qualifier.pos(),
attribExpr(qualifier, localEnv,
encl));
- } else if (methName == names._super) {
- // qualifier omitted; check for existence
- // of an appropriate implicit qualifier.
- checkNewInnerClass(tree.meth.pos(), localEnv, site, true);
}
} else if (tree.meth.hasTag(SELECT)) {
log.error(tree.meth.pos(),
@@ -2598,6 +2594,15 @@ public void visitApply(JCMethodInvocation tree) {
attribExpr(((JCFieldAccess) tree.meth).selected, localEnv, site);
}
+ if (tree.meth.hasTag(IDENT)) {
+ // non-qualified super(...) call; check whether explicit constructor
+ // invocation is well-formed. If the super class is an inner class,
+ // make sure that an appropriate implicit qualifier exists. If the super
+ // class is a local class, make sure that the current class is defined
+ // in the same context as the local class.
+ checkNewInnerClass(tree.meth.pos(), localEnv, site, true);
+ }
+
// if we're calling a java.lang.Enum constructor,
// prefix the implicit String and int parameters
if (site.tsym == syms.enumSym)
@@ -3065,7 +3070,7 @@ public void report(DiagnosticPosition _unused, JCDiagnostic details) {
}
void checkNewInnerClass(DiagnosticPosition pos, Env env, Type type, boolean isSuper) {
- boolean isLocal = type.tsym.owner.kind == MTH;
+ boolean isLocal = type.tsym.owner.kind == VAR || type.tsym.owner.kind == MTH;
if ((type.tsym.flags() & (INTERFACE | ENUM | RECORD)) != 0 ||
(!isLocal && !type.tsym.isInner()) ||
(isSuper && env.enclClass.sym.isAnonymous())) {
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java
index 43a0c61a069..855b8a4b234 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java
@@ -3834,7 +3834,7 @@ Symbol findSelfContaining(DiagnosticPosition pos,
*/
Symbol findLocalClassOwner(Env env, TypeSymbol c) {
Symbol owner = c.owner;
- Assert.check(owner.kind == MTH);
+ Assert.check(owner.kind == MTH || owner.kind == VAR);
Env env1 = env;
boolean staticOnly = false;
while (env1.outer != null) {
@@ -3846,7 +3846,9 @@ Symbol findLocalClassOwner(Env env, TypeSymbol c) {
if (isStatic(env1)) staticOnly = true;
env1 = env1.outer;
}
- return methodNotFound;
+ return owner.kind == MTH ?
+ methodNotFound :
+ varNotFound;
}
/**
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties
index 96944f698dd..5d3bf557a20 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties
@@ -3770,7 +3770,7 @@ compiler.misc.cant.resolve.modules=\
cannot resolve modules
compiler.misc.bad.requires.flag=\
- bad requires flag: {0}
+ invalid flag for "requires java.base": {0}
# 0: string
compiler.err.invalid.module.specifier=\
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java
index 6c48490cf16..d9aec7c4592 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java
@@ -127,6 +127,7 @@ public static Names instance(Context context) {
// module names
public final Name java_base;
+ public final Name java_se;
public final Name jdk_unsupported;
// attribute names
@@ -315,6 +316,7 @@ public Names(Context context) {
// module names
java_base = fromString("java.base");
+ java_se = fromString("java.se");
jdk_unsupported = fromString("jdk.unsupported");
// attribute names
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java
index 346b00eda5e..b578390e50f 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java
@@ -2869,6 +2869,10 @@ private static ReductionOperation> reductionOperati
toBits(v.rOp(MAX_OR_INF, m, (i, a, b) -> (byte) Math.min(a, b)));
case VECTOR_OP_MAX: return (v, m) ->
toBits(v.rOp(MIN_OR_INF, m, (i, a, b) -> (byte) Math.max(a, b)));
+ case VECTOR_OP_UMIN: return (v, m) ->
+ toBits(v.rOp(MAX_OR_INF, m, (i, a, b) -> (byte) VectorMath.minUnsigned(a, b)));
+ case VECTOR_OP_UMAX: return (v, m) ->
+ toBits(v.rOp(MIN_OR_INF, m, (i, a, b) -> (byte) VectorMath.maxUnsigned(a, b)));
case VECTOR_OP_AND: return (v, m) ->
toBits(v.rOp((byte)-1, m, (i, a, b) -> (byte)(a & b)));
case VECTOR_OP_OR: return (v, m) ->
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java
index 390c8026083..9a46db33de8 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java
@@ -2854,6 +2854,10 @@ private static ReductionOperation> reductionOpera
toBits(v.rOp(MAX_OR_INF, m, (i, a, b) -> (int) Math.min(a, b)));
case VECTOR_OP_MAX: return (v, m) ->
toBits(v.rOp(MIN_OR_INF, m, (i, a, b) -> (int) Math.max(a, b)));
+ case VECTOR_OP_UMIN: return (v, m) ->
+ toBits(v.rOp(MAX_OR_INF, m, (i, a, b) -> (int) VectorMath.minUnsigned(a, b)));
+ case VECTOR_OP_UMAX: return (v, m) ->
+ toBits(v.rOp(MIN_OR_INF, m, (i, a, b) -> (int) VectorMath.maxUnsigned(a, b)));
case VECTOR_OP_AND: return (v, m) ->
toBits(v.rOp((int)-1, m, (i, a, b) -> (int)(a & b)));
case VECTOR_OP_OR: return (v, m) ->
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java
index 43fedc2693b..8963e52cab1 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java
@@ -2720,6 +2720,10 @@ private static ReductionOperation> reductionOperati
toBits(v.rOp(MAX_OR_INF, m, (i, a, b) -> (long) Math.min(a, b)));
case VECTOR_OP_MAX: return (v, m) ->
toBits(v.rOp(MIN_OR_INF, m, (i, a, b) -> (long) Math.max(a, b)));
+ case VECTOR_OP_UMIN: return (v, m) ->
+ toBits(v.rOp(MAX_OR_INF, m, (i, a, b) -> (long) VectorMath.minUnsigned(a, b)));
+ case VECTOR_OP_UMAX: return (v, m) ->
+ toBits(v.rOp(MIN_OR_INF, m, (i, a, b) -> (long) VectorMath.maxUnsigned(a, b)));
case VECTOR_OP_AND: return (v, m) ->
toBits(v.rOp((long)-1, m, (i, a, b) -> (long)(a & b)));
case VECTOR_OP_OR: return (v, m) ->
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java
index 552967d82e7..88965835e9b 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java
@@ -2870,6 +2870,10 @@ private static ReductionOperation> reductionOpera
toBits(v.rOp(MAX_OR_INF, m, (i, a, b) -> (short) Math.min(a, b)));
case VECTOR_OP_MAX: return (v, m) ->
toBits(v.rOp(MIN_OR_INF, m, (i, a, b) -> (short) Math.max(a, b)));
+ case VECTOR_OP_UMIN: return (v, m) ->
+ toBits(v.rOp(MAX_OR_INF, m, (i, a, b) -> (short) VectorMath.minUnsigned(a, b)));
+ case VECTOR_OP_UMAX: return (v, m) ->
+ toBits(v.rOp(MIN_OR_INF, m, (i, a, b) -> (short) VectorMath.maxUnsigned(a, b)));
case VECTOR_OP_AND: return (v, m) ->
toBits(v.rOp((short)-1, m, (i, a, b) -> (short)(a & b)));
case VECTOR_OP_OR: return (v, m) ->
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template
index 7eb1d9810b1..de9c74130cb 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template
@@ -3375,6 +3375,12 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> {
toBits(v.rOp(MAX_OR_INF, m, (i, a, b) -> ($type$) Math.min(a, b)));
case VECTOR_OP_MAX: return (v, m) ->
toBits(v.rOp(MIN_OR_INF, m, (i, a, b) -> ($type$) Math.max(a, b)));
+#if[!FP]
+ case VECTOR_OP_UMIN: return (v, m) ->
+ toBits(v.rOp(MAX_OR_INF, m, (i, a, b) -> ($type$) VectorMath.minUnsigned(a, b)));
+ case VECTOR_OP_UMAX: return (v, m) ->
+ toBits(v.rOp(MIN_OR_INF, m, (i, a, b) -> ($type$) VectorMath.maxUnsigned(a, b)));
+#end[!FP]
#if[BITWISE]
case VECTOR_OP_AND: return (v, m) ->
toBits(v.rOp(($type$)-1, m, (i, a, b) -> ($type$)(a & b)));
diff --git a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java
index 0eda0b5d455..6717d5517d1 100644
--- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java
+++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java
@@ -49,7 +49,6 @@
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
@@ -378,43 +377,61 @@ public static void createImage(JlinkConfiguration config,
// the token for "all modules on the module path"
private static final String ALL_MODULE_PATH = "ALL-MODULE-PATH";
private JlinkConfiguration initJlinkConfig() throws BadArgs {
- Set roots = new HashSet<>();
- for (String mod : options.addMods) {
- if (mod.equals(ALL_MODULE_PATH) && options.modulePath.size() > 0) {
- ModuleFinder finder = newModuleFinder(options.modulePath, options.limitMods, Set.of());
- // all observable modules are roots
- finder.findAll()
- .stream()
- .map(ModuleReference::descriptor)
- .map(ModuleDescriptor::name)
- .forEach(mn -> roots.add(mn));
- } else {
- roots.add(mod);
- }
- }
-
- ModuleFinder finder = newModuleFinder(options.modulePath, options.limitMods, roots);
- if (finder.find("java.base").isEmpty()) {
+ ModuleFinder appModuleFinder = newModuleFinder(options.modulePath);
+ ModuleFinder finder = appModuleFinder;
+ boolean isLinkFromRuntime = false;
+ if (!appModuleFinder.find("java.base").isPresent()) {
+ // If the application module finder doesn't contain the
+ // java.base module we have one of two cases:
+ // 1. A custom module is being linked into a runtime, but the JDK
+ // modules have not been provided on the module path.
+ // 2. We have a run-time image based link.
+ //
+ // Distinguish case 2 by adding the default 'jmods' folder and try
+ // the look-up again. For case 1 this will now find java.base, but
+ // not for case 2, since the jmods folder is not there or doesn't
+ // include the java.base module.
Path defModPath = getDefaultModulePath();
if (defModPath != null) {
options.modulePath.add(defModPath);
+ finder = newModuleFinder(options.modulePath);
+ }
+ // We've just added the default module path ('jmods'). If we still
+ // don't find java.base, we must resolve JDK modules from the
+ // current run-time image.
+ if (!finder.find("java.base").isPresent()) {
+ // If we don't have a linkable run-time image this is an error
+ if (!LinkableRuntimeImage.isLinkableRuntime()) {
+ throw taskHelper.newBadArgs("err.runtime.link.not.linkable.runtime");
+ }
+ isLinkFromRuntime = true;
+ // JDK modules come from the system module path
+ finder = ModuleFinder.compose(ModuleFinder.ofSystem(), appModuleFinder);
}
- finder = newModuleFinder(options.modulePath, options.limitMods, roots);
}
- boolean isLinkFromRuntime = options.modulePath.isEmpty();
- // In case of custom modules outside the JDK we may
- // have a non-empty module path, which must not include
- // java.base. If it did, we link using packaged modules from that
- // module path. If the module path does not include java.base, we have
- // the case where we link from the run-time image. In that case, we take
- // the JDK modules from the run-time image (ModuleFinder.ofSystem()).
- if (finder.find("java.base").isEmpty()) {
- isLinkFromRuntime = true;
- ModuleFinder runtimeImageFinder = ModuleFinder.ofSystem();
- finder = combinedFinders(runtimeImageFinder, finder, options.limitMods, roots);
+ // Sanity check version if we use JMODs
+ if (!isLinkFromRuntime) {
+ checkJavaBaseVersion(finder);
}
+ // Determine the roots set
+ Set roots = new HashSet<>();
+ for (String mod : options.addMods) {
+ if (mod.equals(ALL_MODULE_PATH)) {
+ ModuleFinder mf = newLimitedFinder(finder, options.limitMods,
+ Set.of());
+ mf.findAll()
+ .stream()
+ .map(ModuleReference::descriptor)
+ .map(ModuleDescriptor::name)
+ .forEach(mn -> roots.add(mn));
+ } else {
+ roots.add(mod);
+ }
+ }
+ finder = newLimitedFinder(finder, options.limitMods, roots);
+
// --keep-packaged-modules doesn't make sense as we are not linking
// from packaged modules to begin with.
if (isLinkFromRuntime && options.packagedModulesPath != null) {
@@ -429,48 +446,13 @@ private JlinkConfiguration initJlinkConfig() throws BadArgs {
options.generateLinkableRuntime);
}
- /**
- * Creates a combined module finder of {@code finder} and
- * {@code runtimeImageFinder} that first looks-up modules in the
- * {@code runtimeImageFinder} and if not present in {@code finder}.
- *
- * @param runtimeImageFinder A system modules finder.
- * @param finder A module finder based on packaged modules.
- * @param limitMods The set of limited modules for the resulting
- * finder (if any).
- * @param roots All module roots.
- *
- * @return A combined finder, or the input finder, potentially applying
- * module limits.
+ /*
+ * Creates a ModuleFinder for the given module paths.
*/
- private ModuleFinder combinedFinders(ModuleFinder runtimeImageFinder,
- ModuleFinder finder,
- Set limitMods,
- Set roots) {
- ModuleFinder combined = new ModuleFinder() {
-
- @Override
- public Optional find(String name) {
- Optional mref = runtimeImageFinder.find(name);
- if (mref.isEmpty()) {
- return finder.find(name);
- }
- return mref;
- }
-
- @Override
- public Set findAll() {
- Set all = new HashSet<>();
- all.addAll(runtimeImageFinder.findAll());
- all.addAll(finder.findAll());
- return Collections.unmodifiableSet(all);
- }
- };
- // if limitmods is specified then limit the universe
- if (limitMods != null && !limitMods.isEmpty()) {
- return limitFinder(combined, limitMods, Objects.requireNonNull(roots));
- }
- return combined;
+ public static ModuleFinder newModuleFinder(List paths) {
+ Runtime.Version version = Runtime.version();
+ Path[] entries = paths.toArray(new Path[0]);
+ return ModulePath.of(version, true, entries);
}
private void createImage(JlinkConfiguration config) throws Exception {
@@ -510,48 +492,81 @@ public static Path getDefaultModulePath() {
}
/*
- * Returns a module finder of the given module path or the system modules
- * if the module path is empty that limits the observable modules to those
- * in the transitive closure of the modules specified in {@code limitMods}
- * plus other modules specified in the {@code roots} set.
+ * Returns a module finder of the given module finder that limits the
+ * observable modules to those in the transitive closure of the modules
+ * specified in {@code limitMods} plus other modules specified in the
+ * {@code roots} set.
+ */
+ public static ModuleFinder newLimitedFinder(ModuleFinder finder,
+ Set limitMods,
+ Set roots) {
+ // if limitMods is specified then limit the universe
+ if (limitMods != null && !limitMods.isEmpty()) {
+ Objects.requireNonNull(roots);
+ // resolve all root modules
+ Configuration cf = Configuration.empty()
+ .resolve(finder,
+ ModuleFinder.of(),
+ limitMods);
+
+ // module name -> reference
+ Map map = new HashMap<>();
+ cf.modules().forEach(m -> {
+ ModuleReference mref = m.reference();
+ map.put(mref.descriptor().name(), mref);
+ });
+
+ // add the other modules
+ roots.stream()
+ .map(finder::find)
+ .flatMap(Optional::stream)
+ .forEach(mref -> map.putIfAbsent(mref.descriptor().name(), mref));
+
+ // set of modules that are observable
+ Set mrefs = new HashSet<>(map.values());
+
+ return new ModuleFinder() {
+ @Override
+ public Optional find(String name) {
+ return Optional.ofNullable(map.get(name));
+ }
+
+ @Override
+ public Set findAll() {
+ return mrefs;
+ }
+ };
+ }
+ return finder;
+ }
+
+ /*
+ * Checks the version of the module descriptor of java.base for compatibility
+ * with the current runtime version.
*
- * @throws IllegalArgumentException if java.base module is present
- * but its descriptor has no version
+ * @throws IllegalArgumentException the descriptor of java.base has no
+ * version or the java.base version is not the same as the current runtime's
+ * version.
*/
- public static ModuleFinder newModuleFinder(List paths,
- Set limitMods,
- Set roots)
- {
- Runtime.Version version = Runtime.version();
- Path[] entries = paths.toArray(new Path[0]);
- ModuleFinder finder = paths.isEmpty() ? ModuleFinder.ofSystem()
- : ModulePath.of(version, true, entries);
- if (finder.find("java.base").isPresent()) {
- // use the version of java.base module, if present, as
- // the release version for multi-release JAR files
- ModuleDescriptor.Version v = finder.find("java.base").get()
+ private static void checkJavaBaseVersion(ModuleFinder finder) {
+ assert finder.find("java.base").isPresent();
+
+ // use the version of java.base module, if present, as
+ // the release version for multi-release JAR files
+ ModuleDescriptor.Version v = finder.find("java.base").get()
.descriptor().version().orElseThrow(() ->
- new IllegalArgumentException("No version in java.base descriptor")
- );
-
- // java.base version is different than the current runtime version
- version = Runtime.Version.parse(v.toString());
- if (Runtime.version().feature() != version.feature() ||
- Runtime.version().interim() != version.interim())
- {
- // jlink version and java.base version do not match.
- // We do not (yet) support this mode.
- throw new IllegalArgumentException(taskHelper.getMessage("err.jlink.version.mismatch",
+ new IllegalArgumentException("No version in java.base descriptor")
+ );
+
+ Runtime.Version version = Runtime.Version.parse(v.toString());
+ if (Runtime.version().feature() != version.feature() ||
+ Runtime.version().interim() != version.interim()) {
+ // jlink version and java.base version do not match.
+ // We do not (yet) support this mode.
+ throw new IllegalArgumentException(taskHelper.getMessage("err.jlink.version.mismatch",
Runtime.version().feature(), Runtime.version().interim(),
version.feature(), version.interim()));
- }
- }
-
- // if limitmods is specified then limit the universe
- if (limitMods != null && !limitMods.isEmpty()) {
- finder = limitFinder(finder, limitMods, Objects.requireNonNull(roots));
}
- return finder;
}
private static void deleteDirectory(Path dir) throws IOException {
@@ -611,10 +626,6 @@ private static ImageHelper createImageProvider(JlinkConfiguration config,
// Perform some sanity checks for linking from the run-time image
if (config.linkFromRuntimeImage()) {
- if (!LinkableRuntimeImage.isLinkableRuntime()) {
- String msg = taskHelper.getMessage("err.runtime.link.not.linkable.runtime");
- throw new IllegalArgumentException(msg);
- }
// Do not permit linking from run-time image and also including jdk.jlink module
if (cf.findModule(JlinkTask.class.getModule().getName()).isPresent()) {
String msg = taskHelper.getMessage("err.runtime.link.jdk.jlink.prohibited");
@@ -773,49 +784,6 @@ private static String findModuleName(Path modInfoPath) {
}
}
- /*
- * Returns a ModuleFinder that limits observability to the given root
- * modules, their transitive dependences, plus a set of other modules.
- */
- public static ModuleFinder limitFinder(ModuleFinder finder,
- Set roots,
- Set otherMods) {
-
- // resolve all root modules
- Configuration cf = Configuration.empty()
- .resolve(finder,
- ModuleFinder.of(),
- roots);
-
- // module name -> reference
- Map map = new HashMap<>();
- cf.modules().forEach(m -> {
- ModuleReference mref = m.reference();
- map.put(mref.descriptor().name(), mref);
- });
-
- // add the other modules
- otherMods.stream()
- .map(finder::find)
- .flatMap(Optional::stream)
- .forEach(mref -> map.putIfAbsent(mref.descriptor().name(), mref));
-
- // set of modules that are observable
- Set mrefs = new HashSet<>(map.values());
-
- return new ModuleFinder() {
- @Override
- public Optional find(String name) {
- return Optional.ofNullable(map.get(name));
- }
-
- @Override
- public Set findAll() {
- return mrefs;
- }
- };
- }
-
private static Platform targetPlatform(Configuration cf,
Map modsPaths,
boolean runtimeImageLink) throws IOException {
diff --git a/test/hotspot/jtreg/ProblemList-Virtual.txt b/test/hotspot/jtreg/ProblemList-Virtual.txt
index 24a1d0c7c5b..09f79165980 100644
--- a/test/hotspot/jtreg/ProblemList-Virtual.txt
+++ b/test/hotspot/jtreg/ProblemList-Virtual.txt
@@ -87,19 +87,10 @@ vmTestbase/nsk/jdi/ExceptionEvent/catchLocation/location002/TestDescription.java
vmTestbase/nsk/jdi/VMOutOfMemoryException/VMOutOfMemoryException001/VMOutOfMemoryException001.java 8285417 generic-all
###
-# The test first suspends a vthread and all the carriers and then it resumes the vthread expecting it
-# to run to completion. In mainline it only works because the suspension step happens while the vthread is
-# pinned to the carrier blocked on synchronized. So the carrier only actually suspends on the next unmount
-# transition which in this test happens once the vthread has finished executing the expected code.
-
+# Fails because resume of a virtual thread is not enough to allow the virtual thread
+# to make progress when all other threads are currently suspended.
vmTestbase/nsk/jdi/ThreadReference/isSuspended/issuspended002/TestDescription.java 8338713 generic-all
-###
-# The test sends a StopThread to a vthread expecting that is currently pinned to the carrier blocked on
-# synchronized. Since the vthread is now unmounted StopThread returns JVMTI_ERROR_OPAQUE_FRAME error.
-
-vmTestbase/nsk/jdb/kill/kill001/kill001.java 8338714 generic-all
-
###
# Fails on Windows because of additional memory allocation.
diff --git a/test/hotspot/jtreg/runtime/cds/appcds/LambdaWithUseImplMethodHandle.java b/test/hotspot/jtreg/runtime/cds/appcds/LambdaWithUseImplMethodHandle.java
index 360fce5879a..0c747168945 100644
--- a/test/hotspot/jtreg/runtime/cds/appcds/LambdaWithUseImplMethodHandle.java
+++ b/test/hotspot/jtreg/runtime/cds/appcds/LambdaWithUseImplMethodHandle.java
@@ -27,6 +27,9 @@
* @bug 8290417
* @summary CDS cannot archive lambda proxy with useImplMethodHandle
* @requires vm.cds
+ * @requires vm.cds.supports.aot.class.linking
+ * @comment work around JDK-8345635
+ * @requires !vm.jvmci.enabled
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds /test/hotspot/jtreg/runtime/cds/appcds/test-classes
* @build pkg1.BaseWithProtectedMethod
* @build pkg2.Child
diff --git a/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/BulkLoaderTest.java b/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/BulkLoaderTest.java
index 6e7473c59c1..25361403481 100644
--- a/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/BulkLoaderTest.java
+++ b/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/BulkLoaderTest.java
@@ -29,6 +29,8 @@
/*
* @test id=static
* @requires vm.cds.supports.aot.class.linking
+ * @comment work around JDK-8345635
+ * @requires !vm.jvmci.enabled
* @library /test/jdk/lib/testlibrary /test/lib
* @build InitiatingLoaderTester
* @build BulkLoaderTest
@@ -39,6 +41,8 @@
/*
* @test id=dynamic
* @requires vm.cds.supports.aot.class.linking
+ * @comment work around JDK-8345635
+ * @requires !vm.jvmci.enabled
* @library /test/jdk/lib/testlibrary /test/lib
* @build InitiatingLoaderTester
* @build jdk.test.whitebox.WhiteBox BulkLoaderTest
diff --git a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchiveHeapTestClass.java b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchiveHeapTestClass.java
index 1603d8430b2..ca5a08d20af 100644
--- a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchiveHeapTestClass.java
+++ b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchiveHeapTestClass.java
@@ -27,6 +27,9 @@
* @bug 8214781 8293187
* @summary Test for the -XX:ArchiveHeapTestClass flag
* @requires vm.debug == true & vm.cds.write.archived.java.heap
+ * @requires vm.cds.supports.aot.class.linking
+ * @comment work around JDK-8345635
+ * @requires !vm.jvmci.enabled
* @modules java.logging
* @library /test/jdk/lib/testlibrary /test/lib
* /test/hotspot/jtreg/runtime/cds/appcds
diff --git a/test/hotspot/jtreg/runtime/cds/appcds/resolvedConstants/AOTLinkedLambdas.java b/test/hotspot/jtreg/runtime/cds/appcds/resolvedConstants/AOTLinkedLambdas.java
index 5fb0a30cd61..d015498ed04 100644
--- a/test/hotspot/jtreg/runtime/cds/appcds/resolvedConstants/AOTLinkedLambdas.java
+++ b/test/hotspot/jtreg/runtime/cds/appcds/resolvedConstants/AOTLinkedLambdas.java
@@ -28,6 +28,8 @@
* @bug 8340836
* @requires vm.cds
* @requires vm.cds.supports.aot.class.linking
+ * @comment work around JDK-8345635
+ * @requires !vm.jvmci.enabled
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds/test-classes/
* @build AOTLinkedLambdas
* @run driver jdk.test.lib.helpers.ClassFileInstaller -jar app.jar
diff --git a/test/hotspot/jtreg/runtime/cds/appcds/resolvedConstants/AOTLinkedVarHandles.java b/test/hotspot/jtreg/runtime/cds/appcds/resolvedConstants/AOTLinkedVarHandles.java
index 2098ebc2c71..886e0424c9a 100644
--- a/test/hotspot/jtreg/runtime/cds/appcds/resolvedConstants/AOTLinkedVarHandles.java
+++ b/test/hotspot/jtreg/runtime/cds/appcds/resolvedConstants/AOTLinkedVarHandles.java
@@ -28,6 +28,8 @@
* @bug 8343245
* @requires vm.cds
* @requires vm.cds.supports.aot.class.linking
+ * @comment work around JDK-8345635
+ * @requires !vm.jvmci.enabled
* @library /test/lib
* @build AOTLinkedVarHandles
* @run driver jdk.test.lib.helpers.ClassFileInstaller -jar app.jar
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdb/kill/kill001/kill001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdb/kill/kill001/kill001a.java
index 37102111a93..a9adab65dd8 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdb/kill/kill001/kill001a.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdb/kill/kill001/kill001a.java
@@ -27,6 +27,7 @@
import nsk.share.jpda.*;
import nsk.share.jdb.*;
import nsk.share.jdi.JDIThreadFactory;
+import jdk.test.lib.thread.VThreadPinner;
import java.io.*;
import java.util.*;
@@ -152,6 +153,17 @@ void methodForException() {
}
public void run() {
+ boolean vthreadMode = "Virtual".equals(System.getProperty("test.thread.factory"));
+ if (vthreadMode) {
+ // JVMTI StopThread is only supported for mounted virtual threads. We need to
+ // pin the virtual threads so they remain mounted.
+ VThreadPinner.runPinned(() -> test());
+ } else {
+ test();
+ }
+ }
+
+ public void test() {
// Concatenate strings in advance to avoid lambda calculations later
String ThreadFinished = "Thread finished: " + this.name;
String CaughtExpected = "Thread " + this.name + " caught expected async exception: " + expectedException;
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/jdb/Launcher.java b/test/hotspot/jtreg/vmTestbase/nsk/share/jdb/Launcher.java
index d4437413495..44e476d0be7 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/jdb/Launcher.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jdb/Launcher.java
@@ -137,6 +137,9 @@ private String[] makeJdbCmdLine (String classToExecute) {
/* Some tests need more carrier threads than the default provided. */
args.add("-R-Djdk.virtualThreadScheduler.parallelism=15");
}
+ /* Some jdb tests need java.library.path setup for native libraries. */
+ String libpath = System.getProperty("java.library.path");
+ args.add("-R-Djava.library.path=" + libpath);
}
args.addAll(argumentHandler.enwrapJavaOptions(argumentHandler.getJavaOptions()));
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace007.java b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace007.java
index 61fbc146b60..e4115432c64 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace007.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace007.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2024, 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
@@ -125,6 +125,11 @@ static boolean makeSnapshot() {
StackTraceElement[] all;
for (int i = 1; i < THRD_COUNT; i++) {
all = traces.get(threads[i]);
+ if (all == null) {
+ complain("No stacktrace for thread " + threads[i].getName() +
+ " was found in the set of all traces");
+ return false;
+ }
int k = all.length;
if (count - k > 2) {
complain("wrong lengths of stack traces:\n\t"
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace008.java b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace008.java
index 24b421ae99d..f237daaf049 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace008.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace008.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2024, 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
@@ -129,6 +129,11 @@ static boolean makeSnapshot() {
StackTraceElement[] all;
for (int i = 1; i < THRD_COUNT; i++) {
all = traces.get(threads[i]);
+ if (all == null) {
+ complain("No stacktrace for thread " + threads[i].getName() +
+ " was found in the set of all traces");
+ return false;
+ }
int k = all.length;
if (count - k > 4) {
complain("wrong lengths of stack traces:\n\t"
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace009.java b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace009.java
index 0f8ee03f700..ad9f77f0c58 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace009.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace009.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2024, 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
@@ -129,6 +129,11 @@ static boolean makeSnapshot() {
StackTraceElement[] all;
for (int i = 1; i < THRD_COUNT; i++) {
all = traces.get(threads[i]);
+ if (all == null) {
+ complain("No stacktrace for thread " + threads[i].getName() +
+ " was found in the set of all traces");
+ return false;
+ }
int k = all.length;
if (count - k > 2) {
complain("wrong lengths of stack traces:\n\t"
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace010.java b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace010.java
index 3595ae3735f..ee07292ed01 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace010.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace010.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2024, 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
@@ -145,6 +145,11 @@ boolean makeSnapshot() {
StackTraceElement[] all;
for (int i = 1; i < THRD_COUNT; i++) {
all = traces.get(threads[i]);
+ if (all == null) {
+ complain("No stacktrace for thread " + threads[i].getName() +
+ " was found in the set of all traces");
+ return false;
+ }
int k = all.length;
if (count - k > 2) {
complain("wrong lengths of stack traces:\n\t"
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace011.java b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace011.java
index eb48601b2a2..185bcbc316b 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace011.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace011.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2024, 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
@@ -149,6 +149,11 @@ boolean makeSnapshot() {
StackTraceElement[] all;
for (int i = 1; i < THRD_COUNT; i++) {
all = traces.get(threads[i]);
+ if (all == null) {
+ complain("No stacktrace for thread " + threads[i].getName() +
+ " was found in the set of all traces");
+ return false;
+ }
int k = all.length;
if (count - k > 2) {
complain("wrong lengths of stack traces:\n\t"
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace012.java b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace012.java
index 4ebc3de7395..89451c97732 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace012.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace012.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2024, 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
@@ -151,6 +151,11 @@ boolean makeSnapshot() {
StackTraceElement[] all;
for (int i = 1; i < THRD_COUNT; i++) {
all = traces.get(threads[i]);
+ if (all == null) {
+ complain("No stacktrace for thread " + threads[i].getName() +
+ " was found in the set of all traces");
+ return false;
+ }
int k = all.length;
if (count - k > 2) {
complain("wrong lengths of stack traces:\n\t"
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace013.java b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace013.java
index 87de7d112f8..6bff7354393 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace013.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace013.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2024, 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
@@ -130,6 +130,11 @@ boolean makeSnapshot() {
StackTraceElement[] all;
for (int i = 1; i < THRD_COUNT; i++) {
all = traces.get(threads[i]);
+ if (all == null) {
+ complain("No stacktrace for thread " + threads[i].getName() +
+ " was found in the set of all traces");
+ return false;
+ }
int k = all.length;
if (count - k > 3) {
complain("wrong lengths of stack traces:\n\t"
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace014.java b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace014.java
index bc760f1722a..0ef900b35df 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace014.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace014.java
@@ -140,6 +140,11 @@ boolean makeSnapshot() {
StackTraceElement[] all;
for (int i = 1; i < THRD_COUNT; i++) {
all = traces.get(threads[i]);
+ if (all == null) {
+ complain("No stacktrace for thread " + threads[i].getName() +
+ " was found in the set of all traces");
+ return false;
+ }
int k = all.length;
if (count - k > 4) {
complain("wrong lengths of stack traces:\n\t"
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace015.java b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace015.java
index 437e4f9e21c..940628cff09 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace015.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace015.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2024, 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
@@ -138,6 +138,11 @@ boolean makeSnapshot() {
StackTraceElement[] all;
for (int i = 1; i < THRD_COUNT; i++) {
all = traces.get(threads[i]);
+ if (all == null) {
+ complain("No stacktrace for thread " + threads[i].getName() +
+ " was found in the set of all traces");
+ return false;
+ }
int k = all.length;
if (count - k > 3) {
complain("wrong lengths of stack traces:\n\t"
diff --git a/test/jdk/java/net/Socket/ConnectFailTest.java b/test/jdk/java/net/Socket/ConnectFailTest.java
index 7cc46ce4a4d..f21ed7d132d 100644
--- a/test/jdk/java/net/Socket/ConnectFailTest.java
+++ b/test/jdk/java/net/Socket/ConnectFailTest.java
@@ -29,6 +29,7 @@
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
+import java.net.Proxy;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
@@ -36,6 +37,7 @@
import java.nio.channels.SocketChannel;
import java.util.List;
+import static java.net.InetAddress.getLoopbackAddress;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -50,6 +52,8 @@
*/
class ConnectFailTest {
+ // Implementation Note: Explicitly binding on the loopback address to avoid potential unstabilities.
+
private static final int DEAD_SERVER_PORT = 0xDEAD;
private static final InetSocketAddress REFUSING_SOCKET_ADDRESS = Utils.refusingEndpoint();
@@ -83,7 +87,7 @@ void testUnboundSocket(Socket socket) throws IOException {
@MethodSource("sockets")
void testBoundSocket(Socket socket) throws IOException {
try (socket) {
- socket.bind(new InetSocketAddress(0));
+ socket.bind(new InetSocketAddress(getLoopbackAddress(), 0));
assertTrue(socket.isBound());
assertFalse(socket.isConnected());
assertThrows(IOException.class, () -> socket.connect(REFUSING_SOCKET_ADDRESS));
@@ -132,7 +136,7 @@ void testUnboundSocketWithUnresolvedAddress(Socket socket) throws IOException {
@MethodSource("sockets")
void testBoundSocketWithUnresolvedAddress(Socket socket) throws IOException {
try (socket) {
- socket.bind(new InetSocketAddress(0));
+ socket.bind(new InetSocketAddress(getLoopbackAddress(), 0));
assertTrue(socket.isBound());
assertFalse(socket.isConnected());
assertThrows(UnknownHostException.class, () -> socket.connect(UNRESOLVED_ADDRESS));
@@ -161,7 +165,8 @@ static List sockets() throws Exception {
Socket socket = new Socket();
@SuppressWarnings("resource")
Socket channelSocket = SocketChannel.open().socket();
- return List.of(socket, channelSocket);
+ Socket noProxySocket = new Socket(Proxy.NO_PROXY);
+ return List.of(socket, channelSocket, noProxySocket);
}
private static ServerSocket createEphemeralServerSocket() throws IOException {
diff --git a/test/jdk/java/net/Socket/ConnectSocksProxyTest.java b/test/jdk/java/net/Socket/ConnectSocksProxyTest.java
new file mode 100644
index 00000000000..8bea5ff816e
--- /dev/null
+++ b/test/jdk/java/net/Socket/ConnectSocksProxyTest.java
@@ -0,0 +1,218 @@
+/*
+ * Copyright (c) 2024, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import jdk.test.lib.Utils;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.net.Authenticator;
+import java.net.InetSocketAddress;
+import java.net.PasswordAuthentication;
+import java.net.Proxy;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.SocketException;
+
+import static java.net.InetAddress.getLoopbackAddress;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/*
+ * @test
+ * @bug 8346017
+ * @summary Verifies the `connect()` behaviour of a SOCKS proxy socket. In particular, that passing a resolvable
+ * unresolved address doesn't throw an exception.
+ * @library /test/lib /java/net/Socks
+ * @build SocksServer
+ * @run junit ConnectSocksProxyTest
+ */
+class ConnectSocksProxyTest {
+
+ // Implementation Note: Explicitly binding on the loopback address to avoid potential unstabilities.
+
+ private static final int DEAD_SERVER_PORT = 0xDEAD;
+
+ private static final InetSocketAddress REFUSING_SOCKET_ADDRESS = Utils.refusingEndpoint();
+
+ private static final InetSocketAddress UNRESOLVED_ADDRESS =
+ InetSocketAddress.createUnresolved("no.such.host", DEAD_SERVER_PORT);
+
+ private static final String PROXY_AUTH_USERNAME = "foo";
+
+ private static final String PROXY_AUTH_PASSWORD = "bar";
+
+ private static SocksServer PROXY_SERVER;
+
+ private static Proxy PROXY;
+
+ @BeforeAll
+ static void initAuthenticator() {
+ Authenticator.setDefault(new Authenticator() {
+ @Override
+ protected PasswordAuthentication getPasswordAuthentication() {
+ return new PasswordAuthentication(PROXY_AUTH_USERNAME, PROXY_AUTH_PASSWORD.toCharArray());
+ }
+ });
+ }
+
+ @BeforeAll
+ static void initProxyServer() throws IOException {
+ PROXY_SERVER = new SocksServer(getLoopbackAddress(), 0, false);
+ PROXY_SERVER.addUser(PROXY_AUTH_USERNAME, PROXY_AUTH_PASSWORD);
+ PROXY_SERVER.start();
+ InetSocketAddress proxyAddress = new InetSocketAddress(getLoopbackAddress(), PROXY_SERVER.getPort());
+ PROXY = new Proxy(Proxy.Type.SOCKS, proxyAddress);
+ }
+
+ @AfterAll
+ static void stopProxyServer() {
+ PROXY_SERVER.close();
+ }
+
+ @Test
+ void testUnresolvedAddress() {
+ assertTrue(UNRESOLVED_ADDRESS.isUnresolved());
+ }
+
+ /**
+ * Verifies that an unbound socket is closed when {@code connect()} fails.
+ */
+ @Test
+ void testUnboundSocket() throws IOException {
+ try (Socket socket = createProxiedSocket()) {
+ assertFalse(socket.isBound());
+ assertFalse(socket.isConnected());
+ assertThrows(IOException.class, () -> socket.connect(REFUSING_SOCKET_ADDRESS));
+ assertTrue(socket.isClosed());
+ }
+ }
+
+ /**
+ * Verifies that a bound socket is closed when {@code connect()} fails.
+ */
+ @Test
+ void testBoundSocket() throws IOException {
+ try (Socket socket = createProxiedSocket()) {
+ socket.bind(new InetSocketAddress(getLoopbackAddress(), 0));
+ assertTrue(socket.isBound());
+ assertFalse(socket.isConnected());
+ assertThrows(IOException.class, () -> socket.connect(REFUSING_SOCKET_ADDRESS));
+ assertTrue(socket.isClosed());
+ }
+ }
+
+ /**
+ * Verifies that a connected socket is not closed when {@code connect()} fails.
+ */
+ @Test
+ void testConnectedSocket() throws Throwable {
+ try (Socket socket = createProxiedSocket();
+ ServerSocket serverSocket = createEphemeralServerSocket()) {
+ socket.connect(serverSocket.getLocalSocketAddress());
+ try (Socket _ = serverSocket.accept()) {
+ assertTrue(socket.isBound());
+ assertTrue(socket.isConnected());
+ SocketException exception = assertThrows(
+ SocketException.class,
+ () -> socket.connect(REFUSING_SOCKET_ADDRESS));
+ assertEquals("Already connected", exception.getMessage());
+ assertFalse(socket.isClosed());
+ }
+ }
+ }
+
+ /**
+ * Delegates to {@link #testUnconnectedSocketWithUnresolvedAddress(boolean, Socket)} using an unbound socket.
+ */
+ @Test
+ void testUnboundSocketWithUnresolvedAddress() throws IOException {
+ try (Socket socket = createProxiedSocket()) {
+ assertFalse(socket.isBound());
+ assertFalse(socket.isConnected());
+ testUnconnectedSocketWithUnresolvedAddress(false, socket);
+ }
+ }
+
+ /**
+ * Delegates to {@link #testUnconnectedSocketWithUnresolvedAddress(boolean, Socket)} using a bound socket.
+ */
+ @Test
+ void testBoundSocketWithUnresolvedAddress() throws IOException {
+ try (Socket socket = createProxiedSocket()) {
+ socket.bind(new InetSocketAddress(getLoopbackAddress(), 0));
+ testUnconnectedSocketWithUnresolvedAddress(true, socket);
+ }
+ }
+
+ /**
+ * Verifies the behaviour of an unconnected socket when {@code connect()} is invoked using an unresolved address.
+ */
+ private static void testUnconnectedSocketWithUnresolvedAddress(boolean bound, Socket socket) throws IOException {
+ assertEquals(bound, socket.isBound());
+ assertFalse(socket.isConnected());
+ try (ServerSocket serverSocket = createEphemeralServerSocket()) {
+ InetSocketAddress unresolvedAddress = InetSocketAddress.createUnresolved(
+ getLoopbackAddress().getHostAddress(),
+ serverSocket.getLocalPort());
+ socket.connect(unresolvedAddress);
+ try (Socket _ = serverSocket.accept()) {
+ assertTrue(socket.isBound());
+ assertTrue(socket.isConnected());
+ assertFalse(socket.isClosed());
+ }
+ }
+ }
+
+ /**
+ * Verifies that a connected socket is not closed when {@code connect()} is invoked using an unresolved address.
+ */
+ @Test
+ void testConnectedSocketWithUnresolvedAddress() throws Throwable {
+ try (Socket socket = createProxiedSocket();
+ ServerSocket serverSocket = createEphemeralServerSocket()) {
+ socket.connect(serverSocket.getLocalSocketAddress());
+ try (Socket _ = serverSocket.accept()) {
+ assertTrue(socket.isBound());
+ assertTrue(socket.isConnected());
+ SocketException exception = assertThrows(
+ SocketException.class,
+ () -> socket.connect(UNRESOLVED_ADDRESS));
+ assertEquals("Already connected", exception.getMessage());
+ assertFalse(socket.isClosed());
+ }
+ }
+ }
+
+ private static Socket createProxiedSocket() {
+ return new Socket(PROXY);
+ }
+
+ private static ServerSocket createEphemeralServerSocket() throws IOException {
+ return new ServerSocket(0, 0, getLoopbackAddress());
+ }
+
+}
diff --git a/test/jdk/jdk/classfile/ClassPrinterTest.java b/test/jdk/jdk/classfile/ClassPrinterTest.java
index 5dc136f59c3..506f3382b83 100644
--- a/test/jdk/jdk/classfile/ClassPrinterTest.java
+++ b/test/jdk/jdk/classfile/ClassPrinterTest.java
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8335927
+ * @bug 8335927 8345773
* @summary Testing ClassFile ClassPrinter.
* @run junit ClassPrinterTest
*/
@@ -122,8 +122,7 @@ ClassModel getClassModel() {
@Test
void testPrintYamlTraceAll() throws IOException {
- var out = new StringBuilder();
- ClassPrinter.toYaml(getClassModel(), ClassPrinter.Verbosity.TRACE_ALL, out::append);
+ var out = getClassModel().toDebugString();
assertOut(out,
"""
- class name: Foo
@@ -904,7 +903,7 @@ void testWalkMembersOnly() throws IOException {
assertEquals(node.walk().count(), 42);
}
- private static void assertOut(StringBuilder out, String expected) {
+ private static void assertOut(CharSequence out, String expected) {
// System.out.println("-----------------");
// System.out.println(out.toString());
// System.out.println("-----------------");
diff --git a/test/jdk/jdk/incubator/vector/Byte128VectorTests.java b/test/jdk/jdk/incubator/vector/Byte128VectorTests.java
index 36a140c474a..7c8265169f4 100644
--- a/test/jdk/jdk/incubator/vector/Byte128VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Byte128VectorTests.java
@@ -3912,6 +3912,184 @@ static void MAXReduceByte128VectorTestsMasked(IntFunction fa, IntFunctio
Byte128VectorTests::MAXReduceMasked, Byte128VectorTests::MAXReduceAllMasked);
}
+ static byte UMINReduce(byte[] a, int idx) {
+ byte res = Byte.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (byte) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static byte UMINReduceAll(byte[] a) {
+ byte res = Byte.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (byte) VectorMath.minUnsigned(res, UMINReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "byteUnaryOpProvider")
+ static void UMINReduceByte128VectorTests(IntFunction fa) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+ byte ra = Byte.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Byte.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ ra = (byte) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ Byte128VectorTests::UMINReduce, Byte128VectorTests::UMINReduceAll);
+ }
+
+ static byte UMINReduceMasked(byte[] a, int idx, boolean[] mask) {
+ byte res = Byte.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (byte) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static byte UMINReduceAllMasked(byte[] a, boolean[] mask) {
+ byte res = Byte.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (byte) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "byteUnaryOpMaskProvider")
+ static void UMINReduceByte128VectorTestsMasked(IntFunction fa, IntFunction fm) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ byte ra = Byte.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Byte.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ ra = (byte) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ Byte128VectorTests::UMINReduceMasked, Byte128VectorTests::UMINReduceAllMasked);
+ }
+
+ static byte UMAXReduce(byte[] a, int idx) {
+ byte res = Byte.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (byte) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static byte UMAXReduceAll(byte[] a) {
+ byte res = Byte.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (byte) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "byteUnaryOpProvider")
+ static void UMAXReduceByte128VectorTests(IntFunction fa) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+ byte ra = Byte.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Byte.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ ra = (byte) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ Byte128VectorTests::UMAXReduce, Byte128VectorTests::UMAXReduceAll);
+ }
+
+ static byte UMAXReduceMasked(byte[] a, int idx, boolean[] mask) {
+ byte res = Byte.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (byte) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static byte UMAXReduceAllMasked(byte[] a, boolean[] mask) {
+ byte res = Byte.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (byte) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "byteUnaryOpMaskProvider")
+ static void UMAXReduceByte128VectorTestsMasked(IntFunction fa, IntFunction fm) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ byte ra = Byte.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Byte.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ ra = (byte) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ Byte128VectorTests::UMAXReduceMasked, Byte128VectorTests::UMAXReduceAllMasked);
+ }
+
static byte FIRST_NONZEROReduce(byte[] a, int idx) {
byte res = (byte) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
diff --git a/test/jdk/jdk/incubator/vector/Byte256VectorTests.java b/test/jdk/jdk/incubator/vector/Byte256VectorTests.java
index 0ad567b5ee4..0fbbca79f5d 100644
--- a/test/jdk/jdk/incubator/vector/Byte256VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Byte256VectorTests.java
@@ -3912,6 +3912,184 @@ static void MAXReduceByte256VectorTestsMasked(IntFunction fa, IntFunctio
Byte256VectorTests::MAXReduceMasked, Byte256VectorTests::MAXReduceAllMasked);
}
+ static byte UMINReduce(byte[] a, int idx) {
+ byte res = Byte.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (byte) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static byte UMINReduceAll(byte[] a) {
+ byte res = Byte.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (byte) VectorMath.minUnsigned(res, UMINReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "byteUnaryOpProvider")
+ static void UMINReduceByte256VectorTests(IntFunction fa) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+ byte ra = Byte.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Byte.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ ra = (byte) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ Byte256VectorTests::UMINReduce, Byte256VectorTests::UMINReduceAll);
+ }
+
+ static byte UMINReduceMasked(byte[] a, int idx, boolean[] mask) {
+ byte res = Byte.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (byte) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static byte UMINReduceAllMasked(byte[] a, boolean[] mask) {
+ byte res = Byte.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (byte) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "byteUnaryOpMaskProvider")
+ static void UMINReduceByte256VectorTestsMasked(IntFunction fa, IntFunction fm) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ byte ra = Byte.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Byte.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ ra = (byte) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ Byte256VectorTests::UMINReduceMasked, Byte256VectorTests::UMINReduceAllMasked);
+ }
+
+ static byte UMAXReduce(byte[] a, int idx) {
+ byte res = Byte.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (byte) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static byte UMAXReduceAll(byte[] a) {
+ byte res = Byte.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (byte) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "byteUnaryOpProvider")
+ static void UMAXReduceByte256VectorTests(IntFunction fa) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+ byte ra = Byte.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Byte.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ ra = (byte) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ Byte256VectorTests::UMAXReduce, Byte256VectorTests::UMAXReduceAll);
+ }
+
+ static byte UMAXReduceMasked(byte[] a, int idx, boolean[] mask) {
+ byte res = Byte.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (byte) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static byte UMAXReduceAllMasked(byte[] a, boolean[] mask) {
+ byte res = Byte.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (byte) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "byteUnaryOpMaskProvider")
+ static void UMAXReduceByte256VectorTestsMasked(IntFunction fa, IntFunction fm) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ byte ra = Byte.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Byte.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ ra = (byte) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ Byte256VectorTests::UMAXReduceMasked, Byte256VectorTests::UMAXReduceAllMasked);
+ }
+
static byte FIRST_NONZEROReduce(byte[] a, int idx) {
byte res = (byte) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
diff --git a/test/jdk/jdk/incubator/vector/Byte512VectorTests.java b/test/jdk/jdk/incubator/vector/Byte512VectorTests.java
index 0edc66dfccc..a17e621a0e6 100644
--- a/test/jdk/jdk/incubator/vector/Byte512VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Byte512VectorTests.java
@@ -3912,6 +3912,184 @@ static void MAXReduceByte512VectorTestsMasked(IntFunction fa, IntFunctio
Byte512VectorTests::MAXReduceMasked, Byte512VectorTests::MAXReduceAllMasked);
}
+ static byte UMINReduce(byte[] a, int idx) {
+ byte res = Byte.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (byte) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static byte UMINReduceAll(byte[] a) {
+ byte res = Byte.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (byte) VectorMath.minUnsigned(res, UMINReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "byteUnaryOpProvider")
+ static void UMINReduceByte512VectorTests(IntFunction fa) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+ byte ra = Byte.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Byte.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ ra = (byte) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ Byte512VectorTests::UMINReduce, Byte512VectorTests::UMINReduceAll);
+ }
+
+ static byte UMINReduceMasked(byte[] a, int idx, boolean[] mask) {
+ byte res = Byte.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (byte) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static byte UMINReduceAllMasked(byte[] a, boolean[] mask) {
+ byte res = Byte.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (byte) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "byteUnaryOpMaskProvider")
+ static void UMINReduceByte512VectorTestsMasked(IntFunction fa, IntFunction fm) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ byte ra = Byte.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Byte.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ ra = (byte) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ Byte512VectorTests::UMINReduceMasked, Byte512VectorTests::UMINReduceAllMasked);
+ }
+
+ static byte UMAXReduce(byte[] a, int idx) {
+ byte res = Byte.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (byte) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static byte UMAXReduceAll(byte[] a) {
+ byte res = Byte.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (byte) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "byteUnaryOpProvider")
+ static void UMAXReduceByte512VectorTests(IntFunction fa) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+ byte ra = Byte.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Byte.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ ra = (byte) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ Byte512VectorTests::UMAXReduce, Byte512VectorTests::UMAXReduceAll);
+ }
+
+ static byte UMAXReduceMasked(byte[] a, int idx, boolean[] mask) {
+ byte res = Byte.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (byte) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static byte UMAXReduceAllMasked(byte[] a, boolean[] mask) {
+ byte res = Byte.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (byte) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "byteUnaryOpMaskProvider")
+ static void UMAXReduceByte512VectorTestsMasked(IntFunction fa, IntFunction fm) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ byte ra = Byte.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Byte.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ ra = (byte) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ Byte512VectorTests::UMAXReduceMasked, Byte512VectorTests::UMAXReduceAllMasked);
+ }
+
static byte FIRST_NONZEROReduce(byte[] a, int idx) {
byte res = (byte) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
diff --git a/test/jdk/jdk/incubator/vector/Byte64VectorTests.java b/test/jdk/jdk/incubator/vector/Byte64VectorTests.java
index 98c8382c526..58f1d6295a0 100644
--- a/test/jdk/jdk/incubator/vector/Byte64VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Byte64VectorTests.java
@@ -3912,6 +3912,184 @@ static void MAXReduceByte64VectorTestsMasked(IntFunction fa, IntFunction
Byte64VectorTests::MAXReduceMasked, Byte64VectorTests::MAXReduceAllMasked);
}
+ static byte UMINReduce(byte[] a, int idx) {
+ byte res = Byte.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (byte) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static byte UMINReduceAll(byte[] a) {
+ byte res = Byte.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (byte) VectorMath.minUnsigned(res, UMINReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "byteUnaryOpProvider")
+ static void UMINReduceByte64VectorTests(IntFunction fa) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+ byte ra = Byte.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Byte.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ ra = (byte) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ Byte64VectorTests::UMINReduce, Byte64VectorTests::UMINReduceAll);
+ }
+
+ static byte UMINReduceMasked(byte[] a, int idx, boolean[] mask) {
+ byte res = Byte.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (byte) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static byte UMINReduceAllMasked(byte[] a, boolean[] mask) {
+ byte res = Byte.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (byte) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "byteUnaryOpMaskProvider")
+ static void UMINReduceByte64VectorTestsMasked(IntFunction fa, IntFunction fm) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ byte ra = Byte.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Byte.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ ra = (byte) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ Byte64VectorTests::UMINReduceMasked, Byte64VectorTests::UMINReduceAllMasked);
+ }
+
+ static byte UMAXReduce(byte[] a, int idx) {
+ byte res = Byte.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (byte) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static byte UMAXReduceAll(byte[] a) {
+ byte res = Byte.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (byte) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "byteUnaryOpProvider")
+ static void UMAXReduceByte64VectorTests(IntFunction fa) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+ byte ra = Byte.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Byte.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ ra = (byte) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ Byte64VectorTests::UMAXReduce, Byte64VectorTests::UMAXReduceAll);
+ }
+
+ static byte UMAXReduceMasked(byte[] a, int idx, boolean[] mask) {
+ byte res = Byte.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (byte) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static byte UMAXReduceAllMasked(byte[] a, boolean[] mask) {
+ byte res = Byte.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (byte) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "byteUnaryOpMaskProvider")
+ static void UMAXReduceByte64VectorTestsMasked(IntFunction fa, IntFunction fm) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ byte ra = Byte.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Byte.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ ra = (byte) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ Byte64VectorTests::UMAXReduceMasked, Byte64VectorTests::UMAXReduceAllMasked);
+ }
+
static byte FIRST_NONZEROReduce(byte[] a, int idx) {
byte res = (byte) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
diff --git a/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java b/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java
index 2d9d49f32ad..9aaf1b6db95 100644
--- a/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java
+++ b/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java
@@ -3917,6 +3917,184 @@ static void MAXReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunctio
ByteMaxVectorTests::MAXReduceMasked, ByteMaxVectorTests::MAXReduceAllMasked);
}
+ static byte UMINReduce(byte[] a, int idx) {
+ byte res = Byte.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (byte) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static byte UMINReduceAll(byte[] a) {
+ byte res = Byte.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (byte) VectorMath.minUnsigned(res, UMINReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "byteUnaryOpProvider")
+ static void UMINReduceByteMaxVectorTests(IntFunction fa) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+ byte ra = Byte.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Byte.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ ra = (byte) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ ByteMaxVectorTests::UMINReduce, ByteMaxVectorTests::UMINReduceAll);
+ }
+
+ static byte UMINReduceMasked(byte[] a, int idx, boolean[] mask) {
+ byte res = Byte.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (byte) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static byte UMINReduceAllMasked(byte[] a, boolean[] mask) {
+ byte res = Byte.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (byte) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "byteUnaryOpMaskProvider")
+ static void UMINReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunction fm) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ byte ra = Byte.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Byte.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ ra = (byte) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ ByteMaxVectorTests::UMINReduceMasked, ByteMaxVectorTests::UMINReduceAllMasked);
+ }
+
+ static byte UMAXReduce(byte[] a, int idx) {
+ byte res = Byte.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (byte) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static byte UMAXReduceAll(byte[] a) {
+ byte res = Byte.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (byte) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "byteUnaryOpProvider")
+ static void UMAXReduceByteMaxVectorTests(IntFunction fa) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+ byte ra = Byte.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Byte.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ ra = (byte) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ ByteMaxVectorTests::UMAXReduce, ByteMaxVectorTests::UMAXReduceAll);
+ }
+
+ static byte UMAXReduceMasked(byte[] a, int idx, boolean[] mask) {
+ byte res = Byte.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (byte) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static byte UMAXReduceAllMasked(byte[] a, boolean[] mask) {
+ byte res = Byte.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (byte) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "byteUnaryOpMaskProvider")
+ static void UMAXReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunction fm) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ byte ra = Byte.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Byte.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ ra = (byte) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ ByteMaxVectorTests::UMAXReduceMasked, ByteMaxVectorTests::UMAXReduceAllMasked);
+ }
+
static byte FIRST_NONZEROReduce(byte[] a, int idx) {
byte res = (byte) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
diff --git a/test/jdk/jdk/incubator/vector/Int128VectorTests.java b/test/jdk/jdk/incubator/vector/Int128VectorTests.java
index 028e757e853..4f8f296c519 100644
--- a/test/jdk/jdk/incubator/vector/Int128VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Int128VectorTests.java
@@ -3956,6 +3956,184 @@ static void MAXReduceInt128VectorTestsMasked(IntFunction fa, IntFunction<
Int128VectorTests::MAXReduceMasked, Int128VectorTests::MAXReduceAllMasked);
}
+ static int UMINReduce(int[] a, int idx) {
+ int res = Integer.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (int) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static int UMINReduceAll(int[] a) {
+ int res = Integer.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (int) VectorMath.minUnsigned(res, UMINReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "intUnaryOpProvider")
+ static void UMINReduceInt128VectorTests(IntFunction fa) {
+ int[] a = fa.apply(SPECIES.length());
+ int[] r = fr.apply(SPECIES.length());
+ int ra = Integer.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Integer.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ ra = (int) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ Int128VectorTests::UMINReduce, Int128VectorTests::UMINReduceAll);
+ }
+
+ static int UMINReduceMasked(int[] a, int idx, boolean[] mask) {
+ int res = Integer.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (int) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static int UMINReduceAllMasked(int[] a, boolean[] mask) {
+ int res = Integer.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (int) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "intUnaryOpMaskProvider")
+ static void UMINReduceInt128VectorTestsMasked(IntFunction fa, IntFunction fm) {
+ int[] a = fa.apply(SPECIES.length());
+ int[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ int ra = Integer.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Integer.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ ra = (int) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ Int128VectorTests::UMINReduceMasked, Int128VectorTests::UMINReduceAllMasked);
+ }
+
+ static int UMAXReduce(int[] a, int idx) {
+ int res = Integer.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (int) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static int UMAXReduceAll(int[] a) {
+ int res = Integer.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (int) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "intUnaryOpProvider")
+ static void UMAXReduceInt128VectorTests(IntFunction fa) {
+ int[] a = fa.apply(SPECIES.length());
+ int[] r = fr.apply(SPECIES.length());
+ int ra = Integer.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Integer.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ ra = (int) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ Int128VectorTests::UMAXReduce, Int128VectorTests::UMAXReduceAll);
+ }
+
+ static int UMAXReduceMasked(int[] a, int idx, boolean[] mask) {
+ int res = Integer.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (int) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static int UMAXReduceAllMasked(int[] a, boolean[] mask) {
+ int res = Integer.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (int) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "intUnaryOpMaskProvider")
+ static void UMAXReduceInt128VectorTestsMasked(IntFunction fa, IntFunction fm) {
+ int[] a = fa.apply(SPECIES.length());
+ int[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ int ra = Integer.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Integer.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ ra = (int) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ Int128VectorTests::UMAXReduceMasked, Int128VectorTests::UMAXReduceAllMasked);
+ }
+
static int FIRST_NONZEROReduce(int[] a, int idx) {
int res = (int) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
diff --git a/test/jdk/jdk/incubator/vector/Int256VectorTests.java b/test/jdk/jdk/incubator/vector/Int256VectorTests.java
index 6dab8a39873..312227c54e1 100644
--- a/test/jdk/jdk/incubator/vector/Int256VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Int256VectorTests.java
@@ -3956,6 +3956,184 @@ static void MAXReduceInt256VectorTestsMasked(IntFunction fa, IntFunction<
Int256VectorTests::MAXReduceMasked, Int256VectorTests::MAXReduceAllMasked);
}
+ static int UMINReduce(int[] a, int idx) {
+ int res = Integer.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (int) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static int UMINReduceAll(int[] a) {
+ int res = Integer.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (int) VectorMath.minUnsigned(res, UMINReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "intUnaryOpProvider")
+ static void UMINReduceInt256VectorTests(IntFunction fa) {
+ int[] a = fa.apply(SPECIES.length());
+ int[] r = fr.apply(SPECIES.length());
+ int ra = Integer.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Integer.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ ra = (int) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ Int256VectorTests::UMINReduce, Int256VectorTests::UMINReduceAll);
+ }
+
+ static int UMINReduceMasked(int[] a, int idx, boolean[] mask) {
+ int res = Integer.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (int) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static int UMINReduceAllMasked(int[] a, boolean[] mask) {
+ int res = Integer.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (int) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "intUnaryOpMaskProvider")
+ static void UMINReduceInt256VectorTestsMasked(IntFunction fa, IntFunction fm) {
+ int[] a = fa.apply(SPECIES.length());
+ int[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ int ra = Integer.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Integer.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ ra = (int) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ Int256VectorTests::UMINReduceMasked, Int256VectorTests::UMINReduceAllMasked);
+ }
+
+ static int UMAXReduce(int[] a, int idx) {
+ int res = Integer.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (int) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static int UMAXReduceAll(int[] a) {
+ int res = Integer.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (int) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "intUnaryOpProvider")
+ static void UMAXReduceInt256VectorTests(IntFunction fa) {
+ int[] a = fa.apply(SPECIES.length());
+ int[] r = fr.apply(SPECIES.length());
+ int ra = Integer.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Integer.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ ra = (int) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ Int256VectorTests::UMAXReduce, Int256VectorTests::UMAXReduceAll);
+ }
+
+ static int UMAXReduceMasked(int[] a, int idx, boolean[] mask) {
+ int res = Integer.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (int) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static int UMAXReduceAllMasked(int[] a, boolean[] mask) {
+ int res = Integer.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (int) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "intUnaryOpMaskProvider")
+ static void UMAXReduceInt256VectorTestsMasked(IntFunction fa, IntFunction fm) {
+ int[] a = fa.apply(SPECIES.length());
+ int[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ int ra = Integer.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Integer.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ ra = (int) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ Int256VectorTests::UMAXReduceMasked, Int256VectorTests::UMAXReduceAllMasked);
+ }
+
static int FIRST_NONZEROReduce(int[] a, int idx) {
int res = (int) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
diff --git a/test/jdk/jdk/incubator/vector/Int512VectorTests.java b/test/jdk/jdk/incubator/vector/Int512VectorTests.java
index 0c86655ff22..3e5b51180b6 100644
--- a/test/jdk/jdk/incubator/vector/Int512VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Int512VectorTests.java
@@ -3956,6 +3956,184 @@ static void MAXReduceInt512VectorTestsMasked(IntFunction fa, IntFunction<
Int512VectorTests::MAXReduceMasked, Int512VectorTests::MAXReduceAllMasked);
}
+ static int UMINReduce(int[] a, int idx) {
+ int res = Integer.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (int) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static int UMINReduceAll(int[] a) {
+ int res = Integer.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (int) VectorMath.minUnsigned(res, UMINReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "intUnaryOpProvider")
+ static void UMINReduceInt512VectorTests(IntFunction fa) {
+ int[] a = fa.apply(SPECIES.length());
+ int[] r = fr.apply(SPECIES.length());
+ int ra = Integer.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Integer.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ ra = (int) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ Int512VectorTests::UMINReduce, Int512VectorTests::UMINReduceAll);
+ }
+
+ static int UMINReduceMasked(int[] a, int idx, boolean[] mask) {
+ int res = Integer.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (int) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static int UMINReduceAllMasked(int[] a, boolean[] mask) {
+ int res = Integer.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (int) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "intUnaryOpMaskProvider")
+ static void UMINReduceInt512VectorTestsMasked(IntFunction fa, IntFunction fm) {
+ int[] a = fa.apply(SPECIES.length());
+ int[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ int ra = Integer.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Integer.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ ra = (int) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ Int512VectorTests::UMINReduceMasked, Int512VectorTests::UMINReduceAllMasked);
+ }
+
+ static int UMAXReduce(int[] a, int idx) {
+ int res = Integer.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (int) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static int UMAXReduceAll(int[] a) {
+ int res = Integer.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (int) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "intUnaryOpProvider")
+ static void UMAXReduceInt512VectorTests(IntFunction fa) {
+ int[] a = fa.apply(SPECIES.length());
+ int[] r = fr.apply(SPECIES.length());
+ int ra = Integer.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Integer.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ ra = (int) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ Int512VectorTests::UMAXReduce, Int512VectorTests::UMAXReduceAll);
+ }
+
+ static int UMAXReduceMasked(int[] a, int idx, boolean[] mask) {
+ int res = Integer.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (int) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static int UMAXReduceAllMasked(int[] a, boolean[] mask) {
+ int res = Integer.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (int) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "intUnaryOpMaskProvider")
+ static void UMAXReduceInt512VectorTestsMasked(IntFunction fa, IntFunction fm) {
+ int[] a = fa.apply(SPECIES.length());
+ int[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ int ra = Integer.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Integer.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ ra = (int) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ Int512VectorTests::UMAXReduceMasked, Int512VectorTests::UMAXReduceAllMasked);
+ }
+
static int FIRST_NONZEROReduce(int[] a, int idx) {
int res = (int) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
diff --git a/test/jdk/jdk/incubator/vector/Int64VectorTests.java b/test/jdk/jdk/incubator/vector/Int64VectorTests.java
index b2cb3698f62..fccad11d4d6 100644
--- a/test/jdk/jdk/incubator/vector/Int64VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Int64VectorTests.java
@@ -3956,6 +3956,184 @@ static void MAXReduceInt64VectorTestsMasked(IntFunction fa, IntFunction fa) {
+ int[] a = fa.apply(SPECIES.length());
+ int[] r = fr.apply(SPECIES.length());
+ int ra = Integer.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Integer.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ ra = (int) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ Int64VectorTests::UMINReduce, Int64VectorTests::UMINReduceAll);
+ }
+
+ static int UMINReduceMasked(int[] a, int idx, boolean[] mask) {
+ int res = Integer.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (int) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static int UMINReduceAllMasked(int[] a, boolean[] mask) {
+ int res = Integer.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (int) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "intUnaryOpMaskProvider")
+ static void UMINReduceInt64VectorTestsMasked(IntFunction fa, IntFunction fm) {
+ int[] a = fa.apply(SPECIES.length());
+ int[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ int ra = Integer.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Integer.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ ra = (int) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ Int64VectorTests::UMINReduceMasked, Int64VectorTests::UMINReduceAllMasked);
+ }
+
+ static int UMAXReduce(int[] a, int idx) {
+ int res = Integer.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (int) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static int UMAXReduceAll(int[] a) {
+ int res = Integer.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (int) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "intUnaryOpProvider")
+ static void UMAXReduceInt64VectorTests(IntFunction fa) {
+ int[] a = fa.apply(SPECIES.length());
+ int[] r = fr.apply(SPECIES.length());
+ int ra = Integer.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Integer.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ ra = (int) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ Int64VectorTests::UMAXReduce, Int64VectorTests::UMAXReduceAll);
+ }
+
+ static int UMAXReduceMasked(int[] a, int idx, boolean[] mask) {
+ int res = Integer.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (int) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static int UMAXReduceAllMasked(int[] a, boolean[] mask) {
+ int res = Integer.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (int) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "intUnaryOpMaskProvider")
+ static void UMAXReduceInt64VectorTestsMasked(IntFunction fa, IntFunction fm) {
+ int[] a = fa.apply(SPECIES.length());
+ int[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ int ra = Integer.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Integer.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ ra = (int) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ Int64VectorTests::UMAXReduceMasked, Int64VectorTests::UMAXReduceAllMasked);
+ }
+
static int FIRST_NONZEROReduce(int[] a, int idx) {
int res = (int) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
diff --git a/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java b/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java
index fc0f6c1c139..3254c2fb86c 100644
--- a/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java
+++ b/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java
@@ -3961,6 +3961,184 @@ static void MAXReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction<
IntMaxVectorTests::MAXReduceMasked, IntMaxVectorTests::MAXReduceAllMasked);
}
+ static int UMINReduce(int[] a, int idx) {
+ int res = Integer.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (int) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static int UMINReduceAll(int[] a) {
+ int res = Integer.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (int) VectorMath.minUnsigned(res, UMINReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "intUnaryOpProvider")
+ static void UMINReduceIntMaxVectorTests(IntFunction fa) {
+ int[] a = fa.apply(SPECIES.length());
+ int[] r = fr.apply(SPECIES.length());
+ int ra = Integer.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Integer.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ ra = (int) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ IntMaxVectorTests::UMINReduce, IntMaxVectorTests::UMINReduceAll);
+ }
+
+ static int UMINReduceMasked(int[] a, int idx, boolean[] mask) {
+ int res = Integer.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (int) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static int UMINReduceAllMasked(int[] a, boolean[] mask) {
+ int res = Integer.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (int) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "intUnaryOpMaskProvider")
+ static void UMINReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction fm) {
+ int[] a = fa.apply(SPECIES.length());
+ int[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ int ra = Integer.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Integer.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ ra = (int) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ IntMaxVectorTests::UMINReduceMasked, IntMaxVectorTests::UMINReduceAllMasked);
+ }
+
+ static int UMAXReduce(int[] a, int idx) {
+ int res = Integer.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (int) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static int UMAXReduceAll(int[] a) {
+ int res = Integer.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (int) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "intUnaryOpProvider")
+ static void UMAXReduceIntMaxVectorTests(IntFunction fa) {
+ int[] a = fa.apply(SPECIES.length());
+ int[] r = fr.apply(SPECIES.length());
+ int ra = Integer.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Integer.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ ra = (int) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ IntMaxVectorTests::UMAXReduce, IntMaxVectorTests::UMAXReduceAll);
+ }
+
+ static int UMAXReduceMasked(int[] a, int idx, boolean[] mask) {
+ int res = Integer.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (int) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static int UMAXReduceAllMasked(int[] a, boolean[] mask) {
+ int res = Integer.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (int) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "intUnaryOpMaskProvider")
+ static void UMAXReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction fm) {
+ int[] a = fa.apply(SPECIES.length());
+ int[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ int ra = Integer.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Integer.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ IntVector av = IntVector.fromArray(SPECIES, a, i);
+ ra = (int) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ IntMaxVectorTests::UMAXReduceMasked, IntMaxVectorTests::UMAXReduceAllMasked);
+ }
+
static int FIRST_NONZEROReduce(int[] a, int idx) {
int res = (int) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
diff --git a/test/jdk/jdk/incubator/vector/Long128VectorTests.java b/test/jdk/jdk/incubator/vector/Long128VectorTests.java
index 3694128877a..09fdc3c1979 100644
--- a/test/jdk/jdk/incubator/vector/Long128VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Long128VectorTests.java
@@ -3978,6 +3978,184 @@ static void MAXReduceLong128VectorTestsMasked(IntFunction fa, IntFunctio
Long128VectorTests::MAXReduceMasked, Long128VectorTests::MAXReduceAllMasked);
}
+ static long UMINReduce(long[] a, int idx) {
+ long res = Long.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (long) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static long UMINReduceAll(long[] a) {
+ long res = Long.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (long) VectorMath.minUnsigned(res, UMINReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "longUnaryOpProvider")
+ static void UMINReduceLong128VectorTests(IntFunction fa) {
+ long[] a = fa.apply(SPECIES.length());
+ long[] r = fr.apply(SPECIES.length());
+ long ra = Long.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Long.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ ra = (long) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ Long128VectorTests::UMINReduce, Long128VectorTests::UMINReduceAll);
+ }
+
+ static long UMINReduceMasked(long[] a, int idx, boolean[] mask) {
+ long res = Long.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (long) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static long UMINReduceAllMasked(long[] a, boolean[] mask) {
+ long res = Long.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (long) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "longUnaryOpMaskProvider")
+ static void UMINReduceLong128VectorTestsMasked(IntFunction fa, IntFunction fm) {
+ long[] a = fa.apply(SPECIES.length());
+ long[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ long ra = Long.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Long.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ ra = (long) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ Long128VectorTests::UMINReduceMasked, Long128VectorTests::UMINReduceAllMasked);
+ }
+
+ static long UMAXReduce(long[] a, int idx) {
+ long res = Long.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (long) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static long UMAXReduceAll(long[] a) {
+ long res = Long.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (long) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "longUnaryOpProvider")
+ static void UMAXReduceLong128VectorTests(IntFunction fa) {
+ long[] a = fa.apply(SPECIES.length());
+ long[] r = fr.apply(SPECIES.length());
+ long ra = Long.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Long.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ ra = (long) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ Long128VectorTests::UMAXReduce, Long128VectorTests::UMAXReduceAll);
+ }
+
+ static long UMAXReduceMasked(long[] a, int idx, boolean[] mask) {
+ long res = Long.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (long) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static long UMAXReduceAllMasked(long[] a, boolean[] mask) {
+ long res = Long.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (long) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "longUnaryOpMaskProvider")
+ static void UMAXReduceLong128VectorTestsMasked(IntFunction fa, IntFunction fm) {
+ long[] a = fa.apply(SPECIES.length());
+ long[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ long ra = Long.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Long.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ ra = (long) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ Long128VectorTests::UMAXReduceMasked, Long128VectorTests::UMAXReduceAllMasked);
+ }
+
static long FIRST_NONZEROReduce(long[] a, int idx) {
long res = (long) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
diff --git a/test/jdk/jdk/incubator/vector/Long256VectorTests.java b/test/jdk/jdk/incubator/vector/Long256VectorTests.java
index 1fc441680fd..7dd0da772ed 100644
--- a/test/jdk/jdk/incubator/vector/Long256VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Long256VectorTests.java
@@ -3978,6 +3978,184 @@ static void MAXReduceLong256VectorTestsMasked(IntFunction fa, IntFunctio
Long256VectorTests::MAXReduceMasked, Long256VectorTests::MAXReduceAllMasked);
}
+ static long UMINReduce(long[] a, int idx) {
+ long res = Long.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (long) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static long UMINReduceAll(long[] a) {
+ long res = Long.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (long) VectorMath.minUnsigned(res, UMINReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "longUnaryOpProvider")
+ static void UMINReduceLong256VectorTests(IntFunction fa) {
+ long[] a = fa.apply(SPECIES.length());
+ long[] r = fr.apply(SPECIES.length());
+ long ra = Long.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Long.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ ra = (long) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ Long256VectorTests::UMINReduce, Long256VectorTests::UMINReduceAll);
+ }
+
+ static long UMINReduceMasked(long[] a, int idx, boolean[] mask) {
+ long res = Long.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (long) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static long UMINReduceAllMasked(long[] a, boolean[] mask) {
+ long res = Long.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (long) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "longUnaryOpMaskProvider")
+ static void UMINReduceLong256VectorTestsMasked(IntFunction fa, IntFunction fm) {
+ long[] a = fa.apply(SPECIES.length());
+ long[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ long ra = Long.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Long.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ ra = (long) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ Long256VectorTests::UMINReduceMasked, Long256VectorTests::UMINReduceAllMasked);
+ }
+
+ static long UMAXReduce(long[] a, int idx) {
+ long res = Long.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (long) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static long UMAXReduceAll(long[] a) {
+ long res = Long.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (long) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "longUnaryOpProvider")
+ static void UMAXReduceLong256VectorTests(IntFunction fa) {
+ long[] a = fa.apply(SPECIES.length());
+ long[] r = fr.apply(SPECIES.length());
+ long ra = Long.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Long.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ ra = (long) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ Long256VectorTests::UMAXReduce, Long256VectorTests::UMAXReduceAll);
+ }
+
+ static long UMAXReduceMasked(long[] a, int idx, boolean[] mask) {
+ long res = Long.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (long) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static long UMAXReduceAllMasked(long[] a, boolean[] mask) {
+ long res = Long.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (long) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "longUnaryOpMaskProvider")
+ static void UMAXReduceLong256VectorTestsMasked(IntFunction fa, IntFunction fm) {
+ long[] a = fa.apply(SPECIES.length());
+ long[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ long ra = Long.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Long.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ ra = (long) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ Long256VectorTests::UMAXReduceMasked, Long256VectorTests::UMAXReduceAllMasked);
+ }
+
static long FIRST_NONZEROReduce(long[] a, int idx) {
long res = (long) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
diff --git a/test/jdk/jdk/incubator/vector/Long512VectorTests.java b/test/jdk/jdk/incubator/vector/Long512VectorTests.java
index 81d538a55c4..360e822e121 100644
--- a/test/jdk/jdk/incubator/vector/Long512VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Long512VectorTests.java
@@ -3978,6 +3978,184 @@ static void MAXReduceLong512VectorTestsMasked(IntFunction fa, IntFunctio
Long512VectorTests::MAXReduceMasked, Long512VectorTests::MAXReduceAllMasked);
}
+ static long UMINReduce(long[] a, int idx) {
+ long res = Long.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (long) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static long UMINReduceAll(long[] a) {
+ long res = Long.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (long) VectorMath.minUnsigned(res, UMINReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "longUnaryOpProvider")
+ static void UMINReduceLong512VectorTests(IntFunction fa) {
+ long[] a = fa.apply(SPECIES.length());
+ long[] r = fr.apply(SPECIES.length());
+ long ra = Long.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Long.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ ra = (long) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ Long512VectorTests::UMINReduce, Long512VectorTests::UMINReduceAll);
+ }
+
+ static long UMINReduceMasked(long[] a, int idx, boolean[] mask) {
+ long res = Long.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (long) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static long UMINReduceAllMasked(long[] a, boolean[] mask) {
+ long res = Long.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (long) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "longUnaryOpMaskProvider")
+ static void UMINReduceLong512VectorTestsMasked(IntFunction fa, IntFunction fm) {
+ long[] a = fa.apply(SPECIES.length());
+ long[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ long ra = Long.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Long.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ ra = (long) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ Long512VectorTests::UMINReduceMasked, Long512VectorTests::UMINReduceAllMasked);
+ }
+
+ static long UMAXReduce(long[] a, int idx) {
+ long res = Long.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (long) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static long UMAXReduceAll(long[] a) {
+ long res = Long.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (long) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "longUnaryOpProvider")
+ static void UMAXReduceLong512VectorTests(IntFunction fa) {
+ long[] a = fa.apply(SPECIES.length());
+ long[] r = fr.apply(SPECIES.length());
+ long ra = Long.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Long.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ ra = (long) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ Long512VectorTests::UMAXReduce, Long512VectorTests::UMAXReduceAll);
+ }
+
+ static long UMAXReduceMasked(long[] a, int idx, boolean[] mask) {
+ long res = Long.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (long) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static long UMAXReduceAllMasked(long[] a, boolean[] mask) {
+ long res = Long.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (long) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "longUnaryOpMaskProvider")
+ static void UMAXReduceLong512VectorTestsMasked(IntFunction fa, IntFunction fm) {
+ long[] a = fa.apply(SPECIES.length());
+ long[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ long ra = Long.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Long.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ ra = (long) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ Long512VectorTests::UMAXReduceMasked, Long512VectorTests::UMAXReduceAllMasked);
+ }
+
static long FIRST_NONZEROReduce(long[] a, int idx) {
long res = (long) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
diff --git a/test/jdk/jdk/incubator/vector/Long64VectorTests.java b/test/jdk/jdk/incubator/vector/Long64VectorTests.java
index 1d85fc510d9..31f6fafea7c 100644
--- a/test/jdk/jdk/incubator/vector/Long64VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Long64VectorTests.java
@@ -3978,6 +3978,184 @@ static void MAXReduceLong64VectorTestsMasked(IntFunction fa, IntFunction
Long64VectorTests::MAXReduceMasked, Long64VectorTests::MAXReduceAllMasked);
}
+ static long UMINReduce(long[] a, int idx) {
+ long res = Long.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (long) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static long UMINReduceAll(long[] a) {
+ long res = Long.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (long) VectorMath.minUnsigned(res, UMINReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "longUnaryOpProvider")
+ static void UMINReduceLong64VectorTests(IntFunction fa) {
+ long[] a = fa.apply(SPECIES.length());
+ long[] r = fr.apply(SPECIES.length());
+ long ra = Long.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Long.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ ra = (long) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ Long64VectorTests::UMINReduce, Long64VectorTests::UMINReduceAll);
+ }
+
+ static long UMINReduceMasked(long[] a, int idx, boolean[] mask) {
+ long res = Long.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (long) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static long UMINReduceAllMasked(long[] a, boolean[] mask) {
+ long res = Long.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (long) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "longUnaryOpMaskProvider")
+ static void UMINReduceLong64VectorTestsMasked(IntFunction fa, IntFunction fm) {
+ long[] a = fa.apply(SPECIES.length());
+ long[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ long ra = Long.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Long.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ ra = (long) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ Long64VectorTests::UMINReduceMasked, Long64VectorTests::UMINReduceAllMasked);
+ }
+
+ static long UMAXReduce(long[] a, int idx) {
+ long res = Long.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (long) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static long UMAXReduceAll(long[] a) {
+ long res = Long.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (long) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "longUnaryOpProvider")
+ static void UMAXReduceLong64VectorTests(IntFunction fa) {
+ long[] a = fa.apply(SPECIES.length());
+ long[] r = fr.apply(SPECIES.length());
+ long ra = Long.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Long.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ ra = (long) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ Long64VectorTests::UMAXReduce, Long64VectorTests::UMAXReduceAll);
+ }
+
+ static long UMAXReduceMasked(long[] a, int idx, boolean[] mask) {
+ long res = Long.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (long) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static long UMAXReduceAllMasked(long[] a, boolean[] mask) {
+ long res = Long.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (long) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "longUnaryOpMaskProvider")
+ static void UMAXReduceLong64VectorTestsMasked(IntFunction fa, IntFunction fm) {
+ long[] a = fa.apply(SPECIES.length());
+ long[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ long ra = Long.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Long.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ ra = (long) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ Long64VectorTests::UMAXReduceMasked, Long64VectorTests::UMAXReduceAllMasked);
+ }
+
static long FIRST_NONZEROReduce(long[] a, int idx) {
long res = (long) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
diff --git a/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java b/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java
index bae5b968d79..a3cacbe3251 100644
--- a/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java
+++ b/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java
@@ -3983,6 +3983,184 @@ static void MAXReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunctio
LongMaxVectorTests::MAXReduceMasked, LongMaxVectorTests::MAXReduceAllMasked);
}
+ static long UMINReduce(long[] a, int idx) {
+ long res = Long.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (long) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static long UMINReduceAll(long[] a) {
+ long res = Long.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (long) VectorMath.minUnsigned(res, UMINReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "longUnaryOpProvider")
+ static void UMINReduceLongMaxVectorTests(IntFunction fa) {
+ long[] a = fa.apply(SPECIES.length());
+ long[] r = fr.apply(SPECIES.length());
+ long ra = Long.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Long.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ ra = (long) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ LongMaxVectorTests::UMINReduce, LongMaxVectorTests::UMINReduceAll);
+ }
+
+ static long UMINReduceMasked(long[] a, int idx, boolean[] mask) {
+ long res = Long.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (long) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static long UMINReduceAllMasked(long[] a, boolean[] mask) {
+ long res = Long.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (long) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "longUnaryOpMaskProvider")
+ static void UMINReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunction fm) {
+ long[] a = fa.apply(SPECIES.length());
+ long[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ long ra = Long.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Long.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ ra = (long) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ LongMaxVectorTests::UMINReduceMasked, LongMaxVectorTests::UMINReduceAllMasked);
+ }
+
+ static long UMAXReduce(long[] a, int idx) {
+ long res = Long.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (long) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static long UMAXReduceAll(long[] a) {
+ long res = Long.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (long) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "longUnaryOpProvider")
+ static void UMAXReduceLongMaxVectorTests(IntFunction fa) {
+ long[] a = fa.apply(SPECIES.length());
+ long[] r = fr.apply(SPECIES.length());
+ long ra = Long.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Long.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ ra = (long) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ LongMaxVectorTests::UMAXReduce, LongMaxVectorTests::UMAXReduceAll);
+ }
+
+ static long UMAXReduceMasked(long[] a, int idx, boolean[] mask) {
+ long res = Long.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (long) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static long UMAXReduceAllMasked(long[] a, boolean[] mask) {
+ long res = Long.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (long) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "longUnaryOpMaskProvider")
+ static void UMAXReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunction fm) {
+ long[] a = fa.apply(SPECIES.length());
+ long[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ long ra = Long.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Long.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ LongVector av = LongVector.fromArray(SPECIES, a, i);
+ ra = (long) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ LongMaxVectorTests::UMAXReduceMasked, LongMaxVectorTests::UMAXReduceAllMasked);
+ }
+
static long FIRST_NONZEROReduce(long[] a, int idx) {
long res = (long) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
diff --git a/test/jdk/jdk/incubator/vector/Short128VectorTests.java b/test/jdk/jdk/incubator/vector/Short128VectorTests.java
index 2d6a1fd0a5f..967418181bf 100644
--- a/test/jdk/jdk/incubator/vector/Short128VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Short128VectorTests.java
@@ -3903,6 +3903,184 @@ static void MAXReduceShort128VectorTestsMasked(IntFunction fa, IntFunct
Short128VectorTests::MAXReduceMasked, Short128VectorTests::MAXReduceAllMasked);
}
+ static short UMINReduce(short[] a, int idx) {
+ short res = Short.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (short) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static short UMINReduceAll(short[] a) {
+ short res = Short.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (short) VectorMath.minUnsigned(res, UMINReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "shortUnaryOpProvider")
+ static void UMINReduceShort128VectorTests(IntFunction fa) {
+ short[] a = fa.apply(SPECIES.length());
+ short[] r = fr.apply(SPECIES.length());
+ short ra = Short.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Short.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ Short128VectorTests::UMINReduce, Short128VectorTests::UMINReduceAll);
+ }
+
+ static short UMINReduceMasked(short[] a, int idx, boolean[] mask) {
+ short res = Short.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (short) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static short UMINReduceAllMasked(short[] a, boolean[] mask) {
+ short res = Short.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (short) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "shortUnaryOpMaskProvider")
+ static void UMINReduceShort128VectorTestsMasked(IntFunction fa, IntFunction fm) {
+ short[] a = fa.apply(SPECIES.length());
+ short[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ short ra = Short.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Short.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ Short128VectorTests::UMINReduceMasked, Short128VectorTests::UMINReduceAllMasked);
+ }
+
+ static short UMAXReduce(short[] a, int idx) {
+ short res = Short.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (short) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static short UMAXReduceAll(short[] a) {
+ short res = Short.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (short) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "shortUnaryOpProvider")
+ static void UMAXReduceShort128VectorTests(IntFunction fa) {
+ short[] a = fa.apply(SPECIES.length());
+ short[] r = fr.apply(SPECIES.length());
+ short ra = Short.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Short.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ Short128VectorTests::UMAXReduce, Short128VectorTests::UMAXReduceAll);
+ }
+
+ static short UMAXReduceMasked(short[] a, int idx, boolean[] mask) {
+ short res = Short.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (short) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static short UMAXReduceAllMasked(short[] a, boolean[] mask) {
+ short res = Short.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (short) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "shortUnaryOpMaskProvider")
+ static void UMAXReduceShort128VectorTestsMasked(IntFunction fa, IntFunction fm) {
+ short[] a = fa.apply(SPECIES.length());
+ short[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ short ra = Short.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Short.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ Short128VectorTests::UMAXReduceMasked, Short128VectorTests::UMAXReduceAllMasked);
+ }
+
static short FIRST_NONZEROReduce(short[] a, int idx) {
short res = (short) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
diff --git a/test/jdk/jdk/incubator/vector/Short256VectorTests.java b/test/jdk/jdk/incubator/vector/Short256VectorTests.java
index fa8ec1f31b6..2386d89e53b 100644
--- a/test/jdk/jdk/incubator/vector/Short256VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Short256VectorTests.java
@@ -3903,6 +3903,184 @@ static void MAXReduceShort256VectorTestsMasked(IntFunction fa, IntFunct
Short256VectorTests::MAXReduceMasked, Short256VectorTests::MAXReduceAllMasked);
}
+ static short UMINReduce(short[] a, int idx) {
+ short res = Short.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (short) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static short UMINReduceAll(short[] a) {
+ short res = Short.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (short) VectorMath.minUnsigned(res, UMINReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "shortUnaryOpProvider")
+ static void UMINReduceShort256VectorTests(IntFunction fa) {
+ short[] a = fa.apply(SPECIES.length());
+ short[] r = fr.apply(SPECIES.length());
+ short ra = Short.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Short.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ Short256VectorTests::UMINReduce, Short256VectorTests::UMINReduceAll);
+ }
+
+ static short UMINReduceMasked(short[] a, int idx, boolean[] mask) {
+ short res = Short.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (short) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static short UMINReduceAllMasked(short[] a, boolean[] mask) {
+ short res = Short.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (short) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "shortUnaryOpMaskProvider")
+ static void UMINReduceShort256VectorTestsMasked(IntFunction fa, IntFunction fm) {
+ short[] a = fa.apply(SPECIES.length());
+ short[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ short ra = Short.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Short.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ Short256VectorTests::UMINReduceMasked, Short256VectorTests::UMINReduceAllMasked);
+ }
+
+ static short UMAXReduce(short[] a, int idx) {
+ short res = Short.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (short) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static short UMAXReduceAll(short[] a) {
+ short res = Short.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (short) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "shortUnaryOpProvider")
+ static void UMAXReduceShort256VectorTests(IntFunction fa) {
+ short[] a = fa.apply(SPECIES.length());
+ short[] r = fr.apply(SPECIES.length());
+ short ra = Short.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Short.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ Short256VectorTests::UMAXReduce, Short256VectorTests::UMAXReduceAll);
+ }
+
+ static short UMAXReduceMasked(short[] a, int idx, boolean[] mask) {
+ short res = Short.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (short) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static short UMAXReduceAllMasked(short[] a, boolean[] mask) {
+ short res = Short.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (short) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "shortUnaryOpMaskProvider")
+ static void UMAXReduceShort256VectorTestsMasked(IntFunction fa, IntFunction fm) {
+ short[] a = fa.apply(SPECIES.length());
+ short[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ short ra = Short.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Short.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ Short256VectorTests::UMAXReduceMasked, Short256VectorTests::UMAXReduceAllMasked);
+ }
+
static short FIRST_NONZEROReduce(short[] a, int idx) {
short res = (short) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
diff --git a/test/jdk/jdk/incubator/vector/Short512VectorTests.java b/test/jdk/jdk/incubator/vector/Short512VectorTests.java
index ba6a7dadebd..cb9fc1830b9 100644
--- a/test/jdk/jdk/incubator/vector/Short512VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Short512VectorTests.java
@@ -3903,6 +3903,184 @@ static void MAXReduceShort512VectorTestsMasked(IntFunction fa, IntFunct
Short512VectorTests::MAXReduceMasked, Short512VectorTests::MAXReduceAllMasked);
}
+ static short UMINReduce(short[] a, int idx) {
+ short res = Short.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (short) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static short UMINReduceAll(short[] a) {
+ short res = Short.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (short) VectorMath.minUnsigned(res, UMINReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "shortUnaryOpProvider")
+ static void UMINReduceShort512VectorTests(IntFunction fa) {
+ short[] a = fa.apply(SPECIES.length());
+ short[] r = fr.apply(SPECIES.length());
+ short ra = Short.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Short.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ Short512VectorTests::UMINReduce, Short512VectorTests::UMINReduceAll);
+ }
+
+ static short UMINReduceMasked(short[] a, int idx, boolean[] mask) {
+ short res = Short.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (short) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static short UMINReduceAllMasked(short[] a, boolean[] mask) {
+ short res = Short.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (short) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "shortUnaryOpMaskProvider")
+ static void UMINReduceShort512VectorTestsMasked(IntFunction fa, IntFunction fm) {
+ short[] a = fa.apply(SPECIES.length());
+ short[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ short ra = Short.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Short.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ Short512VectorTests::UMINReduceMasked, Short512VectorTests::UMINReduceAllMasked);
+ }
+
+ static short UMAXReduce(short[] a, int idx) {
+ short res = Short.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (short) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static short UMAXReduceAll(short[] a) {
+ short res = Short.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (short) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "shortUnaryOpProvider")
+ static void UMAXReduceShort512VectorTests(IntFunction fa) {
+ short[] a = fa.apply(SPECIES.length());
+ short[] r = fr.apply(SPECIES.length());
+ short ra = Short.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Short.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ Short512VectorTests::UMAXReduce, Short512VectorTests::UMAXReduceAll);
+ }
+
+ static short UMAXReduceMasked(short[] a, int idx, boolean[] mask) {
+ short res = Short.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (short) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static short UMAXReduceAllMasked(short[] a, boolean[] mask) {
+ short res = Short.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (short) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "shortUnaryOpMaskProvider")
+ static void UMAXReduceShort512VectorTestsMasked(IntFunction fa, IntFunction fm) {
+ short[] a = fa.apply(SPECIES.length());
+ short[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ short ra = Short.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Short.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ Short512VectorTests::UMAXReduceMasked, Short512VectorTests::UMAXReduceAllMasked);
+ }
+
static short FIRST_NONZEROReduce(short[] a, int idx) {
short res = (short) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
diff --git a/test/jdk/jdk/incubator/vector/Short64VectorTests.java b/test/jdk/jdk/incubator/vector/Short64VectorTests.java
index 939da11d53a..64bb5f52329 100644
--- a/test/jdk/jdk/incubator/vector/Short64VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Short64VectorTests.java
@@ -3903,6 +3903,184 @@ static void MAXReduceShort64VectorTestsMasked(IntFunction fa, IntFuncti
Short64VectorTests::MAXReduceMasked, Short64VectorTests::MAXReduceAllMasked);
}
+ static short UMINReduce(short[] a, int idx) {
+ short res = Short.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (short) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static short UMINReduceAll(short[] a) {
+ short res = Short.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (short) VectorMath.minUnsigned(res, UMINReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "shortUnaryOpProvider")
+ static void UMINReduceShort64VectorTests(IntFunction fa) {
+ short[] a = fa.apply(SPECIES.length());
+ short[] r = fr.apply(SPECIES.length());
+ short ra = Short.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Short.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ Short64VectorTests::UMINReduce, Short64VectorTests::UMINReduceAll);
+ }
+
+ static short UMINReduceMasked(short[] a, int idx, boolean[] mask) {
+ short res = Short.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (short) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static short UMINReduceAllMasked(short[] a, boolean[] mask) {
+ short res = Short.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (short) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "shortUnaryOpMaskProvider")
+ static void UMINReduceShort64VectorTestsMasked(IntFunction fa, IntFunction fm) {
+ short[] a = fa.apply(SPECIES.length());
+ short[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ short ra = Short.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Short.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ Short64VectorTests::UMINReduceMasked, Short64VectorTests::UMINReduceAllMasked);
+ }
+
+ static short UMAXReduce(short[] a, int idx) {
+ short res = Short.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (short) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static short UMAXReduceAll(short[] a) {
+ short res = Short.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (short) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "shortUnaryOpProvider")
+ static void UMAXReduceShort64VectorTests(IntFunction fa) {
+ short[] a = fa.apply(SPECIES.length());
+ short[] r = fr.apply(SPECIES.length());
+ short ra = Short.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Short.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ Short64VectorTests::UMAXReduce, Short64VectorTests::UMAXReduceAll);
+ }
+
+ static short UMAXReduceMasked(short[] a, int idx, boolean[] mask) {
+ short res = Short.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (short) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static short UMAXReduceAllMasked(short[] a, boolean[] mask) {
+ short res = Short.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (short) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "shortUnaryOpMaskProvider")
+ static void UMAXReduceShort64VectorTestsMasked(IntFunction fa, IntFunction fm) {
+ short[] a = fa.apply(SPECIES.length());
+ short[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ short ra = Short.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Short.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ Short64VectorTests::UMAXReduceMasked, Short64VectorTests::UMAXReduceAllMasked);
+ }
+
static short FIRST_NONZEROReduce(short[] a, int idx) {
short res = (short) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
diff --git a/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java b/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java
index ade78e1f3f5..6445443b9d6 100644
--- a/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java
+++ b/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java
@@ -3908,6 +3908,184 @@ static void MAXReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunct
ShortMaxVectorTests::MAXReduceMasked, ShortMaxVectorTests::MAXReduceAllMasked);
}
+ static short UMINReduce(short[] a, int idx) {
+ short res = Short.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (short) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static short UMINReduceAll(short[] a) {
+ short res = Short.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (short) VectorMath.minUnsigned(res, UMINReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "shortUnaryOpProvider")
+ static void UMINReduceShortMaxVectorTests(IntFunction fa) {
+ short[] a = fa.apply(SPECIES.length());
+ short[] r = fr.apply(SPECIES.length());
+ short ra = Short.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Short.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ ShortMaxVectorTests::UMINReduce, ShortMaxVectorTests::UMINReduceAll);
+ }
+
+ static short UMINReduceMasked(short[] a, int idx, boolean[] mask) {
+ short res = Short.MAX_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (short) VectorMath.minUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static short UMINReduceAllMasked(short[] a, boolean[] mask) {
+ short res = Short.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (short) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "shortUnaryOpMaskProvider")
+ static void UMINReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunction fm) {
+ short[] a = fa.apply(SPECIES.length());
+ short[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ short ra = Short.MAX_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Short.MAX_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ ShortMaxVectorTests::UMINReduceMasked, ShortMaxVectorTests::UMINReduceAllMasked);
+ }
+
+ static short UMAXReduce(short[] a, int idx) {
+ short res = Short.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ res = (short) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static short UMAXReduceAll(short[] a) {
+ short res = Short.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (short) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "shortUnaryOpProvider")
+ static void UMAXReduceShortMaxVectorTests(IntFunction fa) {
+ short[] a = fa.apply(SPECIES.length());
+ short[] r = fr.apply(SPECIES.length());
+ short ra = Short.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Short.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
+ }
+ }
+
+ assertReductionArraysEquals(r, ra, a,
+ ShortMaxVectorTests::UMAXReduce, ShortMaxVectorTests::UMAXReduceAll);
+ }
+
+ static short UMAXReduceMasked(short[] a, int idx, boolean[] mask) {
+ short res = Short.MIN_VALUE;
+ for (int i = idx; i < (idx + SPECIES.length()); i++) {
+ if (mask[i % SPECIES.length()])
+ res = (short) VectorMath.maxUnsigned(res, a[i]);
+ }
+
+ return res;
+ }
+
+ static short UMAXReduceAllMasked(short[] a, boolean[] mask) {
+ short res = Short.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ res = (short) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
+ }
+
+ return res;
+ }
+
+ @Test(dataProvider = "shortUnaryOpMaskProvider")
+ static void UMAXReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunction fm) {
+ short[] a = fa.apply(SPECIES.length());
+ short[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0);
+ short ra = Short.MIN_VALUE;
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
+ }
+ }
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ ra = Short.MIN_VALUE;
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
+ }
+ }
+
+ assertReductionArraysEqualsMasked(r, ra, a, mask,
+ ShortMaxVectorTests::UMAXReduceMasked, ShortMaxVectorTests::UMAXReduceAllMasked);
+ }
+
static short FIRST_NONZEROReduce(short[] a, int idx) {
short res = (short) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
diff --git a/test/jdk/jdk/incubator/vector/gen-template.sh b/test/jdk/jdk/incubator/vector/gen-template.sh
index 232de04ba7c..06e89b824cd 100644
--- a/test/jdk/jdk/incubator/vector/gen-template.sh
+++ b/test/jdk/jdk/incubator/vector/gen-template.sh
@@ -484,6 +484,8 @@ gen_reduction_op "ADD" "+" "" "0"
gen_reduction_op "MUL" "*" "" "1"
gen_reduction_op_func "MIN" "(\$type\$) Math.min" "" "\$Wideboxtype\$.\$MaxValue\$"
gen_reduction_op_func "MAX" "(\$type\$) Math.max" "" "\$Wideboxtype\$.\$MinValue\$"
+gen_reduction_op_func "UMIN" "(\$type\$) VectorMath.minUnsigned" "BITWISE" "\$Wideboxtype\$.\$MaxValue\$"
+gen_reduction_op_func "UMAX" "(\$type\$) VectorMath.maxUnsigned" "BITWISE" "\$Wideboxtype\$.\$MinValue\$"
gen_reduction_op_func "FIRST_NONZERO" "firstNonZero" "" "(\$type\$) 0"
# Boolean reductions.
diff --git a/test/jdk/sun/net/www/http/KeepAliveCache/TestConnectionIDFeature.java b/test/jdk/sun/net/www/http/KeepAliveCache/TestConnectionIDFeature.java
index 6edf5097dad..2b52178e9db 100644
--- a/test/jdk/sun/net/www/http/KeepAliveCache/TestConnectionIDFeature.java
+++ b/test/jdk/sun/net/www/http/KeepAliveCache/TestConnectionIDFeature.java
@@ -123,7 +123,7 @@ public String get() {
try {
URL url = URIBuilder.newBuilder()
.scheme("http")
- .host(InetAddress.getLocalHost())
+ .host(InetAddress.getLoopbackAddress())
.port(server.getAddress().getPort())
.path("/" + connectionId)
.toURL();
@@ -154,7 +154,7 @@ public String get() {
try {
URL url = URIBuilder.newBuilder()
.scheme("http")
- .host(InetAddress.getLocalHost())
+ .host(InetAddress.getLoopbackAddress())
.port(server.getAddress().getPort())
.path("/" + connectionId)
.toURL();
@@ -173,7 +173,7 @@ public String get() {
public static void initialize() {
// start server
try {
- server = HttpServer.create(new InetSocketAddress(InetAddress.getLocalHost(), 0), 10, "/", new TestConnectionIDFeature.TestHttpHandler());
+ server = HttpServer.create(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), 10, "/", new TestConnectionIDFeature.TestHttpHandler());
} catch (IOException e) {
throw new RuntimeException("Could not create server", e);
}
@@ -200,7 +200,7 @@ public static void runRequests() {
// run second batch of requests where we expect that connections be reused
clientFutures.clear();
while (connectionIds.peek() != null) {
- clientFutures.add(CompletableFuture.supplyAsync(new InitialRequest(connectionIds.pop()), executor));
+ clientFutures.add(CompletableFuture.supplyAsync(new SecondRequest(connectionIds.pop()), executor));
}
for (var future : clientFutures) {
connectionIds.push(future.join());
diff --git a/test/jdk/tools/jlink/IntegrationTest.java b/test/jdk/tools/jlink/IntegrationTest.java
index d79752f6d56..7f3dc223461 100644
--- a/test/jdk/tools/jlink/IntegrationTest.java
+++ b/test/jdk/tools/jlink/IntegrationTest.java
@@ -154,9 +154,13 @@ private static void test() throws Exception {
mods.add("java.management");
Set limits = new HashSet<>();
limits.add("java.management");
+ boolean linkFromRuntime = false;
JlinkConfiguration config = new Jlink.JlinkConfiguration(output,
mods,
- JlinkTask.newModuleFinder(modulePaths, limits, mods), false, false, false);
+ JlinkTask.newLimitedFinder(JlinkTask.newModuleFinder(modulePaths), limits, mods),
+ linkFromRuntime,
+ false /* ignore modified runtime */,
+ false /* generate run-time image */);
List lst = new ArrayList<>();
diff --git a/test/jdk/tools/jlink/bindservices/BindServices.java b/test/jdk/tools/jlink/bindservices/BindServices.java
index 02f8bfd52d2..89095631040 100644
--- a/test/jdk/tools/jlink/bindservices/BindServices.java
+++ b/test/jdk/tools/jlink/bindservices/BindServices.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2024, 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
@@ -21,6 +21,9 @@
* questions.
*/
+import static jdk.test.lib.process.ProcessTools.executeProcess;
+import static org.testng.Assert.assertTrue;
+
import java.io.File;
import java.io.PrintWriter;
import java.io.StringWriter;
@@ -33,21 +36,20 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import jdk.test.lib.compiler.CompilerUtils;
-import static jdk.test.lib.process.ProcessTools.*;
-
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
-import static org.testng.Assert.*;
+
+import jdk.test.lib.compiler.CompilerUtils;
+import jdk.tools.jlink.internal.LinkableRuntimeImage;
/**
* @test
- * @bug 8174826
+ * @bug 8174826 8345573
* @library /test/lib
- * @modules jdk.compiler jdk.jlink
+ * @modules jdk.compiler jdk.jlink/jdk.tools.jlink.internal
* @build BindServices jdk.test.lib.process.ProcessTools
* jdk.test.lib.compiler.CompilerUtils
- * @run testng BindServices
+ * @run testng/othervm BindServices
*/
public class BindServices {
@@ -56,21 +58,23 @@ public class BindServices {
private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
private static final Path MODS_DIR = Paths.get("mods");
+ private static final boolean LINKABLE_RUNTIME = LinkableRuntimeImage.isLinkableRuntime();
+ private static final boolean JMODS_EXIST = Files.exists(Paths.get(JAVA_HOME, "jmods"));
- private static final String MODULE_PATH =
- Paths.get(JAVA_HOME, "jmods").toString() +
- File.pathSeparator + MODS_DIR.toString();
+ private static final String MODULE_PATH = (JMODS_EXIST ? Paths.get(JAVA_HOME, "jmods").toString() +
+ File.pathSeparator : "") +
+ MODS_DIR.toString();
// the names of the modules in this test
private static String[] modules = new String[] {"m1", "m2", "m3"};
- private static boolean hasJmods() {
- if (!Files.exists(Paths.get(JAVA_HOME, "jmods"))) {
- System.err.println("Test skipped. NO jmods directory");
- return false;
+ private static boolean isExplodedJDKImage() {
+ if (!JMODS_EXIST && !LINKABLE_RUNTIME) {
+ System.err.println("Test skipped. Not a linkable runtime and no JMODs");
+ return true;
}
- return true;
+ return false;
}
/*
@@ -78,7 +82,7 @@ private static boolean hasJmods() {
*/
@BeforeTest
public void compileAll() throws Throwable {
- if (!hasJmods()) return;
+ if (isExplodedJDKImage()) return;
for (String mn : modules) {
Path msrc = SRC_DIR.resolve(mn);
@@ -89,7 +93,7 @@ public void compileAll() throws Throwable {
@Test
public void noServiceBinding() throws Throwable {
- if (!hasJmods()) return;
+ if (isExplodedJDKImage()) return;
Path dir = Paths.get("noServiceBinding");
@@ -103,7 +107,7 @@ public void noServiceBinding() throws Throwable {
@Test
public void fullServiceBinding() throws Throwable {
- if (!hasJmods()) return;
+ if (isExplodedJDKImage()) return;
Path dir = Paths.get("fullServiceBinding");
@@ -122,7 +126,7 @@ public void fullServiceBinding() throws Throwable {
@Test
public void testVerbose() throws Throwable {
- if (!hasJmods()) return;
+ if (isExplodedJDKImage()) return;
Path dir = Paths.get("verbose");
@@ -153,7 +157,7 @@ public void testVerbose() throws Throwable {
@Test
public void testVerboseAndNoBindServices() throws Throwable {
- if (!hasJmods()) return;
+ if (isExplodedJDKImage()) return;
Path dir = Paths.get("verboseNoBind");
diff --git a/test/jdk/tools/jlink/bindservices/SuggestProviders.java b/test/jdk/tools/jlink/bindservices/SuggestProviders.java
index 9685f927f8d..794d22fc570 100644
--- a/test/jdk/tools/jlink/bindservices/SuggestProviders.java
+++ b/test/jdk/tools/jlink/bindservices/SuggestProviders.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2024, 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
@@ -21,6 +21,9 @@
* questions.
*/
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
import java.io.File;
import java.io.PrintWriter;
import java.io.StringWriter;
@@ -32,17 +35,18 @@
import java.util.spi.ToolProvider;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import jdk.test.lib.compiler.CompilerUtils;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
-import static org.testng.Assert.*;
+
+import jdk.test.lib.compiler.CompilerUtils;
+import jdk.tools.jlink.internal.LinkableRuntimeImage;
/**
* @test
- * @bug 8174826
+ * @bug 8174826 8345573
* @library /lib/testlibrary /test/lib
- * @modules jdk.charsets jdk.compiler jdk.jlink
+ * @modules jdk.charsets jdk.compiler jdk.jlink/jdk.tools.jlink.internal
* @build SuggestProviders jdk.test.lib.compiler.CompilerUtils
* @run testng SuggestProviders
*/
@@ -54,20 +58,23 @@ public class SuggestProviders {
private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
private static final Path MODS_DIR = Paths.get("mods");
- private static final String MODULE_PATH =
- Paths.get(JAVA_HOME, "jmods").toString() +
- File.pathSeparator + MODS_DIR.toString();
+ private static final boolean LINKABLE_RUNTIME = LinkableRuntimeImage.isLinkableRuntime();
+ private static final boolean JMODS_EXIST = Files.exists(Paths.get(JAVA_HOME, "jmods"));
+
+ private static final String MODULE_PATH = (JMODS_EXIST ? Paths.get(JAVA_HOME, "jmods").toString() +
+ File.pathSeparator : "") +
+ MODS_DIR.toString();
// the names of the modules in this test
private static String[] modules = new String[] {"m1", "m2", "m3"};
- private static boolean hasJmods() {
- if (!Files.exists(Paths.get(JAVA_HOME, "jmods"))) {
- System.err.println("Test skipped. NO jmods directory");
- return false;
+ private static boolean isExplodedJDKImage() {
+ if (!JMODS_EXIST && !LINKABLE_RUNTIME) {
+ System.err.println("Test skipped. Not a linkable runtime and no JMODs");
+ return true;
}
- return true;
+ return false;
}
/*
@@ -75,7 +82,7 @@ private static boolean hasJmods() {
*/
@BeforeTest
public void compileAll() throws Throwable {
- if (!hasJmods()) return;
+ if (isExplodedJDKImage()) return;
for (String mn : modules) {
Path msrc = SRC_DIR.resolve(mn);
@@ -125,7 +132,7 @@ public void compileAll() throws Throwable {
@Test
public void suggestProviders() throws Throwable {
- if (!hasJmods()) return;
+ if (isExplodedJDKImage()) return;
List output = JLink.run("--module-path", MODULE_PATH,
"--suggest-providers").output();
@@ -145,7 +152,7 @@ public void suggestProviders() throws Throwable {
*/
@Test
public void observableModules() throws Throwable {
- if (!hasJmods()) return;
+ if (isExplodedJDKImage()) return;
List output = JLink.run("--module-path", MODULE_PATH,
"--add-modules", "m1",
@@ -165,7 +172,7 @@ public void observableModules() throws Throwable {
*/
@Test
public void limitModules() throws Throwable {
- if (!hasJmods()) return;
+ if (isExplodedJDKImage()) return;
List output = JLink.run("--module-path", MODULE_PATH,
"--limit-modules", "m1",
@@ -184,7 +191,7 @@ public void limitModules() throws Throwable {
@Test
public void providersForServices() throws Throwable {
- if (!hasJmods()) return;
+ if (isExplodedJDKImage()) return;
List output =
JLink.run("--module-path", MODULE_PATH,
@@ -203,7 +210,7 @@ public void providersForServices() throws Throwable {
@Test
public void unusedService() throws Throwable {
- if (!hasJmods()) return;
+ if (isExplodedJDKImage()) return;
List output =
JLink.run("--module-path", MODULE_PATH,
@@ -221,7 +228,7 @@ public void unusedService() throws Throwable {
@Test
public void nonExistentService() throws Throwable {
- if (!hasJmods()) return;
+ if (isExplodedJDKImage()) return;
List output =
JLink.run("--module-path", MODULE_PATH,
@@ -236,7 +243,7 @@ public void nonExistentService() throws Throwable {
@Test
public void noSuggestProviders() throws Throwable {
- if (!hasJmods()) return;
+ if (isExplodedJDKImage()) return;
List output =
JLink.run("--module-path", MODULE_PATH,
@@ -250,7 +257,7 @@ public void noSuggestProviders() throws Throwable {
@Test
public void suggestTypeNotRealProvider() throws Throwable {
- if (!hasJmods()) return;
+ if (isExplodedJDKImage()) return;
List output =
JLink.run("--module-path", MODULE_PATH,
@@ -268,7 +275,7 @@ public void suggestTypeNotRealProvider() throws Throwable {
@Test
public void addNonObservableModule() throws Throwable {
- if (!hasJmods()) return;
+ if (isExplodedJDKImage()) return;
List output =
JLink.run("--module-path", MODULE_PATH,
diff --git a/test/jdk/tools/jlink/runtimeImage/AbstractLinkableRuntimeTest.java b/test/jdk/tools/jlink/runtimeImage/AbstractLinkableRuntimeTest.java
index e7d5340e3b0..1df4455bc7d 100644
--- a/test/jdk/tools/jlink/runtimeImage/AbstractLinkableRuntimeTest.java
+++ b/test/jdk/tools/jlink/runtimeImage/AbstractLinkableRuntimeTest.java
@@ -192,7 +192,8 @@ protected Path jlinkUsingImage(JlinkSpec spec, OutputAnalyzerHandler handler, Pr
// if the exit checker failed, we expected the other outcome
// i.e. fail for success and success for fail.
boolean successExit = analyzer.getExitValue() == 0;
- String msg = String.format("Expected jlink to %s given a jmodless image. Exit code was: %d",
+ String msg = String.format("Expected jlink to %s given a linkable run-time image. " +
+ "Exit code was: %d",
(successExit ? "fail" : "pass"), analyzer.getExitValue());
throw new AssertionError(msg);
}
diff --git a/test/langtools/tools/javac/ImportModule.java b/test/langtools/tools/javac/ImportModule.java
index 1224a9d7470..ac00ea823f1 100644
--- a/test/langtools/tools/javac/ImportModule.java
+++ b/test/langtools/tools/javac/ImportModule.java
@@ -23,7 +23,7 @@
/**
* @test
- * @bug 8328481 8332236 8332890
+ * @bug 8328481 8332236 8332890 8344647
* @summary Check behavior of module imports.
* @library /tools/lib
* @modules java.logging
@@ -33,7 +33,7 @@
* jdk.compiler/com.sun.tools.javac.util
* @build toolbox.ToolBox toolbox.JavacTask
* @run main ImportModule
-*/
+ */
import com.sun.source.tree.Tree;
import com.sun.source.util.TaskEvent;
@@ -829,6 +829,7 @@ public class Test {
}
}
+ @Test
public void testPackageImportDisambiguates(Path base) throws Exception {
Path current = base.resolve(".");
Path src = current.resolve("src");
@@ -919,4 +920,50 @@ public class Test {
.run(Task.Expect.SUCCESS)
.writeAll();
}
+
+ @Test //JDK-8344647
+ public void testJavaBaseOverride(Path base) throws Exception {
+ Path current = base.resolve(".");
+ Path src = current.resolve("src");
+ Path javaBaseClasses = current.resolve("javaBaseClasses");
+ Path javaBase = src.resolve("java.base");
+ tb.writeJavaFiles(javaBase,
+ """
+ module java.base {
+ exports java.lang;
+ }
+ """,
+ """
+ package java.lang;
+ public class Object {}
+ """);
+
+ Files.createDirectories(javaBaseClasses);
+
+ new JavacTask(tb)
+ .options("--patch-module", "java.base=" + src.toString())
+ .outdir(javaBaseClasses)
+ .files(tb.findJavaFiles(src))
+ .run(Task.Expect.SUCCESS)
+ .writeAll()
+ .getOutputLines(Task.OutputKind.DIRECT);
+
+ Path test = current.resolve("test");
+ tb.writeJavaFiles(test,
+ """
+ module test {
+ requires java.se;
+ }
+ """);
+
+ Path classes = current.resolve("classes");
+ Files.createDirectories(classes);
+
+ new JavacTask(tb)
+ .options("--patch-module", "java.base=" + javaBaseClasses.toString())
+ .outdir(classes)
+ .files(tb.findJavaFiles(test))
+ .run(Task.Expect.SUCCESS)
+ .writeAll();
+ }
}
diff --git a/test/langtools/tools/javac/LocalFreeVarStaticInstantiate.java b/test/langtools/tools/javac/LocalFreeVarStaticInstantiate.java
index 39b419c694a..09d33573da5 100644
--- a/test/langtools/tools/javac/LocalFreeVarStaticInstantiate.java
+++ b/test/langtools/tools/javac/LocalFreeVarStaticInstantiate.java
@@ -1,6 +1,6 @@
/*
* @test /nodynamiccopyright/
- * @bug 8322882
+ * @bug 8322882 8345953
* @summary Disallow attempts to access a free variable proxy field from a static method
* @compile/fail/ref=LocalFreeVarStaticInstantiate.out -XDrawDiagnostics LocalFreeVarStaticInstantiate.java
*/
@@ -41,4 +41,61 @@ class Local {
};
}
};
+
+ // local class in switch
+ static Object bar = switch (foo) {
+ case Runnable r -> {
+ Object there = "";
+ class Local {
+ {
+ there.hashCode();
+ }
+
+ static {
+ new Local(); // can't get there from here
+ }
+
+ static Runnable r = () -> {
+ new Local(); // can't get there from here
+ };
+ }
+ yield r;
+ }
+ };
+
+ // local class in instance init
+ {
+ Object there = "";
+ class Local {
+ {
+ there.hashCode();
+ }
+
+ static {
+ new Local(); // can't get there from here
+ }
+
+ static Runnable r = () -> {
+ new Local(); // can't get there from here
+ };
+ }
+ }
+
+ // local class in static init
+ static {
+ Object there = "";
+ class Local {
+ {
+ there.hashCode();
+ }
+
+ static {
+ new Local(); // can't get there from here
+ }
+
+ static Runnable r = () -> {
+ new Local(); // can't get there from here
+ };
+ }
+ }
}
diff --git a/test/langtools/tools/javac/LocalFreeVarStaticInstantiate.out b/test/langtools/tools/javac/LocalFreeVarStaticInstantiate.out
index 50e913083b0..9c26cf4a527 100644
--- a/test/langtools/tools/javac/LocalFreeVarStaticInstantiate.out
+++ b/test/langtools/tools/javac/LocalFreeVarStaticInstantiate.out
@@ -2,4 +2,10 @@ LocalFreeVarStaticInstantiate.java:18:17: compiler.err.local.cant.be.inst.static
LocalFreeVarStaticInstantiate.java:22:17: compiler.err.local.cant.be.inst.static: kindname.class, Local
LocalFreeVarStaticInstantiate.java:36:17: compiler.err.local.cant.be.inst.static: kindname.class, Local
LocalFreeVarStaticInstantiate.java:40:17: compiler.err.local.cant.be.inst.static: kindname.class, Local
-4 errors
+LocalFreeVarStaticInstantiate.java:55:21: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticInstantiate.java:59:21: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticInstantiate.java:75:17: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticInstantiate.java:79:17: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticInstantiate.java:93:17: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticInstantiate.java:97:17: compiler.err.local.cant.be.inst.static: kindname.class, Local
+10 errors
diff --git a/test/langtools/tools/javac/LocalFreeVarStaticSuper.java b/test/langtools/tools/javac/LocalFreeVarStaticSuper.java
new file mode 100644
index 00000000000..332eb239e35
--- /dev/null
+++ b/test/langtools/tools/javac/LocalFreeVarStaticSuper.java
@@ -0,0 +1,161 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8345944
+ * @summary JEP 492: extending local class in a different static context should not be allowed
+ * @compile/fail/ref=LocalFreeVarStaticSuper.out -XDrawDiagnostics LocalFreeVarStaticSuper.java
+ */
+
+class LocalFreeVarStaticSuper {
+
+ // local class in method
+ static void foo(Object there) {
+ class Local {
+ {
+ there.hashCode();
+ }
+
+ static {
+ class Sub1 extends Local { }
+ class Sub2 extends Local {
+ Sub2() { }
+ }
+ class Sub3 extends Local {
+ Sub3() { super(); }
+ }
+ }
+
+ static Runnable r = () -> {
+ class Sub1 extends Local { }
+ class Sub2 extends Local {
+ Sub2() { }
+ }
+ class Sub3 extends Local {
+ Sub3() { super(); }
+ }
+ };
+ }
+ }
+
+ // local class in lambda
+ static Runnable foo = () -> {
+ Object there = "";
+ class Local {
+ {
+ there.hashCode();
+ }
+
+ static {
+ class Sub1 extends Local { }
+ class Sub2 extends Local {
+ Sub2() { }
+ }
+ class Sub3 extends Local {
+ Sub3() { super(); }
+ }
+ }
+
+ static Runnable r = () -> {
+ class Sub1 extends Local { }
+ class Sub2 extends Local {
+ Sub2() { }
+ }
+ class Sub3 extends Local {
+ Sub3() { super(); }
+ }
+ };
+ }
+ };
+
+ // local class in switch
+ static Object bar = switch (foo) {
+ case Runnable r -> {
+ Object there = "";
+ class Local {
+ {
+ there.hashCode();
+ }
+
+ static {
+ class Sub1 extends Local { }
+ class Sub2 extends Local {
+ Sub2() { }
+ }
+ class Sub3 extends Local {
+ Sub3() { super(); }
+ }
+ }
+
+ static Runnable r = () -> {
+ class Sub1 extends Local { }
+ class Sub2 extends Local {
+ Sub2() { }
+ }
+ class Sub3 extends Local {
+ Sub3() { super(); }
+ }
+ };
+ }
+ yield r;
+ }
+ };
+
+ // local class in instance init
+ {
+ Object there = "";
+ class Local {
+ {
+ there.hashCode();
+ }
+
+ static {
+ class Sub1 extends Local { }
+ class Sub2 extends Local {
+ Sub2() { }
+ }
+ class Sub3 extends Local {
+ Sub3() { super(); }
+ }
+ }
+
+ static Runnable r = () -> {
+ class Sub1 extends Local { }
+ class Sub2 extends Local {
+ Sub2() { }
+ }
+ class Sub3 extends Local {
+ Sub3() { super(); }
+ }
+ };
+ }
+ }
+
+ // local class in static init
+ static {
+ Object there = "";
+ class Local {
+ {
+ there.hashCode();
+ }
+
+ static {
+ class Sub1 extends Local { }
+ class Sub2 extends Local {
+ Sub2() { }
+ }
+ class Sub3 extends Local {
+ Sub3() { super(); }
+ }
+ }
+
+ static Runnable r = () -> {
+ class Sub1 extends Local { }
+ class Sub2 extends Local {
+ Sub2() { }
+ }
+ class Sub3 extends Local {
+ Sub3() { super(); }
+ }
+ };
+ }
+ }
+}
diff --git a/test/langtools/tools/javac/LocalFreeVarStaticSuper.out b/test/langtools/tools/javac/LocalFreeVarStaticSuper.out
new file mode 100644
index 00000000000..d85451337bd
--- /dev/null
+++ b/test/langtools/tools/javac/LocalFreeVarStaticSuper.out
@@ -0,0 +1,31 @@
+LocalFreeVarStaticSuper.java:18:17: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticSuper.java:20:28: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticSuper.java:23:30: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticSuper.java:28:17: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticSuper.java:30:28: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticSuper.java:33:30: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticSuper.java:48:17: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticSuper.java:50:28: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticSuper.java:53:30: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticSuper.java:58:17: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticSuper.java:60:28: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticSuper.java:63:30: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticSuper.java:79:21: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticSuper.java:81:32: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticSuper.java:84:34: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticSuper.java:89:21: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticSuper.java:91:32: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticSuper.java:94:34: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticSuper.java:111:17: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticSuper.java:113:28: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticSuper.java:116:30: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticSuper.java:121:17: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticSuper.java:123:28: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticSuper.java:126:30: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticSuper.java:141:17: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticSuper.java:143:28: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticSuper.java:146:30: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticSuper.java:151:17: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticSuper.java:153:28: compiler.err.local.cant.be.inst.static: kindname.class, Local
+LocalFreeVarStaticSuper.java:156:30: compiler.err.local.cant.be.inst.static: kindname.class, Local
+30 errors
diff --git a/test/langtools/tools/javac/modules/AnnotationsOnModules.java b/test/langtools/tools/javac/modules/AnnotationsOnModules.java
index 65019854360..291633b4fb2 100644
--- a/test/langtools/tools/javac/modules/AnnotationsOnModules.java
+++ b/test/langtools/tools/javac/modules/AnnotationsOnModules.java
@@ -804,7 +804,7 @@ public class C {}
.writeAll()
.getOutputLines(OutputKind.DIRECT);
List expectedErrors = List.of(
- "- compiler.err.cant.access: m.module-info, (compiler.misc.bad.class.file.header: module-info.class, (compiler.misc.bad.requires.flag: ACC_TRANSITIVE (0x0020))",
+ "- compiler.err.cant.access: m.module-info, (compiler.misc.bad.class.file.header: module-info.class, (compiler.misc.bad.requires.flag: ACC_TRANSITIVE (0x0020)))",
"1 error"
);