Package org.microproxy.simd
Class Simd
java.lang.Object
org.microproxy.simd.Simd
Byte loops on the proxy's hot paths, with an optional SIMD implementation.
The SIMD version uses the Vector API, which is still an incubating JDK module. It is used
only when the JVM runs with --add-modules jdk.incubator.vector (the JVM then prints an
incubator warning at startup). The system property microproxy.simd can be
auto (the default: use SIMD when the module is present), true (warn if it is not), or
false (never). Without the module the scalar version runs, so the proxy needs nothing
beyond JDK 21.
Public for use across MicroProxy's packages; not a supported API.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThe operations, in scalar and SIMD flavours. -
Method Summary
Modifier and TypeMethodDescriptionstatic intindexOf(byte[] a, int from, int to, byte value) Finds the first matching byte within the specified range.static booleanReports whether the selected implementation uses SIMD.static Simd.Opsops()Returns the implementation in use.static Simd.Opsscalar()Returns the scalar implementation, always available.static Simd.Opsvector()Returns the SIMD implementation, ornullif the Vector API module is not present.static voidxorMask(byte[] a, int off, int len, int mask) Applies the repeating four-byte WebSocket mask to an array range.
-
Method Details
-
ops
Returns the implementation in use.- Returns:
- the implementation in use
-
scalar
Returns the scalar implementation, always available.- Returns:
- the scalar implementation, always available
-
vector
Returns the SIMD implementation, ornullif the Vector API module is not present.- Returns:
- the SIMD implementation, or
nullif the Vector API module is not present
-
isVectorized
public static boolean isVectorized()Reports whether the selected implementation uses SIMD.- Returns:
- whether SIMD is in use
-
indexOf
public static int indexOf(byte[] a, int from, int to, byte value) Finds the first matching byte within the specified range.- Parameters:
a- the byte array to searchfrom- the first array index, inclusiveto- the last array index, exclusivevalue- the byte value to find- Returns:
- the first matching index, or -1 if no byte matches
-
xorMask
public static void xorMask(byte[] a, int off, int len, int mask) Applies the repeating four-byte WebSocket mask to an array range.- Parameters:
a- the byte array to modifyoff- the first byte offset to modifylen- the number of bytes to modifymask- the four-byte mask, applied most significant byte first
-