This commit is contained in:
Jesper Wilhelmsson 2021-06-23 01:05:44 +00:00
commit b6cfca8a89
59 changed files with 810 additions and 1218 deletions

View file

@ -4844,7 +4844,8 @@ instruct vaddB_reg(vec dst, vec src1, vec src2) %{
%}
instruct vaddB_mem(vec dst, vec src, memory mem) %{
predicate(UseAVX > 0);
predicate((UseAVX > 0) &&
(vector_length_in_bytes(n->in(1)) > 8));
match(Set dst (AddVB src (LoadVector mem)));
format %{ "vpaddb $dst,$src,$mem\t! add packedB" %}
ins_encode %{
@ -4877,7 +4878,8 @@ instruct vaddS_reg(vec dst, vec src1, vec src2) %{
%}
instruct vaddS_mem(vec dst, vec src, memory mem) %{
predicate(UseAVX > 0);
predicate((UseAVX > 0) &&
(vector_length_in_bytes(n->in(1)) > 8));
match(Set dst (AddVS src (LoadVector mem)));
format %{ "vpaddw $dst,$src,$mem\t! add packedS" %}
ins_encode %{
@ -4911,7 +4913,8 @@ instruct vaddI_reg(vec dst, vec src1, vec src2) %{
instruct vaddI_mem(vec dst, vec src, memory mem) %{
predicate(UseAVX > 0);
predicate((UseAVX > 0) &&
(vector_length_in_bytes(n->in(1)) > 8));
match(Set dst (AddVI src (LoadVector mem)));
format %{ "vpaddd $dst,$src,$mem\t! add packedI" %}
ins_encode %{
@ -4944,7 +4947,8 @@ instruct vaddL_reg(vec dst, vec src1, vec src2) %{
%}
instruct vaddL_mem(vec dst, vec src, memory mem) %{
predicate(UseAVX > 0);
predicate((UseAVX > 0) &&
(vector_length_in_bytes(n->in(1)) > 8));
match(Set dst (AddVL src (LoadVector mem)));
format %{ "vpaddq $dst,$src,$mem\t! add packedL" %}
ins_encode %{
@ -4977,7 +4981,8 @@ instruct vaddF_reg(vec dst, vec src1, vec src2) %{
%}
instruct vaddF_mem(vec dst, vec src, memory mem) %{
predicate(UseAVX > 0);
predicate((UseAVX > 0) &&
(vector_length_in_bytes(n->in(1)) > 8));
match(Set dst (AddVF src (LoadVector mem)));
format %{ "vaddps $dst,$src,$mem\t! add packedF" %}
ins_encode %{
@ -5010,7 +5015,8 @@ instruct vaddD_reg(vec dst, vec src1, vec src2) %{
%}
instruct vaddD_mem(vec dst, vec src, memory mem) %{
predicate(UseAVX > 0);
predicate((UseAVX > 0) &&
(vector_length_in_bytes(n->in(1)) > 8));
match(Set dst (AddVD src (LoadVector mem)));
format %{ "vaddpd $dst,$src,$mem\t! add packedD" %}
ins_encode %{
@ -5045,7 +5051,8 @@ instruct vsubB_reg(vec dst, vec src1, vec src2) %{
%}
instruct vsubB_mem(vec dst, vec src, memory mem) %{
predicate(UseAVX > 0);
predicate((UseAVX > 0) &&
(vector_length_in_bytes(n->in(1)) > 8));
match(Set dst (SubVB src (LoadVector mem)));
format %{ "vpsubb $dst,$src,$mem\t! sub packedB" %}
ins_encode %{
@ -5079,7 +5086,8 @@ instruct vsubS_reg(vec dst, vec src1, vec src2) %{
%}
instruct vsubS_mem(vec dst, vec src, memory mem) %{
predicate(UseAVX > 0);
predicate((UseAVX > 0) &&
(vector_length_in_bytes(n->in(1)) > 8));
match(Set dst (SubVS src (LoadVector mem)));
format %{ "vpsubw $dst,$src,$mem\t! sub packedS" %}
ins_encode %{
@ -5112,7 +5120,8 @@ instruct vsubI_reg(vec dst, vec src1, vec src2) %{
%}
instruct vsubI_mem(vec dst, vec src, memory mem) %{
predicate(UseAVX > 0);
predicate((UseAVX > 0) &&
(vector_length_in_bytes(n->in(1)) > 8));
match(Set dst (SubVI src (LoadVector mem)));
format %{ "vpsubd $dst,$src,$mem\t! sub packedI" %}
ins_encode %{
@ -5146,7 +5155,8 @@ instruct vsubL_reg(vec dst, vec src1, vec src2) %{
instruct vsubL_mem(vec dst, vec src, memory mem) %{
predicate(UseAVX > 0);
predicate((UseAVX > 0) &&
(vector_length_in_bytes(n->in(1)) > 8));
match(Set dst (SubVL src (LoadVector mem)));
format %{ "vpsubq $dst,$src,$mem\t! sub packedL" %}
ins_encode %{
@ -5179,7 +5189,8 @@ instruct vsubF_reg(vec dst, vec src1, vec src2) %{
%}
instruct vsubF_mem(vec dst, vec src, memory mem) %{
predicate(UseAVX > 0);
predicate((UseAVX > 0) &&
(vector_length_in_bytes(n->in(1)) > 8));
match(Set dst (SubVF src (LoadVector mem)));
format %{ "vsubps $dst,$src,$mem\t! sub packedF" %}
ins_encode %{
@ -5212,7 +5223,8 @@ instruct vsubD_reg(vec dst, vec src1, vec src2) %{
%}
instruct vsubD_mem(vec dst, vec src, memory mem) %{
predicate(UseAVX > 0);
predicate((UseAVX > 0) &&
(vector_length_in_bytes(n->in(1)) > 8));
match(Set dst (SubVD src (LoadVector mem)));
format %{ "vsubpd $dst,$src,$mem\t! sub packedD" %}
ins_encode %{
@ -5360,7 +5372,8 @@ instruct vmulS_reg(vec dst, vec src1, vec src2) %{
%}
instruct vmulS_mem(vec dst, vec src, memory mem) %{
predicate(UseAVX > 0);
predicate((UseAVX > 0) &&
(vector_length_in_bytes(n->in(1)) > 8));
match(Set dst (MulVS src (LoadVector mem)));
format %{ "vpmullw $dst,$src,$mem\t! mul packedS" %}
ins_encode %{
@ -5394,7 +5407,8 @@ instruct vmulI_reg(vec dst, vec src1, vec src2) %{
%}
instruct vmulI_mem(vec dst, vec src, memory mem) %{
predicate(UseAVX > 0);
predicate((UseAVX > 0) &&
(vector_length_in_bytes(n->in(1)) > 8));
match(Set dst (MulVI src (LoadVector mem)));
format %{ "vpmulld $dst,$src,$mem\t! mul packedI" %}
ins_encode %{
@ -5418,7 +5432,8 @@ instruct vmulL_reg(vec dst, vec src1, vec src2) %{
%}
instruct vmulL_mem(vec dst, vec src, memory mem) %{
predicate(VM_Version::supports_avx512dq());
predicate(VM_Version::supports_avx512dq() &&
(vector_length_in_bytes(n->in(1)) > 8));
match(Set dst (MulVL src (LoadVector mem)));
format %{ "vpmullq $dst,$src,$mem\t! mul packedL" %}
ins_encode %{
@ -5503,7 +5518,8 @@ instruct vmulF_reg(vec dst, vec src1, vec src2) %{
%}
instruct vmulF_mem(vec dst, vec src, memory mem) %{
predicate(UseAVX > 0);
predicate((UseAVX > 0) &&
(vector_length_in_bytes(n->in(1)) > 8));
match(Set dst (MulVF src (LoadVector mem)));
format %{ "vmulps $dst,$src,$mem\t! mul packedF" %}
ins_encode %{
@ -5536,7 +5552,8 @@ instruct vmulD_reg(vec dst, vec src1, vec src2) %{
%}
instruct vmulD_mem(vec dst, vec src, memory mem) %{
predicate(UseAVX > 0);
predicate((UseAVX > 0) &&
(vector_length_in_bytes(n->in(1)) > 8));
match(Set dst (MulVD src (LoadVector mem)));
format %{ "vmulpd $dst,$src,$mem\t! mul packedD" %}
ins_encode %{
@ -5607,7 +5624,8 @@ instruct vdivF_reg(vec dst, vec src1, vec src2) %{
%}
instruct vdivF_mem(vec dst, vec src, memory mem) %{
predicate(UseAVX > 0);
predicate((UseAVX > 0) &&
(vector_length_in_bytes(n->in(1)) > 8));
match(Set dst (DivVF src (LoadVector mem)));
format %{ "vdivps $dst,$src,$mem\t! div packedF" %}
ins_encode %{
@ -5640,7 +5658,8 @@ instruct vdivD_reg(vec dst, vec src1, vec src2) %{
%}
instruct vdivD_mem(vec dst, vec src, memory mem) %{
predicate(UseAVX > 0);
predicate((UseAVX > 0) &&
(vector_length_in_bytes(n->in(1)) > 8));
match(Set dst (DivVD src (LoadVector mem)));
format %{ "vdivpd $dst,$src,$mem\t! div packedD" %}
ins_encode %{
@ -5824,6 +5843,7 @@ instruct vsqrtF_reg(vec dst, vec src) %{
%}
instruct vsqrtF_mem(vec dst, memory mem) %{
predicate(vector_length_in_bytes(n->in(1)) > 8);
match(Set dst (SqrtVF (LoadVector mem)));
format %{ "vsqrtps $dst,$mem\t! sqrt packedF" %}
ins_encode %{
@ -5847,6 +5867,7 @@ instruct vsqrtD_reg(vec dst, vec src) %{
%}
instruct vsqrtD_mem(vec dst, memory mem) %{
predicate(vector_length_in_bytes(n->in(1)) > 8);
match(Set dst (SqrtVD (LoadVector mem)));
format %{ "vsqrtpd $dst,$mem\t! sqrt packedD" %}
ins_encode %{
@ -6459,7 +6480,8 @@ instruct vand_reg(vec dst, vec src1, vec src2) %{
%}
instruct vand_mem(vec dst, vec src, memory mem) %{
predicate(UseAVX > 0);
predicate((UseAVX > 0) &&
(vector_length_in_bytes(n->in(1)) > 8));
match(Set dst (AndV src (LoadVector mem)));
format %{ "vpand $dst,$src,$mem\t! and vectors" %}
ins_encode %{
@ -6493,7 +6515,8 @@ instruct vor_reg(vec dst, vec src1, vec src2) %{
%}
instruct vor_mem(vec dst, vec src, memory mem) %{
predicate(UseAVX > 0);
predicate((UseAVX > 0) &&
(vector_length_in_bytes(n->in(1)) > 8));
match(Set dst (OrV src (LoadVector mem)));
format %{ "vpor $dst,$src,$mem\t! or vectors" %}
ins_encode %{
@ -6527,7 +6550,8 @@ instruct vxor_reg(vec dst, vec src1, vec src2) %{
%}
instruct vxor_mem(vec dst, vec src, memory mem) %{
predicate(UseAVX > 0);
predicate((UseAVX > 0) &&
(vector_length_in_bytes(n->in(1)) > 8));
match(Set dst (XorV src (LoadVector mem)));
format %{ "vpxor $dst,$src,$mem\t! xor vectors" %}
ins_encode %{
@ -7947,6 +7971,7 @@ instruct vfmaF_reg(vec a, vec b, vec c) %{
%}
instruct vfmaF_mem(vec a, memory b, vec c) %{
predicate(vector_length_in_bytes(n->in(1)) > 8);
match(Set c (FmaVF c (Binary a (LoadVector b))));
format %{ "fmaps $a,$b,$c\t# $c = $a * $b + $c fma packedF" %}
ins_cost(150);
@ -7971,6 +7996,7 @@ instruct vfmaD_reg(vec a, vec b, vec c) %{
%}
instruct vfmaD_mem(vec a, memory b, vec c) %{
predicate(vector_length_in_bytes(n->in(1)) > 8);
match(Set c (FmaVD c (Binary a (LoadVector b))));
format %{ "fmapd $a,$b,$c\t# $c = $a * $b + $c fma packedD" %}
ins_cost(150);
@ -8048,6 +8074,7 @@ instruct vpternlog(vec dst, vec src2, vec src3, immU8 func) %{
%}
instruct vpternlog_mem(vec dst, vec src2, memory src3, immU8 func) %{
predicate(vector_length_in_bytes(n->in(1)) > 8);
match(Set dst (MacroLogicV (Binary dst src2) (Binary (LoadVector src3) func)));
effect(TEMP dst);
format %{ "vpternlogd $dst,$src2,$src3,$func\t! vector ternary logic" %}

View file

@ -1596,9 +1596,19 @@ void nmethod::post_compiled_method_load_event(JvmtiThreadState* state) {
// Don't post this nmethod load event if it is already dying
// because the sweeper might already be deleting this nmethod.
{
MutexLocker ml(CompiledMethod_lock, Mutex::_no_safepoint_check_flag);
// When the nmethod is acquired from the CodeCache iterator, it can racingly become zombie
// before this code is called. Filter them out here under the CompiledMethod_lock.
if (!is_alive()) {
return;
}
// As for is_alive() nmethods, we also don't want them to racingly become zombie once we
// release this lock, so we check that this is not going to be the case.
if (is_not_entrant() && can_convert_to_zombie()) {
return;
}
}
// This is a bad time for a safepoint. We don't want
// this nmethod to get unloaded while we're queueing the event.

View file

@ -2851,6 +2851,16 @@ int PhaseIdealLoop::do_range_check(IdealLoopTree *loop, Node_List &old_new) {
register_new_node(main_cmp, main_cle->in(0));
_igvn.replace_input_of(main_bol, 1, main_cmp);
}
assert(main_limit == cl->limit() || get_ctrl(main_limit) == pre_ctrl, "wrong control for added limit");
const TypeInt* orig_limit_t = _igvn.type(orig_limit)->is_int();
bool upward = cl->stride_con() > 0;
// The new loop limit is <= (for an upward loop) >= (for a downward loop) than the orig limit.
// The expression that computes the new limit may be too complicated and the computed type of the new limit
// may be too pessimistic. A CastII here guarantees it's not lost.
main_limit = new CastIINode(main_limit, TypeInt::make(upward ? min_jint : orig_limit_t->_lo,
upward ? orig_limit_t->_hi : max_jint, Type::WidenMax));
main_limit->init_req(0, pre_ctrl);
register_new_node(main_limit, pre_ctrl);
// Hack the now-private loop bounds
_igvn.replace_input_of(main_cmp, 2, main_limit);
// The OpaqueNode is unshared by design

View file

@ -227,8 +227,10 @@ jvmtiError JvmtiCodeBlobEvents::generate_compiled_method_load_events(JvmtiEnv* e
{
NoSafepointVerifier nsv; // safepoints are not safe while collecting methods to post.
{
// Walk the CodeCache notifying for live nmethods, don't release the CodeCache_lock
// because the sweeper may be running concurrently.
// Walk the CodeCache notifying for live nmethods. We hold the CodeCache_lock
// to ensure the iteration is safe and nmethods are not concurrently freed.
// However, they may still change states and become !is_alive(). Filtering
// those out is done inside of nmethod::post_compiled_method_load_event().
// Save events to the queue for posting outside the CodeCache_lock.
MutexLocker mu(java_thread, CodeCache_lock, Mutex::_no_safepoint_check_flag);
// Iterate over non-profiled and profiled nmethods

View file

@ -44,14 +44,16 @@ import java.lang.reflect.Executable;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.net.URI;
import java.net.URL;
import java.nio.charset.CharacterCodingException;
import java.security.AccessControlContext;
import java.security.ProtectionDomain;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.nio.channels.Channel;
import java.nio.channels.spi.SelectorProvider;
import java.nio.charset.Charset;
import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.CodeSource;
import java.security.PrivilegedAction;
import java.security.ProtectionDomain;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@ -324,6 +326,16 @@ public final class System {
private static native void setOut0(PrintStream out);
private static native void setErr0(PrintStream err);
// Remember initial System.err. setSecurityManager() warning goes here
private static volatile @Stable PrintStream initialErrStream;
private static URL codeSource(Class<?> clazz) {
PrivilegedAction<ProtectionDomain> pa = clazz::getProtectionDomain;
@SuppressWarnings("removal")
CodeSource cs = AccessController.doPrivileged(pa).getCodeSource();
return (cs != null) ? cs.getLocation() : null;
}
/**
* Sets the system-wide security manager.
*
@ -362,16 +374,29 @@ public final class System {
* method.
*/
@Deprecated(since="17", forRemoval=true)
@CallerSensitive
public static void setSecurityManager(@SuppressWarnings("removal") SecurityManager sm) {
if (allowSecurityManager()) {
System.err.println("WARNING: java.lang.System::setSecurityManager" +
" is deprecated and will be removed in a future release.");
var callerClass = Reflection.getCallerClass();
URL url = codeSource(callerClass);
final String source;
if (url == null) {
source = callerClass.getName();
} else {
source = callerClass.getName() + " (" + url + ")";
}
initialErrStream.printf("""
WARNING: A terminally deprecated method in java.lang.System has been called
WARNING: System::setSecurityManager has been called by %s
WARNING: Please consider reporting this to the maintainers of %s
WARNING: System::setSecurityManager will be removed in a future release
""", source, callerClass.getName());
implSetSecurityManager(sm);
} else {
// security manager not allowed
if (sm != null) {
throw new UnsupportedOperationException(
"Runtime configured to disallow security manager");
"The Security Manager is deprecated and will be removed in a future release");
}
}
}
@ -2191,10 +2216,13 @@ public final class System {
}
if (needWarning) {
System.err.println("WARNING: The Security Manager is deprecated" +
" and will be removed in a future release.");
System.err.println("""
WARNING: A command line option has enabled the Security Manager
WARNING: The Security Manager is deprecated and will be removed in a future release""");
}
initialErrStream = System.err;
// initializing the system class loader
VM.initLevel(3);

View file

@ -105,7 +105,7 @@ public sealed interface DirectMethodHandleDesc
* @throws IllegalArgumentException if there is no such member
*/
public static Kind valueOf(int refKind) {
return valueOf(refKind, false);
return valueOf(refKind, refKind == REF_invokeInterface);
}
/**
@ -134,16 +134,10 @@ public sealed interface DirectMethodHandleDesc
*/
public static Kind valueOf(int refKind, boolean isInterface) {
int i = tableIndex(refKind, isInterface);
if (i >= 0 && i < TABLE.length) {
Kind kind = TABLE[i];
if (kind == null) {
throw new IllegalArgumentException(String.format("refKind=%d", refKind));
if (i >= 2 && i < TABLE.length) {
return TABLE[i];
}
if (kind.refKind == refKind && kind.isInterface == isInterface) {
return kind;
}
}
throw new IllegalArgumentException(String.format("refKind=%d", refKind));
throw new IllegalArgumentException(String.format("refKind=%d isInterface=%s", refKind, isInterface));
}
private static int tableIndex(int refKind, boolean isInterface) {
@ -180,9 +174,7 @@ public sealed interface DirectMethodHandleDesc
// for either truth value of X.
int i = tableIndex(kind.refKind, true);
if (TABLE[i] == null) {
// There is not a specific Kind for interfaces
if (kind == VIRTUAL) kind = INTERFACE_VIRTUAL;
if (TABLE[i] == null) TABLE[i] = kind;
TABLE[i] = kind;
}
}
}

View file

@ -634,8 +634,7 @@ sun.security.krb5.maxReferrals=5
#
#
jdk.certpath.disabledAlgorithms=MD2, MD5, SHA1 jdkCA & usage TLSServer, \
RSA keySize < 1024, DSA keySize < 1024, EC keySize < 224, \
SHA1 jdkCA & usage SignedJAR & denyAfter 2019-01-01
RSA keySize < 1024, DSA keySize < 1024, EC keySize < 224
#
# Legacy algorithms for certification path (CertPath) processing and
@ -699,7 +698,7 @@ jdk.security.legacyAlgorithms=SHA1, \
# See "jdk.certpath.disabledAlgorithms" for syntax descriptions.
#
jdk.jar.disabledAlgorithms=MD2, MD5, RSA keySize < 1024, \
DSA keySize < 1024, SHA1 jdkCA & denyAfter 2019-01-01
DSA keySize < 1024
#
# Algorithm restrictions for Secure Socket Layer/Transport Layer Security

View file

@ -190,16 +190,16 @@ public interface StandardJavaFileManager extends JavaFileManager {
* Returns file objects representing the given paths.
*
* @implSpec
* The default implementation converts each path to a file and calls
* {@link #getJavaFileObjectsFromFiles getJavaObjectsFromFiles}.
* IllegalArgumentException will be thrown if any of the paths
* cannot be converted to a file.
* The default implementation lazily converts each path to a file and calls
* {@link #getJavaFileObjectsFromFiles(Iterable) getJavaFileObjectsFromFiles}.
* {@code IllegalArgumentException} will be thrown
* if any of the paths cannot be converted to a file at the point the conversion happens.
*
* @param paths a list of paths
* @return a list of file objects
* @throws IllegalArgumentException if the list of paths includes
* a directory or if this file manager does not support any of the
* given paths.
* given paths
*
* @since 13
*/
@ -212,10 +212,10 @@ public interface StandardJavaFileManager extends JavaFileManager {
* Returns file objects representing the given paths.
*
* @implSpec
* The default implementation converts each path to a file and calls
* {@link #getJavaFileObjectsFromFiles getJavaObjectsFromFiles}.
* IllegalArgumentException will be thrown if any of the paths
* cannot be converted to a file.
* The default implementation lazily converts each path to a file and calls
* {@link #getJavaFileObjectsFromPaths(Collection) getJavaFileObjectsFromPaths}.
* {@code IllegalArgumentException} will be thrown
* if any of the paths cannot be converted to a file at the point the conversion happens.
*
* @param paths a list of paths
* @return a list of file objects
@ -248,7 +248,8 @@ public interface StandardJavaFileManager extends JavaFileManager {
* @param files an array of files
* @return a list of file objects
* @throws IllegalArgumentException if the array of files includes
* a directory
* a directory or if this file manager does not support any of the
* given paths
* @throws NullPointerException if the given array contains null
* elements
*/
@ -262,10 +263,15 @@ public interface StandardJavaFileManager extends JavaFileManager {
* getJavaFileObjectsFromPaths({@linkplain java.util.Arrays#asList Arrays.asList}(paths))
* </pre>
*
* @implSpec
* The default implementation will only throw {@code NullPointerException}
* if {@linkplain #getJavaFileObjectsFromPaths(Collection)} throws it.
*
* @param paths an array of paths
* @return a list of file objects
* @throws IllegalArgumentException if the array of files includes
* a directory
* a directory or if this file manager does not support any of the
* given paths
* @throws NullPointerException if the given array contains null
* elements
*
@ -332,10 +338,10 @@ public interface StandardJavaFileManager extends JavaFileManager {
* will be cancelled.
*
* @implSpec
* The default implementation converts each path to a file and calls
* {@link #getJavaFileObjectsFromFiles getJavaObjectsFromFiles}.
* {@linkplain IllegalArgumentException IllegalArgumentException}
* will be thrown if any of the paths cannot be converted to a file.
* The default implementation lazily converts each path to a file and calls
* {@link #setLocation setLocation}.
* {@code IllegalArgumentException} will be thrown if any of the paths cannot
* be converted to a file at the point the conversion happens.
*
* @param location a location
* @param paths a list of paths, if {@code null} use the default

View file

@ -41,6 +41,7 @@ import java.lang.constant.Constable;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodType;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
import java.util.function.Consumer;
@ -285,7 +286,7 @@ public sealed interface CLinker permits AbstractCLinker {
}
/**
* Converts a Java string into a null-terminated C string, using the platform's default charset,
* Converts a Java string into a UTF-8 encoded, null-terminated C string,
* storing the result into a native memory segment allocated using the provided allocator.
* <p>
* This method always replaces malformed-input and unmappable-character
@ -300,11 +301,11 @@ public sealed interface CLinker permits AbstractCLinker {
static MemorySegment toCString(String str, SegmentAllocator allocator) {
Objects.requireNonNull(str);
Objects.requireNonNull(allocator);
return toCString(str.getBytes(), allocator);
return toCString(str.getBytes(StandardCharsets.UTF_8), allocator);
}
/**
* Converts a Java string into a null-terminated C string, using the platform's default charset,
* Converts a Java string into a UTF-8 encoded, null-terminated C string,
* storing the result into a native memory segment associated with the provided resource scope.
* <p>
* This method always replaces malformed-input and unmappable-character
@ -323,48 +324,7 @@ public sealed interface CLinker permits AbstractCLinker {
}
/**
* Converts a Java string into a null-terminated C string, using the given {@linkplain java.nio.charset.Charset charset},
* storing the result into a new native memory segment native memory segment allocated using the provided allocator.
* <p>
* This method always replaces malformed-input and unmappable-character
* sequences with this charset's default replacement byte array. The
* {@link java.nio.charset.CharsetEncoder} class should be used when more
* control over the encoding process is required.
*
* @param str the Java string to be converted into a C string.
* @param charset The {@link java.nio.charset.Charset} to be used to compute the contents of the C string.
* @param allocator the allocator to be used for the native segment allocation.
* @return a new native memory segment containing the converted C string.
*/
static MemorySegment toCString(String str, Charset charset, SegmentAllocator allocator) {
Objects.requireNonNull(str);
Objects.requireNonNull(charset);
Objects.requireNonNull(allocator);
return toCString(str.getBytes(charset), allocator);
}
/**
* Converts a Java string into a null-terminated C string, using the given {@linkplain java.nio.charset.Charset charset},
* storing the result into a native memory segment associated with the provided resource scope.
* <p>
* This method always replaces malformed-input and unmappable-character
* sequences with this charset's default replacement byte array. The
* {@link java.nio.charset.CharsetEncoder} class should be used when more
* control over the encoding process is required.
*
* @param str the Java string to be converted into a C string.
* @param charset The {@link java.nio.charset.Charset} to be used to compute the contents of the C string.
* @param scope the resource scope to be associated with the returned segment.
* @return a new native memory segment containing the converted C string.
* @throws IllegalStateException if {@code scope} has been already closed, or if access occurs from a thread other
* than the thread owning {@code scope}.
*/
static MemorySegment toCString(String str, Charset charset, ResourceScope scope) {
return toCString(str, charset, SegmentAllocator.ofScope(scope));
}
/**
* Converts a null-terminated C string stored at given address into a Java string, using the platform's default charset.
* Converts a UTF-8 encoded, null-terminated C string stored at given address into a Java string.
* <p>
* This method always replaces malformed-input and unmappable-character
* sequences with this charset's default replacement string. The {@link
@ -378,7 +338,8 @@ public sealed interface CLinker permits AbstractCLinker {
*
* @param addr the address at which the string is stored.
* @return a Java string with the contents of the null-terminated C string at given address.
* @throws IllegalArgumentException if the size of the native string is greater than the largest string supported by the platform.
* @throws IllegalArgumentException if the size of the native string is greater than the largest string supported by the platform,
* or if {@code addr == MemoryAddress.NULL}.
* @throws IllegalCallerException if access to this method occurs from a module {@code M} and the command line option
* {@code --enable-native-access} is either absent, or does not mention the module name {@code M}, or
* {@code ALL-UNNAMED} in case {@code M} is an unnamed module.
@ -386,41 +347,12 @@ public sealed interface CLinker permits AbstractCLinker {
@CallerSensitive
static String toJavaString(MemoryAddress addr) {
Reflection.ensureNativeAccess(Reflection.getCallerClass());
Objects.requireNonNull(addr);
return SharedUtils.toJavaStringInternal(NativeMemorySegmentImpl.EVERYTHING, addr.toRawLongValue(), Charset.defaultCharset());
SharedUtils.checkAddress(addr);
return SharedUtils.toJavaStringInternal(NativeMemorySegmentImpl.EVERYTHING, addr.toRawLongValue());
}
/**
* Converts a null-terminated C string stored at given address into a Java string, using the given {@linkplain java.nio.charset.Charset charset}.
* <p>
* This method always replaces malformed-input and unmappable-character
* sequences with this charset's default replacement string. The {@link
* java.nio.charset.CharsetDecoder} class should be used when more control
* over the decoding process is required.
* <p>
* This method is <a href="package-summary.html#restricted"><em>restricted</em></a>.
* Restricted methods are unsafe, and, if used incorrectly, their use might crash
* the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on
* restricted methods, and use safe and supported functionalities, where possible.
*
* @param addr the address at which the string is stored.
* @param charset The {@link java.nio.charset.Charset} to be used to compute the contents of the Java string.
* @return a Java string with the contents of the null-terminated C string at given address.
* @throws IllegalArgumentException if the size of the native string is greater than the largest string supported by the platform.
* @throws IllegalCallerException if access to this method occurs from a module {@code M} and the command line option
* {@code --enable-native-access} is either absent, or does not mention the module name {@code M}, or
* {@code ALL-UNNAMED} in case {@code M} is an unnamed module.
*/
@CallerSensitive
static String toJavaString(MemoryAddress addr, Charset charset) {
Reflection.ensureNativeAccess(Reflection.getCallerClass());
Objects.requireNonNull(addr);
Objects.requireNonNull(charset);
return SharedUtils.toJavaStringInternal(NativeMemorySegmentImpl.EVERYTHING, addr.toRawLongValue(), charset);
}
/**
* Converts a null-terminated C string stored at given address into a Java string, using the platform's default charset.
* Converts a UTF-8 encoded, null-terminated C string stored at given address into a Java string.
* <p>
* This method always replaces malformed-input and unmappable-character
* sequences with this charset's default replacement string. The {@link
@ -434,27 +366,7 @@ public sealed interface CLinker permits AbstractCLinker {
*/
static String toJavaString(MemorySegment addr) {
Objects.requireNonNull(addr);
return SharedUtils.toJavaStringInternal(addr, 0L, Charset.defaultCharset());
}
/**
* Converts a null-terminated C string stored at given address into a Java string, using the given {@linkplain java.nio.charset.Charset charset}.
* <p>
* This method always replaces malformed-input and unmappable-character
* sequences with this charset's default replacement string. The {@link
* java.nio.charset.CharsetDecoder} class should be used when more control
* over the decoding process is required.
* @param addr the address at which the string is stored.
* @param charset The {@link java.nio.charset.Charset} to be used to compute the contents of the Java string.
* @return a Java string with the contents of the null-terminated C string at given address.
* @throws IllegalArgumentException if the size of the native string is greater than the largest string supported by the platform.
* @throws IllegalStateException if the size of the native string is greater than the size of the segment
* associated with {@code addr}, or if {@code addr} is associated with a segment that is <em>not alive</em>.
*/
static String toJavaString(MemorySegment addr, Charset charset) {
Objects.requireNonNull(addr);
Objects.requireNonNull(charset);
return SharedUtils.toJavaStringInternal(addr, 0L, charset);
return SharedUtils.toJavaStringInternal(addr, 0L);
}
private static void copy(MemorySegment addr, byte[] bytes) {
@ -505,13 +417,14 @@ public sealed interface CLinker permits AbstractCLinker {
*
* @param addr memory address of the native memory to be freed
* @throws IllegalCallerException if access to this method occurs from a module {@code M} and the command line option
* @throws IllegalArgumentException if {@code addr == MemoryAddress.NULL}.
* {@code --enable-native-access} is either absent, or does not mention the module name {@code M}, or
* {@code ALL-UNNAMED} in case {@code M} is an unnamed module.
*/
@CallerSensitive
static void freeMemory(MemoryAddress addr) {
Reflection.ensureNativeAccess(Reflection.getCallerClass());
Objects.requireNonNull(addr);
SharedUtils.checkAddress(addr);
SharedUtils.freeMemoryInternal(addr);
}

View file

@ -53,6 +53,8 @@ import java.lang.invoke.MethodType;
import java.lang.invoke.VarHandle;
import java.lang.ref.Reference;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@ -282,12 +284,12 @@ public class SharedUtils {
};
}
public static String toJavaStringInternal(MemorySegment segment, long start, Charset charset) {
public static String toJavaStringInternal(MemorySegment segment, long start) {
int len = strlen(segment, start);
byte[] bytes = new byte[len];
MemorySegment.ofArray(bytes)
.copyFrom(segment.asSlice(start, len));
return new String(bytes, charset);
return new String(bytes, StandardCharsets.UTF_8);
}
private static int strlen(MemorySegment segment, long start) {
@ -447,6 +449,14 @@ public class SharedUtils {
}
public static MemoryAddress checkSymbol(Addressable symbol) {
return checkAddressable(symbol, "Symbol is NULL");
}
public static MemoryAddress checkAddress(MemoryAddress address) {
return checkAddressable(address, "Address is NULL");
}
private static MemoryAddress checkAddressable(Addressable symbol, String msg) {
Objects.requireNonNull(symbol);
MemoryAddress symbolAddr = symbol.address();
if (symbolAddr.equals(MemoryAddress.NULL))

View file

@ -600,18 +600,10 @@ final class Byte128Vector extends ByteVector {
@ForceInline
private final <E>
VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
assert(length() == dsp.laneCount());
if (length() != dsp.laneCount())
throw new IllegalArgumentException("VectorMask length and species length differ");
boolean[] maskArray = toArray();
// enum-switches don't optimize properly JDK-8161245
return switch (dsp.laneType.switchKey) {
case LaneType.SK_BYTE -> new Byte128Vector.Byte128Mask(maskArray).check(dsp);
case LaneType.SK_SHORT -> new Short128Vector.Short128Mask(maskArray).check(dsp);
case LaneType.SK_INT -> new Int128Vector.Int128Mask(maskArray).check(dsp);
case LaneType.SK_LONG -> new Long128Vector.Long128Mask(maskArray).check(dsp);
case LaneType.SK_FLOAT -> new Float128Vector.Float128Mask(maskArray).check(dsp);
case LaneType.SK_DOUBLE -> new Double128Vector.Double128Mask(maskArray).check(dsp);
default -> throw new AssertionError(dsp);
};
return dsp.maskFactory(maskArray).check(dsp);
}
@Override
@ -782,24 +774,7 @@ final class Byte128Vector extends ByteVector {
if (length() != species.laneCount())
throw new IllegalArgumentException("VectorShuffle length and species length differ");
int[] shuffleArray = toArray();
// enum-switches don't optimize properly JDK-8161245
switch (species.laneType.switchKey) {
case LaneType.SK_BYTE:
return new Byte128Vector.Byte128Shuffle(shuffleArray).check(species);
case LaneType.SK_SHORT:
return new Short128Vector.Short128Shuffle(shuffleArray).check(species);
case LaneType.SK_INT:
return new Int128Vector.Int128Shuffle(shuffleArray).check(species);
case LaneType.SK_LONG:
return new Long128Vector.Long128Shuffle(shuffleArray).check(species);
case LaneType.SK_FLOAT:
return new Float128Vector.Float128Shuffle(shuffleArray).check(species);
case LaneType.SK_DOUBLE:
return new Double128Vector.Double128Shuffle(shuffleArray).check(species);
}
// Should not reach here.
throw new AssertionError(species);
return s.shuffleFromArray(shuffleArray, 0).check(s);
}
@ForceInline

View file

@ -632,18 +632,10 @@ final class Byte256Vector extends ByteVector {
@ForceInline
private final <E>
VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
assert(length() == dsp.laneCount());
if (length() != dsp.laneCount())
throw new IllegalArgumentException("VectorMask length and species length differ");
boolean[] maskArray = toArray();
// enum-switches don't optimize properly JDK-8161245
return switch (dsp.laneType.switchKey) {
case LaneType.SK_BYTE -> new Byte256Vector.Byte256Mask(maskArray).check(dsp);
case LaneType.SK_SHORT -> new Short256Vector.Short256Mask(maskArray).check(dsp);
case LaneType.SK_INT -> new Int256Vector.Int256Mask(maskArray).check(dsp);
case LaneType.SK_LONG -> new Long256Vector.Long256Mask(maskArray).check(dsp);
case LaneType.SK_FLOAT -> new Float256Vector.Float256Mask(maskArray).check(dsp);
case LaneType.SK_DOUBLE -> new Double256Vector.Double256Mask(maskArray).check(dsp);
default -> throw new AssertionError(dsp);
};
return dsp.maskFactory(maskArray).check(dsp);
}
@Override
@ -814,24 +806,7 @@ final class Byte256Vector extends ByteVector {
if (length() != species.laneCount())
throw new IllegalArgumentException("VectorShuffle length and species length differ");
int[] shuffleArray = toArray();
// enum-switches don't optimize properly JDK-8161245
switch (species.laneType.switchKey) {
case LaneType.SK_BYTE:
return new Byte256Vector.Byte256Shuffle(shuffleArray).check(species);
case LaneType.SK_SHORT:
return new Short256Vector.Short256Shuffle(shuffleArray).check(species);
case LaneType.SK_INT:
return new Int256Vector.Int256Shuffle(shuffleArray).check(species);
case LaneType.SK_LONG:
return new Long256Vector.Long256Shuffle(shuffleArray).check(species);
case LaneType.SK_FLOAT:
return new Float256Vector.Float256Shuffle(shuffleArray).check(species);
case LaneType.SK_DOUBLE:
return new Double256Vector.Double256Shuffle(shuffleArray).check(species);
}
// Should not reach here.
throw new AssertionError(species);
return s.shuffleFromArray(shuffleArray, 0).check(s);
}
@ForceInline

View file

@ -696,18 +696,10 @@ final class Byte512Vector extends ByteVector {
@ForceInline
private final <E>
VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
assert(length() == dsp.laneCount());
if (length() != dsp.laneCount())
throw new IllegalArgumentException("VectorMask length and species length differ");
boolean[] maskArray = toArray();
// enum-switches don't optimize properly JDK-8161245
return switch (dsp.laneType.switchKey) {
case LaneType.SK_BYTE -> new Byte512Vector.Byte512Mask(maskArray).check(dsp);
case LaneType.SK_SHORT -> new Short512Vector.Short512Mask(maskArray).check(dsp);
case LaneType.SK_INT -> new Int512Vector.Int512Mask(maskArray).check(dsp);
case LaneType.SK_LONG -> new Long512Vector.Long512Mask(maskArray).check(dsp);
case LaneType.SK_FLOAT -> new Float512Vector.Float512Mask(maskArray).check(dsp);
case LaneType.SK_DOUBLE -> new Double512Vector.Double512Mask(maskArray).check(dsp);
default -> throw new AssertionError(dsp);
};
return dsp.maskFactory(maskArray).check(dsp);
}
@Override
@ -878,24 +870,7 @@ final class Byte512Vector extends ByteVector {
if (length() != species.laneCount())
throw new IllegalArgumentException("VectorShuffle length and species length differ");
int[] shuffleArray = toArray();
// enum-switches don't optimize properly JDK-8161245
switch (species.laneType.switchKey) {
case LaneType.SK_BYTE:
return new Byte512Vector.Byte512Shuffle(shuffleArray).check(species);
case LaneType.SK_SHORT:
return new Short512Vector.Short512Shuffle(shuffleArray).check(species);
case LaneType.SK_INT:
return new Int512Vector.Int512Shuffle(shuffleArray).check(species);
case LaneType.SK_LONG:
return new Long512Vector.Long512Shuffle(shuffleArray).check(species);
case LaneType.SK_FLOAT:
return new Float512Vector.Float512Shuffle(shuffleArray).check(species);
case LaneType.SK_DOUBLE:
return new Double512Vector.Double512Shuffle(shuffleArray).check(species);
}
// Should not reach here.
throw new AssertionError(species);
return s.shuffleFromArray(shuffleArray, 0).check(s);
}
@ForceInline

View file

@ -584,18 +584,10 @@ final class Byte64Vector extends ByteVector {
@ForceInline
private final <E>
VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
assert(length() == dsp.laneCount());
if (length() != dsp.laneCount())
throw new IllegalArgumentException("VectorMask length and species length differ");
boolean[] maskArray = toArray();
// enum-switches don't optimize properly JDK-8161245
return switch (dsp.laneType.switchKey) {
case LaneType.SK_BYTE -> new Byte64Vector.Byte64Mask(maskArray).check(dsp);
case LaneType.SK_SHORT -> new Short64Vector.Short64Mask(maskArray).check(dsp);
case LaneType.SK_INT -> new Int64Vector.Int64Mask(maskArray).check(dsp);
case LaneType.SK_LONG -> new Long64Vector.Long64Mask(maskArray).check(dsp);
case LaneType.SK_FLOAT -> new Float64Vector.Float64Mask(maskArray).check(dsp);
case LaneType.SK_DOUBLE -> new Double64Vector.Double64Mask(maskArray).check(dsp);
default -> throw new AssertionError(dsp);
};
return dsp.maskFactory(maskArray).check(dsp);
}
@Override
@ -766,24 +758,7 @@ final class Byte64Vector extends ByteVector {
if (length() != species.laneCount())
throw new IllegalArgumentException("VectorShuffle length and species length differ");
int[] shuffleArray = toArray();
// enum-switches don't optimize properly JDK-8161245
switch (species.laneType.switchKey) {
case LaneType.SK_BYTE:
return new Byte64Vector.Byte64Shuffle(shuffleArray).check(species);
case LaneType.SK_SHORT:
return new Short64Vector.Short64Shuffle(shuffleArray).check(species);
case LaneType.SK_INT:
return new Int64Vector.Int64Shuffle(shuffleArray).check(species);
case LaneType.SK_LONG:
return new Long64Vector.Long64Shuffle(shuffleArray).check(species);
case LaneType.SK_FLOAT:
return new Float64Vector.Float64Shuffle(shuffleArray).check(species);
case LaneType.SK_DOUBLE:
return new Double64Vector.Double64Shuffle(shuffleArray).check(species);
}
// Should not reach here.
throw new AssertionError(species);
return s.shuffleFromArray(shuffleArray, 0).check(s);
}
@ForceInline

View file

@ -570,18 +570,10 @@ final class ByteMaxVector extends ByteVector {
@ForceInline
private final <E>
VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
assert(length() == dsp.laneCount());
if (length() != dsp.laneCount())
throw new IllegalArgumentException("VectorMask length and species length differ");
boolean[] maskArray = toArray();
// enum-switches don't optimize properly JDK-8161245
return switch (dsp.laneType.switchKey) {
case LaneType.SK_BYTE -> new ByteMaxVector.ByteMaxMask(maskArray).check(dsp);
case LaneType.SK_SHORT -> new ShortMaxVector.ShortMaxMask(maskArray).check(dsp);
case LaneType.SK_INT -> new IntMaxVector.IntMaxMask(maskArray).check(dsp);
case LaneType.SK_LONG -> new LongMaxVector.LongMaxMask(maskArray).check(dsp);
case LaneType.SK_FLOAT -> new FloatMaxVector.FloatMaxMask(maskArray).check(dsp);
case LaneType.SK_DOUBLE -> new DoubleMaxVector.DoubleMaxMask(maskArray).check(dsp);
default -> throw new AssertionError(dsp);
};
return dsp.maskFactory(maskArray).check(dsp);
}
@Override
@ -752,24 +744,7 @@ final class ByteMaxVector extends ByteVector {
if (length() != species.laneCount())
throw new IllegalArgumentException("VectorShuffle length and species length differ");
int[] shuffleArray = toArray();
// enum-switches don't optimize properly JDK-8161245
switch (species.laneType.switchKey) {
case LaneType.SK_BYTE:
return new ByteMaxVector.ByteMaxShuffle(shuffleArray).check(species);
case LaneType.SK_SHORT:
return new ShortMaxVector.ShortMaxShuffle(shuffleArray).check(species);
case LaneType.SK_INT:
return new IntMaxVector.IntMaxShuffle(shuffleArray).check(species);
case LaneType.SK_LONG:
return new LongMaxVector.LongMaxShuffle(shuffleArray).check(species);
case LaneType.SK_FLOAT:
return new FloatMaxVector.FloatMaxShuffle(shuffleArray).check(species);
case LaneType.SK_DOUBLE:
return new DoubleMaxVector.DoubleMaxShuffle(shuffleArray).check(species);
}
// Should not reach here.
throw new AssertionError(species);
return s.shuffleFromArray(shuffleArray, 0).check(s);
}
@ForceInline

View file

@ -568,18 +568,10 @@ final class Double128Vector extends DoubleVector {
@ForceInline
private final <E>
VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
assert(length() == dsp.laneCount());
if (length() != dsp.laneCount())
throw new IllegalArgumentException("VectorMask length and species length differ");
boolean[] maskArray = toArray();
// enum-switches don't optimize properly JDK-8161245
return switch (dsp.laneType.switchKey) {
case LaneType.SK_BYTE -> new Byte128Vector.Byte128Mask(maskArray).check(dsp);
case LaneType.SK_SHORT -> new Short128Vector.Short128Mask(maskArray).check(dsp);
case LaneType.SK_INT -> new Int128Vector.Int128Mask(maskArray).check(dsp);
case LaneType.SK_LONG -> new Long128Vector.Long128Mask(maskArray).check(dsp);
case LaneType.SK_FLOAT -> new Float128Vector.Float128Mask(maskArray).check(dsp);
case LaneType.SK_DOUBLE -> new Double128Vector.Double128Mask(maskArray).check(dsp);
default -> throw new AssertionError(dsp);
};
return dsp.maskFactory(maskArray).check(dsp);
}
@Override
@ -750,24 +742,7 @@ final class Double128Vector extends DoubleVector {
if (length() != species.laneCount())
throw new IllegalArgumentException("VectorShuffle length and species length differ");
int[] shuffleArray = toArray();
// enum-switches don't optimize properly JDK-8161245
switch (species.laneType.switchKey) {
case LaneType.SK_BYTE:
return new Byte128Vector.Byte128Shuffle(shuffleArray).check(species);
case LaneType.SK_SHORT:
return new Short128Vector.Short128Shuffle(shuffleArray).check(species);
case LaneType.SK_INT:
return new Int128Vector.Int128Shuffle(shuffleArray).check(species);
case LaneType.SK_LONG:
return new Long128Vector.Long128Shuffle(shuffleArray).check(species);
case LaneType.SK_FLOAT:
return new Float128Vector.Float128Shuffle(shuffleArray).check(species);
case LaneType.SK_DOUBLE:
return new Double128Vector.Double128Shuffle(shuffleArray).check(species);
}
// Should not reach here.
throw new AssertionError(species);
return s.shuffleFromArray(shuffleArray, 0).check(s);
}
@ForceInline

View file

@ -572,18 +572,10 @@ final class Double256Vector extends DoubleVector {
@ForceInline
private final <E>
VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
assert(length() == dsp.laneCount());
if (length() != dsp.laneCount())
throw new IllegalArgumentException("VectorMask length and species length differ");
boolean[] maskArray = toArray();
// enum-switches don't optimize properly JDK-8161245
return switch (dsp.laneType.switchKey) {
case LaneType.SK_BYTE -> new Byte256Vector.Byte256Mask(maskArray).check(dsp);
case LaneType.SK_SHORT -> new Short256Vector.Short256Mask(maskArray).check(dsp);
case LaneType.SK_INT -> new Int256Vector.Int256Mask(maskArray).check(dsp);
case LaneType.SK_LONG -> new Long256Vector.Long256Mask(maskArray).check(dsp);
case LaneType.SK_FLOAT -> new Float256Vector.Float256Mask(maskArray).check(dsp);
case LaneType.SK_DOUBLE -> new Double256Vector.Double256Mask(maskArray).check(dsp);
default -> throw new AssertionError(dsp);
};
return dsp.maskFactory(maskArray).check(dsp);
}
@Override
@ -754,24 +746,7 @@ final class Double256Vector extends DoubleVector {
if (length() != species.laneCount())
throw new IllegalArgumentException("VectorShuffle length and species length differ");
int[] shuffleArray = toArray();
// enum-switches don't optimize properly JDK-8161245
switch (species.laneType.switchKey) {
case LaneType.SK_BYTE:
return new Byte256Vector.Byte256Shuffle(shuffleArray).check(species);
case LaneType.SK_SHORT:
return new Short256Vector.Short256Shuffle(shuffleArray).check(species);
case LaneType.SK_INT:
return new Int256Vector.Int256Shuffle(shuffleArray).check(species);
case LaneType.SK_LONG:
return new Long256Vector.Long256Shuffle(shuffleArray).check(species);
case LaneType.SK_FLOAT:
return new Float256Vector.Float256Shuffle(shuffleArray).check(species);
case LaneType.SK_DOUBLE:
return new Double256Vector.Double256Shuffle(shuffleArray).check(species);
}
// Should not reach here.
throw new AssertionError(species);
return s.shuffleFromArray(shuffleArray, 0).check(s);
}
@ForceInline

View file

@ -580,18 +580,10 @@ final class Double512Vector extends DoubleVector {
@ForceInline
private final <E>
VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
assert(length() == dsp.laneCount());
if (length() != dsp.laneCount())
throw new IllegalArgumentException("VectorMask length and species length differ");
boolean[] maskArray = toArray();
// enum-switches don't optimize properly JDK-8161245
return switch (dsp.laneType.switchKey) {
case LaneType.SK_BYTE -> new Byte512Vector.Byte512Mask(maskArray).check(dsp);
case LaneType.SK_SHORT -> new Short512Vector.Short512Mask(maskArray).check(dsp);
case LaneType.SK_INT -> new Int512Vector.Int512Mask(maskArray).check(dsp);
case LaneType.SK_LONG -> new Long512Vector.Long512Mask(maskArray).check(dsp);
case LaneType.SK_FLOAT -> new Float512Vector.Float512Mask(maskArray).check(dsp);
case LaneType.SK_DOUBLE -> new Double512Vector.Double512Mask(maskArray).check(dsp);
default -> throw new AssertionError(dsp);
};
return dsp.maskFactory(maskArray).check(dsp);
}
@Override
@ -762,24 +754,7 @@ final class Double512Vector extends DoubleVector {
if (length() != species.laneCount())
throw new IllegalArgumentException("VectorShuffle length and species length differ");
int[] shuffleArray = toArray();
// enum-switches don't optimize properly JDK-8161245
switch (species.laneType.switchKey) {
case LaneType.SK_BYTE:
return new Byte512Vector.Byte512Shuffle(shuffleArray).check(species);
case LaneType.SK_SHORT:
return new Short512Vector.Short512Shuffle(shuffleArray).check(species);
case LaneType.SK_INT:
return new Int512Vector.Int512Shuffle(shuffleArray).check(species);
case LaneType.SK_LONG:
return new Long512Vector.Long512Shuffle(shuffleArray).check(species);
case LaneType.SK_FLOAT:
return new Float512Vector.Float512Shuffle(shuffleArray).check(species);
case LaneType.SK_DOUBLE:
return new Double512Vector.Double512Shuffle(shuffleArray).check(species);
}
// Should not reach here.
throw new AssertionError(species);
return s.shuffleFromArray(shuffleArray, 0).check(s);
}
@ForceInline

View file

@ -566,18 +566,10 @@ final class Double64Vector extends DoubleVector {
@ForceInline
private final <E>
VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
assert(length() == dsp.laneCount());
if (length() != dsp.laneCount())
throw new IllegalArgumentException("VectorMask length and species length differ");
boolean[] maskArray = toArray();
// enum-switches don't optimize properly JDK-8161245
return switch (dsp.laneType.switchKey) {
case LaneType.SK_BYTE -> new Byte64Vector.Byte64Mask(maskArray).check(dsp);
case LaneType.SK_SHORT -> new Short64Vector.Short64Mask(maskArray).check(dsp);
case LaneType.SK_INT -> new Int64Vector.Int64Mask(maskArray).check(dsp);
case LaneType.SK_LONG -> new Long64Vector.Long64Mask(maskArray).check(dsp);
case LaneType.SK_FLOAT -> new Float64Vector.Float64Mask(maskArray).check(dsp);
case LaneType.SK_DOUBLE -> new Double64Vector.Double64Mask(maskArray).check(dsp);
default -> throw new AssertionError(dsp);
};
return dsp.maskFactory(maskArray).check(dsp);
}
@Override
@ -748,24 +740,7 @@ final class Double64Vector extends DoubleVector {
if (length() != species.laneCount())
throw new IllegalArgumentException("VectorShuffle length and species length differ");
int[] shuffleArray = toArray();
// enum-switches don't optimize properly JDK-8161245
switch (species.laneType.switchKey) {
case LaneType.SK_BYTE:
return new Byte64Vector.Byte64Shuffle(shuffleArray).check(species);
case LaneType.SK_SHORT:
return new Short64Vector.Short64Shuffle(shuffleArray).check(species);
case LaneType.SK_INT:
return new Int64Vector.Int64Shuffle(shuffleArray).check(species);
case LaneType.SK_LONG:
return new Long64Vector.Long64Shuffle(shuffleArray).check(species);
case LaneType.SK_FLOAT:
return new Float64Vector.Float64Shuffle(shuffleArray).check(species);
case LaneType.SK_DOUBLE:
return new Double64Vector.Double64Shuffle(shuffleArray).check(species);
}
// Should not reach here.
throw new AssertionError(species);
return s.shuffleFromArray(shuffleArray, 0).check(s);
}
@ForceInline

View file

@ -565,18 +565,10 @@ final class DoubleMaxVector extends DoubleVector {
@ForceInline
private final <E>
VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
assert(length() == dsp.laneCount());
if (length() != dsp.laneCount())
throw new IllegalArgumentException("VectorMask length and species length differ");
boolean[] maskArray = toArray();
// enum-switches don't optimize properly JDK-8161245
return switch (dsp.laneType.switchKey) {
case LaneType.SK_BYTE -> new ByteMaxVector.ByteMaxMask(maskArray).check(dsp);
case LaneType.SK_SHORT -> new ShortMaxVector.ShortMaxMask(maskArray).check(dsp);
case LaneType.SK_INT -> new IntMaxVector.IntMaxMask(maskArray).check(dsp);
case LaneType.SK_LONG -> new LongMaxVector.LongMaxMask(maskArray).check(dsp);
case LaneType.SK_FLOAT -> new FloatMaxVector.FloatMaxMask(maskArray).check(dsp);
case LaneType.SK_DOUBLE -> new DoubleMaxVector.DoubleMaxMask(maskArray).check(dsp);
default -> throw new AssertionError(dsp);
};
return dsp.maskFactory(maskArray).check(dsp);
}
@Override
@ -747,24 +739,7 @@ final class DoubleMaxVector extends DoubleVector {
if (length() != species.laneCount())
throw new IllegalArgumentException("VectorShuffle length and species length differ");
int[] shuffleArray = toArray();
// enum-switches don't optimize properly JDK-8161245
switch (species.laneType.switchKey) {
case LaneType.SK_BYTE:
return new ByteMaxVector.ByteMaxShuffle(shuffleArray).check(species);
case LaneType.SK_SHORT:
return new ShortMaxVector.ShortMaxShuffle(shuffleArray).check(species);
case LaneType.SK_INT:
return new IntMaxVector.IntMaxShuffle(shuffleArray).check(species);
case LaneType.SK_LONG:
return new LongMaxVector.LongMaxShuffle(shuffleArray).check(species);
case LaneType.SK_FLOAT:
return new FloatMaxVector.FloatMaxShuffle(shuffleArray).check(species);
case LaneType.SK_DOUBLE:
return new DoubleMaxVector.DoubleMaxShuffle(shuffleArray).check(species);
}
// Should not reach here.
throw new AssertionError(species);
return s.shuffleFromArray(shuffleArray, 0).check(s);
}
@ForceInline

View file

@ -572,18 +572,10 @@ final class Float128Vector extends FloatVector {
@ForceInline
private final <E>
VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
assert(length() == dsp.laneCount());
if (length() != dsp.laneCount())
throw new IllegalArgumentException("VectorMask length and species length differ");
boolean[] maskArray = toArray();
// enum-switches don't optimize properly JDK-8161245
return switch (dsp.laneType.switchKey) {
case LaneType.SK_BYTE -> new Byte128Vector.Byte128Mask(maskArray).check(dsp);
case LaneType.SK_SHORT -> new Short128Vector.Short128Mask(maskArray).check(dsp);
case LaneType.SK_INT -> new Int128Vector.Int128Mask(maskArray).check(dsp);
case LaneType.SK_LONG -> new Long128Vector.Long128Mask(maskArray).check(dsp);
case LaneType.SK_FLOAT -> new Float128Vector.Float128Mask(maskArray).check(dsp);
case LaneType.SK_DOUBLE -> new Double128Vector.Double128Mask(maskArray).check(dsp);
default -> throw new AssertionError(dsp);
};
return dsp.maskFactory(maskArray).check(dsp);
}
@Override
@ -754,24 +746,7 @@ final class Float128Vector extends FloatVector {
if (length() != species.laneCount())
throw new IllegalArgumentException("VectorShuffle length and species length differ");
int[] shuffleArray = toArray();
// enum-switches don't optimize properly JDK-8161245
switch (species.laneType.switchKey) {
case LaneType.SK_BYTE:
return new Byte128Vector.Byte128Shuffle(shuffleArray).check(species);
case LaneType.SK_SHORT:
return new Short128Vector.Short128Shuffle(shuffleArray).check(species);
case LaneType.SK_INT:
return new Int128Vector.Int128Shuffle(shuffleArray).check(species);
case LaneType.SK_LONG:
return new Long128Vector.Long128Shuffle(shuffleArray).check(species);
case LaneType.SK_FLOAT:
return new Float128Vector.Float128Shuffle(shuffleArray).check(species);
case LaneType.SK_DOUBLE:
return new Double128Vector.Double128Shuffle(shuffleArray).check(species);
}
// Should not reach here.
throw new AssertionError(species);
return s.shuffleFromArray(shuffleArray, 0).check(s);
}
@ForceInline

View file

@ -580,18 +580,10 @@ final class Float256Vector extends FloatVector {
@ForceInline
private final <E>
VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
assert(length() == dsp.laneCount());
if (length() != dsp.laneCount())
throw new IllegalArgumentException("VectorMask length and species length differ");
boolean[] maskArray = toArray();
// enum-switches don't optimize properly JDK-8161245
return switch (dsp.laneType.switchKey) {
case LaneType.SK_BYTE -> new Byte256Vector.Byte256Mask(maskArray).check(dsp);
case LaneType.SK_SHORT -> new Short256Vector.Short256Mask(maskArray).check(dsp);
case LaneType.SK_INT -> new Int256Vector.Int256Mask(maskArray).check(dsp);
case LaneType.SK_LONG -> new Long256Vector.Long256Mask(maskArray).check(dsp);
case LaneType.SK_FLOAT -> new Float256Vector.Float256Mask(maskArray).check(dsp);
case LaneType.SK_DOUBLE -> new Double256Vector.Double256Mask(maskArray).check(dsp);
default -> throw new AssertionError(dsp);
};
return dsp.maskFactory(maskArray).check(dsp);
}
@Override
@ -762,24 +754,7 @@ final class Float256Vector extends FloatVector {
if (length() != species.laneCount())
throw new IllegalArgumentException("VectorShuffle length and species length differ");
int[] shuffleArray = toArray();
// enum-switches don't optimize properly JDK-8161245
switch (species.laneType.switchKey) {
case LaneType.SK_BYTE:
return new Byte256Vector.Byte256Shuffle(shuffleArray).check(species);
case LaneType.SK_SHORT:
return new Short256Vector.Short256Shuffle(shuffleArray).check(species);
case LaneType.SK_INT:
return new Int256Vector.Int256Shuffle(shuffleArray).check(species);
case LaneType.SK_LONG:
return new Long256Vector.Long256Shuffle(shuffleArray).check(species);
case LaneType.SK_FLOAT:
return new Float256Vector.Float256Shuffle(shuffleArray).check(species);
case LaneType.SK_DOUBLE:
return new Double256Vector.Double256Shuffle(shuffleArray).check(species);
}
// Should not reach here.
throw new AssertionError(species);
return s.shuffleFromArray(shuffleArray, 0).check(s);
}
@ForceInline

View file

@ -596,18 +596,10 @@ final class Float512Vector extends FloatVector {
@ForceInline
private final <E>
VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
assert(length() == dsp.laneCount());
if (length() != dsp.laneCount())
throw new IllegalArgumentException("VectorMask length and species length differ");
boolean[] maskArray = toArray();
// enum-switches don't optimize properly JDK-8161245
return switch (dsp.laneType.switchKey) {
case LaneType.SK_BYTE -> new Byte512Vector.Byte512Mask(maskArray).check(dsp);
case LaneType.SK_SHORT -> new Short512Vector.Short512Mask(maskArray).check(dsp);
case LaneType.SK_INT -> new Int512Vector.Int512Mask(maskArray).check(dsp);
case LaneType.SK_LONG -> new Long512Vector.Long512Mask(maskArray).check(dsp);
case LaneType.SK_FLOAT -> new Float512Vector.Float512Mask(maskArray).check(dsp);
case LaneType.SK_DOUBLE -> new Double512Vector.Double512Mask(maskArray).check(dsp);
default -> throw new AssertionError(dsp);
};
return dsp.maskFactory(maskArray).check(dsp);
}
@Override
@ -778,24 +770,7 @@ final class Float512Vector extends FloatVector {
if (length() != species.laneCount())
throw new IllegalArgumentException("VectorShuffle length and species length differ");
int[] shuffleArray = toArray();
// enum-switches don't optimize properly JDK-8161245
switch (species.laneType.switchKey) {
case LaneType.SK_BYTE:
return new Byte512Vector.Byte512Shuffle(shuffleArray).check(species);
case LaneType.SK_SHORT:
return new Short512Vector.Short512Shuffle(shuffleArray).check(species);
case LaneType.SK_INT:
return new Int512Vector.Int512Shuffle(shuffleArray).check(species);
case LaneType.SK_LONG:
return new Long512Vector.Long512Shuffle(shuffleArray).check(species);
case LaneType.SK_FLOAT:
return new Float512Vector.Float512Shuffle(shuffleArray).check(species);
case LaneType.SK_DOUBLE:
return new Double512Vector.Double512Shuffle(shuffleArray).check(species);
}
// Should not reach here.
throw new AssertionError(species);
return s.shuffleFromArray(shuffleArray, 0).check(s);
}
@ForceInline

View file

@ -568,18 +568,10 @@ final class Float64Vector extends FloatVector {
@ForceInline
private final <E>
VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
assert(length() == dsp.laneCount());
if (length() != dsp.laneCount())
throw new IllegalArgumentException("VectorMask length and species length differ");
boolean[] maskArray = toArray();
// enum-switches don't optimize properly JDK-8161245
return switch (dsp.laneType.switchKey) {
case LaneType.SK_BYTE -> new Byte64Vector.Byte64Mask(maskArray).check(dsp);
case LaneType.SK_SHORT -> new Short64Vector.Short64Mask(maskArray).check(dsp);
case LaneType.SK_INT -> new Int64Vector.Int64Mask(maskArray).check(dsp);
case LaneType.SK_LONG -> new Long64Vector.Long64Mask(maskArray).check(dsp);
case LaneType.SK_FLOAT -> new Float64Vector.Float64Mask(maskArray).check(dsp);
case LaneType.SK_DOUBLE -> new Double64Vector.Double64Mask(maskArray).check(dsp);
default -> throw new AssertionError(dsp);
};
return dsp.maskFactory(maskArray).check(dsp);
}
@Override
@ -750,24 +742,7 @@ final class Float64Vector extends FloatVector {
if (length() != species.laneCount())
throw new IllegalArgumentException("VectorShuffle length and species length differ");
int[] shuffleArray = toArray();
// enum-switches don't optimize properly JDK-8161245
switch (species.laneType.switchKey) {
case LaneType.SK_BYTE:
return new Byte64Vector.Byte64Shuffle(shuffleArray).check(species);
case LaneType.SK_SHORT:
return new Short64Vector.Short64Shuffle(shuffleArray).check(species);
case LaneType.SK_INT:
return new Int64Vector.Int64Shuffle(shuffleArray).check(species);
case LaneType.SK_LONG:
return new Long64Vector.Long64Shuffle(shuffleArray).check(species);
case LaneType.SK_FLOAT:
return new Float64Vector.Float64Shuffle(shuffleArray).check(species);
case LaneType.SK_DOUBLE:
return new Double64Vector.Double64Shuffle(shuffleArray).check(species);
}
// Should not reach here.
throw new AssertionError(species);
return s.shuffleFromArray(shuffleArray, 0).check(s);
}
@ForceInline

View file

@ -565,18 +565,10 @@ final class FloatMaxVector extends FloatVector {
@ForceInline
private final <E>
VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
assert(length() == dsp.laneCount());
if (length() != dsp.laneCount())
throw new IllegalArgumentException("VectorMask length and species length differ");
boolean[] maskArray = toArray();
// enum-switches don't optimize properly JDK-8161245
return switch (dsp.laneType.switchKey) {
case LaneType.SK_BYTE -> new ByteMaxVector.ByteMaxMask(maskArray).check(dsp);
case LaneType.SK_SHORT -> new ShortMaxVector.ShortMaxMask(maskArray).check(dsp);
case LaneType.SK_INT -> new IntMaxVector.IntMaxMask(maskArray).check(dsp);
case LaneType.SK_LONG -> new LongMaxVector.LongMaxMask(maskArray).check(dsp);
case LaneType.SK_FLOAT -> new FloatMaxVector.FloatMaxMask(maskArray).check(dsp);
case LaneType.SK_DOUBLE -> new DoubleMaxVector.DoubleMaxMask(maskArray).check(dsp);
default -> throw new AssertionError(dsp);
};
return dsp.maskFactory(maskArray).check(dsp);
}
@Override
@ -747,24 +739,7 @@ final class FloatMaxVector extends FloatVector {
if (length() != species.laneCount())
throw new IllegalArgumentException("VectorShuffle length and species length differ");
int[] shuffleArray = toArray();
// enum-switches don't optimize properly JDK-8161245
switch (species.laneType.switchKey) {
case LaneType.SK_BYTE:
return new ByteMaxVector.ByteMaxShuffle(shuffleArray).check(species);
case LaneType.SK_SHORT:
return new ShortMaxVector.ShortMaxShuffle(shuffleArray).check(species);
case LaneType.SK_INT:
return new IntMaxVector.IntMaxShuffle(shuffleArray).check(species);
case LaneType.SK_LONG:
return new LongMaxVector.LongMaxShuffle(shuffleArray).check(species);
case LaneType.SK_FLOAT:
return new FloatMaxVector.FloatMaxShuffle(shuffleArray).check(species);
case LaneType.SK_DOUBLE:
return new DoubleMaxVector.DoubleMaxShuffle(shuffleArray).check(species);
}
// Should not reach here.
throw new AssertionError(species);
return s.shuffleFromArray(shuffleArray, 0).check(s);
}
@ForceInline

View file

@ -576,18 +576,10 @@ final class Int128Vector extends IntVector {
@ForceInline
private final <E>
VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
assert(length() == dsp.laneCount());
if (length() != dsp.laneCount())
throw new IllegalArgumentException("VectorMask length and species length differ");
boolean[] maskArray = toArray();
// enum-switches don't optimize properly JDK-8161245
return switch (dsp.laneType.switchKey) {
case LaneType.SK_BYTE -> new Byte128Vector.Byte128Mask(maskArray).check(dsp);
case LaneType.SK_SHORT -> new Short128Vector.Short128Mask(maskArray).check(dsp);
case LaneType.SK_INT -> new Int128Vector.Int128Mask(maskArray).check(dsp);
case LaneType.SK_LONG -> new Long128Vector.Long128Mask(maskArray).check(dsp);
case LaneType.SK_FLOAT -> new Float128Vector.Float128Mask(maskArray).check(dsp);
case LaneType.SK_DOUBLE -> new Double128Vector.Double128Mask(maskArray).check(dsp);
default -> throw new AssertionError(dsp);
};
return dsp.maskFactory(maskArray).check(dsp);
}
@Override
@ -758,24 +750,7 @@ final class Int128Vector extends IntVector {
if (length() != species.laneCount())
throw new IllegalArgumentException("VectorShuffle length and species length differ");
int[] shuffleArray = toArray();
// enum-switches don't optimize properly JDK-8161245
switch (species.laneType.switchKey) {
case LaneType.SK_BYTE:
return new Byte128Vector.Byte128Shuffle(shuffleArray).check(species);
case LaneType.SK_SHORT:
return new Short128Vector.Short128Shuffle(shuffleArray).check(species);
case LaneType.SK_INT:
return new Int128Vector.Int128Shuffle(shuffleArray).check(species);
case LaneType.SK_LONG:
return new Long128Vector.Long128Shuffle(shuffleArray).check(species);
case LaneType.SK_FLOAT:
return new Float128Vector.Float128Shuffle(shuffleArray).check(species);
case LaneType.SK_DOUBLE:
return new Double128Vector.Double128Shuffle(shuffleArray).check(species);
}
// Should not reach here.
throw new AssertionError(species);
return s.shuffleFromArray(shuffleArray, 0).check(s);
}
@ForceInline

View file

@ -584,18 +584,10 @@ final class Int256Vector extends IntVector {
@ForceInline
private final <E>
VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
assert(length() == dsp.laneCount());
if (length() != dsp.laneCount())
throw new IllegalArgumentException("VectorMask length and species length differ");
boolean[] maskArray = toArray();
// enum-switches don't optimize properly JDK-8161245
return switch (dsp.laneType.switchKey) {
case LaneType.SK_BYTE -> new Byte256Vector.Byte256Mask(maskArray).check(dsp);
case LaneType.SK_SHORT -> new Short256Vector.Short256Mask(maskArray).check(dsp);
case LaneType.SK_INT -> new Int256Vector.Int256Mask(maskArray).check(dsp);
case LaneType.SK_LONG -> new Long256Vector.Long256Mask(maskArray).check(dsp);
case LaneType.SK_FLOAT -> new Float256Vector.Float256Mask(maskArray).check(dsp);
case LaneType.SK_DOUBLE -> new Double256Vector.Double256Mask(maskArray).check(dsp);
default -> throw new AssertionError(dsp);
};
return dsp.maskFactory(maskArray).check(dsp);
}
@Override
@ -766,24 +758,7 @@ final class Int256Vector extends IntVector {
if (length() != species.laneCount())
throw new IllegalArgumentException("VectorShuffle length and species length differ");
int[] shuffleArray = toArray();
// enum-switches don't optimize properly JDK-8161245
switch (species.laneType.switchKey) {
case LaneType.SK_BYTE:
return new Byte256Vector.Byte256Shuffle(shuffleArray).check(species);
case LaneType.SK_SHORT:
return new Short256Vector.Short256Shuffle(shuffleArray).check(species);
case LaneType.SK_INT:
return new Int256Vector.Int256Shuffle(shuffleArray).check(species);
case LaneType.SK_LONG:
return new Long256Vector.Long256Shuffle(shuffleArray).check(species);
case LaneType.SK_FLOAT:
return new Float256Vector.Float256Shuffle(shuffleArray).check(species);
case LaneType.SK_DOUBLE:
return new Double256Vector.Double256Shuffle(shuffleArray).check(species);
}
// Should not reach here.
throw new AssertionError(species);
return s.shuffleFromArray(shuffleArray, 0).check(s);
}
@ForceInline

View file

@ -600,18 +600,10 @@ final class Int512Vector extends IntVector {
@ForceInline
private final <E>
VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
assert(length() == dsp.laneCount());
if (length() != dsp.laneCount())
throw new IllegalArgumentException("VectorMask length and species length differ");
boolean[] maskArray = toArray();
// enum-switches don't optimize properly JDK-8161245
return switch (dsp.laneType.switchKey) {
case LaneType.SK_BYTE -> new Byte512Vector.Byte512Mask(maskArray).check(dsp);
case LaneType.SK_SHORT -> new Short512Vector.Short512Mask(maskArray).check(dsp);
case LaneType.SK_INT -> new Int512Vector.Int512Mask(maskArray).check(dsp);
case LaneType.SK_LONG -> new Long512Vector.Long512Mask(maskArray).check(dsp);
case LaneType.SK_FLOAT -> new Float512Vector.Float512Mask(maskArray).check(dsp);
case LaneType.SK_DOUBLE -> new Double512Vector.Double512Mask(maskArray).check(dsp);
default -> throw new AssertionError(dsp);
};
return dsp.maskFactory(maskArray).check(dsp);
}
@Override
@ -782,24 +774,7 @@ final class Int512Vector extends IntVector {
if (length() != species.laneCount())
throw new IllegalArgumentException("VectorShuffle length and species length differ");
int[] shuffleArray = toArray();
// enum-switches don't optimize properly JDK-8161245
switch (species.laneType.switchKey) {
case LaneType.SK_BYTE:
return new Byte512Vector.Byte512Shuffle(shuffleArray).check(species);
case LaneType.SK_SHORT:
return new Short512Vector.Short512Shuffle(shuffleArray).check(species);
case LaneType.SK_INT:
return new Int512Vector.Int512Shuffle(shuffleArray).check(species);
case LaneType.SK_LONG:
return new Long512Vector.Long512Shuffle(shuffleArray).check(species);
case LaneType.SK_FLOAT:
return new Float512Vector.Float512Shuffle(shuffleArray).check(species);
case LaneType.SK_DOUBLE:
return new Double512Vector.Double512Shuffle(shuffleArray).check(species);
}
// Should not reach here.
throw new AssertionError(species);
return s.shuffleFromArray(shuffleArray, 0).check(s);
}
@ForceInline

View file

@ -572,18 +572,10 @@ final class Int64Vector extends IntVector {
@ForceInline
private final <E>
VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
assert(length() == dsp.laneCount());
if (length() != dsp.laneCount())
throw new IllegalArgumentException("VectorMask length and species length differ");
boolean[] maskArray = toArray();
// enum-switches don't optimize properly JDK-8161245
return switch (dsp.laneType.switchKey) {
case LaneType.SK_BYTE -> new Byte64Vector.Byte64Mask(maskArray).check(dsp);
case LaneType.SK_SHORT -> new Short64Vector.Short64Mask(maskArray).check(dsp);
case LaneType.SK_INT -> new Int64Vector.Int64Mask(maskArray).check(dsp);
case LaneType.SK_LONG -> new Long64Vector.Long64Mask(maskArray).check(dsp);
case LaneType.SK_FLOAT -> new Float64Vector.Float64Mask(maskArray).check(dsp);
case LaneType.SK_DOUBLE -> new Double64Vector.Double64Mask(maskArray).check(dsp);
default -> throw new AssertionError(dsp);
};
return dsp.maskFactory(maskArray).check(dsp);
}
@Override
@ -754,24 +746,7 @@ final class Int64Vector extends IntVector {
if (length() != species.laneCount())
throw new IllegalArgumentException("VectorShuffle length and species length differ");
int[] shuffleArray = toArray();
// enum-switches don't optimize properly JDK-8161245
switch (species.laneType.switchKey) {
case LaneType.SK_BYTE:
return new Byte64Vector.Byte64Shuffle(shuffleArray).check(species);
case LaneType.SK_SHORT:
return new Short64Vector.Short64Shuffle(shuffleArray).check(species);
case LaneType.SK_INT:
return new Int64Vector.Int64Shuffle(shuffleArray).check(species);
case LaneType.SK_LONG:
return new Long64Vector.Long64Shuffle(shuffleArray).check(species);
case LaneType.SK_FLOAT:
return new Float64Vector.Float64Shuffle(shuffleArray).check(species);
case LaneType.SK_DOUBLE:
return new Double64Vector.Double64Shuffle(shuffleArray).check(species);
}
// Should not reach here.
throw new AssertionError(species);
return s.shuffleFromArray(shuffleArray, 0).check(s);
}
@ForceInline

View file

@ -570,18 +570,10 @@ final class IntMaxVector extends IntVector {
@ForceInline
private final <E>
VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
assert(length() == dsp.laneCount());
if (length() != dsp.laneCount())
throw new IllegalArgumentException("VectorMask length and species length differ");
boolean[] maskArray = toArray();
// enum-switches don't optimize properly JDK-8161245
return switch (dsp.laneType.switchKey) {
case LaneType.SK_BYTE -> new ByteMaxVector.ByteMaxMask(maskArray).check(dsp);
case LaneType.SK_SHORT -> new ShortMaxVector.ShortMaxMask(maskArray).check(dsp);
case LaneType.SK_INT -> new IntMaxVector.IntMaxMask(maskArray).check(dsp);
case LaneType.SK_LONG -> new LongMaxVector.LongMaxMask(maskArray).check(dsp);
case LaneType.SK_FLOAT -> new FloatMaxVector.FloatMaxMask(maskArray).check(dsp);
case LaneType.SK_DOUBLE -> new DoubleMaxVector.DoubleMaxMask(maskArray).check(dsp);
default -> throw new AssertionError(dsp);
};
return dsp.maskFactory(maskArray).check(dsp);
}
@Override
@ -763,24 +755,7 @@ final class IntMaxVector extends IntVector {
if (length() != species.laneCount())
throw new IllegalArgumentException("VectorShuffle length and species length differ");
int[] shuffleArray = toArray();
// enum-switches don't optimize properly JDK-8161245
switch (species.laneType.switchKey) {
case LaneType.SK_BYTE:
return new ByteMaxVector.ByteMaxShuffle(shuffleArray).check(species);
case LaneType.SK_SHORT:
return new ShortMaxVector.ShortMaxShuffle(shuffleArray).check(species);
case LaneType.SK_INT:
return new IntMaxVector.IntMaxShuffle(shuffleArray).check(species);
case LaneType.SK_LONG:
return new LongMaxVector.LongMaxShuffle(shuffleArray).check(species);
case LaneType.SK_FLOAT:
return new FloatMaxVector.FloatMaxShuffle(shuffleArray).check(species);
case LaneType.SK_DOUBLE:
return new DoubleMaxVector.DoubleMaxShuffle(shuffleArray).check(species);
}
// Should not reach here.
throw new AssertionError(species);
return s.shuffleFromArray(shuffleArray, 0).check(s);
}
@ForceInline

View file

@ -562,18 +562,10 @@ final class Long128Vector extends LongVector {
@ForceInline
private final <E>
VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
assert(length() == dsp.laneCount());
if (length() != dsp.laneCount())
throw new IllegalArgumentException("VectorMask length and species length differ");
boolean[] maskArray = toArray();
// enum-switches don't optimize properly JDK-8161245
return switch (dsp.laneType.switchKey) {
case LaneType.SK_BYTE -> new Byte128Vector.Byte128Mask(maskArray).check(dsp);
case LaneType.SK_SHORT -> new Short128Vector.Short128Mask(maskArray).check(dsp);
case LaneType.SK_INT -> new Int128Vector.Int128Mask(maskArray).check(dsp);
case LaneType.SK_LONG -> new Long128Vector.Long128Mask(maskArray).check(dsp);
case LaneType.SK_FLOAT -> new Float128Vector.Float128Mask(maskArray).check(dsp);
case LaneType.SK_DOUBLE -> new Double128Vector.Double128Mask(maskArray).check(dsp);
default -> throw new AssertionError(dsp);
};
return dsp.maskFactory(maskArray).check(dsp);
}
@Override
@ -744,24 +736,7 @@ final class Long128Vector extends LongVector {
if (length() != species.laneCount())
throw new IllegalArgumentException("VectorShuffle length and species length differ");
int[] shuffleArray = toArray();
// enum-switches don't optimize properly JDK-8161245
switch (species.laneType.switchKey) {
case LaneType.SK_BYTE:
return new Byte128Vector.Byte128Shuffle(shuffleArray).check(species);
case LaneType.SK_SHORT:
return new Short128Vector.Short128Shuffle(shuffleArray).check(species);
case LaneType.SK_INT:
return new Int128Vector.Int128Shuffle(shuffleArray).check(species);
case LaneType.SK_LONG:
return new Long128Vector.Long128Shuffle(shuffleArray).check(species);
case LaneType.SK_FLOAT:
return new Float128Vector.Float128Shuffle(shuffleArray).check(species);
case LaneType.SK_DOUBLE:
return new Double128Vector.Double128Shuffle(shuffleArray).check(species);
}
// Should not reach here.
throw new AssertionError(species);
return s.shuffleFromArray(shuffleArray, 0).check(s);
}
@ForceInline

View file

@ -566,18 +566,10 @@ final class Long256Vector extends LongVector {
@ForceInline
private final <E>
VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
assert(length() == dsp.laneCount());
if (length() != dsp.laneCount())
throw new IllegalArgumentException("VectorMask length and species length differ");
boolean[] maskArray = toArray();
// enum-switches don't optimize properly JDK-8161245
return switch (dsp.laneType.switchKey) {
case LaneType.SK_BYTE -> new Byte256Vector.Byte256Mask(maskArray).check(dsp);
case LaneType.SK_SHORT -> new Short256Vector.Short256Mask(maskArray).check(dsp);
case LaneType.SK_INT -> new Int256Vector.Int256Mask(maskArray).check(dsp);
case LaneType.SK_LONG -> new Long256Vector.Long256Mask(maskArray).check(dsp);
case LaneType.SK_FLOAT -> new Float256Vector.Float256Mask(maskArray).check(dsp);
case LaneType.SK_DOUBLE -> new Double256Vector.Double256Mask(maskArray).check(dsp);
default -> throw new AssertionError(dsp);
};
return dsp.maskFactory(maskArray).check(dsp);
}
@Override
@ -748,24 +740,7 @@ final class Long256Vector extends LongVector {
if (length() != species.laneCount())
throw new IllegalArgumentException("VectorShuffle length and species length differ");
int[] shuffleArray = toArray();
// enum-switches don't optimize properly JDK-8161245
switch (species.laneType.switchKey) {
case LaneType.SK_BYTE:
return new Byte256Vector.Byte256Shuffle(shuffleArray).check(species);
case LaneType.SK_SHORT:
return new Short256Vector.Short256Shuffle(shuffleArray).check(species);
case LaneType.SK_INT:
return new Int256Vector.Int256Shuffle(shuffleArray).check(species);
case LaneType.SK_LONG:
return new Long256Vector.Long256Shuffle(shuffleArray).check(species);
case LaneType.SK_FLOAT:
return new Float256Vector.Float256Shuffle(shuffleArray).check(species);
case LaneType.SK_DOUBLE:
return new Double256Vector.Double256Shuffle(shuffleArray).check(species);
}
// Should not reach here.
throw new AssertionError(species);
return s.shuffleFromArray(shuffleArray, 0).check(s);
}
@ForceInline

View file

@ -574,18 +574,10 @@ final class Long512Vector extends LongVector {
@ForceInline
private final <E>
VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
assert(length() == dsp.laneCount());
if (length() != dsp.laneCount())
throw new IllegalArgumentException("VectorMask length and species length differ");
boolean[] maskArray = toArray();
// enum-switches don't optimize properly JDK-8161245
return switch (dsp.laneType.switchKey) {
case LaneType.SK_BYTE -> new Byte512Vector.Byte512Mask(maskArray).check(dsp);
case LaneType.SK_SHORT -> new Short512Vector.Short512Mask(maskArray).check(dsp);
case LaneType.SK_INT -> new Int512Vector.Int512Mask(maskArray).check(dsp);
case LaneType.SK_LONG -> new Long512Vector.Long512Mask(maskArray).check(dsp);
case LaneType.SK_FLOAT -> new Float512Vector.Float512Mask(maskArray).check(dsp);
case LaneType.SK_DOUBLE -> new Double512Vector.Double512Mask(maskArray).check(dsp);
default -> throw new AssertionError(dsp);
};
return dsp.maskFactory(maskArray).check(dsp);
}
@Override
@ -756,24 +748,7 @@ final class Long512Vector extends LongVector {
if (length() != species.laneCount())
throw new IllegalArgumentException("VectorShuffle length and species length differ");
int[] shuffleArray = toArray();
// enum-switches don't optimize properly JDK-8161245
switch (species.laneType.switchKey) {
case LaneType.SK_BYTE:
return new Byte512Vector.Byte512Shuffle(shuffleArray).check(species);
case LaneType.SK_SHORT:
return new Short512Vector.Short512Shuffle(shuffleArray).check(species);
case LaneType.SK_INT:
return new Int512Vector.Int512Shuffle(shuffleArray).check(species);
case LaneType.SK_LONG:
return new Long512Vector.Long512Shuffle(shuffleArray).check(species);
case LaneType.SK_FLOAT:
return new Float512Vector.Float512Shuffle(shuffleArray).check(species);
case LaneType.SK_DOUBLE:
return new Double512Vector.Double512Shuffle(shuffleArray).check(species);
}
// Should not reach here.
throw new AssertionError(species);
return s.shuffleFromArray(shuffleArray, 0).check(s);
}
@ForceInline

View file

@ -560,18 +560,10 @@ final class Long64Vector extends LongVector {
@ForceInline
private final <E>
VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
assert(length() == dsp.laneCount());
if (length() != dsp.laneCount())
throw new IllegalArgumentException("VectorMask length and species length differ");
boolean[] maskArray = toArray();
// enum-switches don't optimize properly JDK-8161245
return switch (dsp.laneType.switchKey) {
case LaneType.SK_BYTE -> new Byte64Vector.Byte64Mask(maskArray).check(dsp);
case LaneType.SK_SHORT -> new Short64Vector.Short64Mask(maskArray).check(dsp);
case LaneType.SK_INT -> new Int64Vector.Int64Mask(maskArray).check(dsp);
case LaneType.SK_LONG -> new Long64Vector.Long64Mask(maskArray).check(dsp);
case LaneType.SK_FLOAT -> new Float64Vector.Float64Mask(maskArray).check(dsp);
case LaneType.SK_DOUBLE -> new Double64Vector.Double64Mask(maskArray).check(dsp);
default -> throw new AssertionError(dsp);
};
return dsp.maskFactory(maskArray).check(dsp);
}
@Override
@ -742,24 +734,7 @@ final class Long64Vector extends LongVector {
if (length() != species.laneCount())
throw new IllegalArgumentException("VectorShuffle length and species length differ");
int[] shuffleArray = toArray();
// enum-switches don't optimize properly JDK-8161245
switch (species.laneType.switchKey) {
case LaneType.SK_BYTE:
return new Byte64Vector.Byte64Shuffle(shuffleArray).check(species);
case LaneType.SK_SHORT:
return new Short64Vector.Short64Shuffle(shuffleArray).check(species);
case LaneType.SK_INT:
return new Int64Vector.Int64Shuffle(shuffleArray).check(species);
case LaneType.SK_LONG:
return new Long64Vector.Long64Shuffle(shuffleArray).check(species);
case LaneType.SK_FLOAT:
return new Float64Vector.Float64Shuffle(shuffleArray).check(species);
case LaneType.SK_DOUBLE:
return new Double64Vector.Double64Shuffle(shuffleArray).check(species);
}
// Should not reach here.
throw new AssertionError(species);
return s.shuffleFromArray(shuffleArray, 0).check(s);
}
@ForceInline

View file

@ -560,18 +560,10 @@ final class LongMaxVector extends LongVector {
@ForceInline
private final <E>
VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
assert(length() == dsp.laneCount());
if (length() != dsp.laneCount())
throw new IllegalArgumentException("VectorMask length and species length differ");
boolean[] maskArray = toArray();
// enum-switches don't optimize properly JDK-8161245
return switch (dsp.laneType.switchKey) {
case LaneType.SK_BYTE -> new ByteMaxVector.ByteMaxMask(maskArray).check(dsp);
case LaneType.SK_SHORT -> new ShortMaxVector.ShortMaxMask(maskArray).check(dsp);
case LaneType.SK_INT -> new IntMaxVector.IntMaxMask(maskArray).check(dsp);
case LaneType.SK_LONG -> new LongMaxVector.LongMaxMask(maskArray).check(dsp);
case LaneType.SK_FLOAT -> new FloatMaxVector.FloatMaxMask(maskArray).check(dsp);
case LaneType.SK_DOUBLE -> new DoubleMaxVector.DoubleMaxMask(maskArray).check(dsp);
default -> throw new AssertionError(dsp);
};
return dsp.maskFactory(maskArray).check(dsp);
}
@Override
@ -742,24 +734,7 @@ final class LongMaxVector extends LongVector {
if (length() != species.laneCount())
throw new IllegalArgumentException("VectorShuffle length and species length differ");
int[] shuffleArray = toArray();
// enum-switches don't optimize properly JDK-8161245
switch (species.laneType.switchKey) {
case LaneType.SK_BYTE:
return new ByteMaxVector.ByteMaxShuffle(shuffleArray).check(species);
case LaneType.SK_SHORT:
return new ShortMaxVector.ShortMaxShuffle(shuffleArray).check(species);
case LaneType.SK_INT:
return new IntMaxVector.IntMaxShuffle(shuffleArray).check(species);
case LaneType.SK_LONG:
return new LongMaxVector.LongMaxShuffle(shuffleArray).check(species);
case LaneType.SK_FLOAT:
return new FloatMaxVector.FloatMaxShuffle(shuffleArray).check(species);
case LaneType.SK_DOUBLE:
return new DoubleMaxVector.DoubleMaxShuffle(shuffleArray).check(species);
}
// Should not reach here.
throw new AssertionError(species);
return s.shuffleFromArray(shuffleArray, 0).check(s);
}
@ForceInline

View file

@ -584,18 +584,10 @@ final class Short128Vector extends ShortVector {
@ForceInline
private final <E>
VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
assert(length() == dsp.laneCount());
if (length() != dsp.laneCount())
throw new IllegalArgumentException("VectorMask length and species length differ");
boolean[] maskArray = toArray();
// enum-switches don't optimize properly JDK-8161245
return switch (dsp.laneType.switchKey) {
case LaneType.SK_BYTE -> new Byte128Vector.Byte128Mask(maskArray).check(dsp);
case LaneType.SK_SHORT -> new Short128Vector.Short128Mask(maskArray).check(dsp);
case LaneType.SK_INT -> new Int128Vector.Int128Mask(maskArray).check(dsp);
case LaneType.SK_LONG -> new Long128Vector.Long128Mask(maskArray).check(dsp);
case LaneType.SK_FLOAT -> new Float128Vector.Float128Mask(maskArray).check(dsp);
case LaneType.SK_DOUBLE -> new Double128Vector.Double128Mask(maskArray).check(dsp);
default -> throw new AssertionError(dsp);
};
return dsp.maskFactory(maskArray).check(dsp);
}
@Override
@ -766,24 +758,7 @@ final class Short128Vector extends ShortVector {
if (length() != species.laneCount())
throw new IllegalArgumentException("VectorShuffle length and species length differ");
int[] shuffleArray = toArray();
// enum-switches don't optimize properly JDK-8161245
switch (species.laneType.switchKey) {
case LaneType.SK_BYTE:
return new Byte128Vector.Byte128Shuffle(shuffleArray).check(species);
case LaneType.SK_SHORT:
return new Short128Vector.Short128Shuffle(shuffleArray).check(species);
case LaneType.SK_INT:
return new Int128Vector.Int128Shuffle(shuffleArray).check(species);
case LaneType.SK_LONG:
return new Long128Vector.Long128Shuffle(shuffleArray).check(species);
case LaneType.SK_FLOAT:
return new Float128Vector.Float128Shuffle(shuffleArray).check(species);
case LaneType.SK_DOUBLE:
return new Double128Vector.Double128Shuffle(shuffleArray).check(species);
}
// Should not reach here.
throw new AssertionError(species);
return s.shuffleFromArray(shuffleArray, 0).check(s);
}
@ForceInline

View file

@ -600,18 +600,10 @@ final class Short256Vector extends ShortVector {
@ForceInline
private final <E>
VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
assert(length() == dsp.laneCount());
if (length() != dsp.laneCount())
throw new IllegalArgumentException("VectorMask length and species length differ");
boolean[] maskArray = toArray();
// enum-switches don't optimize properly JDK-8161245
return switch (dsp.laneType.switchKey) {
case LaneType.SK_BYTE -> new Byte256Vector.Byte256Mask(maskArray).check(dsp);
case LaneType.SK_SHORT -> new Short256Vector.Short256Mask(maskArray).check(dsp);
case LaneType.SK_INT -> new Int256Vector.Int256Mask(maskArray).check(dsp);
case LaneType.SK_LONG -> new Long256Vector.Long256Mask(maskArray).check(dsp);
case LaneType.SK_FLOAT -> new Float256Vector.Float256Mask(maskArray).check(dsp);
case LaneType.SK_DOUBLE -> new Double256Vector.Double256Mask(maskArray).check(dsp);
default -> throw new AssertionError(dsp);
};
return dsp.maskFactory(maskArray).check(dsp);
}
@Override
@ -782,24 +774,7 @@ final class Short256Vector extends ShortVector {
if (length() != species.laneCount())
throw new IllegalArgumentException("VectorShuffle length and species length differ");
int[] shuffleArray = toArray();
// enum-switches don't optimize properly JDK-8161245
switch (species.laneType.switchKey) {
case LaneType.SK_BYTE:
return new Byte256Vector.Byte256Shuffle(shuffleArray).check(species);
case LaneType.SK_SHORT:
return new Short256Vector.Short256Shuffle(shuffleArray).check(species);
case LaneType.SK_INT:
return new Int256Vector.Int256Shuffle(shuffleArray).check(species);
case LaneType.SK_LONG:
return new Long256Vector.Long256Shuffle(shuffleArray).check(species);
case LaneType.SK_FLOAT:
return new Float256Vector.Float256Shuffle(shuffleArray).check(species);
case LaneType.SK_DOUBLE:
return new Double256Vector.Double256Shuffle(shuffleArray).check(species);
}
// Should not reach here.
throw new AssertionError(species);
return s.shuffleFromArray(shuffleArray, 0).check(s);
}
@ForceInline

View file

@ -632,18 +632,10 @@ final class Short512Vector extends ShortVector {
@ForceInline
private final <E>
VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
assert(length() == dsp.laneCount());
if (length() != dsp.laneCount())
throw new IllegalArgumentException("VectorMask length and species length differ");
boolean[] maskArray = toArray();
// enum-switches don't optimize properly JDK-8161245
return switch (dsp.laneType.switchKey) {
case LaneType.SK_BYTE -> new Byte512Vector.Byte512Mask(maskArray).check(dsp);
case LaneType.SK_SHORT -> new Short512Vector.Short512Mask(maskArray).check(dsp);
case LaneType.SK_INT -> new Int512Vector.Int512Mask(maskArray).check(dsp);
case LaneType.SK_LONG -> new Long512Vector.Long512Mask(maskArray).check(dsp);
case LaneType.SK_FLOAT -> new Float512Vector.Float512Mask(maskArray).check(dsp);
case LaneType.SK_DOUBLE -> new Double512Vector.Double512Mask(maskArray).check(dsp);
default -> throw new AssertionError(dsp);
};
return dsp.maskFactory(maskArray).check(dsp);
}
@Override
@ -814,24 +806,7 @@ final class Short512Vector extends ShortVector {
if (length() != species.laneCount())
throw new IllegalArgumentException("VectorShuffle length and species length differ");
int[] shuffleArray = toArray();
// enum-switches don't optimize properly JDK-8161245
switch (species.laneType.switchKey) {
case LaneType.SK_BYTE:
return new Byte512Vector.Byte512Shuffle(shuffleArray).check(species);
case LaneType.SK_SHORT:
return new Short512Vector.Short512Shuffle(shuffleArray).check(species);
case LaneType.SK_INT:
return new Int512Vector.Int512Shuffle(shuffleArray).check(species);
case LaneType.SK_LONG:
return new Long512Vector.Long512Shuffle(shuffleArray).check(species);
case LaneType.SK_FLOAT:
return new Float512Vector.Float512Shuffle(shuffleArray).check(species);
case LaneType.SK_DOUBLE:
return new Double512Vector.Double512Shuffle(shuffleArray).check(species);
}
// Should not reach here.
throw new AssertionError(species);
return s.shuffleFromArray(shuffleArray, 0).check(s);
}
@ForceInline

View file

@ -576,18 +576,10 @@ final class Short64Vector extends ShortVector {
@ForceInline
private final <E>
VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
assert(length() == dsp.laneCount());
if (length() != dsp.laneCount())
throw new IllegalArgumentException("VectorMask length and species length differ");
boolean[] maskArray = toArray();
// enum-switches don't optimize properly JDK-8161245
return switch (dsp.laneType.switchKey) {
case LaneType.SK_BYTE -> new Byte64Vector.Byte64Mask(maskArray).check(dsp);
case LaneType.SK_SHORT -> new Short64Vector.Short64Mask(maskArray).check(dsp);
case LaneType.SK_INT -> new Int64Vector.Int64Mask(maskArray).check(dsp);
case LaneType.SK_LONG -> new Long64Vector.Long64Mask(maskArray).check(dsp);
case LaneType.SK_FLOAT -> new Float64Vector.Float64Mask(maskArray).check(dsp);
case LaneType.SK_DOUBLE -> new Double64Vector.Double64Mask(maskArray).check(dsp);
default -> throw new AssertionError(dsp);
};
return dsp.maskFactory(maskArray).check(dsp);
}
@Override
@ -758,24 +750,7 @@ final class Short64Vector extends ShortVector {
if (length() != species.laneCount())
throw new IllegalArgumentException("VectorShuffle length and species length differ");
int[] shuffleArray = toArray();
// enum-switches don't optimize properly JDK-8161245
switch (species.laneType.switchKey) {
case LaneType.SK_BYTE:
return new Byte64Vector.Byte64Shuffle(shuffleArray).check(species);
case LaneType.SK_SHORT:
return new Short64Vector.Short64Shuffle(shuffleArray).check(species);
case LaneType.SK_INT:
return new Int64Vector.Int64Shuffle(shuffleArray).check(species);
case LaneType.SK_LONG:
return new Long64Vector.Long64Shuffle(shuffleArray).check(species);
case LaneType.SK_FLOAT:
return new Float64Vector.Float64Shuffle(shuffleArray).check(species);
case LaneType.SK_DOUBLE:
return new Double64Vector.Double64Shuffle(shuffleArray).check(species);
}
// Should not reach here.
throw new AssertionError(species);
return s.shuffleFromArray(shuffleArray, 0).check(s);
}
@ForceInline

View file

@ -570,18 +570,10 @@ final class ShortMaxVector extends ShortVector {
@ForceInline
private final <E>
VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
assert(length() == dsp.laneCount());
if (length() != dsp.laneCount())
throw new IllegalArgumentException("VectorMask length and species length differ");
boolean[] maskArray = toArray();
// enum-switches don't optimize properly JDK-8161245
return switch (dsp.laneType.switchKey) {
case LaneType.SK_BYTE -> new ByteMaxVector.ByteMaxMask(maskArray).check(dsp);
case LaneType.SK_SHORT -> new ShortMaxVector.ShortMaxMask(maskArray).check(dsp);
case LaneType.SK_INT -> new IntMaxVector.IntMaxMask(maskArray).check(dsp);
case LaneType.SK_LONG -> new LongMaxVector.LongMaxMask(maskArray).check(dsp);
case LaneType.SK_FLOAT -> new FloatMaxVector.FloatMaxMask(maskArray).check(dsp);
case LaneType.SK_DOUBLE -> new DoubleMaxVector.DoubleMaxMask(maskArray).check(dsp);
default -> throw new AssertionError(dsp);
};
return dsp.maskFactory(maskArray).check(dsp);
}
@Override
@ -752,24 +744,7 @@ final class ShortMaxVector extends ShortVector {
if (length() != species.laneCount())
throw new IllegalArgumentException("VectorShuffle length and species length differ");
int[] shuffleArray = toArray();
// enum-switches don't optimize properly JDK-8161245
switch (species.laneType.switchKey) {
case LaneType.SK_BYTE:
return new ByteMaxVector.ByteMaxShuffle(shuffleArray).check(species);
case LaneType.SK_SHORT:
return new ShortMaxVector.ShortMaxShuffle(shuffleArray).check(species);
case LaneType.SK_INT:
return new IntMaxVector.IntMaxShuffle(shuffleArray).check(species);
case LaneType.SK_LONG:
return new LongMaxVector.LongMaxShuffle(shuffleArray).check(species);
case LaneType.SK_FLOAT:
return new FloatMaxVector.FloatMaxShuffle(shuffleArray).check(species);
case LaneType.SK_DOUBLE:
return new DoubleMaxVector.DoubleMaxShuffle(shuffleArray).check(species);
}
// Should not reach here.
throw new AssertionError(species);
return s.shuffleFromArray(shuffleArray, 0).check(s);
}
@ForceInline

View file

@ -843,18 +843,10 @@ final class $vectortype$ extends $abstractvectortype$ {
@ForceInline
private final <E>
VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
assert(length() == dsp.laneCount());
if (length() != dsp.laneCount())
throw new IllegalArgumentException("VectorMask length and species length differ");
boolean[] maskArray = toArray();
// enum-switches don't optimize properly JDK-8161245
return switch (dsp.laneType.switchKey) {
case LaneType.SK_BYTE -> new Byte$bits$Vector.Byte$bits$Mask(maskArray).check(dsp);
case LaneType.SK_SHORT -> new Short$bits$Vector.Short$bits$Mask(maskArray).check(dsp);
case LaneType.SK_INT -> new Int$bits$Vector.Int$bits$Mask(maskArray).check(dsp);
case LaneType.SK_LONG -> new Long$bits$Vector.Long$bits$Mask(maskArray).check(dsp);
case LaneType.SK_FLOAT -> new Float$bits$Vector.Float$bits$Mask(maskArray).check(dsp);
case LaneType.SK_DOUBLE -> new Double$bits$Vector.Double$bits$Mask(maskArray).check(dsp);
default -> throw new AssertionError(dsp);
};
return dsp.maskFactory(maskArray).check(dsp);
}
@Override
@ -1040,24 +1032,7 @@ final class $vectortype$ extends $abstractvectortype$ {
if (length() != species.laneCount())
throw new IllegalArgumentException("VectorShuffle length and species length differ");
int[] shuffleArray = toArray();
// enum-switches don't optimize properly JDK-8161245
switch (species.laneType.switchKey) {
case LaneType.SK_BYTE:
return new Byte$bits$Vector.Byte$bits$Shuffle(shuffleArray).check(species);
case LaneType.SK_SHORT:
return new Short$bits$Vector.Short$bits$Shuffle(shuffleArray).check(species);
case LaneType.SK_INT:
return new Int$bits$Vector.Int$bits$Shuffle(shuffleArray).check(species);
case LaneType.SK_LONG:
return new Long$bits$Vector.Long$bits$Shuffle(shuffleArray).check(species);
case LaneType.SK_FLOAT:
return new Float$bits$Vector.Float$bits$Shuffle(shuffleArray).check(species);
case LaneType.SK_DOUBLE:
return new Double$bits$Vector.Double$bits$Shuffle(shuffleArray).check(species);
}
// Should not reach here.
throw new AssertionError(species);
return s.shuffleFromArray(shuffleArray, 0).check(s);
}
@ForceInline

View file

@ -0,0 +1,65 @@
/*
* Copyright (c) 2021, Red Hat, Inc. 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.
*/
/**
* @test
* @bug 8267399
* @summary C2: java/text/Normalizer/ConformanceTest.java test failed with assertion
*
* @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation TestDeadCountedLoop
*
*/
public class TestDeadCountedLoop {
public static void main(String[] args) {
for (int i = 0; i < 20_000; i++) {
test(true, new int[10], false, 0, 1);
test(false, new int[10], false, 0, 1);
}
}
private static int test(boolean flag, int[] array2, boolean flag2, int start, int stop) {
if (array2 == null) {
}
int[] array;
if (flag) {
array = new int[1];
} else {
array = new int[2];
}
int len = array.length;
int v = 1;
for (int j = start; j < stop; j++) {
for (int i = 0; i < len; i++) {
if (i > 0) {
if (flag2) {
break;
}
v *= array2[i + j];
}
}
}
return v;
}
}

View file

@ -832,8 +832,6 @@ jdk/jfr/api/consumer/streaming/TestLatestEvent.java 8268297 windows-
# jdk_jpackage
tools/jpackage/windows/WinInstallerIconTest.java 8268404 windows-x64
############################################################################
# Client manual tests

View file

@ -27,7 +27,7 @@
* @modules jdk.incubator.foreign
* @run testng/othervm
* --enable-native-access=ALL-UNNAMED
* TestNULLTarget
* TestNULLAddress
*/
import jdk.incubator.foreign.Addressable;
@ -38,8 +38,9 @@ import org.testng.annotations.Test;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodType;
import java.nio.charset.Charset;
public class TestNULLTarget {
public class TestNULLAddress {
static final CLinker LINKER = CLinker.getInstance();
@ -58,4 +59,14 @@ public class TestNULLTarget {
FunctionDescriptor.ofVoid());
mh.invokeExact((Addressable) MemoryAddress.NULL);
}
@Test(expectedExceptions = IllegalArgumentException.class)
public void testNULLtoJavaString() {
CLinker.toJavaString(MemoryAddress.NULL);
}
@Test(expectedExceptions = IllegalArgumentException.class)
public void testNULLfreeMemory() {
CLinker.freeMemory(MemoryAddress.NULL);
}
}

View file

@ -0,0 +1,64 @@
/*
* Copyright (c) 2021, 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.incubator.foreign.CLinker;
import jdk.incubator.foreign.MemorySegment;
import jdk.incubator.foreign.ResourceScope;
import org.testng.annotations.*;
import static org.testng.Assert.*;
/*
* @test
* @requires ((os.arch == "amd64" | os.arch == "x86_64") & sun.arch.data.model == "64") | os.arch == "aarch64"
* @run testng TestStringEncoding
*/
public class TestStringEncoding {
@Test(dataProvider = "strings")
public void testStrings(String testString, int expectedByteLength) {
try (ResourceScope scope = ResourceScope.newConfinedScope()) {
MemorySegment text = CLinker.toCString(testString, scope);
assertEquals(text.byteSize(), expectedByteLength);
String roundTrip = CLinker.toJavaString(text);
assertEquals(roundTrip, testString);
}
}
@DataProvider
public static Object[][] strings() {
return new Object[][] {
{ "testing", 8 },
{ "", 1 },
{ "X", 2 },
{ "12345", 6 },
{ "yen \u00A5", 7 }, // in UTF-8 2 bytes: 0xC2 0xA5
{ "snowman \u26C4", 12 }, // in UTF-8 three bytes: 0xE2 0x9B 0x84
{ "rainbow \uD83C\uDF08", 13 } // in UTF-8 four bytes: 0xF0 0x9F 0x8C 0x88
};
}
}

View file

@ -58,10 +58,7 @@ public class MethodHandleLookup {
MethodType.methodType(CLinker.class)), "CLinker::getInstance" },
{ MethodHandles.lookup().findStatic(CLinker.class, "toJavaString",
MethodType.methodType(String.class, MemoryAddress.class)),
"CLinker::toJavaString/1" },
{ MethodHandles.lookup().findStatic(CLinker.class, "toJavaString",
MethodType.methodType(String.class, MemoryAddress.class, Charset.class)),
"CLinker::toJavaString/2" },
"CLinker::toJavaString" },
{ MethodHandles.lookup().findStatic(CLinker.class, "allocateMemory",
MethodType.methodType(MemoryAddress.class, long.class)),
"CLinker::allocateMemory" },

View file

@ -36,6 +36,7 @@ import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.ResourceBundle;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
@ -44,15 +45,11 @@ import java.util.function.Supplier;
import java.lang.System.LoggerFinder;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.EnumSet;
import java.util.Iterator;
import java.util.Locale;
import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
import java.util.concurrent.atomic.AtomicReference;
import jdk.internal.logger.SimpleConsoleLogger;
/**
* @test
@ -202,6 +199,10 @@ public class LoggerFinderLoaderTest {
}
}
private static String withoutWarning(String in) {
return in.lines().filter(s -> !s.startsWith("WARNING:")).collect(Collectors.joining());
}
static LoggerFinder getLoggerFinder(Class<?> expectedClass,
String errorPolicy, boolean singleton) {
LoggerFinder provider = null;
@ -235,12 +236,7 @@ public class LoggerFinderLoaderTest {
}
} else if ("QUIET".equals(errorPolicy.toUpperCase(Locale.ROOT))) {
String warning = ErrorStream.errorStream.peek();
String smDeprecationWarning
= "WARNING: java.lang.System::setSecurityManager is deprecated and will be removed in a future release."
+ System.getProperty("line.separator");
if (warning.startsWith(smDeprecationWarning)) {
warning = warning.substring(smDeprecationWarning.length());
}
warning = withoutWarning(warning);
if (!warning.isEmpty()) {
throw new RuntimeException("Unexpected error message found: "
+ ErrorStream.errorStream.peek());

View file

@ -23,70 +23,116 @@
/*
* @test
* @bug 8266459
* @bug 8266459 8268349
* @summary check various warnings
* @library /test/lib
*/
import jdk.test.lib.JDKToolFinder;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.util.JarUtils;
import java.security.Permission;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.PrintStream;
import java.nio.file.Files;
import java.nio.file.Path;
public class SecurityManagerWarnings {
public static void main(String args[]) throws Exception {
if (args.length == 0) {
run(null)
.shouldHaveExitValue(0)
.shouldContain("SM is enabled: false")
.shouldNotContain("Security Manager is deprecated")
.shouldContain("setSecurityManager is deprecated");
run("allow")
.shouldHaveExitValue(0)
.shouldContain("SM is enabled: false")
.shouldNotContain("Security Manager is deprecated")
.shouldContain("setSecurityManager is deprecated");
run("disallow")
.shouldNotHaveExitValue(0)
.shouldContain("SM is enabled: false")
.shouldNotContain("Security Manager is deprecated")
.shouldContain("UnsupportedOperationException");
run("SecurityManagerWarnings$MySM")
.shouldHaveExitValue(0)
.shouldContain("SM is enabled: true")
.shouldContain("Security Manager is deprecated")
.shouldContain("setSecurityManager is deprecated");
run("")
.shouldNotHaveExitValue(0)
.shouldContain("SM is enabled: true")
.shouldContain("Security Manager is deprecated")
.shouldContain("AccessControlException");
run("default")
.shouldNotHaveExitValue(0)
.shouldContain("SM is enabled: true")
.shouldContain("Security Manager is deprecated")
.shouldContain("AccessControlException");
Files.writeString(Path.of("policy"), """
grant {
permission java.lang.RuntimePermission "setIO";
permission java.lang.RuntimePermission "createSecurityManager";
permission java.lang.RuntimePermission "setSecurityManager";
};
""");
String testClasses = System.getProperty("test.classes");
allowTest(null, testClasses);
allowTest("allow", testClasses);
disallowTest("disallow", testClasses);
enableTest("", testClasses);
enableTest("default", testClasses);
enableTest("java.lang.SecurityManager", testClasses);
JarUtils.createJarFile(Path.of("a.jar"),
Path.of(testClasses),
Path.of("SecurityManagerWarnings.class"));
allowTest(null, "a.jar");
} else {
System.out.println("SM is enabled: " + (System.getSecurityManager() != null));
PrintStream oldErr = System.err;
// Modify System.err, thus make sure warnings are always printed
// to the original System.err and will not be swallowed.
System.setErr(new PrintStream(new ByteArrayOutputStream()));
try {
System.setSecurityManager(new SecurityManager());
} catch (Exception e) {
// Exception messages must show in original stderr
e.printStackTrace(oldErr);
throw e;
}
}
}
static OutputAnalyzer run(String prop) throws Exception {
// When SM is allowed, no startup warning, has setSM warning
static void allowTest(String prop, String cp) throws Exception {
checkInstallMessage(run(prop, cp), cp)
.shouldHaveExitValue(0)
.stdoutShouldContain("SM is enabled: false")
.shouldNotContain("A command line option");
}
// When SM is disallowed, no startup warning, setSM fails
static void disallowTest(String prop, String cp) throws Exception {
run(prop, cp)
.shouldNotHaveExitValue(0)
.stdoutShouldContain("SM is enabled: false")
.shouldNotContain("A command line option")
.shouldNotContain("A terminally deprecated method")
.stderrShouldContain("UnsupportedOperationException: The Security Manager is deprecated and will be removed in a future release");
}
// When SM is allowed, has startup warning, has setSM warning
static void enableTest(String prop, String cp) throws Exception {
checkInstallMessage(run(prop, cp), cp)
.shouldHaveExitValue(0)
.stdoutShouldContain("SM is enabled: true")
.stderrShouldContain("WARNING: A command line option has enabled the Security Manager")
.stderrShouldContain("WARNING: The Security Manager is deprecated and will be removed in a future release");
}
// Check the setSM warning
static OutputAnalyzer checkInstallMessage(OutputAnalyzer oa, String cp) {
String uri = new File(cp).toURI().toString();
return oa
.stderrShouldContain("WARNING: A terminally deprecated method in java.lang.System has been called")
.stderrShouldContain("WARNING: System::setSecurityManager has been called by SecurityManagerWarnings (" + uri + ")")
.stderrShouldContain("WARNING: Please consider reporting this to the maintainers of SecurityManagerWarnings")
.stderrShouldContain("WARNING: System::setSecurityManager will be removed in a future release");
}
static OutputAnalyzer run(String prop, String cp) throws Exception {
ProcessBuilder pb;
if (prop == null) {
return ProcessTools.executeTestJvm(
pb = new ProcessBuilder(
JDKToolFinder.getJDKTool("java"),
"-cp", cp,
"SecurityManagerWarnings", "run");
} else {
return ProcessTools.executeTestJvm(
pb = new ProcessBuilder(
JDKToolFinder.getJDKTool("java"),
"-cp", cp,
"-Djava.security.manager=" + prop,
"-Djava.security.policy=policy",
"SecurityManagerWarnings", "run");
}
}
// This SecurityManager allows everything!
public static class MySM extends SecurityManager {
@Override
public void checkPermission(Permission perm) {
}
return ProcessTools.executeProcess(pb);
}
}

View file

@ -53,7 +53,9 @@ import static java.lang.constant.ConstantDescs.CD_Object;
import static java.lang.constant.ConstantDescs.CD_String;
import static java.lang.constant.ConstantDescs.CD_int;
import static java.lang.constant.ConstantDescs.CD_void;
import static java.lang.invoke.MethodHandleInfo.*;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotEquals;
import static org.testng.Assert.assertNotSame;
import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertTrue;
@ -359,7 +361,28 @@ public class MethodHandleDescTest extends SymbolicDescTest {
public void testKind() {
for (Kind k : Kind.values()) {
assertEquals(Kind.valueOf(k.refKind), Kind.valueOf(k.refKind, k.refKind == MethodHandleInfo.REF_invokeInterface));
assertEquals(Kind.valueOf(k.refKind, k.isInterface), k);
}
// let's now verify those cases for which the value of the isInterface parameter is ignored
int[] isInterfaceIgnored = new int[] {
REF_getField,
REF_getStatic,
REF_putField,
REF_putStatic,
REF_newInvokeSpecial,
REF_invokeInterface
};
for (int refKind : isInterfaceIgnored) {
assertEquals(Kind.valueOf(refKind, false), Kind.valueOf(refKind, true));
}
// some explicit tests for REF_invokeStatic and REF_invokeSpecial
assertNotEquals(Kind.valueOf(REF_invokeStatic, false), Kind.valueOf(REF_invokeStatic, true));
assertNotEquals(Kind.valueOf(REF_invokeSpecial, false), Kind.valueOf(REF_invokeSpecial, true));
assertEquals(Kind.valueOf(REF_invokeStatic, false), Kind.STATIC);
assertEquals(Kind.valueOf(REF_invokeStatic, true), Kind.INTERFACE_STATIC);
assertEquals(Kind.valueOf(REF_invokeSpecial, false), Kind.SPECIAL);
assertEquals(Kind.valueOf(REF_invokeSpecial, true), Kind.INTERFACE_SPECIAL);
}
}

View file

@ -147,9 +147,8 @@ public class LogGeneratedClassesTest extends LUtils {
"-Djdk.internal.lambda.dumpProxyClasses=notExist",
"com.example.TestLambda");
assertEquals(tr.testOutput.stream()
.filter(s -> !s.contains("setSecurityManager is deprecated"))
.filter(s -> s.startsWith("WARNING"))
.peek(s -> assertTrue(s.contains("does not exist")))
.filter(s -> s.contains("does not exist"))
.count(),
1, "only show error once");
tr.assertZero("Should still return 0");
@ -164,9 +163,8 @@ public class LogGeneratedClassesTest extends LUtils {
"-Djdk.internal.lambda.dumpProxyClasses=file",
"com.example.TestLambda");
assertEquals(tr.testOutput.stream()
.filter(s -> !s.contains("setSecurityManager is deprecated"))
.filter(s -> s.startsWith("WARNING"))
.peek(s -> assertTrue(s.contains("not a directory")))
.filter(s -> s.contains("not a directory"))
.count(),
1, "only show error once");
tr.assertZero("Should still return 0");
@ -224,9 +222,8 @@ public class LogGeneratedClassesTest extends LUtils {
"-Djdk.internal.lambda.dumpProxyClasses=readOnly",
"com.example.TestLambda");
assertEquals(tr.testOutput.stream()
.filter(s -> !s.contains("setSecurityManager is deprecated"))
.filter(s -> s.startsWith("WARNING"))
.peek(s -> assertTrue(s.contains("not writable")))
.filter(s -> s.contains("not writable"))
.count(),
1, "only show error once");
tr.assertZero("Should still return 0");

View file

@ -86,10 +86,14 @@ public class Basic {
static final String SECURITY_MANAGER_DEPRECATED
= "WARNING: The Security Manager is deprecated and will be removed in a future release."
+ System.getProperty("line.separator");
private static String withoutWarning(String in) {
return in.lines().filter(s -> !s.startsWith("WARNING:")).collect(Collectors.joining());
}
static final Consumer<Result> KNOWN = r -> {
if (r.exitValue != 0 ||
(!r.output.isEmpty() && !r.output.equals(SECURITY_MANAGER_DEPRECATED)))
throw new RuntimeException(r.output);
if (r.exitValue != 0 || !withoutWarning(r.output).isEmpty())
throw new RuntimeException("[" + r.output + "]");
};
static final Consumer<Result> UNKNOWN = r -> {
if (r.exitValue == 0 ||

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2021, 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
@ -23,7 +23,7 @@
/*
* @test
* @bug 4947618
* @bug 4947618 8268349
* @summary Recursion problem in security manager and policy code
*
* @run main/othervm/policy=Recursion.policy -Djava.security.debug=domain RecursionDebug
@ -87,7 +87,5 @@ public class RecursionDebug {
throw new Exception
("Test with custom non-bootclass SecurityManager failed");
}
System.setSecurityManager(null);
}
}

View file

@ -24,7 +24,9 @@
import jdk.incubator.vector.Vector;
import jdk.incubator.vector.VectorOperators;
import jdk.incubator.vector.VectorShape;
import jdk.incubator.vector.VectorMask;
import jdk.incubator.vector.VectorSpecies;
import jdk.incubator.vector.VectorShuffle;
import org.testng.Assert;
import org.testng.ITestResult;
import org.testng.annotations.AfterMethod;
@ -241,6 +243,21 @@ abstract class AbstractVectorConversionTest {
return args.toArray(Object[][]::new);
}
static Object[][] fixedShapeXSegmentedCastSpeciesArgs(VectorShape srcShape, boolean legal) {
List<Object[]> args = new ArrayList<>();
for (Class<?> srcE : List.of(byte.class, short.class, int.class, long.class, float.class, double.class)) {
VectorSpecies<?> src = VectorSpecies.of(srcE, srcShape);
for (VectorShape dstShape : VectorShape.values()) {
for (Class<?> dstE : List.of(byte.class, short.class, int.class, long.class, float.class, double.class)) {
VectorSpecies<?> dst = VectorSpecies.of(dstE, dstShape);
if (legal == (dst.length() == src.length())) {
args.add(new Object[]{src, dst});
}
}
}
}
return args.toArray(Object[][]::new);
}
public enum ConvAPI {CONVERT, CONVERTSHAPE, CASTSHAPE, REINTERPRETSHAPE}
@ -488,4 +505,46 @@ abstract class AbstractVectorConversionTest {
Assert.assertEquals(actual, expected);
}
static <E,F> void legal_mask_cast_kernel(VectorSpecies<E> src, VectorSpecies<F> dst) {
for(int i = 0; i < INVOC_COUNT; i++) {
VectorMask<E> mask = VectorMask.fromLong(src, i);
VectorMask<F> res = mask.cast(dst);
Assert.assertEquals(res.toLong(), mask.toLong());
}
}
static <E,F> void illegal_mask_cast_kernel(VectorSpecies<E> src, VectorSpecies<F> dst) {
VectorMask<E> mask = VectorMask.fromLong(src, -1);
try {
mask.cast(dst);
Assert.fail();
} catch (IllegalArgumentException e) {
}
}
static <E,F> void legal_shuffle_cast_kernel(VectorSpecies<E> src, VectorSpecies<F> dst) {
int [] arr = new int[src.length()*INVOC_COUNT];
for(int i = 0; i < arr.length; i++) {
arr[i] = i;
}
for(int i = 0; i < INVOC_COUNT; i++) {
VectorShuffle<E> shuffle = VectorShuffle.fromArray(src, arr, i);
VectorShuffle<F> res = shuffle.cast(dst);
Assert.assertEquals(res.toArray(), shuffle.toArray());
}
}
static <E,F> void illegal_shuffle_cast_kernel(VectorSpecies<E> src, VectorSpecies<F> dst) {
int [] arr = new int[src.length()];
for(int i = 0; i < arr.length; i++) {
arr[i] = i;
}
VectorShuffle<E> shuffle = VectorShuffle.fromArray(src, arr, 0);
try {
shuffle.cast(dst);
Assert.fail();
} catch (IllegalArgumentException e) {
}
}
}

View file

@ -22,11 +22,15 @@
*/
import jdk.incubator.vector.VectorShape;
import jdk.incubator.vector.VectorMask;
import jdk.incubator.vector.VectorShuffle;
import jdk.incubator.vector.VectorSpecies;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.testng.Assert;
import java.util.function.IntFunction;
import java.util.List;
/**
* @test
@ -52,6 +56,16 @@ public class Vector128ConversionTests extends AbstractVectorConversionTest {
return fixedShapeXShapeSpeciesArgs(SHAPE);
}
@DataProvider
public Object[][] fixedShapeXSegmentedLegalCastSpecies() {
return fixedShapeXSegmentedCastSpeciesArgs(SHAPE, true);
}
@DataProvider
public Object[][] fixedShapeXSegmentedIllegalCastSpecies() {
return fixedShapeXSegmentedCastSpeciesArgs(SHAPE, false);
}
@Test(dataProvider = "fixedShapeXfixedShape")
static <I, O> void convert(VectorSpecies<I> src, VectorSpecies<O> dst, IntFunction<?> fa) {
Object a = fa.apply(BUFFER_SIZE);
@ -75,4 +89,24 @@ public class Vector128ConversionTests extends AbstractVectorConversionTest {
Object a = fa.apply(BUFFER_SIZE);
reinterpret_kernel(src, dst, a);
}
@Test(dataProvider = "fixedShapeXSegmentedLegalCastSpecies")
static <E,F> void shuffleCast(VectorSpecies<E> src, VectorSpecies<F> dst) {
legal_shuffle_cast_kernel(src, dst);
}
@Test(dataProvider = "fixedShapeXSegmentedIllegalCastSpecies")
static <E,F> void shuffleCastNeg(VectorSpecies<E> src, VectorSpecies<F> dst) {
illegal_shuffle_cast_kernel(src, dst);
}
@Test(dataProvider = "fixedShapeXSegmentedLegalCastSpecies")
static <E,F> void maskCast(VectorSpecies<E> src, VectorSpecies<F> dst) {
legal_mask_cast_kernel(src, dst);
}
@Test(dataProvider = "fixedShapeXSegmentedIllegalCastSpecies")
static <E,F> void maskCastNeg(VectorSpecies<E> src, VectorSpecies<F> dst) {
illegal_mask_cast_kernel(src, dst);
}
}

View file

@ -22,11 +22,15 @@
*/
import jdk.incubator.vector.VectorShape;
import jdk.incubator.vector.VectorMask;
import jdk.incubator.vector.VectorShuffle;
import jdk.incubator.vector.VectorSpecies;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.testng.Assert;
import java.util.function.IntFunction;
import java.util.List;
/**
* @test
@ -52,6 +56,16 @@ public class Vector256ConversionTests extends AbstractVectorConversionTest {
return fixedShapeXShapeSpeciesArgs(SHAPE);
}
@DataProvider
public Object[][] fixedShapeXSegmentedLegalCastSpecies() {
return fixedShapeXSegmentedCastSpeciesArgs(SHAPE, true);
}
@DataProvider
public Object[][] fixedShapeXSegmentedIllegalCastSpecies() {
return fixedShapeXSegmentedCastSpeciesArgs(SHAPE, false);
}
@Test(dataProvider = "fixedShapeXfixedShape")
static <I, O> void convert(VectorSpecies<I> src, VectorSpecies<O> dst, IntFunction<?> fa) {
Object a = fa.apply(BUFFER_SIZE);
@ -75,4 +89,24 @@ public class Vector256ConversionTests extends AbstractVectorConversionTest {
Object a = fa.apply(BUFFER_SIZE);
reinterpret_kernel(src, dst, a);
}
@Test(dataProvider = "fixedShapeXSegmentedLegalCastSpecies")
static <E,F> void shuffleCast(VectorSpecies<E> src, VectorSpecies<F> dst) {
legal_shuffle_cast_kernel(src, dst);
}
@Test(dataProvider = "fixedShapeXSegmentedIllegalCastSpecies")
static <E,F> void shuffleCastNeg(VectorSpecies<E> src, VectorSpecies<F> dst) {
illegal_shuffle_cast_kernel(src, dst);
}
@Test(dataProvider = "fixedShapeXSegmentedLegalCastSpecies")
static <E,F> void maskCast(VectorSpecies<E> src, VectorSpecies<F> dst) {
legal_mask_cast_kernel(src, dst);
}
@Test(dataProvider = "fixedShapeXSegmentedIllegalCastSpecies")
static <E,F> void maskCastNeg(VectorSpecies<E> src, VectorSpecies<F> dst) {
illegal_mask_cast_kernel(src, dst);
}
}

View file

@ -22,11 +22,15 @@
*/
import jdk.incubator.vector.VectorShape;
import jdk.incubator.vector.VectorMask;
import jdk.incubator.vector.VectorShuffle;
import jdk.incubator.vector.VectorSpecies;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.testng.Assert;
import java.util.function.IntFunction;
import java.util.List;
/**
* @test
@ -52,6 +56,16 @@ public class Vector512ConversionTests extends AbstractVectorConversionTest {
return fixedShapeXShapeSpeciesArgs(SHAPE);
}
@DataProvider
public Object[][] fixedShapeXSegmentedLegalCastSpecies() {
return fixedShapeXSegmentedCastSpeciesArgs(SHAPE, true);
}
@DataProvider
public Object[][] fixedShapeXSegmentedIllegalCastSpecies() {
return fixedShapeXSegmentedCastSpeciesArgs(SHAPE, false);
}
@Test(dataProvider = "fixedShapeXfixedShape")
static <I, O> void convert(VectorSpecies<I> src, VectorSpecies<O> dst, IntFunction<?> fa) {
Object a = fa.apply(BUFFER_SIZE);
@ -75,4 +89,24 @@ public class Vector512ConversionTests extends AbstractVectorConversionTest {
Object a = fa.apply(BUFFER_SIZE);
reinterpret_kernel(src, dst, a);
}
@Test(dataProvider = "fixedShapeXSegmentedLegalCastSpecies")
static <E,F> void shuffleCast(VectorSpecies<E> src, VectorSpecies<F> dst) {
legal_shuffle_cast_kernel(src, dst);
}
@Test(dataProvider = "fixedShapeXSegmentedIllegalCastSpecies")
static <E,F> void shuffleCastNeg(VectorSpecies<E> src, VectorSpecies<F> dst) {
illegal_shuffle_cast_kernel(src, dst);
}
@Test(dataProvider = "fixedShapeXSegmentedLegalCastSpecies")
static <E,F> void maskCast(VectorSpecies<E> src, VectorSpecies<F> dst) {
legal_mask_cast_kernel(src, dst);
}
@Test(dataProvider = "fixedShapeXSegmentedIllegalCastSpecies")
static <E,F> void maskCastNeg(VectorSpecies<E> src, VectorSpecies<F> dst) {
illegal_mask_cast_kernel(src, dst);
}
}

View file

@ -22,12 +22,15 @@
*/
import jdk.incubator.vector.VectorShape;
import jdk.incubator.vector.VectorMask;
import jdk.incubator.vector.VectorShuffle;
import jdk.incubator.vector.VectorSpecies;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.testng.Assert;
import java.util.function.IntFunction;
import java.util.List;
/**
* @test
@ -74,6 +77,16 @@ public class Vector64ConversionTests extends AbstractVectorConversionTest {
return fixedShapeXShapeSpeciesArgs(SHAPE);
}
@DataProvider
public Object[][] fixedShapeXSegmentedLegalCastSpecies() {
return fixedShapeXSegmentedCastSpeciesArgs(SHAPE, true);
}
@DataProvider
public Object[][] fixedShapeXSegmentedIllegalCastSpecies() {
return fixedShapeXSegmentedCastSpeciesArgs(SHAPE, false);
}
@Test(dataProvider = "fixedShapeXfixedShape")
static <I, O> void convert(VectorSpecies<I> src, VectorSpecies<O> dst, IntFunction<?> fa) {
Object a = fa.apply(BUFFER_SIZE);
@ -97,4 +110,24 @@ public class Vector64ConversionTests extends AbstractVectorConversionTest {
Object a = fa.apply(BUFFER_SIZE);
reinterpret_kernel(src, dst, a);
}
@Test(dataProvider = "fixedShapeXSegmentedLegalCastSpecies")
static <E,F> void shuffleCast(VectorSpecies<E> src, VectorSpecies<F> dst) {
legal_shuffle_cast_kernel(src, dst);
}
@Test(dataProvider = "fixedShapeXSegmentedIllegalCastSpecies")
static <E,F> void shuffleCastNeg(VectorSpecies<E> src, VectorSpecies<F> dst) {
illegal_shuffle_cast_kernel(src, dst);
}
@Test(dataProvider = "fixedShapeXSegmentedLegalCastSpecies")
static <E,F> void maskCast(VectorSpecies<E> src, VectorSpecies<F> dst) {
legal_mask_cast_kernel(src, dst);
}
@Test(dataProvider = "fixedShapeXSegmentedIllegalCastSpecies")
static <E,F> void maskCastNeg(VectorSpecies<E> src, VectorSpecies<F> dst) {
illegal_mask_cast_kernel(src, dst);
}
}

View file

@ -22,11 +22,15 @@
*/
import jdk.incubator.vector.VectorShape;
import jdk.incubator.vector.VectorMask;
import jdk.incubator.vector.VectorShuffle;
import jdk.incubator.vector.VectorSpecies;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.testng.Assert;
import java.util.function.IntFunction;
import java.util.List;
/**
* @test
@ -51,6 +55,16 @@ public class VectorMaxConversionTests extends AbstractVectorConversionTest {
return fixedShapeXShapeSpeciesArgs(SHAPE);
}
@DataProvider
public Object[][] fixedShapeXSegmentedLegalCastSpecies() {
return fixedShapeXSegmentedCastSpeciesArgs(SHAPE, true);
}
@DataProvider
public Object[][] fixedShapeXSegmentedIllegalCastSpecies() {
return fixedShapeXSegmentedCastSpeciesArgs(SHAPE, false);
}
@Test(dataProvider = "fixedShapeXfixedShape")
static <I, O> void convert(VectorSpecies<I> src, VectorSpecies<O> dst, IntFunction<?> fa) {
Object a = fa.apply(1024);
@ -74,4 +88,24 @@ public class VectorMaxConversionTests extends AbstractVectorConversionTest {
Object a = fa.apply(1024);
reinterpret_kernel(src, dst, a);
}
@Test(dataProvider = "fixedShapeXSegmentedLegalCastSpecies")
static <E,F> void shuffleCast(VectorSpecies<E> src, VectorSpecies<F> dst) {
legal_shuffle_cast_kernel(src, dst);
}
@Test(dataProvider = "fixedShapeXSegmentedIllegalCastSpecies")
static <E,F> void shuffleCastNeg(VectorSpecies<E> src, VectorSpecies<F> dst) {
illegal_shuffle_cast_kernel(src, dst);
}
@Test(dataProvider = "fixedShapeXSegmentedLegalCastSpecies")
static <E,F> void maskCast(VectorSpecies<E> src, VectorSpecies<F> dst) {
legal_mask_cast_kernel(src, dst);
}
@Test(dataProvider = "fixedShapeXSegmentedIllegalCastSpecies")
static <E,F> void maskCastNeg(VectorSpecies<E> src, VectorSpecies<F> dst) {
illegal_mask_cast_kernel(src, dst);
}
}

View file

@ -25,7 +25,6 @@ import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.nio.file.Path;
import java.util.function.Consumer;
import javax.swing.Icon;
import javax.swing.filechooser.FileSystemView;
import jdk.jpackage.test.PackageTest;
@ -67,31 +66,23 @@ public class WinInstallerIconTest {
BufferedImage[] defaultInstallerIconImg = new BufferedImage[1];
// Create installer with the default icon
createInstaller(null, "WithDefaultIcon", installerIconImg -> {
defaultInstallerIconImg[0] = installerIconImg;
}, null, null);
BufferedImage[] customInstallerIconImg = new BufferedImage[1];
long size1 = createInstaller(null, "WithDefaultIcon");
// Create installer with custom icon.
// This installer icon should differ from the icon
// of the installer created with the default icon.
createInstaller(customIcon, "2", installerIconImg -> {
customInstallerIconImg[0] = installerIconImg;
}, null, defaultInstallerIconImg[0]);
long size2 = createInstaller(customIcon, "WithCustomIcon");
// Create another installer with custom icon.
long size3 = createInstaller(customIcon, null);
TKit.assertTrue(size2 < size1, "Installer 2 built with custom icon " +
"should be smaller than Installer 1 built with default icon");
TKit.assertTrue(size3 < size1, "Installer 3 built with custom icon " +
"should be smaller than Installer 1 built with default icon");
// Create installer with custom icon again.
// This installer icon should differ from the icon
// of the installer created with the default icon and should have
// the same icon as the icon of installer created with custom icon.
createInstaller(customIcon, null, null,
customInstallerIconImg[0], defaultInstallerIconImg[0]);
}
private void createInstaller(Path icon, String nameSuffix,
Consumer<BufferedImage> installerIconImgConsumer,
BufferedImage expectedInstallerIconImg,
BufferedImage unexpectedInstallerIconImg) throws IOException {
private long createInstaller(Path icon, String nameSuffix) throws IOException {
PackageTest test = new PackageTest()
.forTypes(PackageType.WIN_EXE)
@ -112,67 +103,19 @@ public class WinInstallerIconTest {
test.addBundleVerifier(cmd -> {
installerExePath[0] = cmd.outputBundle();
Icon actualIcon = FileSystemView.getFileSystemView().getSystemIcon(
installerExePath[0].toFile());
BufferedImage actualInstallerIconImg = loadIcon(actualIcon);
if (installerIconImgConsumer != null) {
installerIconImgConsumer.accept(actualInstallerIconImg);
}
if (expectedInstallerIconImg != null) {
TKit.assertTrue(imageEquals(expectedInstallerIconImg,
actualInstallerIconImg), String.format(
"Check icon of %s installer is matching expected value",
installerExePath[0]));
}
if (unexpectedInstallerIconImg != null) {
TKit.assertFalse(imageEquals(unexpectedInstallerIconImg,
actualInstallerIconImg), String.format(
"Check icon of %s installer is NOT matching unexpected value",
installerExePath[0]));
}
});
test.run(CREATE);
if (installerExePath[0] != null && nameSuffix != null) {
long size = 0L;
if (installerExePath[0] != null) {
size = installerExePath[0].toFile().length();
TKit.trace(" installer: " + installerExePath[0] + " - size: " + size);
if (nameSuffix != null) {
TKit.deleteIfExists(installerExePath[0]);
}
}
private BufferedImage loadIcon(Icon icon) {
TKit.assertNotEquals(0, icon.getIconWidth(),
"Check icon has not empty width");
TKit.assertNotEquals(0, icon.getIconHeight(),
"Check icon has not empty height");
BufferedImage img = new BufferedImage(
icon.getIconWidth(),
icon.getIconHeight(),
BufferedImage.TYPE_INT_RGB);
Graphics g = img.createGraphics();
icon.paintIcon(null, g, 0, 0);
g.dispose();
return img;
}
private static boolean imageEquals(BufferedImage imgA, BufferedImage imgB) {
if (imgA.getWidth() == imgB.getWidth() && imgA.getHeight()
== imgB.getHeight()) {
for (int x = 0; x < imgA.getWidth(); x++) {
for (int y = 0; y < imgA.getHeight(); y++) {
if (imgA.getRGB(x, y) != imgB.getRGB(x, y)) {
return false;
}
}
}
} else {
return false;
}
return true;
return size;
}
private static Path iconPath(String name) {